forked from cloudforet-io/plugin-azure-inven-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add frame code for Function App cloud service (cloudforet-io#32)
Signed-off-by: Minho Kim <[email protected]>
- Loading branch information
Showing
13 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from spaceone.inventory.connector.function_app.connector import FunctionAppConnector |
12 changes: 12 additions & 0 deletions
12
src/spaceone/inventory/connector/function_app/connector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import logging | ||
from spaceone.inventory.libs.connector import AzureConnector | ||
|
||
__all__ = ['FunctionAppConnector'] | ||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class FunctionAppConnector(AzureConnector): | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.set_connect(kwargs.get('secret_data')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
40 changes: 40 additions & 0 deletions
40
src/spaceone/inventory/manager/function_app/instance_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import time | ||
import logging | ||
from spaceone.inventory.libs.manager import AzureManager | ||
from spaceone.inventory.libs.schema.base import ReferenceModel | ||
from spaceone.core.utils import * | ||
from spaceone.inventory.model.web_pubsub_service.cloud_service_type import CLOUD_SERVICE_TYPES | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class FunctionAppManager(AzureManager): | ||
connector_name = 'FunctionAppConnector' | ||
cloud_service_types = CLOUD_SERVICE_TYPES | ||
|
||
def collect_cloud_service(self, params): | ||
""" | ||
Args: | ||
params (dict): | ||
- 'options' : 'dict' | ||
- 'schema' : 'str' | ||
- 'secret_data' : 'dict' | ||
- 'filter' : 'dict' | ||
- 'zones' : 'list' | ||
- 'subscription_info' : 'dict' | ||
Response: | ||
CloudServiceResponse (list) : list of azure function app data resource information | ||
ErrorResourceResponse (list) : list of error resource information | ||
""" | ||
|
||
_LOGGER.debug(f'** Function App START **') | ||
start_time = time.time() | ||
subscription_info = params['subscription_info'] | ||
container_instances_responses = [] | ||
error_responses = [] | ||
|
||
_LOGGER.debug(f'** Function App Service Finished {time.time() - start_time} Seconds **') | ||
return container_instances_responses, error_responses |
Empty file.
34 changes: 34 additions & 0 deletions
34
src/spaceone/inventory/model/function_app/cloud_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType | ||
from spaceone.inventory.model.function_app.data import FunctionApp | ||
from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField | ||
from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout | ||
from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta | ||
|
||
''' | ||
Function App | ||
''' | ||
# TAB - Function App | ||
function_app_info_meta = ItemDynamicLayout.set_fields('Web PubSub Service', fields=[ | ||
]) | ||
|
||
|
||
function_app_meta = CloudServiceMeta.set_layouts( | ||
[function_app_info_meta]) | ||
|
||
|
||
class ComputeResource(CloudServiceResource): | ||
cloud_service_group = StringType(default='WebPubSubService') | ||
|
||
|
||
class FunctionAppResource(ComputeResource): | ||
cloud_service_type = StringType(default='ScaleSet') | ||
data = ModelType(FunctionApp) | ||
_metadata = ModelType(CloudServiceMeta, default=function_app_meta, serialized_name='metadata') | ||
name = StringType() | ||
account = StringType(serialize_when_none=False) | ||
instance_type = StringType(serialize_when_none=False) | ||
instance_size = FloatType(serialize_when_none=False) | ||
|
||
|
||
class WebPubSubServiceResponse(CloudServiceResponse): | ||
resource = PolyModelType(FunctionAppResource) |
42 changes: 42 additions & 0 deletions
42
src/spaceone/inventory/model/function_app/cloud_service_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
from spaceone.inventory.libs.utils import * | ||
from spaceone.inventory.libs.schema.metadata.dynamic_widget import CardWidget, ChartWidget | ||
from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, SearchField, DateTimeDyField, ListDyField, \ | ||
EnumDyField | ||
from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ | ||
CloudServiceTypeMeta | ||
|
||
current_dir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
function_app_by_account_conf = os.path.join(current_dir, 'widget/function_app_by_account.yaml') | ||
function_app_by_region_conf = os.path.join(current_dir, 'widget/function_app_by_region.yaml') | ||
function_app_by_resource_group_conf = os.path.join(current_dir, 'widget/function_app_by_resource_group.yaml') | ||
function_app_total_count_count_conf = os.path.join(current_dir, 'widget/function_app_total_count.yaml') | ||
|
||
cst_function_app = CloudServiceTypeResource() | ||
cst_function_app.name = 'Instance' | ||
cst_function_app.group = 'FunctionApp' | ||
cst_function_app.service_code = 'Microsoft.Web/sites' | ||
cst_function_app.labels = ['Compute'] | ||
cst_function_app.is_major = True | ||
cst_function_app.is_primary = True | ||
cst_function_app.tags = { | ||
'spaceone:icon': '', | ||
} | ||
|
||
cst_function_app._metadata = CloudServiceTypeMeta.set_meta( | ||
fields=[ | ||
], | ||
search=[ | ||
|
||
], | ||
widget=[ | ||
|
||
] | ||
|
||
) | ||
|
||
|
||
CLOUD_SERVICE_TYPES = [ | ||
CloudServiceTypeResponse({'resource': cst_function_app}), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from schematics import Model | ||
from schematics.types import StringType | ||
from spaceone.inventory.libs.schema.resource import AzureCloudService | ||
|
||
|
||
class FunctionApp(AzureCloudService): | ||
id = StringType(serialize_when_none=False) | ||
name = StringType(serialize_when_none=False) | ||
location = StringType(serialize_when_none=False) | ||
|
||
def reference(self): | ||
return { | ||
"resource_id": self.id, | ||
"external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters