Skip to content

Commit

Permalink
feat: define model class for function app (cloudforet-io#32)
Browse files Browse the repository at this point in the history
Signed-off-by: Minho Kim <[email protected]>
  • Loading branch information
ImMin5 committed Nov 23, 2022
1 parent ad05cd6 commit 4810b67
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/spaceone/inventory/connector/function_app/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ class FunctionAppConnector(AzureConnector):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_connect(kwargs.get('secret_data'))

def list(self):
return self.function_app_client.web_apps.list()
5 changes: 4 additions & 1 deletion src/spaceone/inventory/libs/connector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging

from spaceone.core.connector import BaseConnector
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.resource import ResourceManagementClient
Expand All @@ -15,7 +16,7 @@
from azure.mgmt.rdbms.postgresql import PostgreSQLManagementClient
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.mgmt.webpubsub import WebPubSubManagementClient
from spaceone.core.connector import BaseConnector
from azure.mgmt.web import WebSiteManagementClient

DEFAULT_SCHEMA = 'azure_client_secret'
_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -52,6 +53,7 @@ def __init__(self, **kwargs):
self.postgre_sql_client = None
self.container_instance_client = None
self.web_pubsub_service_client = None
self.function_app_client = None

def set_connect(self, secret_data):
subscription_id = secret_data['subscription_id']
Expand All @@ -76,6 +78,7 @@ def set_connect(self, secret_data):
self.postgre_sql_client = PostgreSQLManagementClient(credential=credential, subscription_id=subscription_id)
self.container_instance_client = ContainerInstanceManagementClient(credential=credential, subscription_id=subscription_id)
self.web_pubsub_service_client = WebPubSubManagementClient(credential=credential, subscription_id=subscription_id)
self.function_app_client = WebSiteManagementClient(credential=credential, subscription_id=subscription_id)

def verify(self, **kwargs):
self.set_connect(kwargs['secret_data'])
Expand Down
21 changes: 19 additions & 2 deletions src/spaceone/inventory/manager/function_app/instance_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
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
from spaceone.inventory.connector.function_app.connector import FunctionAppConnector

from spaceone.inventory.model.function_app.data import *

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -33,8 +36,22 @@ def collect_cloud_service(self, params):
_LOGGER.debug(f'** Function App START **')
start_time = time.time()
subscription_info = params['subscription_info']
container_instances_responses = []
function_app_responses = []
error_responses = []

function_app_conn: FunctionAppConnector = self.locator.get_connector(self.connector_name, **params)
function_apps = function_app_conn.list()

for function_app in function_apps:
function_app_id = ''
try:
function_app_dict = self.convert_nested_dictionary(function_app)
import pprint
pprint.pprint(function_app_dict)

function_app_data = FunctionApp()
except Exception as e:
print(e)

_LOGGER.debug(f'** Function App Service Finished {time.time() - start_time} Seconds **')
return container_instances_responses, error_responses
return function_app_responses, error_responses
Loading

0 comments on commit 4810b67

Please sign in to comment.