diff --git a/.gitignore b/.gitignore index 52363a75..0ab95c00 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ local-conf.yml .venv/ .venv.nosync/ .DS_Store -!src/spaceone/inventory/metrics/Disks/disk \ No newline at end of file +!src/plugin/metrics/Disks/Disk \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7398579c..04ab1239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV SRC_DIR /tmp/src COPY pkg/*.txt ${PKG_DIR}/ RUN pip install --upgrade pip && \ pip install --upgrade -r ${PKG_DIR}/pip_requirements.txt && \ - pip install --upgrade spaceone-api + pip install --upgrade spaceone-api spaceone-inventory COPY src ${SRC_DIR} @@ -20,4 +20,4 @@ RUN python3 setup.py install && \ EXPOSE ${CLOUDONE_PORT} ENTRYPOINT ["spaceone"] -CMD ["run", "grpc-server", "spaceone.inventory"] +CMD ["run", "plugin-server", "plugin"] diff --git a/pkg/pip_requirements.txt b/pkg/pip_requirements.txt index 5bf4bf43..c1f89042 100644 --- a/pkg/pip_requirements.txt +++ b/pkg/pip_requirements.txt @@ -1,4 +1,4 @@ -schematics +spaceone-api azure-identity azure-mgmt-resource azure-mgmt-compute diff --git a/src/VERSION b/src/VERSION index bd8bf882..8acdd82b 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -1.7.0 +0.0.1 diff --git a/src/__init__.py b/src/plugin/__init__.py similarity index 100% rename from src/__init__.py rename to src/plugin/__init__.py diff --git a/src/spaceone/inventory/conf/__init__.py b/src/plugin/conf/__init__.py similarity index 100% rename from src/spaceone/inventory/conf/__init__.py rename to src/plugin/conf/__init__.py diff --git a/src/plugin/conf/cloud_service_conf.py b/src/plugin/conf/cloud_service_conf.py new file mode 100644 index 00000000..bf51dac5 --- /dev/null +++ b/src/plugin/conf/cloud_service_conf.py @@ -0,0 +1 @@ +ICON_URL = "https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure" diff --git a/src/spaceone/inventory/interface/__init__.py b/src/plugin/connector/__init__.py similarity index 100% rename from src/spaceone/inventory/interface/__init__.py rename to src/plugin/connector/__init__.py diff --git a/src/spaceone/inventory/libs/schema/__init__.py b/src/plugin/connector/application_gateways/__init__.py similarity index 100% rename from src/spaceone/inventory/libs/schema/__init__.py rename to src/plugin/connector/application_gateways/__init__.py diff --git a/src/spaceone/inventory/connector/application_gateways/connector.py b/src/plugin/connector/application_gateways/application_gateways_connector.py similarity index 58% rename from src/spaceone/inventory/connector/application_gateways/connector.py rename to src/plugin/connector/application_gateways/application_gateways_connector.py index 78d88a59..2c62ee3f 100644 --- a/src/spaceone/inventory/connector/application_gateways/connector.py +++ b/src/plugin/connector/application_gateways/application_gateways_connector.py @@ -1,12 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * -__all__ = ['ApplicationGatewaysConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class ApplicationGatewaysConnector(AzureConnector): + +class ApplicationGatewaysConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) @@ -16,4 +15,4 @@ def list_all_application_gateways(self): return self.network_client.application_gateways.list_all() def get_public_ip_addresses(self, public_ip_address_name, resource_group_name): - return self.network_client.public_ip_addresses.get(public_ip_address_name, resource_group_name) + return self.network_client.public_ip_addresses.get(public_ip_address_name, resource_group_name) \ No newline at end of file diff --git a/src/plugin/connector/base.py b/src/plugin/connector/base.py new file mode 100644 index 00000000..9c859acc --- /dev/null +++ b/src/plugin/connector/base.py @@ -0,0 +1,75 @@ +import os +import logging + +from azure.identity import DefaultAzureCredential +from azure.mgmt.compute import ComputeManagementClient +from azure.mgmt.resource import SubscriptionClient +from azure.mgmt.network import NetworkManagementClient +from azure.mgmt.sql import SqlManagementClient +from azure.mgmt.monitor import MonitorManagementClient +from azure.mgmt.containerinstance import ContainerInstanceManagementClient +from azure.mgmt.resource import ResourceManagementClient +from azure.mgmt.storage import StorageManagementClient +from azure.mgmt.cosmosdb import CosmosDBManagementClient +from azure.mgmt.rdbms.postgresql import PostgreSQLManagementClient +from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient as PostgreSQLFlexibleManagementClient +from azure.mgmt.webpubsub import WebPubSubManagementClient +from azure.mgmt.keyvault import KeyVaultManagementClient +from azure.mgmt.rdbms.mysql import MySQLManagementClient +from azure.mgmt.rdbms.mysql_flexibleservers import MySQLManagementClient as MySQLFlexibleManagementClient + + +from spaceone.core.connector import BaseConnector + +DEFAULT_SCHEMA = 'azure_client_secret' +_LOGGER = logging.getLogger(__name__) + + +class AzureBaseConnector(BaseConnector): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.subscription_client = None + self.compute_client = None + self.network_client = None + self.sql_client = None + self.monitor_client = None + self.container_instance_client = None + self.resource_client = None + self.storage_client = None + self.cosmosdb_client = None + self.postgre_sql_client = None + self.postgre_sql_flexible_client = None + self.web_pubsub_service_client = None + self.key_vault_client = None + self.mysql_client = None + self.mysql_flexible_client = None + + + def set_connect(self, secret_data: dict): + subscription_id = secret_data['subscription_id'] + + os.environ["AZURE_SUBSCRIPTION_ID"] = subscription_id + os.environ["AZURE_TENANT_ID"] = secret_data['tenant_id'] + os.environ["AZURE_CLIENT_ID"] = secret_data['client_id'] + os.environ["AZURE_CLIENT_SECRET"] = secret_data['client_secret'] + + credential = DefaultAzureCredential() + + self.subscription_client = SubscriptionClient(credential=credential) + self.compute_client = ComputeManagementClient(credential=credential, subscription_id=subscription_id) + self.network_client = NetworkManagementClient(credential=credential, subscription_id=subscription_id) + self.sql_client = SqlManagementClient(credential=credential, subscription_id=subscription_id) + self.monitor_client = MonitorManagementClient(credential=credential, subscription_id=subscription_id) + self.container_instance_client = ContainerInstanceManagementClient(credential=credential, subscription_id=subscription_id) + self.resource_client = ResourceManagementClient(credential=credential, subscription_id=subscription_id) + self.storage_client = StorageManagementClient(credential=credential, subscription_id=subscription_id) + self.cosmosdb_client = CosmosDBManagementClient(credential=credential, subscription_id=subscription_id) + self.postgre_sql_client = PostgreSQLManagementClient(credential=credential, subscription_id=subscription_id) + self.postgre_sql_flexible_client = PostgreSQLFlexibleManagementClient(credential=credential, subscription_id=subscription_id) + self.web_pubsub_service_client = WebPubSubManagementClient(credential=credential, subscription_id=subscription_id) + self.key_vault_client = KeyVaultManagementClient(credential=credential, subscription_id=subscription_id) + self.mysql_client = MySQLManagementClient(credential=credential, subscription_id=subscription_id) + self.mysql_flexible_client = MySQLFlexibleManagementClient(credential=credential, subscription_id=subscription_id) + + def get_connector(self, cloud_service_group: str, cloud_service_type: str): + pass diff --git a/src/spaceone/inventory/libs/schema/metadata/__init__.py b/src/plugin/connector/container_instances/__init__.py similarity index 100% rename from src/spaceone/inventory/libs/schema/metadata/__init__.py rename to src/plugin/connector/container_instances/__init__.py diff --git a/src/spaceone/inventory/connector/container_instances/connector.py b/src/plugin/connector/container_instances/container_instances_connector.py similarity index 63% rename from src/spaceone/inventory/connector/container_instances/connector.py rename to src/plugin/connector/container_instances/container_instances_connector.py index eec76bd0..301ee294 100644 --- a/src/spaceone/inventory/connector/container_instances/connector.py +++ b/src/plugin/connector/container_instances/container_instances_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * -__all__ = ['ContainerInstancesConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class ContainerInstancesConnector(AzureConnector): +class ContainerInstancesConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -17,4 +15,4 @@ def list_container_groups(self): def get_container_groups(self, resource_group_name, container_group_name): return self.container_instance_client.container_groups.get(resource_group_name=resource_group_name, - container_group_name=container_group_name) + container_group_name=container_group_name) \ No newline at end of file diff --git a/src/spaceone/inventory/manager/application_gateways/__init__.py b/src/plugin/connector/cosmos_db/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/application_gateways/__init__.py rename to src/plugin/connector/cosmos_db/__init__.py diff --git a/src/spaceone/inventory/connector/cosmos_db/connector.py b/src/plugin/connector/cosmos_db/cosmos_db_connector.py similarity index 66% rename from src/spaceone/inventory/connector/cosmos_db/connector.py rename to src/plugin/connector/cosmos_db/cosmos_db_connector.py index 81580ea0..911fa5ca 100644 --- a/src/spaceone/inventory/connector/cosmos_db/connector.py +++ b/src/plugin/connector/cosmos_db/cosmos_db_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * -__all__ = ['CosmosDBConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class CosmosDBConnector(AzureConnector): +class CosmosDBConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -16,8 +14,7 @@ def list_all_cosmos_db_accounts(self): return self.cosmosdb_client.database_accounts.list() def list_keys(self, account_name, resource_group_name): - return self.cosmosdb_client.database_accounts.list_keys(account_name= account_name, resource_group_name=resource_group_name) + return self.cosmosdb_client.database_accounts.list_keys(account_name=account_name, resource_group_name=resource_group_name) def list_sql_resources(self, account_name, resource_group_name): return self.cosmosdb_client.sql_resources.list_sql_databases(account_name=account_name, resource_group_name=resource_group_name) - diff --git a/src/spaceone/inventory/manager/container_instances/__init__.py b/src/plugin/connector/disks/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/container_instances/__init__.py rename to src/plugin/connector/disks/__init__.py diff --git a/src/plugin/connector/disks/disks_connector.py b/src/plugin/connector/disks/disks_connector.py new file mode 100644 index 00000000..34c654d8 --- /dev/null +++ b/src/plugin/connector/disks/disks_connector.py @@ -0,0 +1,14 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class DisksConnector(AzureBaseConnector): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.set_connect(kwargs.get('secret_data')) + + def list_disks(self): + return self.compute_client.disks.list() \ No newline at end of file diff --git a/src/spaceone/inventory/manager/cosmos_db/__init__.py b/src/plugin/connector/key_vaults/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/cosmos_db/__init__.py rename to src/plugin/connector/key_vaults/__init__.py diff --git a/src/spaceone/inventory/connector/key_vaults/connector.py b/src/plugin/connector/key_vaults/key_vaults_connector.py similarity index 83% rename from src/spaceone/inventory/connector/key_vaults/connector.py rename to src/plugin/connector/key_vaults/key_vaults_connector.py index 47ed5ed2..5ca9b1bd 100644 --- a/src/spaceone/inventory/connector/key_vaults/connector.py +++ b/src/plugin/connector/key_vaults/key_vaults_connector.py @@ -1,18 +1,14 @@ import logging -import azure.core.exceptions - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * +from plugin.connector.base import AzureBaseConnector from azure.keyvault.secrets import SecretClient from azure.keyvault.certificates import CertificateClient from azure.identity import DefaultAzureCredential -__all__ = ["KeyVaultsConnector"] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class KeyVaultsConnector(AzureConnector): +class KeyVaultsConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) @@ -47,4 +43,4 @@ def list_keys(self, resource_group_name, vault_name): def list_secrets(self): # return self.key_vault_secrets_client.list_properties_of_secrets() - return self.key_vault_client.secrets.list() + return self.key_vault_client.secrets.list() \ No newline at end of file diff --git a/src/spaceone/inventory/manager/disks/__init__.py b/src/plugin/connector/load_balancers/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/disks/__init__.py rename to src/plugin/connector/load_balancers/__init__.py diff --git a/src/spaceone/inventory/connector/load_balancers/connector.py b/src/plugin/connector/load_balancers/load_balancers_connector.py similarity index 81% rename from src/spaceone/inventory/connector/load_balancers/connector.py rename to src/plugin/connector/load_balancers/load_balancers_connector.py index 68ebdcb4..cbde27c6 100644 --- a/src/spaceone/inventory/connector/load_balancers/connector.py +++ b/src/plugin/connector/load_balancers/load_balancers_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * -__all__ = ['LoadBalancersConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class LoadBalancersConnector(AzureConnector): +class LoadBalancersConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) diff --git a/src/spaceone/inventory/manager/key_vaults/__init__.py b/src/plugin/connector/monitor/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/key_vaults/__init__.py rename to src/plugin/connector/monitor/__init__.py diff --git a/src/spaceone/inventory/connector/monitor/connector.py b/src/plugin/connector/monitor/monitor_connector.py similarity index 73% rename from src/spaceone/inventory/connector/monitor/connector.py rename to src/plugin/connector/monitor/monitor_connector.py index f862a10f..fe1c8cc5 100644 --- a/src/spaceone/inventory/connector/monitor/connector.py +++ b/src/plugin/connector/monitor/monitor_connector.py @@ -1,14 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * +from plugin.connector.base import AzureBaseConnector -__all__ = ['MonitorConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class MonitorConnector(AzureConnector): - +class MonitorConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -19,5 +16,3 @@ def list_diagnostic_settings(self, resource_uri): def list_metrics(self, resource_uri, metricnames, aggregation, timespan=None, interval=None): return self.monitor_client.metrics.list(resource_uri, metricnames=metricnames, aggregation=aggregation, timespan=timespan, interval=interval) - - diff --git a/src/spaceone/inventory/manager/load_balancers/__init__.py b/src/plugin/connector/my_sql_servers/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/load_balancers/__init__.py rename to src/plugin/connector/my_sql_servers/__init__.py diff --git a/src/plugin/connector/my_sql_servers/mysql_flexible_servers_connector.py b/src/plugin/connector/my_sql_servers/mysql_flexible_servers_connector.py new file mode 100644 index 00000000..4ab8a2df --- /dev/null +++ b/src/plugin/connector/my_sql_servers/mysql_flexible_servers_connector.py @@ -0,0 +1,18 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class MySQLFlexibleServersConnector(AzureBaseConnector): + def __init__(self, secret_data=None, **kwargs): + super().__init__(**kwargs) + + self.set_connect(secret_data) + + def list_flexible_servers(self): + return self.mysql_flexible_client.servers.list() + + def list_firewall_rules_by_server(self, resource_group_name, server_name): + return self.mysql_flexible_client.firewall_rules.list_by_server(resource_group_name=resource_group_name, server_name=server_name) \ No newline at end of file diff --git a/src/spaceone/inventory/connector/mysql_servers/connector.py b/src/plugin/connector/my_sql_servers/mysql_servers_connector.py similarity index 70% rename from src/spaceone/inventory/connector/mysql_servers/connector.py rename to src/plugin/connector/my_sql_servers/mysql_servers_connector.py index 786fef46..39afe6a3 100644 --- a/src/spaceone/inventory/connector/mysql_servers/connector.py +++ b/src/plugin/connector/my_sql_servers/mysql_servers_connector.py @@ -1,14 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * +from plugin.connector.base import AzureBaseConnector -__all__ = ['MySQLServersConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class MySQLServersConnector(AzureConnector): - +class MySQLServersConnector(AzureBaseConnector): def __init__(self, secret_data=None, **kwargs): super().__init__(**kwargs) @@ -21,4 +18,4 @@ def list_firewall_rules_by_server(self, resource_group_name, server_name): return self.mysql_client.firewall_rules.list_by_server(resource_group_name=resource_group_name, server_name=server_name) def list_server_parameters(self, resource_group_name, server_name): - return self.mysql_client.server_parameters._list_update_configurations_initial(resource_group_name=resource_group_name, server_name=server_name, value=[]) + return self.mysql_client.server_parameters._list_update_configurations_initial(resource_group_name=resource_group_name, server_name=server_name, value=[]) \ No newline at end of file diff --git a/src/spaceone/inventory/manager/mysql_servers/__init__.py b/src/plugin/connector/nat_gateways/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/mysql_servers/__init__.py rename to src/plugin/connector/nat_gateways/__init__.py diff --git a/src/spaceone/inventory/connector/nat_gateways/connector.py b/src/plugin/connector/nat_gateways/nat_gateways_connector.py similarity index 79% rename from src/spaceone/inventory/connector/nat_gateways/connector.py rename to src/plugin/connector/nat_gateways/nat_gateways_connector.py index 1d3844b9..9f303c14 100644 --- a/src/spaceone/inventory/connector/nat_gateways/connector.py +++ b/src/plugin/connector/nat_gateways/nat_gateways_connector.py @@ -1,14 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * +from plugin.connector.base import AzureBaseConnector -__all__ = ['NATGatewaysConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class NATGatewaysConnector(AzureConnector): - +class NATGatewaysConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) diff --git a/src/spaceone/inventory/manager/nat_gateways/__init__.py b/src/plugin/connector/network_security_groups/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/nat_gateways/__init__.py rename to src/plugin/connector/network_security_groups/__init__.py diff --git a/src/spaceone/inventory/connector/network_security_groups/connector.py b/src/plugin/connector/network_security_groups/network_security_groups_connector.py similarity index 60% rename from src/spaceone/inventory/connector/network_security_groups/connector.py rename to src/plugin/connector/network_security_groups/network_security_groups_connector.py index 2a6c76a8..d4ecac9d 100644 --- a/src/spaceone/inventory/connector/network_security_groups/connector.py +++ b/src/plugin/connector/network_security_groups/network_security_groups_connector.py @@ -1,14 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * +from plugin.connector.base import AzureBaseConnector -__all__ = ['NetworkSecurityGroupsConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class NetworkSecurityGroupsConnector(AzureConnector): - +class NetworkSecurityGroupsConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -20,7 +17,9 @@ def list_all_network_interfaces(self): return self.network_client.network_interfaces.list_all() def get_network_interfaces(self, network_interface_name, resource_group): - return self.network_client.network_interfaces.get(network_interface_name=network_interface_name, resource_group_name=resource_group) + return self.network_client.network_interfaces.get(network_interface_name=network_interface_name, + resource_group_name=resource_group) def get_subnet(self, resource_group_name, subnet_name, virtual_network_name): - return self.network_client.subnets.get(resource_group_name=resource_group_name, subnet_name=subnet_name, virtual_network_name=virtual_network_name) + return self.network_client.subnets.get(resource_group_name=resource_group_name, subnet_name=subnet_name, + virtual_network_name=virtual_network_name) diff --git a/src/spaceone/inventory/manager/network_security_groups/__init__.py b/src/plugin/connector/postgre_sql_servers/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/network_security_groups/__init__.py rename to src/plugin/connector/postgre_sql_servers/__init__.py diff --git a/src/plugin/connector/postgre_sql_servers/postgresql_flexible_servers_connector.py b/src/plugin/connector/postgre_sql_servers/postgresql_flexible_servers_connector.py new file mode 100644 index 00000000..f61d1449 --- /dev/null +++ b/src/plugin/connector/postgre_sql_servers/postgresql_flexible_servers_connector.py @@ -0,0 +1,19 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class PostgreSQLFlexibleServersConnector(AzureBaseConnector): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.set_connect(kwargs.get("secret_data")) + + def list_flexible_servers(self): + return self.postgre_sql_flexible_client.servers.list() + + def list_firewall_rules_by_server(self, resource_group_name, server_name): + return self.postgre_sql_flexible_client.firewall_rules.list_by_server( + resource_group_name=resource_group_name, server_name=server_name + ) \ No newline at end of file diff --git a/src/spaceone/inventory/connector/postgresql_servers/connector.py b/src/plugin/connector/postgre_sql_servers/postgresql_servers_connector.py similarity index 83% rename from src/spaceone/inventory/connector/postgresql_servers/connector.py rename to src/plugin/connector/postgre_sql_servers/postgresql_servers_connector.py index 1f876bbe..964e2875 100644 --- a/src/spaceone/inventory/connector/postgresql_servers/connector.py +++ b/src/plugin/connector/postgre_sql_servers/postgresql_servers_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * +from plugin.connector.base import AzureBaseConnector -__all__ = ["PostgreSQLServersConnector"] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class PostgreSQLServersConnector(AzureConnector): +class PostgreSQLServersConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get("secret_data")) diff --git a/src/spaceone/inventory/manager/postgresql_servers/__init__.py b/src/plugin/connector/public_ip_addresses/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/postgresql_servers/__init__.py rename to src/plugin/connector/public_ip_addresses/__init__.py diff --git a/src/plugin/connector/public_ip_addresses/public_ip_addresses_connector.py b/src/plugin/connector/public_ip_addresses/public_ip_addresses_connector.py new file mode 100644 index 00000000..6bddf41c --- /dev/null +++ b/src/plugin/connector/public_ip_addresses/public_ip_addresses_connector.py @@ -0,0 +1,14 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class PublicIPAddressesConnector(AzureBaseConnector): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.set_connect(kwargs.get('secret_data')) + + def list_all_public_ip_addresses(self): + return self.network_client.public_ip_addresses.list_all() \ No newline at end of file diff --git a/src/spaceone/inventory/manager/public_ip_addresses/__init__.py b/src/plugin/connector/snapshots/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/public_ip_addresses/__init__.py rename to src/plugin/connector/snapshots/__init__.py diff --git a/src/plugin/connector/snapshots/snapshots_connector.py b/src/plugin/connector/snapshots/snapshots_connector.py new file mode 100644 index 00000000..744f7982 --- /dev/null +++ b/src/plugin/connector/snapshots/snapshots_connector.py @@ -0,0 +1,14 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class SnapshotsConnector(AzureBaseConnector): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.set_connect(kwargs.get('secret_data')) + + def list_snapshots(self): + return self.compute_client.snapshots.list() \ No newline at end of file diff --git a/src/spaceone/inventory/manager/snapshots/__init__.py b/src/plugin/connector/sql_databases/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/snapshots/__init__.py rename to src/plugin/connector/sql_databases/__init__.py diff --git a/src/spaceone/inventory/connector/sql_databases/connector.py b/src/plugin/connector/sql_databases/sql_databases_connector.py similarity index 89% rename from src/spaceone/inventory/connector/sql_databases/connector.py rename to src/plugin/connector/sql_databases/sql_databases_connector.py index 4420833a..87168c00 100644 --- a/src/spaceone/inventory/connector/sql_databases/connector.py +++ b/src/plugin/connector/sql_databases/sql_databases_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector +from plugin.connector.base import AzureBaseConnector -__all__ = ['SQLDatabasesConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class SQLDatabasesConnector(AzureConnector): - +class SqlDatabasesConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -37,5 +35,4 @@ def list_replication_link(self, resource_group_name, server_name, database_name) def get_database_auditing_settings(self, resource_group_name, server_name, database_name): return self.sql_client.database_blob_auditing_policies.get(resource_group_name=resource_group_name, server_name=server_name, - database_name=database_name) - + database_name=database_name) \ No newline at end of file diff --git a/src/spaceone/inventory/manager/sql_databases/__init__.py b/src/plugin/connector/sql_servers/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/sql_databases/__init__.py rename to src/plugin/connector/sql_servers/__init__.py diff --git a/src/spaceone/inventory/connector/sql_servers/connector.py b/src/plugin/connector/sql_servers/sql_servers_connector.py similarity index 93% rename from src/spaceone/inventory/connector/sql_servers/connector.py rename to src/plugin/connector/sql_servers/sql_servers_connector.py index 72532e39..861c9ee9 100644 --- a/src/spaceone/inventory/connector/sql_servers/connector.py +++ b/src/plugin/connector/sql_servers/sql_servers_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * -__all__ = ['SQLServersConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class SQLServersConnector(AzureConnector): +class SqlServersConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) diff --git a/src/spaceone/inventory/manager/sql_servers/__init__.py b/src/plugin/connector/storage_accounts/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/sql_servers/__init__.py rename to src/plugin/connector/storage_accounts/__init__.py diff --git a/src/spaceone/inventory/connector/storage_accounts/connector.py b/src/plugin/connector/storage_accounts/storage_accounts_connector.py similarity index 68% rename from src/spaceone/inventory/connector/storage_accounts/connector.py rename to src/plugin/connector/storage_accounts/storage_accounts_connector.py index c6660791..161bd025 100644 --- a/src/spaceone/inventory/connector/storage_accounts/connector.py +++ b/src/plugin/connector/storage_accounts/storage_accounts_connector.py @@ -1,12 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector +from plugin.connector.base import AzureBaseConnector -__all__ = ["StorageAccountsConnector"] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class StorageAccountsConnector(AzureConnector): +class StorageAccountsConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get("secret_data")) @@ -17,4 +16,4 @@ def list_storage_accounts(self): def list_blob_containers(self, rg_name, account_name): return self.storage_client.blob_containers.list( resource_group_name=rg_name, account_name=account_name - ) + ) \ No newline at end of file diff --git a/src/spaceone/inventory/manager/storage_accounts/__init__.py b/src/plugin/connector/subscriptions/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/storage_accounts/__init__.py rename to src/plugin/connector/subscriptions/__init__.py diff --git a/src/plugin/connector/subscriptions/subscriptions_connector.py b/src/plugin/connector/subscriptions/subscriptions_connector.py new file mode 100644 index 00000000..3cf7c9e8 --- /dev/null +++ b/src/plugin/connector/subscriptions/subscriptions_connector.py @@ -0,0 +1,18 @@ +import logging + +from plugin.connector.base import AzureBaseConnector + +_LOGGER = logging.getLogger("spaceone") + + +class SubscriptionsConnector(AzureBaseConnector): + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.set_connect(kwargs.get('secret_data')) + + def get_subscription(self, subscription_id: str): + return self.subscription_client.subscriptions.get(subscription_id) + + def list_location_info(self, subscription_id: str): + return self.subscription_client.subscriptions.list_locations(subscription_id) diff --git a/src/spaceone/inventory/manager/subscriptions/__init__.py b/src/plugin/connector/virtual_machines/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/subscriptions/__init__.py rename to src/plugin/connector/virtual_machines/__init__.py diff --git a/src/spaceone/inventory/connector/virtual_machines/connector.py b/src/plugin/connector/virtual_machines/virtual_machines_connector.py similarity index 92% rename from src/spaceone/inventory/connector/virtual_machines/connector.py rename to src/plugin/connector/virtual_machines/virtual_machines_connector.py index 3200de2c..01857625 100644 --- a/src/spaceone/inventory/connector/virtual_machines/connector.py +++ b/src/plugin/connector/virtual_machines/virtual_machines_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -__all__ = ['VirtualMachinesConnector'] -_LOGGER = logging.getLogger(__name__) -DEFAULT_REGION = '' +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class VirtualMachinesConnector(AzureConnector): +class VirtualMachinesConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -80,4 +78,4 @@ def list_virtual_machine_scale_sets_in_rg(self, resource_group_name): return self.compute_client.virtual_machine_scale_sets.list(resource_group_name) def list_skus(self): - return self.compute_client.resource_skus.list() + return self.compute_client.resource_skus.list() \ No newline at end of file diff --git a/src/spaceone/inventory/manager/virtual_networks/__init__.py b/src/plugin/connector/virtual_networks/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/virtual_networks/__init__.py rename to src/plugin/connector/virtual_networks/__init__.py diff --git a/src/spaceone/inventory/connector/virtual_networks/connector.py b/src/plugin/connector/virtual_networks/virtual_networks_connector.py similarity index 59% rename from src/spaceone/inventory/connector/virtual_networks/connector.py rename to src/plugin/connector/virtual_networks/virtual_networks_connector.py index bbe8be89..caf03583 100644 --- a/src/spaceone/inventory/connector/virtual_networks/connector.py +++ b/src/plugin/connector/virtual_networks/virtual_networks_connector.py @@ -1,14 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * +from plugin.connector.base import AzureBaseConnector -__all__ = ['VirtualNetworksConnector'] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class VirtualNetworksConnector(AzureConnector): - +class VirtualNetworksConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -17,4 +14,4 @@ def list_all_virtual_networks(self): return self.network_client.virtual_networks.list_all() def list_all_firewalls(self, resource_group_name): - return self.network_client.azure_firewalls.list(resource_group_name) + return self.network_client.azure_firewalls.list(resource_group_name) \ No newline at end of file diff --git a/src/spaceone/inventory/manager/vm_scale_sets/__init__.py b/src/plugin/connector/vm_scale_sets/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/vm_scale_sets/__init__.py rename to src/plugin/connector/vm_scale_sets/__init__.py diff --git a/src/spaceone/inventory/connector/vm_scale_sets/connector.py b/src/plugin/connector/vm_scale_sets/vm_scale_sets_connector.py similarity index 77% rename from src/spaceone/inventory/connector/vm_scale_sets/connector.py rename to src/plugin/connector/vm_scale_sets/vm_scale_sets_connector.py index 313f9233..86e745fb 100644 --- a/src/spaceone/inventory/connector/vm_scale_sets/connector.py +++ b/src/plugin/connector/vm_scale_sets/vm_scale_sets_connector.py @@ -1,13 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error.custom import * +from plugin.connector.base import AzureBaseConnector -__all__ = ["VmScaleSetsConnector"] -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") -class VmScaleSetsConnector(AzureConnector): +class VMScaleSetsConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get("secret_data")) @@ -21,7 +19,7 @@ def list_vm_scale_set_vms(self, resource_group, vm_scale_set_name): ) def get_vm_scale_set_instance_view( - self, resource_group, vm_scale_set_name, instance_id + self, resource_group, vm_scale_set_name, instance_id ): return self.compute_client.virtual_machine_scale_set_vms.get_instance_view( resource_group_name=resource_group, @@ -30,7 +28,7 @@ def get_vm_scale_set_instance_view( ) def list_vm_scale_set_instance_view( - self, resource_group, vm_scale_set_name, instance_id + self, resource_group, vm_scale_set_name, instance_id ): return self.compute_client.virtual_machine_scale_set_vms.list( resource_group_name=resource_group, diff --git a/src/spaceone/inventory/manager/web_pubsub_service/__init__.py b/src/plugin/connector/web_pub_sub_service/__init__.py similarity index 100% rename from src/spaceone/inventory/manager/web_pubsub_service/__init__.py rename to src/plugin/connector/web_pub_sub_service/__init__.py diff --git a/src/spaceone/inventory/connector/web_pubsub_service/connector.py b/src/plugin/connector/web_pub_sub_service/web_pubsub_service_connector.py similarity index 77% rename from src/spaceone/inventory/connector/web_pubsub_service/connector.py rename to src/plugin/connector/web_pub_sub_service/web_pubsub_service_connector.py index 9e3ee6bd..c91b13c1 100644 --- a/src/spaceone/inventory/connector/web_pubsub_service/connector.py +++ b/src/plugin/connector/web_pub_sub_service/web_pubsub_service_connector.py @@ -1,12 +1,11 @@ import logging -from spaceone.inventory.libs.connector import AzureConnector -__all__ = ['WebPubSubServiceConnector'] -_LOGGER = logging.getLogger(__name__) +from plugin.connector.base import AzureBaseConnector +_LOGGER = logging.getLogger("spaceone") -class WebPubSubServiceConnector(AzureConnector): +class WebPubSubServiceConnector(AzureBaseConnector): def __init__(self, **kwargs): super().__init__(**kwargs) self.set_connect(kwargs.get('secret_data')) @@ -20,4 +19,4 @@ def list_hubs(self, resource_group_name, resource_name): def list_keys(self, resource_group_name, resource_name): return self.web_pubsub_service_client.web_pub_sub.list_keys(resource_group_name=resource_group_name, - resource_name=resource_name) + resource_name=resource_name) \ No newline at end of file diff --git a/src/plugin/main.py b/src/plugin/main.py new file mode 100644 index 00000000..ff2e8d12 --- /dev/null +++ b/src/plugin/main.py @@ -0,0 +1,135 @@ +import logging +import time +from typing import Generator + +from spaceone.core.error import ERROR_REQUIRED_PARAMETER +from spaceone.inventory.plugin.collector.lib.server import CollectorPluginServer + +from plugin.manager.base import AzureBaseManager +from plugin.manager.subscriptions.subscription_manager import SubscriptionsManager + +app = CollectorPluginServer() + +_LOGGER = logging.getLogger("spaceone") + +DEFAULT_RESOURCE_TYPES = ["inventory.CloudService", "inventory.CloudServiceType", "inventory.Metric", + "inventory.Region"] + + +@app.route('Collector.init') +def collector_init(params: dict) -> dict: + return _create_init_metadata() + + +@app.route('Collector.verify') +def collector_verify(params: dict) -> None: + pass + + +@app.route('Collector.collect') +def collector_collect(params: dict) -> Generator[dict, None, None]: + options: dict = params.get("options", {}) or {} + secret_data: dict = params["secret_data"] + schema: str = params.get("schema") + task_options: dict = params.get("task_options", {}) or {} + domain_id: str = params["domain_id"] + subscription_id = secret_data.get("subscription_id") + + _check_secret_data(secret_data) + + start_time = time.time() + _LOGGER.debug(f"[collector_collect] Start Collecting Azure Resources {subscription_id}") + + cloud_service_groups = _get_cloud_service_groups_from_options_and_task_options(options, task_options) + resource_type = task_options.get("resource_type") + + if resource_type == "inventory.Region": + subscriptions_mgr = SubscriptionsManager() + location_info = subscriptions_mgr.list_location_info(secret_data) + yield from AzureBaseManager().collect_region(location_info) + else: + for manager in AzureBaseManager.list_managers_by_cloud_service_groups(cloud_service_groups): + if resource_type == "inventory.CloudService": + yield from manager().collect_cloud_services(options, secret_data, schema) + elif resource_type == "inventory.CloudServiceType": + yield from manager().collect_cloud_service_type() + elif resource_type == "inventory.Metric": + yield from AzureBaseManager.collect_metrics(manager.cloud_service_group) + else: + yield from manager().collect_resources(options, secret_data, schema) + _LOGGER.debug( + f"[collector_collect] Finished Collecting Azure Resources {subscription_id} duration: {time.time() - start_time} seconds") + + +@app.route('Job.get_tasks') +def job_get_tasks(params: dict) -> dict: + domain_id = params["domain_id"] + options = params.get("options", {}) + cloud_service_groups = options.get("cloud_service_groups", []) + resource_types = options.get("resource_types", DEFAULT_RESOURCE_TYPES) + + tasks = [] + + if not resource_types: + resource_types = DEFAULT_RESOURCE_TYPES + + for manager in AzureBaseManager.list_managers_by_cloud_service_groups(cloud_service_groups): + for resource_type in resource_types: + tasks.append({ + "task_options": { + "resource_type": resource_type, + "cloud_service_groups": [manager.cloud_service_group] + } + }) + + return {"tasks": tasks} + + +def _create_init_metadata() -> dict: + return { + "metadata": { + "options_schema": { + "type": "object", + "properties": { + "cloud_service_groups": { + "title": "Specific services", + "type": "string", + "items": {"type": "string"}, + "default": "All", + "enum": _get_cloud_service_group_enum(), + "description": "Choose one of the service to collect data. If you choose 'All', it will collect all services." + } + } + } + } + } + + +def _get_cloud_service_group_enum() -> list: + enum = ["All"] + for manager in AzureBaseManager.__subclasses__(): + if manager.cloud_service_group: + enum.append(manager.cloud_service_group) + + return enum + + +def _get_cloud_service_groups_from_options_and_task_options(options: dict, task_options: dict) -> list: + cloud_service_groups = options.get("cloud_service_groups", []) + if task_options: + cloud_service_groups = task_options.get("cloud_service_groups", cloud_service_groups) + return cloud_service_groups + + +def _check_secret_data(secret_data: dict): + if "tenant_id" not in secret_data: + raise ERROR_REQUIRED_PARAMETER(key='secret_data.tenant_id') + + if "subscription_id" not in secret_data: + raise ERROR_REQUIRED_PARAMETER(key='secret_data.subscription_id') + + if "client_id" not in secret_data: + raise ERROR_REQUIRED_PARAMETER(key='secret_data.client_id') + + if "client_secret" not in secret_data: + raise ERROR_REQUIRED_PARAMETER(key='secret_data.client_secret') diff --git a/src/plugin/manager/__init__.py b/src/plugin/manager/__init__.py new file mode 100644 index 00000000..893cd79d --- /dev/null +++ b/src/plugin/manager/__init__.py @@ -0,0 +1,19 @@ +from .disks import * +from .public_ip_addresses import * +from .sql_databases import * +from .sql_servers import * +from .virtual_networks import * +from .application_gatways import * +from .nat_gateways import * +from .container_instances import * +from .network_security_groups import * +from .storage_accounts import * +from .snapshots import * +from .vm_scale_sets import * +from .load_balancers import * +from .cosmos_db import * +from .postgre_sql_servers import * +from .web_pub_sub_service import * +from .key_vaults import * +from .my_sql_servers import * +from .virtual_machines import * diff --git a/src/plugin/manager/application_gatways/__init__.py b/src/plugin/manager/application_gatways/__init__.py new file mode 100644 index 00000000..8ffe4b83 --- /dev/null +++ b/src/plugin/manager/application_gatways/__init__.py @@ -0,0 +1 @@ +from .instance_manager import InstanceManager diff --git a/src/spaceone/inventory/manager/application_gateways/instance_manager.py b/src/plugin/manager/application_gatways/instance_manager.py similarity index 78% rename from src/spaceone/inventory/manager/application_gateways/instance_manager.py rename to src/plugin/manager/application_gatways/instance_manager.py index c2e5ce6a..dacfb456 100644 --- a/src/spaceone/inventory/manager/application_gateways/instance_manager.py +++ b/src/plugin/manager/application_gatways/instance_manager.py @@ -1,59 +1,51 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.application_gateways import ( - ApplicationGatewaysConnector, -) -from spaceone.inventory.model.application_gateways.cloud_service import * -from spaceone.inventory.model.application_gateways.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.application_gateways.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.application_gateways.application_gateways_connector import ApplicationGatewaysConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class ApplicationGatewaysManager(AzureManager): - connector_name = "ApplicationGatewaysConnector" - 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 application gateway data resource information - ErrorResourceResponse (list) : list of error resource information - """ - - _LOGGER.debug(f"** Application Gateway START **") - - start_time = time.time() - subscription_info = params["subscription_info"] - - application_gateway_conn: ApplicationGatewaysConnector = ( - self.locator.get_connector(self.connector_name, **params) +class InstanceManager(AzureBaseManager): + cloud_service_group = "ApplicationGateways" + cloud_service_type = "Instance" + service_code = "/Microsoft.Network/applicationGateways" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-application-gateways.svg" + } ) - application_gateways_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - application_gateways_list = ( - application_gateway_conn.list_all_application_gateways() - ) + application_gateways_conn = ApplicationGatewaysConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + application_gateways_list = application_gateways_conn.list_all_application_gateways() + for application_gateway in application_gateways_list: - application_gateway_id = "" try: - application_gateway_dict = self.convert_nested_dictionary( - application_gateway - ) + application_gateway_dict = self.convert_nested_dictionary(application_gateway) application_gateway_id = application_gateway_dict["id"] # update application_gateway_dict @@ -63,7 +55,7 @@ def collect_cloud_service(self, params): application_gateway_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": application_gateway_id}, } ) @@ -87,8 +79,8 @@ def collect_cloud_service(self, params): for frontend_ip_configuration_dict in frontend_ip_configurations: if ( - frontend_ip_configuration_dict.get("private_ip_address") - is not None + frontend_ip_configuration_dict.get("private_ip_address") + is not None ): application_gateway_dict.update( { @@ -106,14 +98,14 @@ def collect_cloud_service(self, params): } ) elif ( - frontend_ip_configuration_dict.get("public_ip_address") - is not None + frontend_ip_configuration_dict.get("public_ip_address") + is not None ): public_ip_address_name = frontend_ip_configuration_dict[ "public_ip_address" ]["id"].split("/")[8] public_ip_address_dict = self.get_public_ip_address( - application_gateway_conn, + application_gateways_conn, application_gateway_dict["resource_group"], public_ip_address_name, ) @@ -123,7 +115,7 @@ def collect_cloud_service(self, params): frontend_ip_configuration_dict.update( { "ip_type": "Public", - "ip_address": f'{public_ip_address_dict.get("ip_address", "-")} ({public_ip_address_dict.get("name","")})', + "ip_address": f'{public_ip_address_dict.get("ip_address", "-")} ({public_ip_address_dict.get("name", "")})', "associated_listener": self.get_associated_listener( frontend_ip_configuration_dict, application_gateway_dict.get("http_listeners", []), @@ -144,8 +136,8 @@ def collect_cloud_service(self, params): ) if ( - application_gateway_dict.get("backend_http_settings_collection") - is not None + application_gateway_dict.get("backend_http_settings_collection") + is not None ): for backend_setting in application_gateway_dict[ "backend_http_settings_collection" @@ -226,10 +218,10 @@ def collect_cloud_service(self, params): http_listener_id = request_routing_rule["http_listener"]["id"] for request_routing_rule in application_gateway_dict.get( - "request_routing_rules", [] + "request_routing_rules", [] ): if http_listener_id in request_routing_rule.get( - "http_listener" + "http_listener" ).get("id", ""): http_applied_rules_list.append( request_routing_rule["name"] @@ -262,44 +254,35 @@ def collect_cloud_service(self, params): {"backend_addresses_display": backend_addresses_display} ) - application_gateway_data = ApplicationGateway( - application_gateway_dict, strict=False - ) - application_gateway_resource = ApplicationGatewayResource( - { - "data": application_gateway_data, - "tags": application_gateway_dict.get("tags", {}), - "region_code": application_gateway_data.location, - "reference": ReferenceModel( - application_gateway_data.reference() - ), - "name": application_gateway_data.name, - "instance_type": application_gateway_data.sku.name, - "account": application_gateway_data.subscription_id, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(application_gateway_data["location"]) - application_gateways_responses.append( - ApplicationGatewayResponse( - {"resource": application_gateway_resource} + self.set_region_code(application_gateway_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=application_gateway_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=application_gateway_dict, + account=application_gateway_dict["subscription_id"], + instance_type=application_gateway_dict["sku"]["name"], + region_code=application_gateway_dict["location"], + reference=self.make_reference(application_gateway_dict.get("id")), + data_format="dict" ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {application_gateway_id} {e}", exc_info=True - ) - error_response = self.generate_resource_error_response( - e, "Network", "ApplicationGateway", application_gateway_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_response) - _LOGGER.debug( - f"** Application Gateway Finished {time.time() - start_time} Seconds **" - ) - return application_gateways_responses, error_responses + return cloud_services, error_responses def get_public_ip_address( self, application_gateway_conn, resource_group_name, pip_name diff --git a/src/plugin/manager/base.py b/src/plugin/manager/base.py new file mode 100644 index 00000000..6306542a --- /dev/null +++ b/src/plugin/manager/base.py @@ -0,0 +1,270 @@ +import os +import abc +import logging +import datetime +import time +import re +from typing import Union + +from spaceone.core.manager import BaseManager +from spaceone.core import utils +from spaceone.inventory.plugin.collector.lib import * + +_LOGGER = logging.getLogger("spaceone") +_CURRENT_DIR = os.path.dirname(__file__) +_METRIC_DIR = os.path.join(_CURRENT_DIR, "../metrics/") +_METADATA_DIR = os.path.join(_CURRENT_DIR, "../metadata/") + +__all__ = ["AzureBaseManager"] + + +class AzureBaseManager(BaseManager): + service = None + cloud_service_group = None + cloud_service_type = None + region_info = {} + collected_region_codes = [] + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.provider = "azure" + + @abc.abstractmethod + def create_cloud_service_type(self): + raise NotImplementedError( + "method `create_cloud_service_type` should be implemented" + ) + + @abc.abstractmethod + def create_cloud_service(self, options, secret_data, schema): + raise NotImplementedError("method `create_cloud_service` should be implemented") + + @classmethod + def list_managers_by_cloud_service_groups(cls, cloud_service_groups: list): + if cloud_service_groups in ["All"] or not cloud_service_groups: + for manager in cls.__subclasses__(): + if manager.cloud_service_group: + yield manager + elif cloud_service_groups: + for manager in cls.__subclasses__(): + if manager.cloud_service_group and manager.cloud_service_group in cloud_service_groups: + yield manager + + @classmethod + def get_managers_by_cloud_service_group(cls, cloud_service_group: str): + sub_cls = cls.__subclasses__() + for manager in sub_cls: + if manager.__name__ == cloud_service_group: + return manager + + @classmethod + def collect_metrics(cls, cloud_service_group: str): + if not os.path.exists(os.path.join(_METRIC_DIR, cloud_service_group)): + os.mkdir(os.path.join(_METRIC_DIR, cloud_service_group)) + for dirname in os.listdir(os.path.join(_METRIC_DIR, cloud_service_group)): + for filename in os.listdir(os.path.join(_METRIC_DIR, cloud_service_group, dirname)): + if filename.endswith(".yaml"): + file_path = os.path.join(_METRIC_DIR, cloud_service_group, dirname, filename) + info = utils.load_yaml_from_file(file_path) + if filename == "namespace.yaml": + yield make_response( + namespace=info, + resource_type="inventory.Namespace", + match_keys=[] + ) + else: + yield make_response( + metric=info, + resource_type="inventory.Metric", + match_keys=[] + ) + + def collect_resources(self, options: dict, secret_data: dict, schema: str): + subscription_id = secret_data.get("subscription_id") + start_time = time.time() + _LOGGER.debug( + f"[START] Collecting {self.__repr__()} (subscription_id: {subscription_id})" + ) + success_count, error_count = [0, 0] + try: + yield from self.collect_cloud_service_type() + + cloud_services, total_count = self.collect_cloud_service(options, secret_data, schema + ) + for cloud_service in cloud_services: + yield cloud_service + success_count, error_count = total_count + + subscriptions_manager = AzureBaseManager.get_managers_by_cloud_service_group("SubscriptionsManager") + location_info = subscriptions_manager().list_location_info(secret_data) + + yield from self.collect_region(location_info) + # yield from self.collect_region(secret_data) + + except Exception as e: + yield make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + + _LOGGER.debug( + f"[DONE] {self.__repr__()} Collected Time: {time.time() - start_time:.2f}s, Total Count: {success_count + error_count} (Success: {success_count}, Failure: {error_count})" + ) + + def collect_cloud_service_type(self): + _LOGGER.debug(f"[START] Collecting cloud service type {self.__repr__()}") + + cloud_service_type = self.create_cloud_service_type() + yield make_response( + cloud_service_type=cloud_service_type, + match_keys=[["name", "group", "provider"]], + resource_type="inventory.CloudServiceType", + ) + + def collect_cloud_services(self, options: dict, secret_data: dict, schema: str): + subscription_id = secret_data.get("subscription_id") + start_time = time.time() + _LOGGER.debug( + f"[START] Collecting cloud services {self.__repr__()} (subscription_id: {subscription_id})" + ) + success_count, error_count = [0, 0] + try: + cloud_services, total_count = self.collect_cloud_service( + options, secret_data, schema + ) + for cloud_service in cloud_services: + yield cloud_service + success_count, error_count = total_count + + except Exception as e: + yield make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + + _LOGGER.debug( + f"[DONE] {self.__repr__()} Collected Time: {time.time() - start_time:.2f}s, Total Count: {success_count + error_count} (Success: {success_count}, Failure: {error_count})" + ) + + def collect_cloud_service(self, options: dict, secret_data: dict, schema: str): + total_resources = [] + cloud_services, error_resources = self.create_cloud_service( + options, secret_data, schema + ) + + for cloud_service in cloud_services: + total_resources.append( + make_response( + cloud_service=cloud_service, + match_keys=[ + [ + "reference.resource_id", + "provider", + "cloud_service_type", + "cloud_service_group", + "account" + ] + ], + ) + ) + total_resources.extend(error_resources) + total_count = [len(cloud_services), len(error_resources)] + return total_resources, total_count + + def collect_region(self, location_info: dict): + _LOGGER.debug(f"[START] Collecting region {self.__repr__()}") + for region_info in location_info.values(): + yield make_response( + region=region_info, + match_keys=[["region_code", "provider"]], + resource_type="inventory.Region", + ) + + def get_metadata_path(self): + _cloud_service_group = self._camel_to_snake(self.cloud_service_group) + _cloud_service_type = self._camel_to_snake(self.cloud_service_type) + + return os.path.join(_METADATA_DIR, _cloud_service_group, f"{_cloud_service_type}.yaml") + + def convert_nested_dictionary(self, cloud_svc_object: object) -> Union[object, dict]: + cloud_svc_dict = {} + if hasattr( + cloud_svc_object, "__dict__" + ): # if cloud_svc_object is not a dictionary type but has dict method + cloud_svc_dict = cloud_svc_object.__dict__ + elif isinstance(cloud_svc_object, dict): + cloud_svc_dict = cloud_svc_object + elif not isinstance( + cloud_svc_object, list + ): # if cloud_svc_object is one of type like int, float, char, ... + return cloud_svc_object + + # if cloud_svc_object is dictionary type + for key, value in cloud_svc_dict.items(): + if hasattr(value, "__dict__") or isinstance(value, dict): + cloud_svc_dict[key] = self.convert_nested_dictionary(value) + if "azure" in str(type(value)): + cloud_svc_dict[key] = self.convert_nested_dictionary(value) + elif isinstance(value, list): + value_list = [] + for v in value: + value_list.append(self.convert_nested_dictionary(v)) + cloud_svc_dict[key] = value_list + elif isinstance(value, datetime.datetime): + cloud_svc_dict[key] = utils.datetime_to_iso8601(value) + + return cloud_svc_dict + + def set_region_code(self, region): + if region not in self.region_info: + region = "global" + + if region not in self.collected_region_codes: + self.collected_region_codes.append(region) + + @staticmethod + def make_reference(resource_id: str, external_link_format: str = None) -> dict: + if external_link_format: + external_link = external_link_format.format(resource_id=resource_id) + else: + external_link = f"https://portal.azure.com/#@.onmicrosoft.com/resource{resource_id}/overview" + return { + "resource_id": resource_id, + "external_link": external_link + } + + @staticmethod + def _camel_to_snake(name): + name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) + return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower() + + @staticmethod + def get_resource_group_from_id(dict_id): + resource_group = dict_id.split("/")[4] + return resource_group + + @staticmethod + def update_tenant_id_from_secret_data( + cloud_service_data: dict, secret_data: dict + ) -> dict: + if tenant_id := secret_data.get("tenant_id"): + cloud_service_data.update({"tenant_id": tenant_id}) + return cloud_service_data + + @staticmethod + def convert_dictionary(obj): + return vars(obj) + + @staticmethod + def convert_tag_format(tags): + convert_tags = [] + + if tags: + for k, v in tags.items(): + convert_tags.append({"key": k, "value": v}) + + return convert_tags diff --git a/src/plugin/manager/container_instances/__init__.py b/src/plugin/manager/container_instances/__init__.py new file mode 100644 index 00000000..f47d688a --- /dev/null +++ b/src/plugin/manager/container_instances/__init__.py @@ -0,0 +1 @@ +from .container_manager import ContainerInstancesManage diff --git a/src/spaceone/inventory/manager/container_instances/container_manager.py b/src/plugin/manager/container_instances/container_manager.py similarity index 51% rename from src/spaceone/inventory/manager/container_instances/container_manager.py rename to src/plugin/manager/container_instances/container_manager.py index e6d17068..d3953423 100644 --- a/src/spaceone/inventory/manager/container_instances/container_manager.py +++ b/src/plugin/manager/container_instances/container_manager.py @@ -1,71 +1,61 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.connector.container_instances import ContainerInstancesConnector -from spaceone.inventory.model.container_instances.cloud_service import * -from spaceone.inventory.model.container_instances.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.container_instances.data import * -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.core.utils import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.container_instances.container_instances_connector import ContainerInstancesConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class ContainerInstancesManager(AzureManager): - connector_name = "ContainerInstancesConnector" - 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 container instances data resource information - ErrorResourceResponse (list) : list of error resource information - """ - - _LOGGER.debug(f"** Container Instances START **") - start_time = time.time() - secret_data = params.get("secret_data", {}) - subscription_info = params["subscription_info"] - - container_instances_conn: ContainerInstancesConnector = ( - self.locator.get_connector(self.connector_name, **params) +class ContainerInstancesManage(AzureBaseManager): + cloud_service_group = "ContainerInstances" + cloud_service_type = "Container" + service_code = "/Microsoft.Compute/disks" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Container"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-container-instances.svg" + } ) - container_instances_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] + container_instances_conn = ContainerInstancesConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + container_instances = container_instances_conn.list_container_groups() + for container_instance in container_instances: - container_instance_id = "" + try: - container_instance_dict = self.convert_nested_dictionary( - container_instance - ) + container_instance_dict = self.convert_nested_dictionary(container_instance) container_instance_id = container_instance_dict["id"] - # if bug fix these code will be deleted - resource_group_name = self.get_resource_group_from_id( - container_instance_id - ) + resource_group_name = self.get_resource_group_from_id(container_instance_id) container_group_name = container_instance_dict["name"] container_instance = container_instances_conn.get_container_groups( resource_group_name=resource_group_name, container_group_name=container_group_name, ) - container_instance_dict = self.convert_nested_dictionary( - container_instance - ) - time.sleep(0.2) # end code + container_instance_dict = self.convert_nested_dictionary(container_instance) # Update data info in Container Instance's Raw Data _cpu_count_display = 0 @@ -93,6 +83,12 @@ def collect_cloud_service(self, params): container_instance_dict["volume_count_display"] = len( container_instance_dict["volumes"] ) + else: + for container in container_instance_dict["containers"]: + container["volume_mount_count_display"] = 0 + + container_instance_dict["volume_count_display"] = 0 + container_instance_dict = self.update_tenant_id_from_secret_data( container_instance_dict, secret_data @@ -104,7 +100,7 @@ def collect_cloud_service(self, params): container_instance_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": container_instance_id}, "container_count_display": len( container_instance_dict["containers"] @@ -115,42 +111,34 @@ def collect_cloud_service(self, params): } ) - container_instance_data = ContainerInstance( - container_instance_dict, strict=False - ) - - # Update resource info of Container Instance - container_instance_resource = ContainerInstanceResource( - { - "name": container_instance_data.name, - "account": container_instance_dict["subscription_id"], - "data": container_instance_data, - "tags": container_instance_dict.get("tags", {}), - "region_code": container_instance_data.location, - "reference": ReferenceModel( - container_instance_data.reference() - ), - } - ) - - self.set_region_code(container_instance_data["location"]) - container_instances_responses.append( - ContainerInstanceResponse({"resource": container_instance_resource}) + self.set_region_code(container_instance_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=container_instance_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=container_instance_dict, + account=container_instance_dict["subscription_id"], + region_code=container_instance_dict["location"], + reference=self.make_reference(container_instance_dict.get("id")), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {container_instance_id} {e}", exc_info=True - ) - error_response = self.generate_resource_error_response( - e, "Container", "ContainerInstances", container_instance_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_response) - _LOGGER.debug( - f"** Container Instances Finished {time.time() - start_time} Seconds **" - ) - return container_instances_responses, error_responses + return cloud_services, error_responses @staticmethod def _set_container_instance_volume_type(volumes): @@ -183,26 +171,9 @@ def _set_volumes_detail_info(volume, containers): def _get_gpu_count_display(container): _gpu_count = 0 if ( - _gpu_info := container.get("resources", {}) - .get("requests", {}) - .get("gpu", {}) + _gpu_info := container.get("resources", {}) + .get("requests", {}) + .get("gpu", {}) ): _gpu_count = _gpu_info.get("count", 0) return _gpu_count - - @staticmethod - def _convert_start_time_datetime_to_iso861(container): - if ( - _start_time := container.get("instance_view", {}) - .get("current_state", {}) - .get("start_time") - ): - _start_time = datetime_to_iso8601(_start_time) - container["instance_view"]["current_state"]["start_time"] = _start_time - elif ( - _finish_time := container.get("instance_view", {}) - .get("current_state", {}) - .get("_finish_time") - ): - _finish_time = datetime_to_iso8601(_finish_time) - container["instance_view"]["current_state"]["finished_time"] = _finish_time diff --git a/src/plugin/manager/cosmos_db/__init__.py b/src/plugin/manager/cosmos_db/__init__.py new file mode 100644 index 00000000..fad53c07 --- /dev/null +++ b/src/plugin/manager/cosmos_db/__init__.py @@ -0,0 +1 @@ +from .instance_manager import CosmosDBManager diff --git a/src/spaceone/inventory/manager/cosmos_db/instance_manager.py b/src/plugin/manager/cosmos_db/instance_manager.py similarity index 64% rename from src/spaceone/inventory/manager/cosmos_db/instance_manager.py rename to src/plugin/manager/cosmos_db/instance_manager.py index dadc059d..1acaacf7 100644 --- a/src/spaceone/inventory/manager/cosmos_db/instance_manager.py +++ b/src/plugin/manager/cosmos_db/instance_manager.py @@ -1,51 +1,48 @@ -import time import logging -from spaceone.core.utils import * -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.cosmos_db import CosmosDBConnector -from spaceone.inventory.model.cosmos_db.cloud_service import * -from spaceone.inventory.model.cosmos_db.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.inventory.model.cosmos_db.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.cosmos_db.cosmos_db_connector import CosmosDBConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class CosmosDBManager(AzureManager): - connector_name = "CosmosDBConnector" - 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) : dictionary of azure cosmosdb data resource information - ErrorResourceResponse (list) : list of error resource information - - - """ - _LOGGER.debug(f"** CosmosDB START **") - - start_time = time.time() - subscription_info = params["subscription_info"] - cosmos_db_conn: CosmosDBConnector = self.locator.get_connector( - self.connector_name, **params +class CosmosDBManager(AzureBaseManager): + cloud_service_group = "CosmosDB" + cloud_service_type = "Instance" + service_code = "/Microsoft.DocumentDB/databaseAccounts" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-cosmos-db.svg" + } ) - cosmos_db_account_responses = [] + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] + cosmos_db_conn = CosmosDBConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + cosmos_db_accounts_list = cosmos_db_conn.list_all_cosmos_db_accounts() for cosmos_db_account in cosmos_db_accounts_list: - cosmos_db_account_id = "" try: cosmos_db_account_dict = self.convert_nested_dictionary( @@ -58,7 +55,7 @@ def collect_cloud_service(self, params): # update cosmosdb_dict cosmos_db_account_dict = self.update_tenant_id_from_secret_data( - cosmos_db_account_dict, params["secret_data"] + cosmos_db_account_dict, secret_data ) cosmos_db_account_dict.update( { @@ -66,7 +63,7 @@ def collect_cloud_service(self, params): cosmos_db_account_dict["id"] ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": cosmos_db_account_id}, } ) @@ -90,8 +87,8 @@ def collect_cloud_service(self, params): ) if ( - cosmos_db_account_dict.get("private_endpoint_connections") - is not None + cosmos_db_account_dict.get("private_endpoint_connections") + is not None ): for private_connection in cosmos_db_account_dict[ "private_endpoint_connections" @@ -106,6 +103,7 @@ def collect_cloud_service(self, params): ), } ) + if cosmos_db_account_dict.get("cors") is not None: cosmos_db_account_dict.update( { @@ -134,42 +132,37 @@ def collect_cloud_service(self, params): } ) - cosmos_db_account_data = DatabaseAccountGetResults( - cosmos_db_account_dict, strict=False - ) - cosmos_db_resource = CosmosDBResource( - { - "data": cosmos_db_account_data, - "tags": cosmos_db_account_dict.get("tags", {}), - "region_code": cosmos_db_account_data.location, - "reference": ReferenceModel(cosmos_db_account_data.reference()), - "name": cosmos_db_account_data.name, - "account": cosmos_db_account_data.subscription_id, - "instance_type": cosmos_db_account_data.database_account_offer_type, - "launched_at": datetime_to_iso8601( - cosmos_db_account_data.system_data.created_at - ), - } - ) - - # Must set_region_code method for region collection - self.set_region_code(cosmos_db_account_data["location"]) - cosmos_db_account_responses.append( - CosmosDBResponse({"resource": cosmos_db_resource}) + self.set_region_code(cosmos_db_account_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=cosmos_db_account_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=cosmos_db_account_dict, + account=secret_data["subscription_id"], + instance_type=cosmos_db_account_dict["database_account_offer_type"], + region_code=cosmos_db_account_dict["location"], + reference=self.make_reference(cosmos_db_account_dict.get("id")), + # launched_at=cosmos_db_account_dict.system_data.created_at, + tags=cosmos_db_account_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {cosmos_db_account_id} {e}", exc_info=True - ) - error_response = self.generate_resource_error_response( - e, "Database", "AzureCosmosDB", cosmos_db_account_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_response) - - _LOGGER.debug(f"** CosmosDB Finished {time.time() - start_time} Seconds **") - return cosmos_db_account_responses, error_responses + return cloud_services, error_responses def get_keys(self, cosmos_db_conn, account_name, resource_group): keys_obj = cosmos_db_conn.list_keys( diff --git a/src/plugin/manager/disks/__init__.py b/src/plugin/manager/disks/__init__.py new file mode 100644 index 00000000..3b627d7d --- /dev/null +++ b/src/plugin/manager/disks/__init__.py @@ -0,0 +1 @@ +from .disk_manager import DisksManager diff --git a/src/spaceone/inventory/manager/disks/disk_manager.py b/src/plugin/manager/disks/disk_manager.py similarity index 54% rename from src/spaceone/inventory/manager/disks/disk_manager.py rename to src/plugin/manager/disks/disk_manager.py index 46f25cfa..18174644 100644 --- a/src/spaceone/inventory/manager/disks/disk_manager.py +++ b/src/plugin/manager/disks/disk_manager.py @@ -1,47 +1,48 @@ -import time import logging -from spaceone.core.utils import * -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.model.disks.cloud_service import * -from spaceone.inventory.connector.disks import DisksConnector -from spaceone.inventory.model.disks.cloud_service_type import CLOUD_SERVICE_TYPES + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.disks.disks_connector import DisksConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class DisksManager(AzureManager): - connector_name = "DisksConnector" - 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) : dictionary of azure disk data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f"** Disk START **") - start_time = time.time() - subscription_info = params["subscription_info"] - - disk_conn: DisksConnector = self.locator.get_connector( - self.connector_name, **params +class DisksManager(AzureBaseManager): + cloud_service_group = "Disks" + cloud_service_type = "Disk" + service_code = "/Microsoft.Compute/disks" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Compute", "Storage"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-disk.svg" + } ) - disk_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - disks = disk_conn.list_disks() + disks_conn = DisksConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + disks = disks_conn.list_disks() + for disk in disks: - disk_id = "" try: disk_dict = self.convert_nested_dictionary(disk) @@ -56,18 +57,15 @@ def collect_cloud_service(self, params): # update disk_data dict disk_dict.update( { - "resource_group": self.get_resource_group_from_id( - disk_dict["id"] - ), # parse resource_group from ID + "resource_group": self.get_resource_group_from_id(disk_dict["id"]), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "size": disk_dict["disk_size_bytes"], "tier_display": self.get_tier_display( disk_dict["disk_iops_read_write"], disk_dict["disk_m_bps_read_write"], ), - "azure_monitor": {"resource_id": disk_id}, - "time_created": datetime_to_iso8601(disk_dict["time_created"]), + "azure_monitor": {"resource_id": disk_id} } ) @@ -95,51 +93,46 @@ def collect_cloud_service(self, params): max_shares = disk_dict.get("max_shares") if max_shares is not None and max_shares > 0: disk_dict.update({"enable_shared_disk_display": True}) + else: + disk_dict.update({"enable_shared_disk_display": False}) if disk_dict.get("bursting_enabled") is None: disk_dict["bursting_enabled"] = False - disk_dict = self.update_tenant_id_from_secret_data( - disk_dict, params.get("secret_data", {}) + disk_data = self.update_tenant_id_from_secret_data( + disk_dict, secret_data ) - disk_data = Disk(disk_dict, strict=False) + self.set_region_code(disk_data["location"]) - disk_resource = DiskResource( - { - "data": disk_data, - "region_code": disk_data.location, - "reference": ReferenceModel(disk_data.reference()), - "tags": disk_dict.get("tags", {}), - "name": disk_data.name, - "account": disk_data.subscription_id, - "instance_type": disk_data.sku.name, - "instance_size": float(disk_data.disk_size_bytes), - } + cloud_services.append( + make_cloud_service( + name=disk_data["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=disk_data, + account=secret_data["subscription_id"], + instance_type=disk_data["sku"]["name"], + instance_size=disk_data["disk_size_bytes"], + region_code=disk_data["location"], + reference=self.make_reference(disk_data.get("id")), + data_format="dict" + ) ) - # Must set_region_code method for region collection - self.set_region_code(disk_data["location"]) - # _LOGGER.debug(f'[DISK INFO: {disk_resource.to_primitive()}]') - disk_responses.append(DiskResponse({"resource": disk_resource})) - except Exception as e: - _LOGGER.error(f"[list_instances] {disk_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, - resource_id=disk_id, - cloud_service_group="Compute", - cloud_service_type="Disk", + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** Disk Finished {time.time() - start_time} Seconds **") - return disk_responses, error_responses - - @staticmethod - def get_attached_vm_name_from_managed_by(managed_by): - attached_vm_name = managed_by.split("/")[8] - return attached_vm_name + return cloud_services, error_responses @staticmethod def get_disk_sku_name(sku_tier): @@ -153,6 +146,17 @@ def get_disk_sku_name(sku_tier): sku_name = "Ultra SSD" return sku_name + @staticmethod + def get_tier_display(disk_iops_read_write, disk_m_bps_read_write): + tier_display = ( + str(disk_iops_read_write) + + " IOPS" + + ", " + + str(disk_m_bps_read_write) + + " Mbps" + ) + return tier_display + @staticmethod def get_network_access_policy(network_access_policy): network_access_policy_display = "" @@ -166,12 +170,6 @@ def get_network_access_policy(network_access_policy): return network_access_policy_display @staticmethod - def get_tier_display(disk_iops_read_write, disk_m_bps_read_write): - tier_display = ( - str(disk_iops_read_write) - + " IOPS" - + ", " - + str(disk_m_bps_read_write) - + " Mbps" - ) - return tier_display + def get_attached_vm_name_from_managed_by(managed_by): + attached_vm_name = managed_by.split("/")[8] + return attached_vm_name diff --git a/src/plugin/manager/key_vaults/__init__.py b/src/plugin/manager/key_vaults/__init__.py new file mode 100644 index 00000000..26e1d194 --- /dev/null +++ b/src/plugin/manager/key_vaults/__init__.py @@ -0,0 +1 @@ +from .instance_manager import KeyVaultsManager diff --git a/src/spaceone/inventory/manager/key_vaults/instance_manager.py b/src/plugin/manager/key_vaults/instance_manager.py similarity index 53% rename from src/spaceone/inventory/manager/key_vaults/instance_manager.py rename to src/plugin/manager/key_vaults/instance_manager.py index f826373e..fd53caa8 100644 --- a/src/spaceone/inventory/manager/key_vaults/instance_manager.py +++ b/src/plugin/manager/key_vaults/instance_manager.py @@ -1,60 +1,59 @@ -import time import logging +import datetime +from typing import Union import azure.core.exceptions -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.key_vaults import KeyVaultsConnector -from spaceone.inventory.model.key_vaults.cloud_service import * -from spaceone.inventory.model.key_vaults.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.inventory.model.key_vaults.data import * +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.key_vaults.key_vaults_connector import KeyVaultsConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class KeyVaultsManager(AzureManager): - connector_name = "KeyVaultsConnector" - cloud_service_types = CLOUD_SERVICE_TYPES - - def collect_cloud_service(self, params: dict): - """ - Args: - params (dict): - - 'options' : 'dict' - - 'schema' : 'str' - - 'secret_data' : 'dict' - - 'filter' : 'dict' - - 'zones' : 'list' - - 'subscription_info' : 'dict' - Response: - CloudServiceResponse (list) : dictionary of azure key vault data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f"** Key Vault START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - key_vault_conn: KeyVaultsConnector = self.locator.get_connector( - self.connector_name, **params +class KeyVaultsManager(AzureBaseManager): + cloud_service_group = "KeyVaults" + cloud_service_type = "Instance" + service_code = "/Microsoft.KeyVault/vaults" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Security"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-key-vault.svg" + } ) - key_vault_responses = [] + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - key_vaults_obj_list = key_vault_conn.list_all_key_vaults() + key_vaults_conn = KeyVaultsConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + key_vaults_obj_list = key_vaults_conn.list_all_key_vaults() for key_vault in key_vaults_obj_list: - key_vault_id = "" try: key_vault_dict = self.convert_nested_dictionary(key_vault) key_vault_id = key_vault_dict["id"] key_vault_dict = self.update_tenant_id_from_secret_data( - key_vault_dict, params.get("secret_data", {}) + key_vault_dict, secret_data ) key_vault_dict.update( @@ -63,7 +62,7 @@ def collect_cloud_service(self, params: dict): key_vault_id ), # parse resource_group from ID "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": key_vault_id}, } ) @@ -77,16 +76,26 @@ def collect_cloud_service(self, params: dict): vault_uri = key_vault_dict["properties"]["vault_uri"] keys = self.list_keys( - key_vault_conn, resource_group_name, vault_name + key_vaults_conn, resource_group_name, vault_name ) + + for key in keys: + key["attributes"].update( + { + "created": self.timestamp_to_iso8601(key["attributes"]["created"]), + "updated": self.timestamp_to_iso8601(key["attributes"]["updated"]), + } + ) + secrets, secrets_permissions_display = self.list_secrets( - key_vault_conn, subscription_id, vault_uri + key_vaults_conn, subscription_id, vault_uri ) + ( certificates, certificates_permissions_display, ) = self.list_certificates( - key_vault_conn, subscription_id, vault_uri + key_vaults_conn, subscription_id, vault_uri ) key_vault_dict.update( @@ -98,79 +107,80 @@ def collect_cloud_service(self, params: dict): "secret_count": len(secrets), "certificate_count": len(certificates), "total_credentials_count": len(keys) - + len(secrets) - + len(certificates), + + len(secrets) + + len(certificates), "keys_permissions_description_display": "Microsoft.KeyVault/vaults/read", "secrets_permissions_description_display": secrets_permissions_display, "certificates_permissions_description_display": certificates_permissions_display, } ) - # Get name of private connection from ID - if ( - key_vault_dict.get("properties", {}).get( - "private_endpoint_connections" - ) - is not None - ): - key_vault_dict["properties"].update( - { - "private_endpoint_connections": self.get_private_endpoint_name( - key_vault_dict["properties"][ - "private_endpoint_connections" - ] + # Get name of private connection from ID + if ( + key_vault_dict.get("properties", {}).get( + "private_endpoint_connections" ) - } - ) - - # Change purge protection to user-friendly word - if ( - key_vault_dict.get("properties", {}).get("enable_purge_protection") - is not None - ): + is not None + ): + key_vault_dict["properties"].update( + { + "private_endpoint_connections": self.get_private_endpoint_name( + key_vault_dict["properties"][ + "private_endpoint_connections" + ] + ) + } + ) + + # Change purge protection to user-friendly word key_vault_dict["properties"].update( { "enable_purge_protection_str": "Disabled" - if key_vault_dict["properties"]["enable_purge_protection"] - is False - else "Enabled" } ) - if sku := key_vault_dict.get("properties", {}).get("sku"): - key_vault_dict["sku"] = sku - - # switch tags form - - key_vault_data = KeyVault(key_vault_dict, strict=False) - - key_vault_resource = KeyVaultResource( - { - "data": key_vault_data, - "region_code": key_vault_data.location, - "reference": ReferenceModel(key_vault_data.reference()), - "name": key_vault_data.name, - "instance_type": key_vault_data.properties.sku.name, - "account": key_vault_data.subscription_id, - "tags": key_vault_dict.get("tags", {}), - } - ) - - # Must set_region_code method for region collection - self.set_region_code(key_vault_data["location"]) - # _LOGGER.debug(f'[KEY VAULT INFO]{key_vault_resource.to_primitive()}') - key_vault_responses.append( - KeyVaultResponse({"resource": key_vault_resource}) - ) + if ( + key_vault_dict.get("properties", {}).get("enable_purge_protection") + is not None + ): + if key_vault_dict["properties"]["enable_purge_protection"]: + key_vault_dict["properties"].update( + { + "enable_purge_protection_str": "Enabled" + } + ) + if sku := key_vault_dict.get("properties", {}).get("sku"): + key_vault_dict["sku"] = sku + + self.set_region_code(key_vault_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=key_vault_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=key_vault_dict, + account=secret_data["subscription_id"], + instance_type=key_vault_dict["properties"]["sku"]["name"], + region_code=key_vault_dict["location"], + reference=self.make_reference(key_vault_dict.get("id")), + tags=key_vault_dict.get("tags", {}), + data_format="dict" + ) + ) except Exception as e: - _LOGGER.error(f"[list_instances] {key_vault_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "KeyVault", "KeyVault", key_vault_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** Key Vault Finished {time.time() - start_time} Seconds **") - return key_vault_responses, error_responses + return cloud_services, error_responses def list_keys(self, key_vault_conn, resource_group_name, vault_name): keys = [] @@ -233,3 +243,11 @@ def get_private_endpoint_name(private_endpoint_connections): for private_endpoint in private_endpoint_connections: private_endpoint.update({"name": private_endpoint["id"].split("/")[10]}) return private_endpoint_connections + + @staticmethod + def timestamp_to_iso8601(timestamp: int) -> Union[str, None]: + if isinstance(timestamp, int): + dt = datetime.datetime.utcfromtimestamp(timestamp) + return f"{dt.isoformat(timespec='milliseconds')}Z" + + return None diff --git a/src/plugin/manager/load_balancers/__init__.py b/src/plugin/manager/load_balancers/__init__.py new file mode 100644 index 00000000..8957ae28 --- /dev/null +++ b/src/plugin/manager/load_balancers/__init__.py @@ -0,0 +1 @@ +from .instance_manager import LoadBalancersManager diff --git a/src/spaceone/inventory/manager/load_balancers/instance_manager.py b/src/plugin/manager/load_balancers/instance_manager.py similarity index 81% rename from src/spaceone/inventory/manager/load_balancers/instance_manager.py rename to src/plugin/manager/load_balancers/instance_manager.py index 26336136..2daad824 100644 --- a/src/spaceone/inventory/manager/load_balancers/instance_manager.py +++ b/src/plugin/manager/load_balancers/instance_manager.py @@ -1,54 +1,53 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.load_balancers import LoadBalancersConnector -from spaceone.inventory.model.load_balancers.cloud_service import * -from spaceone.inventory.model.load_balancers.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.load_balancers.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.load_balancers.load_balancers_connector import LoadBalancersConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class LoadBalancersManager(AzureManager): - connector_name = "LoadBalancersConnector" - 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) : dictionary of azure load balancer data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f"** LoadBalancer START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - load_balancer_conn: LoadBalancersConnector = self.locator.get_connector( - self.connector_name, **params +class LoadBalancersManager(AzureBaseManager): + cloud_service_group = "LoadBalancers" + cloud_service_type = "Instance" + service_code = "/Microsoft.Network/loadBalancers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-loadbalancers.svg" + } ) - load_balancer_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - load_balancers = load_balancer_conn.list_load_balancers() + + load_balancers_conn = LoadBalancersConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + load_balancers = load_balancers_conn.list_load_balancers() for load_balancer in load_balancers: - load_balancer_id = "" try: load_balancer_dict = self.convert_nested_dictionary(load_balancer) load_balancer_dict = self.update_tenant_id_from_secret_data( - load_balancer_dict, params["secret_data"] + load_balancer_dict, secret_data ) load_balancer_id = load_balancer_dict["id"] @@ -59,7 +58,7 @@ def collect_cloud_service(self, params): load_balancer_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": load_balancer_id}, } ) @@ -68,7 +67,7 @@ def collect_cloud_service(self, params): load_balancer_dict.update( { "network_interfaces": self.get_network_interfaces( - load_balancer_conn, + load_balancers_conn, load_balancer_dict["resource_group"], load_balancer_dict["name"], ) @@ -82,12 +81,12 @@ def collect_cloud_service(self, params): for fic in load_balancer_dict["frontend_ip_configurations"]: if fic.get( - "subnet" + "subnet" ): # If the 'public' type, Skip this part because there isn't subnet information for them. fic["subnet"][ "address_prefix" ] = self.get_frontend_address_prefix( - load_balancer_conn, fic["subnet"] + load_balancers_conn, fic["subnet"] ) fic["subnet"]["name"] = self.get_frontend_ip_subnet_name( fic["subnet"]["id"] @@ -126,12 +125,13 @@ def collect_cloud_service(self, params): load_balancer_dict.update( { "backend_address_pools": self.list_load_balancer_backend_address_pools( - load_balancer_conn, + load_balancers_conn, load_balancer_dict["resource_group"], load_balancer_dict["name"], ) } ) + # get backend address pool's count load_balancer_dict.update( { @@ -188,6 +188,7 @@ def collect_cloud_service(self, params): ) } ) + for inr in load_balancer_dict["inbound_nat_rules"]: inr.update( { @@ -214,35 +215,36 @@ def collect_cloud_service(self, params): } ) - load_balancer_data = LoadBalancer(load_balancer_dict, strict=False) - load_balancer_resource = LoadBalancerResource( - { - "data": load_balancer_data, - "region_code": load_balancer_data.location, - "reference": ReferenceModel(load_balancer_data.reference()), - "tags": load_balancer_dict.get("tags", {}), - "name": load_balancer_data.name, - "instance_type": load_balancer_data.sku.name, - "account": load_balancer_data.subscription_id, - } - ) - # Must set_region_code method for region collection - self.set_region_code(load_balancer_data["location"]) - - # _LOGGER.debug(f'[LOAD BALANCER INFO] {load_balancer_resource.to_primitive()}') - load_balancer_responses.append( - LoadBalancerResponse({"resource": load_balancer_resource}) + self.set_region_code(load_balancer_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=load_balancer_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=load_balancer_dict, + account=load_balancer_dict["subscription_id"], + instance_type=load_balancer_dict["sku"]["name"], + region_code=load_balancer_dict["location"], + reference=self.make_reference(load_balancer_dict.get("id")), + tags=load_balancer_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error(f"[list_instances] {load_balancer_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Network", "LoadBalancer", load_balancer_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** LoadBalancer Finished {time.time() - start_time} Seconds **") - return load_balancer_responses, error_responses + return cloud_services, error_responses def get_network_interfaces(self, load_balancer_conn, rg_name, lb_name): network_interface_object_list = list( @@ -259,8 +261,8 @@ def get_network_interfaces(self, load_balancer_conn, rg_name, lb_name): # Get LB's name, VMs name attached to Backend Pool for ip_configuration in network_interface_dict["ip_configurations"]: if ( - ip_configuration.get("load_balancer_backend_address_pools") - is not None + ip_configuration.get("load_balancer_backend_address_pools") + is not None ): for ic in ip_configuration[ "load_balancer_backend_address_pools" @@ -298,7 +300,7 @@ def get_network_interfaces(self, load_balancer_conn, rg_name, lb_name): return network_interface_list def get_ip_configurations_list( - self, load_balancer_conn, rg_name, network_interface_name + self, load_balancer_conn, rg_name, network_interface_name ): ip_configuration_list = [] if network_interface_name: @@ -373,11 +375,11 @@ def get_backend_address_pools_count(backend_address_dict): if backend_address_pools_count == 1: backend_address_pools_count_display = ( - str(backend_address_pools_count) + " backend pool" + str(backend_address_pools_count) + " backend pool" ) else: backend_address_pools_count_display = ( - str(backend_address_pools_count) + " backend pools" + str(backend_address_pools_count) + " backend pools" ) return backend_address_pools_count_display @@ -387,7 +389,7 @@ def get_matched_vm_info(find_key, find_list_pool): matched_vm_list = list() for find_object in find_list_pool: if ( - find_object["id"] in find_key + find_object["id"] in find_key ): # if network interface card's id matches to the backend configuration's id if find_object.get("virtual_machine") is not None: matched_vm_list.append( @@ -424,7 +426,7 @@ def get_nat_rules_display(inbound_nat_rules_list): @staticmethod def get_backend_address_pool_name( - lbr_backend_address_pool, + lbr_backend_address_pool, ): # id must exist if there is a backend address pool object return lbr_backend_address_pool["id"].split("/")[10] diff --git a/src/plugin/manager/my_sql_servers/__init__.py b/src/plugin/manager/my_sql_servers/__init__.py new file mode 100644 index 00000000..a383d3a3 --- /dev/null +++ b/src/plugin/manager/my_sql_servers/__init__.py @@ -0,0 +1,2 @@ +from .server_manager import MySQLServersManager +from .flexible_server_manager import MySQLFlexibleServersManager diff --git a/src/plugin/manager/my_sql_servers/flexible_server_manager.py b/src/plugin/manager/my_sql_servers/flexible_server_manager.py new file mode 100644 index 00000000..ab96db68 --- /dev/null +++ b/src/plugin/manager/my_sql_servers/flexible_server_manager.py @@ -0,0 +1,138 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.my_sql_servers.mysql_flexible_servers_connector import MySQLFlexibleServersConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager + +_LOGGER = logging.getLogger(__name__) + + +class MySQLFlexibleServersManager(AzureBaseManager): + cloud_service_group = "MySQLServers" + cloud_service_type = "FlexibleServer" + service_code = "/Microsoft.DBforMySQL/flexibleServers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-mysql-servers.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + mysql_flexible_servers_conn = MySQLFlexibleServersConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + mysql_flexible_servers_obj_list = mysql_flexible_servers_conn.list_flexible_servers() + + for mysql_flexible_server in mysql_flexible_servers_obj_list: + + try: + mysql_flexible_server_dict = self.convert_nested_dictionary(mysql_flexible_server) + mysql_flexible_server_id = mysql_flexible_server_dict["id"] + + mysql_flexible_server_dict.update( + { + "resource_group": self.get_resource_group_from_id( + mysql_flexible_server_id + ), + "subscription_id": subscription_info["subscription_id"], + "subscription_name": subscription_info["display_name"], + "azure_monitor": {"resource_id": mysql_flexible_server_id}, + } + ) + + if mysql_flexible_server_dict.get("name") is not None: + resource_group = mysql_flexible_server_dict.get("resource_group", "") + server_name = mysql_flexible_server_dict.get("name") + mysql_flexible_server_dict.update( + { + "firewall_rules": self.get_firewall_rules_by_server( + mysql_flexible_servers_conn, resource_group, server_name + ), + } + ) + + if mysql_flexible_server_dict.get("firewall_rules") is not None: + mysql_flexible_server_dict.update( + { + "allow_azure_services_access": self.get_azure_service_access( + mysql_flexible_server_dict["firewall_rules"] + ) + } + ) + + self.set_region_code(mysql_flexible_server_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=mysql_flexible_server_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=mysql_flexible_server_dict, + account=secret_data["subscription_id"], + instance_type="Azure DB for MySQL Flexible Server", + region_code=mysql_flexible_server_dict["location"], + reference=self.make_reference(mysql_flexible_server_dict.get("id")), + tags=mysql_flexible_server_dict.get("tags", {}), + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + def get_firewall_rules_by_server( + self, mysql_flexible_servers_conn, resource_group, server_name + ): + firewall_rules = [] + firewall_rule_obj = mysql_flexible_servers_conn.list_firewall_rules_by_server( + resource_group_name=resource_group, server_name=server_name + ) + + for firewall_rule in firewall_rule_obj: + firewall_dict = self.convert_nested_dictionary(firewall_rule) + firewall_rules.append(firewall_dict) + + return firewall_rules + + @staticmethod + def get_azure_service_access(firewall_rules): + firewall_rule_name_list = [] + + for firewall_rule in firewall_rules: + if firewall_rule.get("name") is not None: + firewall_rule_name_list.append(firewall_rule["name"]) + + if "AllowAllWindowsAzureIps" in firewall_rule_name_list: + return True + + return False diff --git a/src/spaceone/inventory/manager/mysql_servers/server_manager.py b/src/plugin/manager/my_sql_servers/server_manager.py similarity index 52% rename from src/spaceone/inventory/manager/mysql_servers/server_manager.py rename to src/plugin/manager/my_sql_servers/server_manager.py index 83868dda..3748051d 100644 --- a/src/spaceone/inventory/manager/mysql_servers/server_manager.py +++ b/src/plugin/manager/my_sql_servers/server_manager.py @@ -1,51 +1,48 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.mysql_servers import MySQLServersConnector -from spaceone.inventory.model.mysql_servers.cloud_service import * -from spaceone.inventory.model.mysql_servers.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.mysql_servers.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.my_sql_servers.mysql_servers_connector import MySQLServersConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class MySQLServersManager(AzureManager): - connector_name = "MySQLServersConnector" - 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 (dict) : dictionary of mysql servers data resource information - ErrorResourceResponse (list) : list of error resource information - """ - - _LOGGER.debug(f"** MySQL Servers START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - mysql_servers_conn: MySQLServersConnector = self.locator.get_connector( - self.connector_name, **params +class MySQLServersManager(AzureBaseManager): + cloud_service_group = "MySQLServers" + cloud_service_type = "Server" + service_code = "/Microsoft.DBforMySQL/servers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-mysql-servers.svg" + } ) - mysql_server_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] + mysql_servers_conn = MySQLServersConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + mysql_servers_obj_list = mysql_servers_conn.list_servers() for mysql_server in mysql_servers_obj_list: - mysql_server_id = "" try: mysql_server_dict = self.convert_nested_dictionary(mysql_server) @@ -57,7 +54,7 @@ def collect_cloud_service(self, params): mysql_server_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": mysql_server_id}, } ) @@ -93,38 +90,39 @@ def collect_cloud_service(self, params): } ) - mysql_server_data = MySQLServer(mysql_server_dict, strict=False) - mysql_server_resource = MySQLServerResource( - { - "data": mysql_server_data, - "tags": mysql_server_dict.get("tags", {}), - "region_code": mysql_server_data.location, - "reference": ReferenceModel(mysql_server_data.reference()), - "name": mysql_server_data.name, - "account": mysql_server_data.subscription_id, - "instance_type": mysql_server_data.sku.tier, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(mysql_server_data["location"]) - # _LOGGER.debug(f'[MYSQL SERVER INFO] {mysql_server_resource.to_primitive()}') - mysql_server_responses.append( - MySQLServerResponse({"resource": mysql_server_resource}) + self.set_region_code(mysql_server_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=mysql_server_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=mysql_server_dict, + account=secret_data["subscription_id"], + instance_type=mysql_server_dict["sku"]["tier"], + region_code=mysql_server_dict["location"], + reference=self.make_reference(mysql_server_dict.get("id")), + tags=mysql_server_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error(f"[list_instances] {mysql_server_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Database", "MySQLServer", mysql_server_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** MySQL Server Finished {time.time() - start_time} Seconds **") - return mysql_server_responses, error_responses + return cloud_services, error_responses def get_firewall_rules_by_server( - self, mysql_servers_conn, resource_group, server_name + self, mysql_servers_conn, resource_group, server_name ): firewall_rules = [] firewall_rules_obj = mysql_servers_conn.list_firewall_rules_by_server( diff --git a/src/plugin/manager/nat_gateways/__init__.py b/src/plugin/manager/nat_gateways/__init__.py new file mode 100644 index 00000000..6af62b84 --- /dev/null +++ b/src/plugin/manager/nat_gateways/__init__.py @@ -0,0 +1 @@ +from .instance_manager import NATGatewaysManager diff --git a/src/spaceone/inventory/manager/nat_gateways/instance_manager.py b/src/plugin/manager/nat_gateways/instance_manager.py similarity index 57% rename from src/spaceone/inventory/manager/nat_gateways/instance_manager.py rename to src/plugin/manager/nat_gateways/instance_manager.py index 9948eea6..a6df374a 100644 --- a/src/spaceone/inventory/manager/nat_gateways/instance_manager.py +++ b/src/plugin/manager/nat_gateways/instance_manager.py @@ -1,49 +1,48 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.nat_gateways import NATGatewaysConnector -from spaceone.inventory.model.nat_gateways.cloud_service import * -from spaceone.inventory.model.nat_gateways.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.inventory.model.nat_gateways.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.nat_gateways.nat_gateways_connector import NATGatewaysConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class NATGatewaysManager(AzureManager): - connector_name = "NATGatewaysConnector" - 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 (dict) : dictionary of azure nat gateway data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f"** NAT Gateway START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - nat_gateway_conn: NATGatewaysConnector = self.locator.get_connector( - self.connector_name, **params +class NATGatewaysManager(AzureBaseManager): + cloud_service_group = "NATGateways" + cloud_service_type = "Instance" + service_code = "/Microsoft.Network/natGateways" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-nat.svg" + } ) - nat_gateway_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - nat_gateways = nat_gateway_conn.list_all_nat_gateways() + nat_gateways_conn = NATGatewaysConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + nat_gateways = nat_gateways_conn.list_all_nat_gateways() for nat_gateway in nat_gateways: - nat_gateway_id = "" try: nat_gateway_dict = self.convert_nested_dictionary(nat_gateway) @@ -57,7 +56,7 @@ def collect_cloud_service(self, params): nat_gateway_dict["sku"]["tier"] = sku_tier nat_gateway_dict = self.update_tenant_id_from_secret_data( - nat_gateway_dict, params["secret_data"] + nat_gateway_dict, secret_data ) # update application_gateway_dict @@ -67,7 +66,7 @@ def collect_cloud_service(self, params): nat_gateway_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": nat_gateway_id}, } ) @@ -91,11 +90,19 @@ def collect_cloud_service(self, params): for pip in nat_gateway_dict["public_ip_addresses"]: public_ip_prefixes_id = pip["id"] pip_dict = self.get_public_ip_address_dict( - nat_gateway_conn, public_ip_prefixes_id + nat_gateways_conn, public_ip_prefixes_id ) pip_list.append(pip_dict) + nat_gateway_dict["public_ip_addresses"] = pip_list + else: + nat_gateway_dict.update( + { + "public_ip_addresses_count": 0 + } + ) + if nat_gateway_dict.get("public_ip_prefixes") is not None: nat_gateway_dict.update( { @@ -114,51 +121,64 @@ def collect_cloud_service(self, params): for pip in nat_gateway_dict["public_ip_prefixes"]: public_ip_prefixes_id = pip["id"] pip_dict = self.get_public_ip_prefixes_dict( - nat_gateway_conn, public_ip_prefixes_id + nat_gateways_conn, public_ip_prefixes_id ) pip_list.append(pip_dict) nat_gateway_dict["public_ip_prefixes"] = pip_list + else: + nat_gateway_dict.update( + { + "public_ip_prefixes_count": 0 + } + ) + if nat_gateway_dict.get("subnets") is not None: nat_gateway_dict.update( { "subnets": self.get_subnets( - nat_gateway_conn, nat_gateway_dict["subnets"] + nat_gateways_conn, nat_gateway_dict["subnets"] ), "subnets_count": len(nat_gateway_dict["subnets"]), } ) + else: + nat_gateway_dict.update( + { + "subnets_count": 0 + } + ) - nat_gateway_data = NatGateway(nat_gateway_dict, strict=False) - nat_gateway_resource = NatGatewayResource( - { - "data": nat_gateway_data, - "tags": nat_gateway_dict.get("tags", {}), - "region_code": nat_gateway_data.location, - "reference": ReferenceModel(nat_gateway_data.reference()), - "name": nat_gateway_data.name, - "account": nat_gateway_data.subscription_id, - "instance_type": nat_gateway_data.sku.name, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(nat_gateway_data["location"]) - # _LOGGER.debug(f'[NAT GATEWAYS INFO] {nat_gateway_resource.to_primitive()}') - nat_gateway_responses.append( - NatGatewayResponse({"resource": nat_gateway_resource}) + self.set_region_code(nat_gateway_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=nat_gateway_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=nat_gateway_dict, + account=nat_gateway_dict["subscription_id"], + instance_type=nat_gateway_dict["sku"]["name"], + region_code=nat_gateway_dict["location"], + reference=self.make_reference(nat_gateway_dict.get("id")), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error(f"[list_instances] {nat_gateway_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Network", "NATGateway", nat_gateway_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** NAT Gateway Finished {time.time() - start_time} Seconds **") - return nat_gateway_responses, error_responses + return cloud_services, error_responses def get_public_ip_address_dict(self, nat_gateway_conn, pip_id): pip_name = pip_id.split("/")[8] @@ -198,3 +218,4 @@ def get_subnets(self, nat_gateway_conn, subnets): subnet_list.append(subnet_dict) return subnet_list + diff --git a/src/plugin/manager/network_security_groups/__init__.py b/src/plugin/manager/network_security_groups/__init__.py new file mode 100644 index 00000000..94a669e9 --- /dev/null +++ b/src/plugin/manager/network_security_groups/__init__.py @@ -0,0 +1 @@ +from .instance_manager import NetworkSecurityGroupsManager diff --git a/src/spaceone/inventory/manager/network_security_groups/instance_manager.py b/src/plugin/manager/network_security_groups/instance_manager.py similarity index 68% rename from src/spaceone/inventory/manager/network_security_groups/instance_manager.py rename to src/plugin/manager/network_security_groups/instance_manager.py index 68e61580..59774781 100644 --- a/src/spaceone/inventory/manager/network_security_groups/instance_manager.py +++ b/src/plugin/manager/network_security_groups/instance_manager.py @@ -1,66 +1,56 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.network_security_groups import ( - NetworkSecurityGroupsConnector, -) -from spaceone.inventory.model.network_security_groups.cloud_service import * -from spaceone.inventory.model.network_security_groups.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.network_security_groups.data import * -_LOGGER = logging.getLogger(__name__) +from spaceone.inventory.plugin.collector.lib import * +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.sql_databases.sql_databases_connector import SqlDatabasesConnector +from plugin.connector.network_security_groups.network_security_groups_connector import NetworkSecurityGroupsConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager -class NetworkSecurityGroupsManager(AzureManager): - connector_name = "NetworkSecurityGroupsConnector" - cloud_service_types = CLOUD_SERVICE_TYPES +_LOGGER = logging.getLogger(__name__) - 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) : dictionary of azure network security group data resource information - ErrorResourceResponse (list) : list of error resource information +class NetworkSecurityGroupsManager(AzureBaseManager): + cloud_service_group = "NetworkSecurityGroups" + cloud_service_type = "Instance" + service_code = "/Microsoft.Network/networkSecurityGroups" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-network-security-groups.svg" + } + ) - """ - _LOGGER.debug("** Network Security Group START **") - start_time = time.time() + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] - subscription_info = params["subscription_info"] - # cloud_service_info = self.get_cloud + network_security_groups_conn = NetworkSecurityGroupsConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) - network_security_group_conn: NetworkSecurityGroupsConnector = ( - self.locator.get_connector(self.connector_name, **params) - ) + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) - network_security_group_responses = [] - error_responses = [] - network_security_groups = ( - network_security_group_conn.list_all_network_security_groups() - ) + network_security_groups = network_security_groups_conn.list_all_network_security_groups() network_interfaces = [ self.convert_nested_dictionary(ni) - for ni in network_security_group_conn.list_all_network_interfaces() + for ni in network_security_groups_conn.list_all_network_interfaces() ] for network_security_group in network_security_groups: - network_security_group_id = "" try: - network_security_group_dict = self.convert_nested_dictionary( - network_security_group - ) + network_security_group_dict = self.convert_nested_dictionary(network_security_group) network_security_group_id = network_security_group_dict["id"] inbound_rules = [] outbound_rules = [] @@ -77,8 +67,8 @@ def collect_cloud_service(self, params): # update default security rules if ( - network_security_group_dict.get("default_security_rules") - is not None + network_security_group_dict.get("default_security_rules") + is not None ): inbound, outbound = self.split_security_rules( network_security_group_dict, "default_security_rules" @@ -94,6 +84,7 @@ def collect_cloud_service(self, params): "outbound_security_rules": outbound_rules, } ) + # TODO : update network interface name """ # get network interfaces @@ -128,10 +119,9 @@ def collect_cloud_service(self, params): # Get Subnet information if network_security_group_dict.get("subnets") is not None: network_security_group_dict["subnets"] = self.get_subnet( - network_security_group_conn, + network_security_groups_conn, network_security_group_dict["subnets"], ) - if network_security_group_dict.get("subnets"): for subnet in network_security_group_dict["subnets"]: subnet.update( @@ -144,7 +134,7 @@ def collect_cloud_service(self, params): # update application_gateway_dict network_security_group_dict = self.update_tenant_id_from_secret_data( - network_security_group_dict, params["secret_data"] + network_security_group_dict, secret_data ) network_security_group_dict.update( { @@ -152,53 +142,42 @@ def collect_cloud_service(self, params): network_security_group_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": network_security_group_id}, } ) - network_security_group_data = NetworkSecurityGroup( - network_security_group_dict, strict=False - ) - - network_security_group_resource = NetworkSecurityGroupResource( - { - "data": network_security_group_data, - "tags": network_security_group_dict.get("tags", {}), - "region_code": network_security_group_data.location, - "reference": ReferenceModel( - network_security_group_data.reference() - ), - "name": network_security_group_data.name, - "account": network_security_group_data.subscription_id, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(network_security_group_data["location"]) - # _LOGGER.debug(f'[NETWORK SECURITY GROUP INFO] {network_security_group_resource.to_primitive()}') - network_security_group_responses.append( - NetworkSecurityGroupResponse( - {"resource": network_security_group_resource} + self.set_region_code(network_security_group_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=network_security_group_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=network_security_group_dict, + account=secret_data["subscription_id"], + region_code=network_security_group_dict["location"], + reference=self.make_reference(network_security_group_dict.get("id")), + data_format="dict" ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {network_security_group_id} {e}", exc_info=True - ) - error_resource_response = self.generate_resource_error_response( - e, "Network", "NetworkSecurityGroup", network_security_group_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug( - f"** Network Security Group Finished {time.time() - start_time} Seconds **" - ) - return network_security_group_responses, error_responses + return cloud_services, error_responses def get_network_interfaces( - self, network_security_group_conn, network_interfaces_list + self, network_security_group_conn, network_interfaces_list ): network_interfaces_new_list = [] virtual_machines_display_list = [] @@ -305,13 +284,14 @@ def get_virtual_network(subnet_id): return virtual_network @staticmethod - def get_virtual_machine_name(network_interfaces, network_security_group_id): + def get_virtual_machine_name(network_interfaces: list, network_security_group_id: str): virtual_machine_name = None - for network_interface in network_interfaces: - if _network_security_group := network_interface["network_security_group"]: + for network_interface_info in network_interfaces: + if _network_security_group := network_interface_info.get("network_security_group"): if ( - _network_security_group["id"].split("/")[-1] - == network_security_group_id.split("/")[-1] + _network_security_group["id"].split("/")[-1] + == network_security_group_id.split("/")[-1] ): + virtual_machine_name = network_interface_info["virtual_machine"]["id"].split("/")[-1] return virtual_machine_name return virtual_machine_name diff --git a/src/plugin/manager/postgre_sql_servers/__init__.py b/src/plugin/manager/postgre_sql_servers/__init__.py new file mode 100644 index 00000000..e693aa6d --- /dev/null +++ b/src/plugin/manager/postgre_sql_servers/__init__.py @@ -0,0 +1,2 @@ +from .server_manager import PostgreSQLServersManager +from .flexible_server_manager import PostgreSQLFlexibleServersManager diff --git a/src/plugin/manager/postgre_sql_servers/flexible_server_manager.py b/src/plugin/manager/postgre_sql_servers/flexible_server_manager.py new file mode 100644 index 00000000..07e45930 --- /dev/null +++ b/src/plugin/manager/postgre_sql_servers/flexible_server_manager.py @@ -0,0 +1,131 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.postgre_sql_servers.postgresql_flexible_servers_connector import PostgreSQLFlexibleServersConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager + +_LOGGER = logging.getLogger(__name__) + + +class PostgreSQLFlexibleServersManager(AzureBaseManager): + cloud_service_group = "PostgreSQLServers" + cloud_service_type = "FlexibleServer" + service_code = "/Microsoft.DBforPostgreSQL/flexibleServers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-sql-postgresql-server.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + postgre_sql_flexible_servers_conn = PostgreSQLFlexibleServersConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + postgre_sql_flexible_servers = postgre_sql_flexible_servers_conn.list_flexible_servers() + + for postgre_sql_flexible_server in postgre_sql_flexible_servers: + + try: + postgre_sql_flexible_server_dict = self.convert_nested_dictionary( + postgre_sql_flexible_server + ) + postgre_sql_flexible_server_id = postgre_sql_flexible_server_dict["id"] + + postgre_sql_flexible_server_dict = self.update_tenant_id_from_secret_data( + postgre_sql_flexible_server_dict, secret_data + ) + + postgre_sql_flexible_server_dict.update( + { + "resource_group": self.get_resource_group_from_id( + postgre_sql_flexible_server_id + ), + "subscription_id": subscription_info["subscription_id"], + "subscription_name": subscription_info["display_name"], + "azure_monitor": {"resource_id": postgre_sql_flexible_server_id}, + "version_display": self.get_version_display( + postgre_sql_flexible_server_dict.get("version"), + postgre_sql_flexible_server_dict.get("minor_version"), + ) + } + ) + + if postgre_sql_flexible_server_dict.get("name") is not None: + resource_group = postgre_sql_flexible_server_dict["resource_group"] + server_name = postgre_sql_flexible_server_dict["name"] + postgre_sql_flexible_server_dict.update( + { + "firewall_rules": self.list_firewall_rules_by_server( + postgre_sql_flexible_servers_conn, resource_group, server_name + ), + } + ) + + self.set_region_code(postgre_sql_flexible_server_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=postgre_sql_flexible_server_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=postgre_sql_flexible_server_dict, + account=secret_data["subscription_id"], + instance_type="Azure DB for PostgreSQL Flexible Server", + instance_size=float(postgre_sql_flexible_server_dict["storage"]["storage_size_gb"]), + region_code=postgre_sql_flexible_server_dict["location"], + reference=self.make_reference(postgre_sql_flexible_server_dict.get("id")), + tags=postgre_sql_flexible_server_dict.get("tags", {}), + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + def list_firewall_rules_by_server(self, postgresql_conn, resource_group, name): + firewall_rules = [] + firewall_rules_obj = postgresql_conn.list_firewall_rules_by_server( + resource_group_name=resource_group, server_name=name + ) + + for firewall_rule in firewall_rules_obj: + firewall_rule_dict = self.convert_nested_dictionary(firewall_rule) + firewall_rules.append(firewall_rule_dict) + + return firewall_rules + + @staticmethod + def get_version_display(version, minor_version): + version_display = f"{version}.{minor_version}" + return version_display + diff --git a/src/spaceone/inventory/manager/postgresql_servers/server_manager.py b/src/plugin/manager/postgre_sql_servers/server_manager.py similarity index 59% rename from src/spaceone/inventory/manager/postgresql_servers/server_manager.py rename to src/plugin/manager/postgre_sql_servers/server_manager.py index 5878c0c1..c1ca280d 100644 --- a/src/spaceone/inventory/manager/postgresql_servers/server_manager.py +++ b/src/plugin/manager/postgre_sql_servers/server_manager.py @@ -1,51 +1,48 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.postgresql_servers import PostgreSQLServersConnector -from spaceone.inventory.model.postgresql_servers.cloud_service import * -from spaceone.inventory.model.postgresql_servers.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.postgresql_servers.data import * -_LOGGER = logging.getLogger(__name__) +from spaceone.inventory.plugin.collector.lib import * +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.postgre_sql_servers.postgresql_servers_connector import PostgreSQLServersConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager -class PostgreSQLServersManager(AzureManager): - connector_name = "PostgreSQLServersConnector" - cloud_service_types = CLOUD_SERVICE_TYPES +_LOGGER = logging.getLogger(__name__) - 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) : dictionary of azure postgresql servers data resource information - ErrorResourceResponse (list) : list of error resource information +class PostgreSQLServersManager(AzureBaseManager): + cloud_service_group = "PostgreSQLServers" + cloud_service_type = "Server" + service_code = "/Microsoft.DBforPostgreSQL/servers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-sql-postgresql-server.svg" + } + ) - """ - _LOGGER.debug(f"** Postgre SQL Servers START **") + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] - start_time = time.time() + postgre_sql_servers_conn = PostgreSQLServersConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) - subscription_info = params["subscription_info"] - postgre_sql_conn: PostgreSQLServersConnector = self.locator.get_connector( - self.connector_name, **params - ) - postgre_sql_server_responses = [] - error_responses = [] - postgre_sql_servers = postgre_sql_conn.list_servers() + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + postgre_sql_servers = postgre_sql_servers_conn.list_servers() for postgre_sql_server in postgre_sql_servers: - postgre_sql_server_id = "" try: postgre_sql_server_dict = self.convert_nested_dictionary( @@ -55,15 +52,16 @@ def collect_cloud_service(self, params): # update application_gateway_dict postgre_sql_server_dict = self.update_tenant_id_from_secret_data( - postgre_sql_server_dict, params["secret_data"] + postgre_sql_server_dict, secret_data ) + postgre_sql_server_dict.update( { "resource_group": self.get_resource_group_from_id( postgre_sql_server_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": postgre_sql_server_id}, } ) @@ -74,60 +72,51 @@ def collect_cloud_service(self, params): postgre_sql_server_dict.update( { "firewall_rules": self.list_firewall_rules_by_server( - postgre_sql_conn, resource_group, server_name + postgre_sql_servers_conn, resource_group, server_name ), "virtual_network_rules": self.list_virtual_network_rules_by_server( - postgre_sql_conn, resource_group, server_name + postgre_sql_servers_conn, resource_group, server_name ), "replicas": self.list_replicas_by_server( - postgre_sql_conn, resource_group, server_name + postgre_sql_servers_conn, resource_group, server_name ), "server_administrators": self.list_server_administrators( - postgre_sql_conn, resource_group, server_name + postgre_sql_servers_conn, resource_group, server_name ), } ) - postgre_sql_server_data = PostgreSQLServer( - postgre_sql_server_dict, strict=False - ) - postgre_sql_server_resource = PostgreSQLServerResource( - { - "data": postgre_sql_server_data, - "region_code": postgre_sql_server_data.location, - "reference": ReferenceModel( - postgre_sql_server_data.reference() - ), - "tags": postgre_sql_server_dict.get("tags", {}), - "name": postgre_sql_server_data.name, - "account": postgre_sql_server_data.subscription_id, - "instance_type": postgre_sql_server_data.sku.tier, - "instance_size": float( - postgre_sql_server_data.storage_profile.storage_mb - ), - } - ) - - # Must set_region_code method for region collection - self.set_region_code(postgre_sql_server_data["location"]) - # _LOGGER.debug(f'[POSTGRESQL SERVERS INFO] {postgre_sql_server_resource.to_primitive()}') - postgre_sql_server_responses.append( - PostgreSQLServerResponse({"resource": postgre_sql_server_resource}) + self.set_region_code(postgre_sql_server_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=postgre_sql_server_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=postgre_sql_server_dict, + account=secret_data["subscription_id"], + instance_type=postgre_sql_server_dict["sku"]["tier"], + instance_size=float(postgre_sql_server_dict["storage_profile"]["max_size_gb"]), + region_code=postgre_sql_server_dict["location"], + reference=self.make_reference(postgre_sql_server_dict.get("id")), + tags=postgre_sql_server_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {postgre_sql_server_id} {e}", exc_info=True - ) - error_resource_response = self.generate_resource_error_response( - e, "Database", "PostgreSQLServer", postgre_sql_server_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug( - f"** PostgreSQLServer Finished {time.time() - start_time} Seconds **" - ) - return postgre_sql_server_responses, error_responses + return cloud_services, error_responses def get_sql_resources(self, cosmos_db_conn, account_name, resource_group): sql_resources = [] @@ -227,3 +216,4 @@ def get_virtual_network_name(subnet_id): def get_replica_master_server_name(master_server_id): master_server_name = master_server_id.split("/")[8] return master_server_name + diff --git a/src/plugin/manager/public_ip_addresses/__init__.py b/src/plugin/manager/public_ip_addresses/__init__.py new file mode 100644 index 00000000..bbe21011 --- /dev/null +++ b/src/plugin/manager/public_ip_addresses/__init__.py @@ -0,0 +1 @@ +from .ip_address_manager import PublicIPAddressesManager diff --git a/src/plugin/manager/public_ip_addresses/ip_address_manager.py b/src/plugin/manager/public_ip_addresses/ip_address_manager.py new file mode 100644 index 00000000..ac3d2659 --- /dev/null +++ b/src/plugin/manager/public_ip_addresses/ip_address_manager.py @@ -0,0 +1,101 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.public_ip_addresses.public_ip_addresses_connector import PublicIPAddressesConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager + +_LOGGER = logging.getLogger(__name__) + + +class PublicIPAddressesManager(AzureBaseManager): + cloud_service_group = "PublicIPAddresses" + cloud_service_type = "IPAddress" + service_code = "/Microsoft.Network/publicIPAddresses" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-public-ip-address.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + public_ip_addresses_conn = PublicIPAddressesConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + public_ip_addresses_list = public_ip_addresses_conn.list_all_public_ip_addresses() + + for ip_address in public_ip_addresses_list: + + try: + ip_address_dict = self.convert_nested_dictionary(ip_address) + ip_address_id = ip_address_dict["id"] + + ip_address_dict.update( + { + "resource_group": self.get_resource_group_from_id( + ip_address_id + ), + "subscription_id": subscription_info["subscription_id"], + "subscription_name": subscription_info["display_name"], + "azure_monitor": {"resource_id": ip_address_id}, + } + ) + + if ip_address_dict.get("ip_configuration") is not None: + associated_to = ip_address_dict["ip_configuration"]["id"].split("/")[8] + + if associated_to: + ip_address_dict.update({"associated_to": associated_to}) + + ip_address_dict = self.update_tenant_id_from_secret_data( + ip_address_dict, secret_data + ) + + self.set_region_code(ip_address_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=ip_address_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=ip_address_dict, + account=secret_data["subscription_id"], + instance_type=ip_address_dict["sku"]["name"], + tags=ip_address_dict.get("tags", {}), + region_code=ip_address_dict["location"], + reference=self.make_reference(ip_address_dict.get("id")), + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses diff --git a/src/plugin/manager/snapshots/__init__.py b/src/plugin/manager/snapshots/__init__.py new file mode 100644 index 00000000..b0e0b0de --- /dev/null +++ b/src/plugin/manager/snapshots/__init__.py @@ -0,0 +1 @@ +from .instance_manager import SnapshotsManager diff --git a/src/spaceone/inventory/manager/snapshots/instance_manager.py b/src/plugin/manager/snapshots/instance_manager.py similarity index 64% rename from src/spaceone/inventory/manager/snapshots/instance_manager.py rename to src/plugin/manager/snapshots/instance_manager.py index f5157356..fc2d43f2 100644 --- a/src/spaceone/inventory/manager/snapshots/instance_manager.py +++ b/src/plugin/manager/snapshots/instance_manager.py @@ -1,49 +1,49 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.model.snapshots.cloud_service import * -from spaceone.inventory.connector.snapshots import SnapshotsConnector -from spaceone.inventory.model.snapshots.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.core.utils import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.snapshots.snapshots_connector import SnapshotsConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class SnapshotsManager(AzureManager): - connector_name = "SnapshotsConnector" - 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) : dictionary of azure snapshot data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug("** Snapshot START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - snapshot_conn: SnapshotsConnector = self.locator.get_connector( - self.connector_name, **params +class SnapshotsManager(AzureBaseManager): + cloud_service_group = "Snapshots" + cloud_service_type = "Instance" + service_code = "/Microsoft.Compute/snapshots" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Compute", "Storage"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-disk-snapshot.svg" + } ) - snapshot_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - snapshots = snapshot_conn.list_snapshots() + snapshots_conn = SnapshotsConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + snapshots = snapshots_conn.list_snapshots() for snapshot in snapshots: - snapshot_id = "" + try: snapshot_dict = self.convert_nested_dictionary(snapshot) snapshot_id = snapshot_dict["id"] @@ -74,7 +74,7 @@ def collect_cloud_service(self, params): # update snapshot_dict snapshot_dict = self.update_tenant_id_from_secret_data( - snapshot_dict, params["secret_data"] + snapshot_dict, secret_data ) snapshot_dict.update( { @@ -82,16 +82,14 @@ def collect_cloud_service(self, params): snapshot_id ), # parse resource_group from ID "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "size": snapshot_dict["disk_size_bytes"], "sku": sku_dict, "incremental_display": self.get_incremental_display( snapshot_dict["incremental"] ), "azure_monitor": {"resource_id": snapshot_id}, - "time_created": datetime_to_iso8601( - snapshot_dict["time_created"] - ), + "time_created": snapshot_dict["time_created"], } ) @@ -104,16 +102,6 @@ def collect_cloud_service(self, params): } ) - # get attached vm's name - if snapshot_dict.get("managed_by") is not None: - snapshot_dict.update( - { - "managed_by": self.get_attached_vm_name_from_managed_by( - snapshot_dict["managed_by"] - ) - } - ) - # get source_disk_name from source_resource_id if snapshot_dict.get("creation_data") is not None: source_resource_id = snapshot_dict["creation_data"].get( @@ -127,36 +115,47 @@ def collect_cloud_service(self, params): } ) - snapshot_data = Snapshot(snapshot_dict, strict=False) - snapshot_resource = SnapshotResource( - { - "data": snapshot_data, - "region_code": snapshot_data.location, - "reference": ReferenceModel(snapshot_data.reference()), - "tags": snapshot_dict.get("tags", {}), - "name": snapshot_data.name, - "account": snapshot_data.subscription_id, - "instance_size": float(snapshot_data.disk_size_bytes), - "instance_type": snapshot_data.sku.name, - } - ) + # get attached vm's name + if snapshot_dict.get("managed_by") is not None: + snapshot_dict.update( + { + "managed_by": self.get_attached_vm_name_from_managed_by( + snapshot_dict["managed_by"] + ) + } + ) - # Must set_region_code method for region collection - self.set_region_code(snapshot_data["location"]) - # _LOGGER.debug(f'[SNAPSHOT INFO] {snapshot_resource.to_primitive()}') - snapshot_responses.append( - SnapshotResponse({"resource": snapshot_resource}) + self.set_region_code(snapshot_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=snapshot_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=snapshot_dict, + account=snapshot_dict["subscription_id"], + instance_type=snapshot_dict["sku"]["name"], + instance_size=float(snapshot_dict["disk_size_bytes"]), + region_code=snapshot_dict["location"], + reference=self.make_reference(snapshot_dict.get("id")), + tags=snapshot_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error(f"[list_instances] {snapshot_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Compute", "Snapshot", snapshot_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** Snapshot Finished {time.time() - start_time} Seconds **") - return snapshot_responses, error_responses + return cloud_services, error_responses @staticmethod def get_attached_vm_name_from_managed_by(managed_by): diff --git a/src/plugin/manager/sql_databases/__init__.py b/src/plugin/manager/sql_databases/__init__.py new file mode 100644 index 00000000..f16b5621 --- /dev/null +++ b/src/plugin/manager/sql_databases/__init__.py @@ -0,0 +1 @@ +from .database_manager import SQLDatabasesManager diff --git a/src/spaceone/inventory/manager/sql_databases/database_manager.py b/src/plugin/manager/sql_databases/database_manager.py similarity index 70% rename from src/spaceone/inventory/manager/sql_databases/database_manager.py rename to src/plugin/manager/sql_databases/database_manager.py index 19dd98d7..cf15e691 100644 --- a/src/spaceone/inventory/manager/sql_databases/database_manager.py +++ b/src/plugin/manager/sql_databases/database_manager.py @@ -1,56 +1,58 @@ import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.model.sql_databases.cloud_service import * -from spaceone.inventory.model.sql_databases.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.inventory.model.sql_databases.data import * -from spaceone.inventory.connector.sql_databases import SQLDatabasesConnector -from spaceone.inventory.connector.monitor import MonitorConnector -from spaceone.core.utils import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.sql_databases.sql_databases_connector import SqlDatabasesConnector +from plugin.connector.monitor.monitor_connector import MonitorConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class SQLDatabasesManager(AzureManager): - connector_name = 'SQLDatabasesConnector' - monitor_connector_name = 'MonitorConnector' - 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) : dictionary of azure sql databases data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f'** SQL Databases START *') - start_time = time.time() - - subscription_info = params['subscription_info'] - sql_databases_conn: SQLDatabasesConnector = self.locator.get_connector(self.connector_name, **params) - sql_monitor_conn: MonitorConnector = self.locator.get_connector(self.monitor_connector_name, **params) - - sql_database_responses = [] +class SQLDatabasesManager(AzureBaseManager): + cloud_service_group = "SQLDatabases" + cloud_service_type = "Database" + service_code = "/Microsoft.Sql/servers/databases" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-sql-databases.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] + sql_databases_conn = SqlDatabasesConnector(secret_data=secret_data) + sql_monitor_conn = MonitorConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + # get resource_group_name and server_name from sql_server for sql_databases list sql_servers = sql_databases_conn.list_servers() + for sql_server in sql_servers: - sql_database_id = '' + try: sql_server_dict = self.convert_nested_dictionary(sql_server) - # get resource_group_name and server_name from sql_server for sql_databases list - server_name = sql_server_dict['name'] - resource_group_name = self.get_resource_group_from_id(sql_server_dict['id']) - server_admin_name = sql_server_dict.get('administrator_login') + server_name = sql_server_dict["name"] + resource_group_name = self.get_resource_group_from_id(sql_server_dict["id"]) + server_admin_name = sql_server_dict.get("administrator_login") # get list sql_databases = sql_databases_conn.list_databases_in_server(resource_group_name, server_name) @@ -61,8 +63,9 @@ def collect_cloud_service(self, params): # database for loop for sql_database in sql_databases: sql_database_dict = self.convert_nested_dictionary(sql_database) - database_name = sql_database_dict['name'] - current_sku_tier = sql_database_dict.get('current_sku').get('tier') + database_name = sql_database_dict["name"] + sql_database_id = sql_database_dict["id"] + current_sku_tier = sql_database_dict.get("current_sku").get("tier") if sql_database_dict.get('sku'): if sql_database_dict.get('name') != 'master': # No pricing tier for system database @@ -70,6 +73,7 @@ def collect_cloud_service(self, params): 'pricing_tier_display': self.get_pricing_tier_display(sql_database_dict['sku']), 'service_tier_display': sql_database_dict['sku'].get('tier') }) + if db_id := sql_database_dict.get('id'): sql_database_dict.update({ 'server_name': db_id.split('/')[8], @@ -114,25 +118,17 @@ def collect_cloud_service(self, params): sql_database_dict.update({ 'sync_agent_display': self.get_sync_agent_display(sql_database_dict['sync_agent']) }) - ''' - # Get Data masking rules - database_dict.update({ - 'data_masking_rules': self.list_data_masking_rules(self, sql_servers_conn, rg_name, server_name, database_dict['name']) - }) - ''' # Get Diagnostic Settings sql_database_dict.update({ 'diagnostic_settings_resource': self.list_diagnostics_settings(sql_monitor_conn, sql_database_dict['id']) }) - # Get Database Replication Type sql_database_dict.update({ 'replication_link': self.list_replication_link_in_database(replication_links, database_name=database_name) }) - # Get azure_ad_admin name if server_admin_name is not None: sql_database_dict.update({ @@ -150,36 +146,52 @@ def collect_cloud_service(self, params): sql_database_dict.update({ 'resource_group': resource_group_name, 'subscription_id': subscription_info['subscription_id'], - 'subscription_name': subscription_info['subscription_name'], + 'subscription_name': subscription_info['display_name'], 'azure_monitor': {'resource_id': sql_database_id} }) - sql_database_data = SQLDatabase(sql_database_dict, strict=False) - sql_database_resource = SQLDatabaseResource({ - 'name': database_name, - 'region_code': sql_database_data.location, - 'reference': ReferenceModel(sql_database_data.reference()), - 'data': sql_database_data, - 'account': subscription_info['subscription_id'], - 'instance_type': sql_database_data.sku.tier, - 'instance_size': float(sql_database_data.max_size_gb), - 'launched_at': datetime_to_iso8601(sql_database_data.creation_date), - 'tags': sql_database_dict.get('tags', {}) - }) - - # Must set_region_code method for region collection - self.set_region_code(sql_database_dict['location']) - - sql_database_responses.append(SQLDatabaseResponse({'resource': sql_database_resource})) + self.set_region_code(sql_database_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=database_name, + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=sql_database_dict, + account=secret_data["subscription_id"], + instance_type=sql_database_dict["sku"]["tier"], + instance_size=float(sql_database_dict["max_size_gb"]), + region_code=sql_database_dict["location"], + reference=self.make_reference(sql_database_dict.get("id")), + # launched_at=sql_database_dict["creation_date"], + tags=sql_database_dict.get("tags", {}), + data_format="dict" + ) + ) except Exception as e: - _LOGGER.error(f'[list_instances] {sql_database_id} {e}', exc_info=True) - error_resource_response = self.generate_resource_error_response(e, 'Database', 'SQLDatabse', - sql_database_id) - error_responses.append(error_resource_response) + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + def list_replication_links(self, replication_links_from_params) -> list: + replication_links = [] + for replication_link in replication_links_from_params: + replication_link_dict = self.convert_nested_dictionary(replication_link) + replication_link_dict['replica_state'] = 'Online' if replication_link_dict['role'] == 'Primary' \ + else 'Readable' + replication_links.append(replication_link_dict) - _LOGGER.debug(f'** SQL Databases Finished {time.time() - start_time} Seconds **') - return sql_database_responses, error_responses + return replication_links def get_sync_group_by_databases(self, replication_links_from_params: list) -> list: sync_groups = [] @@ -210,16 +222,6 @@ def list_diagnostics_settings(self, sql_monitor_conn, resource_uri): return diagnostic_settings_list - def list_replication_links(self, replication_links_from_params) -> list: - replication_links = [] - for replication_link in replication_links_from_params: - replication_link_dict = self.convert_nested_dictionary(replication_link) - replication_link_dict['replica_state'] = 'Online' if replication_link_dict['role'] == 'Primary' \ - else 'Readable' - replication_links.append(replication_link_dict) - - return replication_links - def get_database_auditing_settings(self, sql_databases_conn, resource_group_name, server_name, database_name): database_auditing_settings = sql_databases_conn.get_database_auditing_settings( resource_group_name=resource_group_name, diff --git a/src/plugin/manager/sql_servers/__init__.py b/src/plugin/manager/sql_servers/__init__.py new file mode 100644 index 00000000..19ba993c --- /dev/null +++ b/src/plugin/manager/sql_servers/__init__.py @@ -0,0 +1 @@ +from .server_manager import SQLServersManager diff --git a/src/spaceone/inventory/manager/sql_servers/server_manager.py b/src/plugin/manager/sql_servers/server_manager.py similarity index 84% rename from src/spaceone/inventory/manager/sql_servers/server_manager.py rename to src/plugin/manager/sql_servers/server_manager.py index f8285a37..ca32ed32 100644 --- a/src/spaceone/inventory/manager/sql_servers/server_manager.py +++ b/src/plugin/manager/sql_servers/server_manager.py @@ -1,61 +1,50 @@ import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.model.sql_servers.cloud_service import * -from spaceone.inventory.model.sql_databases.cloud_service import * -from spaceone.inventory.connector.sql_servers import SQLServersConnector -from spaceone.inventory.connector.monitor import MonitorConnector -from spaceone.inventory.model.sql_servers.cloud_service_type import CLOUD_SERVICE_TYPES -from spaceone.inventory.model.sql_databases.data import * -from spaceone.inventory.model.sql_servers.data import * -from spaceone.inventory.manager.sql_databases.database_manager import ( - SQLDatabasesManager, -) -from spaceone.core.utils import * -_LOGGER = logging.getLogger(__name__) - - -class SQLServersManager(AzureManager): - connector_name = "SQLServersConnector" - monitor_connector_name = "MonitorConnector" +from spaceone.inventory.plugin.collector.lib import * - cloud_service_types = CLOUD_SERVICE_TYPES +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.sql_servers.sql_servers_connector import SqlServersConnector +from plugin.connector.monitor.monitor_connector import MonitorConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager - 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) : dictionary of azure sql servers data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug(f"** SQL Servers START **") - start_time = time.time() +_LOGGER = logging.getLogger(__name__) - subscription_info = params["subscription_info"] - sql_servers_conn: SQLServersConnector = self.locator.get_connector( - self.connector_name, **params - ) - sql_servers_monitor_conn: MonitorConnector = self.locator.get_connector( - self.monitor_connector_name, **params +class SQLServersManager(AzureBaseManager): + cloud_service_group = "SQLServers" + cloud_service_type = "Server" + service_code = "/Microsoft.Sql/servers" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Database"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-sql-servers.svg" + } ) - sql_server_responses = [] + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] + sql_servers_conn = SqlServersConnector(secret_data=secret_data) + monitor_conn = MonitorConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + sql_servers = sql_servers_conn.list_servers() for sql_server in sql_servers: - sql_server_id = "" try: sql_server_dict = self.convert_nested_dictionary(sql_server) @@ -63,15 +52,16 @@ def collect_cloud_service(self, params): # update sql_servers_data dict sql_server_dict = self.update_tenant_id_from_secret_data( - sql_server_dict, params["secret_data"] + sql_server_dict, secret_data ) + sql_server_dict.update( { "resource_group": self.get_resource_group_from_id( sql_server_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": sql_server_id}, } ) @@ -97,11 +87,14 @@ def collect_cloud_service(self, params): ) databases_list = self.list_databases( sql_servers_conn=sql_servers_conn, - sql_monitor_conn=sql_servers_monitor_conn, + sql_monitor_conn=monitor_conn, resource_group_name=resource_group_name, server_name=name, server_admin_name=sql_server_dict.get("administrator_login"), ) + + number_of_databases_display = len(databases_list) + elastic_pools_list = self.list_elastic_pools( sql_servers_conn, resource_group_name, name ) @@ -121,6 +114,7 @@ def collect_cloud_service(self, params): "server_auditing_settings": server_auditing_settings_dict, "failover_groups": failover_group_list, "server_automatic_tuning": server_automatic_tuning_dict, + "number_of_databases": number_of_databases_display, "databases": databases_list, "elastic_pools": elastic_pools_list, "deleted_databases": deleted_databases_list, @@ -148,35 +142,35 @@ def collect_cloud_service(self, params): } ) - sql_server_data = SQLServer(sql_server_dict, strict=False) - sql_server_resource = SQLServerResource( - { - "data": sql_server_data, - "region_code": sql_server_data.location, - "reference": ReferenceModel(sql_server_data.reference()), - "tags": sql_server_dict.get("tags", {}), - "name": sql_server_data.name, - "account": sql_server_data.subscription_id, - } - ) - sql_server_responses.append( - SQLServerResponse({"resource": sql_server_resource}) + self.set_region_code(sql_server_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=sql_server_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=sql_server_dict, + account=secret_data["subscription_id"], + region_code=sql_server_dict["location"], + reference=self.make_reference(sql_server_dict.get("id")), + tags=sql_server_dict.get("tags", {}), + data_format="dict" + ) ) - # _LOGGER.debug(f'[SQL SERVER INFO] {sql_server_resource.to_primitive()}') - - # Must set_region_code method for region collection - self.set_region_code(sql_server_data["location"]) except Exception as e: - _LOGGER.error(f"[list_instances] {sql_server_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Database", "SQLServer", sql_server_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - - _LOGGER.debug(f"** SQL Servers Finished {time.time() - start_time} Seconds **") - return sql_server_responses, error_responses + return cloud_services, error_responses def list_elastic_pools(self, sql_servers_conn, rg_name, server_name): elastic_pools_list = [] @@ -202,7 +196,7 @@ def list_elastic_pools(self, sql_servers_conn, rg_name, server_name): "per_db_settings_display": self.get_per_db_settings( elastic_pool_dict["per_database_settings"] ), - "number_of_databases": len(elastic_pool_dict["databases"]), + "number_of_databases_display": len(elastic_pool_dict["databases"]), "unit_display": elastic_pool_dict["sku"]["tier"], "server_name_display": elastic_pool_dict["id"].split("/")[8], "resource_group_display": elastic_pool_dict["id"].split("/")[4], @@ -215,7 +209,7 @@ def list_elastic_pools(self, sql_servers_conn, rg_name, server_name): return elastic_pools_list def get_databases_by_elastic_pools( - self, sql_servers_conn, elastic_pool_name, rg_name, server_name + self, sql_servers_conn, elastic_pool_name, rg_name, server_name ): databases_obj = sql_servers_conn.list_databases_by_elastic_pool( elastic_pool_name, rg_name, server_name @@ -265,7 +259,7 @@ def list_virtual_network_rules(self, sql_servers_conn, rg_name, server_name): ) if ( - virtual_network_rule_dict.get("id") is not None + virtual_network_rule_dict.get("id") is not None ): # Get Virtual Network's name virtual_network_rule_dict.update( { @@ -366,7 +360,7 @@ def list_failover_groups(self, sql_servers_conn, rg_name, server_name): ) if ( - failover_dict.get("partner_servers") is not None + failover_dict.get("partner_servers") is not None ): # Get Secondary Server's name failover_dict.update( { @@ -393,7 +387,7 @@ def list_failover_groups(self, sql_servers_conn, rg_name, server_name): return failover_groups_list def list_data_masking_rules( - self, sql_servers_conn, rg_name, server_name, database_name + self, sql_servers_conn, rg_name, server_name, database_name ): data_masking_rules_list = [] data_masking_rule_obj = sql_servers_conn.list_data_masking_rules_by_database( @@ -407,12 +401,12 @@ def list_data_masking_rules( return data_masking_rules_list def list_databases( - self, - sql_servers_conn, - sql_monitor_conn, - resource_group_name, - server_name, - server_admin_name, + self, + sql_servers_conn, + sql_monitor_conn, + resource_group_name, + server_name, + server_admin_name, ): databases_list = [] databases = sql_servers_conn.list_databases_by_server( @@ -423,7 +417,7 @@ def list_databases( database_dict = self.convert_nested_dictionary(database) if database_dict.get("sku"): if ( - database_dict.get("name") != "master" + database_dict.get("name") != "master" ): # No pricing tier for system database database_dict.update( { @@ -453,7 +447,7 @@ def list_databases( database_dict.update( { "max_size_gb": database_dict["max_size_bytes"] - / 1073741824 # 2의 30승 + / 1073741824 # 2의 30승 } ) @@ -562,7 +556,7 @@ def list_diagnostics_settings(self, sql_monitor_conn, resource_uri): return diagnostic_settings_list def list_replication_link( - self, sql_servers_conn, rg_name, server_name, database_name + self, sql_servers_conn, rg_name, server_name, database_name ): replication_link_list = [] replication_link_obj = sql_servers_conn.list_replication_link( @@ -576,7 +570,7 @@ def list_replication_link( return replication_link_list def get_sync_group_by_databases( - self, sql_servers_conn, resource_group_name, server_name, database_name + self, sql_servers_conn, resource_group_name, server_name, database_name ): sync_group_obj = sql_servers_conn.list_sync_groups_by_databases( resource_group=resource_group_name, @@ -675,3 +669,5 @@ def get_sync_group_display(sync_group_list): sync_group_display_list.append(sync_display) return sync_group_display_list + + diff --git a/src/plugin/manager/storage_accounts/__init__.py b/src/plugin/manager/storage_accounts/__init__.py new file mode 100644 index 00000000..cda4782f --- /dev/null +++ b/src/plugin/manager/storage_accounts/__init__.py @@ -0,0 +1 @@ +from .instance_manager import StorageAccountsManager diff --git a/src/spaceone/inventory/manager/storage_accounts/instance_manager.py b/src/plugin/manager/storage_accounts/instance_manager.py similarity index 75% rename from src/spaceone/inventory/manager/storage_accounts/instance_manager.py rename to src/plugin/manager/storage_accounts/instance_manager.py index 8383aa21..23dcfaa2 100644 --- a/src/spaceone/inventory/manager/storage_accounts/instance_manager.py +++ b/src/plugin/manager/storage_accounts/instance_manager.py @@ -1,57 +1,51 @@ import datetime import logging -import time - -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.storage_accounts import StorageAccountsConnector -from spaceone.inventory.connector.monitor import MonitorConnector -from spaceone.inventory.model.storage_accounts.cloud_service import * -from spaceone.inventory.model.storage_accounts.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.storage_accounts.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.storage_accounts.storage_accounts_connector import StorageAccountsConnector +from plugin.connector.monitor.monitor_connector import MonitorConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class StorageAccountsManager(AzureManager): - connector_name = "StorageAccountsConnector" - 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) : dictionary of azure storage account data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug("** Storage Account START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - storage_account_conn: StorageAccountsConnector = self.locator.get_connector( - self.connector_name, **params - ) - monitor_conn: MonitorConnector = self.locator.get_connector( - "MonitorConnector", **params +class StorageAccountsManager(AzureBaseManager): + cloud_service_group = "StorageAccounts" + cloud_service_type = "Instance" + service_code = "/Microsoft.Storage/storageAccounts" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Storage"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-service-accounts.svg" + } ) - storage_account_responses = [] + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - storage_accounts = storage_account_conn.list_storage_accounts() + storage_accounts_conn = StorageAccountsConnector(secret_data=secret_data) + monitor_conn = MonitorConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + storage_accounts = storage_accounts_conn.list_storage_accounts() for storage_account in storage_accounts: - storage_account_id = "" try: storage_account_dict = self.convert_nested_dictionary(storage_account) @@ -73,15 +67,13 @@ def collect_cloud_service(self, params): "FileStorage" ]: container_count = self.get_blob_containers_count( - storage_account_conn, + storage_accounts_conn, resource_group, storage_account_dict["name"], ) - storage_account_dict.update( {"container_count_display": container_count} ) - if storage_account_dict.get("routing_preference") is not None: storage_account_dict.update( {"routing_preference_display": "Internet routing"} @@ -90,15 +82,14 @@ def collect_cloud_service(self, params): storage_account_dict.update( {"routing_preference_display": "Microsoft network routing"} ) - storage_account_dict = self.update_tenant_id_from_secret_data( - storage_account_dict, params["secret_data"] + storage_account_dict, secret_data ) storage_account_dict.update( { "resource_group": resource_group, "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": storage_account_id}, "blob_count_display": self._get_blob_count_from_monitoring( monitor_conn, storage_account_id @@ -109,40 +100,36 @@ def collect_cloud_service(self, params): } ) - storage_account_data = StorageAccount( - storage_account_dict, strict=False - ) - storage_account_resource = StorageAccountResource( - { - "data": storage_account_data, - "tags": storage_account_dict.get("tags", {}), - "region_code": storage_account_data.location, - "reference": ReferenceModel(storage_account_data.reference()), - "name": storage_account_data.name, - "account": storage_account_data.subscription_id, - "instance_type": storage_account_data.sku.tier, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(storage_account_data["location"]) - storage_account_responses.append( - StorageAccountResponse({"resource": storage_account_resource}) + self.set_region_code(storage_account_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=storage_account_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=storage_account_dict, + account=storage_account_dict["subscription_id"], + instance_type=storage_account_dict["sku"]["tier"], + region_code=storage_account_dict["location"], + reference=self.make_reference(storage_account_dict.get("id")), + tags=storage_account_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {storage_account_id} {e}", exc_info=True - ) - error_resource_response = self.generate_resource_error_response( - e, "Storage", "StorageAccount", storage_account_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug( - f"** Storage Account Finished {time.time() - start_time} Seconds **" - ) - return storage_account_responses, error_responses + return cloud_services, error_responses def get_public_ip_address( self, application_gateway_conn, resource_group_name, pip_name diff --git a/src/spaceone/inventory/model/application_gateways/__init__.py b/src/plugin/manager/subscriptions/__init__.py similarity index 100% rename from src/spaceone/inventory/model/application_gateways/__init__.py rename to src/plugin/manager/subscriptions/__init__.py diff --git a/src/spaceone/inventory/manager/subscriptions/subscription_manager.py b/src/plugin/manager/subscriptions/subscription_manager.py similarity index 53% rename from src/spaceone/inventory/manager/subscriptions/subscription_manager.py rename to src/plugin/manager/subscriptions/subscription_manager.py index e3dc66e5..49571a93 100644 --- a/src/spaceone/inventory/manager/subscriptions/subscription_manager.py +++ b/src/plugin/manager/subscriptions/subscription_manager.py @@ -1,25 +1,25 @@ -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.connector.subscriptions import SubscriptionsConnector +import logging import re +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager -class SubscriptionsManager(AzureManager): - connector_name = 'SubscriptionsConnector' +_LOGGER = logging.getLogger(__name__) - def get_subscription_info(self, params): - secret_data = params['secret_data'] - subscription_connector: SubscriptionsConnector = self.locator.get_connector(self.connector_name, secret_data=secret_data) - subscription_info = subscription_connector.get_subscription_info(secret_data['subscription_id']) - return { - 'subscription_id': subscription_info.subscription_id, - 'subscription_name': subscription_info.display_name, - 'tenant_id': subscription_info.tenant_id - } +class SubscriptionsManager(AzureBaseManager): + # cloud_service_group = "Subscriptions" + # cloud_service_type = "Subscription" + service_code = "/Microsoft.subscriptions" - def list_location_info(self, params): - secret_data = params['secret_data'] - subscription_connector: SubscriptionsConnector = self.locator.get_connector(self.connector_name, secret_data=secret_data) + def create_cloud_service_type(self): + pass + + def create_cloud_service(self, options: dict, secret_data: dict, schema: str): + pass + + def list_location_info(self, secret_data: dict): + subscription_connector = SubscriptionsConnector(secret_data=secret_data) location_infos = subscription_connector.list_location_info(secret_data['subscription_id']) region_info = {} @@ -33,6 +33,8 @@ def list_location_info(self, params): if _name and _latitude and _longitude and _continent: region_info.update({ _loc_info['name']: { + 'region_code': _loc_info['name'], + 'provider': self.provider, 'name': _name, 'tags': { 'latitude': _latitude, diff --git a/src/plugin/manager/virtual_machines/__init__.py b/src/plugin/manager/virtual_machines/__init__.py new file mode 100644 index 00000000..11b1bdda --- /dev/null +++ b/src/plugin/manager/virtual_machines/__init__.py @@ -0,0 +1,8 @@ +from plugin.manager.virtual_machines.disk_manager import VirtualMachineDiskManager +from plugin.manager.virtual_machines.load_balancer_manager import VirtualMachineLoadBalancerManager +from plugin.manager.virtual_machines.network_security_group_manager import VirtualMachineNetworkSecurityGroupManager +from plugin.manager.virtual_machines.nic_manager import VirtualMachineNICManager +from plugin.manager.virtual_machines.vm_manager import VirtualMachineVmManager +from plugin.manager.virtual_machines.vnet_manager import VirtualMachineVNetManager + +from .instance_manager import VirtualMachinesManager diff --git a/src/spaceone/inventory/manager/virtual_machines/disk_manager.py b/src/plugin/manager/virtual_machines/disk_manager.py similarity index 83% rename from src/spaceone/inventory/manager/virtual_machines/disk_manager.py rename to src/plugin/manager/virtual_machines/disk_manager.py index ea10b3d5..a53f5dec 100644 --- a/src/spaceone/inventory/manager/virtual_machines/disk_manager.py +++ b/src/plugin/manager/virtual_machines/disk_manager.py @@ -1,15 +1,4 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import Disk -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector - - -class VirtualMachineDiskManager(BaseManager): - - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - +class VirtualMachineDiskManager: def get_disk_info(self, vm, list_disks): ''' disk_data = { @@ -36,7 +25,7 @@ def get_disk_info(self, vm, list_disks): volume_data.update({ 'disk_type': 'os_disk' }) - disk_data.append(Disk(volume_data, strict=False)) + disk_data.append(volume_data) index += 1 data_disks = vm.storage_profile.data_disks @@ -46,7 +35,7 @@ def get_disk_info(self, vm, list_disks): volume_data_sub.update({ 'disk_type': 'data_disk' }) - disk_data.append(Disk(volume_data_sub, strict=False)) + disk_data.append(volume_data_sub) index += 1 return disk_data diff --git a/src/plugin/manager/virtual_machines/instance_manager.py b/src/plugin/manager/virtual_machines/instance_manager.py new file mode 100644 index 00000000..ba648f8a --- /dev/null +++ b/src/plugin/manager/virtual_machines/instance_manager.py @@ -0,0 +1,246 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.virtual_machines.virtual_machines_connector import VirtualMachinesConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.virtual_machines import ( + VirtualMachineDiskManager, + VirtualMachineLoadBalancerManager, + VirtualMachineNetworkSecurityGroupManager, + VirtualMachineNICManager, + VirtualMachineVmManager, + VirtualMachineVNetManager, +) +from plugin.manager.base import AzureBaseManager + +_LOGGER = logging.getLogger(__name__) + + +class VirtualMachinesManager(AzureBaseManager): + cloud_service_group = "VirtualMachines" + cloud_service_type = "Instance" + service_code = "/Microsoft.Compute/virtualMachines" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Compute", "Server"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-vm.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + vm_conn = VirtualMachinesConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + # call all managers + vm_manager = VirtualMachineVmManager(vm_conn=vm_conn) + disk_manager = VirtualMachineDiskManager() + load_balancer_manager = VirtualMachineLoadBalancerManager() + network_security_group_manager = VirtualMachineNetworkSecurityGroupManager() + nic_manager = VirtualMachineNICManager() + vnet_manager = VirtualMachineVNetManager() + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + subscription_data = { + "subscription_id": secret_data["subscription_id"], + "subscription_name": subscription_info["display_name"], + "tenant_id": subscription_info["tenant_id"], + } + + vms = list(vm_conn.list_all_vms()) + resource_groups = list(vm_conn.list_resource_groups()) + load_balancers = list(vm_conn.list_load_balancers()) + network_security_groups = list(vm_conn.list_network_security_groups()) + network_interfaces = list(vm_conn.list_network_interfaces()) + disks = list(vm_conn.list_disks()) + public_ip_addresses = list(vm_conn.list_public_ip_addresses()) + virtual_networks = list(vm_conn.list_virtual_networks()) + skus = list(vm_conn.list_skus()) + + for vm in vms: + try: + vnet_data = None + subnet_data = None + lb_vos = [] + + resource_group, resource_group_name = self.get_resource_info_in_vm( + vm, resource_groups + ) + skus_dict = self.get_skus_resource(skus) + + disk_vos = disk_manager.get_disk_info(vm, disks) + nic_vos, primary_ip = nic_manager.get_nic_info( + vm, network_interfaces, public_ip_addresses, virtual_networks + ) + + vm_resource = vm_manager.get_vm_info( + vm, + disk_vos, + nic_vos, + resource_group, + subscription_data["subscription_id"], + network_security_groups, + primary_ip, + skus_dict, + ) + + if load_balancers is not None: + lb_vos = load_balancer_manager.get_load_balancer_info( + vm, load_balancers, public_ip_addresses + ) + + nsg_vos = ( + network_security_group_manager.get_network_security_group_info( + vm, network_security_groups, network_interfaces + ) + ) + + nic_name = vm.network_profile.network_interfaces[0].id.split("/")[-1] + + if nic_name is not None: + vnet_subnet_dict = vnet_manager.get_vnet_subnet_info( + nic_name, network_interfaces, virtual_networks + ) + + if vnet_subnet_dict.get("vnet_info"): + vnet_data = vnet_subnet_dict["vnet_info"] + + if vnet_subnet_dict.get("subnet_info"): + subnet_data = vnet_subnet_dict["subnet_info"] + + vm_resource.update({"tags": self.get_tags(vm.tags)}) + + resource_id = f'/subscriptions/{subscription_data["subscription_id"]}/resourceGroups/{resource_group_name}/providers/Microsoft.Compute/virtualMachines/{vm_resource["name"]}' + + # update vm_resource data + vm_resource["data"].update( + { + "tenant_id": subscription_data["tenant_id"], + "subscription_name": subscription_data["subscription_name"], + "subscription_id": subscription_data["subscription_id"], + "resource_group": resource_group_name, + } + ) + + vm_resource["data"].update( + { + "load_balancer": lb_vos, + "security_group": nsg_vos, + "vnet": vnet_data, + "subnet": subnet_data, + "azure_monitor": {"resource_id": resource_id}, + "activity_log": {"resource_uri": resource_id}, + } + ) + + vm_resource["data"]["compute"]["account"] = subscription_data[ + "subscription_name" + ] + + self.set_region_code(vm_resource["region_code"]) + + cloud_services.append( + make_cloud_service( + name=vm_resource["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=vm_resource["data"], + account=subscription_data["subscription_id"], + instance_type=vm_resource["data"]["compute"]["instance_type"], + ip_addresses=vm_resource["ip_addresses"], + region_code=vm_resource["region_code"], + reference=self.make_reference( + vm_resource["data"]["compute"]["instance_id"], + f"https://portal.azure.com/#@.onmicrosoft.com/resource/subscriptions/{subscription_data['subscription_id']}/resourceGroups/{resource_group_name}/providers/Microsoft.Compute/virtualMachines/{vm_resource['data']['compute']['instance_name']}/overview" + ), + tags=vm_resource["tags"], + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + @staticmethod + def get_tags(tags): + tags_result = [] + if tags: + for k, v in tags.items(): + tags_result.append({"key": k, "value": v}) + + return tags_result + + @staticmethod + def get_resource_info_in_vm(vm, resource_groups): + for rg in resource_groups: + vm_info = vm.id.split("/") + for info in vm_info: + if info == rg.name.upper(): + resource_group = rg + resource_group_name = rg.name + return resource_group, resource_group_name + + @staticmethod + def get_resources_in_resource_group(resources, resource_group_name): + infos = [] + for resource in resources: + id_info = resource.id.split("/") + for info in id_info: + if info == resource_group_name.upper(): + infos.append(resource) + return infos + + @staticmethod + def get_skus_resource(skus): + skus_dict = {} + for sku in skus: + if sku.resource_type == "virtualMachines": + location = sku.locations[0].lower() + if location not in skus_dict: + skus_dict[location] = [] + info = {} + # get sku information for discriminating Instance type + info.update( + { + "resource_type": sku.resource_type, + "name": sku.name, + "tier": sku.tier, + "size": sku.size, + "family": sku.family, + } + ) + + # get cpu and memory information + for capa in sku.capabilities: + if capa.name == "vCPUs": + info["core"] = capa.value + elif capa.name == "MemoryGB": + info["memory"] = capa.value + skus_dict[location].append(info) + + return skus_dict diff --git a/src/spaceone/inventory/manager/virtual_machines/load_balancer_manager.py b/src/plugin/manager/virtual_machines/load_balancer_manager.py similarity index 86% rename from src/spaceone/inventory/manager/virtual_machines/load_balancer_manager.py rename to src/plugin/manager/virtual_machines/load_balancer_manager.py index 898b1a18..ff4699c4 100644 --- a/src/spaceone/inventory/manager/virtual_machines/load_balancer_manager.py +++ b/src/plugin/manager/virtual_machines/load_balancer_manager.py @@ -1,14 +1,4 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import LoadBalancer -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector - - -class VirtualMachineLoadBalancerManager(BaseManager): - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - +class VirtualMachineLoadBalancerManager: def get_load_balancer_info(self, vm, load_balancers, public_ip_addresses): """ lb_data = { @@ -23,6 +13,7 @@ def get_load_balancer_info(self, vm, load_balancers, public_ip_addresses): } } """ + lb_data = [] match_load_balancers = self.get_load_balancers_from_nic( vm.network_profile.network_interfaces, load_balancers @@ -41,7 +32,7 @@ def get_load_balancer_info(self, vm, load_balancers, public_ip_addresses): "protocol": protocols, "tags": {"lb_id": match_load_balancer.id}, } - lb_data.append(LoadBalancer(load_balancer_data, strict=False)) + lb_data.append(load_balancer_data) return lb_data @@ -112,4 +103,4 @@ def get_lb_port_protocol(match_load_balancer): ports.append(lbr.frontend_port) protocols.append(lbr.protocol.upper()) - return ports, protocols + return ports, protocols \ No newline at end of file diff --git a/src/spaceone/inventory/manager/virtual_machines/network_security_group_manager.py b/src/plugin/manager/virtual_machines/network_security_group_manager.py similarity index 92% rename from src/spaceone/inventory/manager/virtual_machines/network_security_group_manager.py rename to src/plugin/manager/virtual_machines/network_security_group_manager.py index 709ae778..567337d2 100644 --- a/src/spaceone/inventory/manager/virtual_machines/network_security_group_manager.py +++ b/src/plugin/manager/virtual_machines/network_security_group_manager.py @@ -1,14 +1,4 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import SecurityGroup -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector - - -class VirtualMachineNetworkSecurityGroupManager(BaseManager): - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - +class VirtualMachineNetworkSecurityGroupManager: def get_network_security_group_info( self, vm, network_security_groups, network_interfaces ): @@ -58,7 +48,7 @@ def get_network_security_group_info( network_security_groups_data.extend(default_security_data) for nsg in network_security_groups_data: - nsg_data.append(SecurityGroup(nsg, strict=False)) + nsg_data.append(nsg) return nsg_data @@ -217,4 +207,4 @@ def get_nsg_port(s_rule): if len(port_result) > 0: return port_result - return None + return None \ No newline at end of file diff --git a/src/spaceone/inventory/manager/virtual_machines/nic_manager.py b/src/plugin/manager/virtual_machines/nic_manager.py similarity index 87% rename from src/spaceone/inventory/manager/virtual_machines/nic_manager.py rename to src/plugin/manager/virtual_machines/nic_manager.py index 80525382..08b6cf90 100644 --- a/src/spaceone/inventory/manager/virtual_machines/nic_manager.py +++ b/src/plugin/manager/virtual_machines/nic_manager.py @@ -1,14 +1,4 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import NIC, NICTags -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector - - -class VirtualMachineNICManager(BaseManager): - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - +class VirtualMachineNICManager: def get_nic_info( self, vm, network_interfaces, public_ip_addresses, virtual_networks ): @@ -58,7 +48,7 @@ def get_nic_info( ) index += 1 - nic_data.append(NIC(network_data, strict=False)) + nic_data.append(network_data) return nic_data, primary_ip diff --git a/src/spaceone/inventory/manager/virtual_machines/vm_manager.py b/src/plugin/manager/virtual_machines/vm_manager.py similarity index 90% rename from src/spaceone/inventory/manager/virtual_machines/vm_manager.py rename to src/plugin/manager/virtual_machines/vm_manager.py index 58a4e9ce..779f6593 100644 --- a/src/spaceone/inventory/manager/virtual_machines/vm_manager.py +++ b/src/plugin/manager/virtual_machines/vm_manager.py @@ -1,16 +1,12 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import Compute, Azure, OS, Hardware, ResourceGroup -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector +from plugin.connector.virtual_machines.virtual_machines_connector import VirtualMachinesConnector -class VirtualMachineVmManager(BaseManager): +class VirtualMachineVmManager: + def __init__(self, vm_conn): + self.vm_conn: VirtualMachinesConnector = vm_conn - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - - def get_vm_info(self, vm, disks, nics, resource_group, subscription, network_security_groups, primary_ip, skus_dict): + def get_vm_info(self, vm, disks, nics, resource_group, subscription, network_security_groups, primary_ip, + skus_dict): ''' server_data = { "name": "" @@ -117,7 +113,7 @@ def get_os_data(self, vm_storage_profile): 'details': self.get_os_details(image_reference), 'os_type': os_type } - return OS(os_data, strict=False) + return os_data except Exception as e: print(f'[ERROR: GET OS Distro Data]: {e}') @@ -126,7 +122,7 @@ def get_os_data(self, vm_storage_profile): print(f'[ERROR: GET OS Data]: {e}') def get_compute_data(self, vm, resource_group_name, network_security_groups, subscription_id): - vm_info = self.azure_vm_connector.get_vm(resource_group_name, vm.name) + vm_info = self.vm_conn.get_vm(resource_group_name, vm.name) compute_data = { # 'keypair': self.get_keypair(vm.os_profile.linux_configuration), 'keypair': '', # TODO: not implemented yet @@ -151,7 +147,7 @@ def get_compute_data(self, vm, resource_group_name, network_security_groups, sub 'az': vm.location }) - return Compute(compute_data, strict=False) + return compute_data def get_azure_data(self, vm): azure_data = { @@ -161,15 +157,16 @@ def get_azure_data(self, vm): 'tags': self.get_tags(vm.tags) } - if getattr(vm, 'diagnostics_profile') and getattr(vm.diagnostics_profile, "boot_diagnostics") and vm.diagnostics_profile.boot_diagnostics: + if getattr(vm, 'diagnostics_profile') and getattr(vm.diagnostics_profile, + "boot_diagnostics") and vm.diagnostics_profile.boot_diagnostics: azure_data.update({ 'boot_diagnostics': self.get_boot_diagnostics(vm.diagnostics_profile.boot_diagnostics) }) - return Azure(azure_data, strict=False) + return azure_data def get_vm_size(self, location): - return self.azure_vm_connector.list_virtual_machine_sizes(location) + return self.vm_conn.list_virtual_machine_sizes(location) @staticmethod def get_hardware_data(vm, skus_dict, compute_data): @@ -188,12 +185,12 @@ def get_hardware_data(vm, skus_dict, compute_data): """ location = vm.location.lower() - instance_type = compute_data.instance_type + instance_type = compute_data["instance_type"] - hardware_data = Hardware(strict=False) + hardware_data = [] for sku in skus_dict[location]: if sku['name'] == instance_type: - hardware_data = Hardware(sku, strict=False) + hardware_data = sku return hardware_data def get_os_distro(self, os_type, offer): @@ -223,10 +220,10 @@ def get_keypair(linux_configuration): def get_ip_addresses(nic_vos): ip_addrs = [] for nic_vo in nic_vos: - ip_addrs.extend(nic_vo.ip_addresses) + ip_addrs.extend(nic_vo.get("ip_addresses")) - if nic_vo.public_ip_address: - ip_addrs.append(nic_vo.public_ip_address) + if nic_vo["public_ip_address"]: + ip_addrs.append(nic_vo.get("public_ip_address")) return list(set(ip_addrs)) @@ -316,7 +313,7 @@ def get_resource_group_data(resource_group): 'resource_group_name': resource_group.name, 'resource_group_id': resource_group.id } - return ResourceGroup(resource_group_data, strict=False) + return resource_group_data @staticmethod def get_ultra_ssd_enabled(additional_capabilities): @@ -398,7 +395,7 @@ def get_image_detail(location, image_reference, subscription_id): if publisher and offer and sku and version: image_detail = f'/Subscriptions/{subscription_id}/Providers/Microsoft.Compute/Locations/{location}' \ - f'/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/{version}' + f'/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/{version}' return image_detail return None diff --git a/src/spaceone/inventory/manager/virtual_machines/vnet_manager.py b/src/plugin/manager/virtual_machines/vnet_manager.py similarity index 75% rename from src/spaceone/inventory/manager/virtual_machines/vnet_manager.py rename to src/plugin/manager/virtual_machines/vnet_manager.py index 0155eb5a..0b673c3c 100644 --- a/src/spaceone/inventory/manager/virtual_machines/vnet_manager.py +++ b/src/plugin/manager/virtual_machines/vnet_manager.py @@ -1,15 +1,4 @@ -from spaceone.core.manager import BaseManager -from spaceone.inventory.model.virtual_machines.data import VNet, Subnet -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector - - -class VirtualMachineVNetManager(BaseManager): - - def __init__(self, params, azure_vm_connector=None, **kwargs): - super().__init__(**kwargs) - self.params = params - self.azure_vm_connector: VirtualMachinesConnector = azure_vm_connector - +class VirtualMachineVNetManager: def get_vnet_subnet_info(self, nic_name, network_interfaces, virtual_networks): ''' vnet_subnet_dict = { @@ -51,7 +40,7 @@ def convert_vnet_info(vnet): 'cidr': vnet.address_space.address_prefixes[0] } - return VNet(vnet_data, strict=False) + return vnet_data @staticmethod def convert_subnet_info(subnet): @@ -69,4 +58,4 @@ def convert_subnet_info(subnet): 'cidr': subnet.address_prefix } - return Subnet(subnet_data, strict=False) + return subnet_data diff --git a/src/plugin/manager/virtual_networks/__init__.py b/src/plugin/manager/virtual_networks/__init__.py new file mode 100644 index 00000000..ec0863d8 --- /dev/null +++ b/src/plugin/manager/virtual_networks/__init__.py @@ -0,0 +1 @@ +from .instance_manager import VirtualNetworksManager diff --git a/src/spaceone/inventory/manager/virtual_networks/instance_manager.py b/src/plugin/manager/virtual_networks/instance_manager.py similarity index 54% rename from src/spaceone/inventory/manager/virtual_networks/instance_manager.py rename to src/plugin/manager/virtual_networks/instance_manager.py index d4f6d97f..c1529b38 100644 --- a/src/spaceone/inventory/manager/virtual_networks/instance_manager.py +++ b/src/plugin/manager/virtual_networks/instance_manager.py @@ -1,136 +1,120 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.virtual_networks import VirtualNetworksConnector -from spaceone.inventory.model.virtual_networks.cloud_service import * -from spaceone.inventory.model.virtual_networks.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.virtual_networks.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.virtual_networks.virtual_networks_connector import VirtualNetworksConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class VirtualNetworksManager(AzureManager): - connector_name = "VirtualNetworksConnector" - 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) : dictionary of virtual network data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug("** Vnet START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - vnet_conn: VirtualNetworksConnector = self.locator.get_connector( - self.connector_name, **params +class VirtualNetworksManager(AzureBaseManager): + cloud_service_group = "VirtualNetworks" + cloud_service_type = "Instance" + service_code = "/Microsoft.Network/virtualNetworks" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Networking"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-virtual-networks.svg" + } ) - virtual_network_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - virtual_networks = vnet_conn.list_all_virtual_networks() + virtual_networks_conn = VirtualNetworksConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + virtual_networks = virtual_networks_conn.list_all_virtual_networks() for virtual_network in virtual_networks: - virtual_network_id = "" try: - vnet_dict = self.convert_nested_dictionary(virtual_network) - virtual_network_id = vnet_dict["id"] + virtual_network_dict = self.convert_nested_dictionary(virtual_network) + virtual_network_id = virtual_network_dict["id"] # update vnet_dict - vnet_dict = self.update_tenant_id_from_secret_data( - vnet_dict, params["secret_data"] + virtual_network_dict = self.update_tenant_id_from_secret_data( + virtual_network_dict, secret_data ) - vnet_dict.update( + virtual_network_dict.update( { "resource_group": self.get_resource_group_from_id( virtual_network_id ), "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": virtual_network_id}, } ) - if vnet_dict.get("subnets") is not None: - subnets = vnet_dict["subnets"] - resource_group = vnet_dict["resource_group"] + if virtual_network_dict.get("subnets") is not None: + subnets = virtual_network_dict["subnets"] + resource_group = virtual_network_dict["resource_group"] # Change attached network interfaces objects to id self.change_subnet_object_to_ids_list(subnets) - vnet_dict.update( + virtual_network_dict.update( { "subnets": self.update_subnet_info(subnets), "service_endpoints": self.get_service_endpoints(subnets), "private_endpoints": self.get_private_endpoints(subnets), "azure_firewall": self.get_azure_firewall( - vnet_conn, subnets, resource_group + virtual_networks_conn, subnets, resource_group ), "connected_devices": self.get_connected_devices(subnets), } ) # If not 'custom dns servers', add default azure dns server dict to vnet - if vnet_dict.get("dhcp_options") is None: + if virtual_network_dict.get("dhcp_options") is None: dhcp_option_dict = {"dns_servers": ["Azure provided DNS service"]} - vnet_dict.update({"dhcp_options": dhcp_option_dict}) - - """ - # Get IP Address Range, Count - if vnet_dict.get('address_space') is not None: - if vnet_dict['address_space'].get('address_prefixes') is not None: - for address_space in vnet_dict['address_space']['address_prefixes']: # ex. address_space = '10.0.0.0/16' - ip = IPNetwork(address_space) - # vnet_dict['address_space']['address_count'] = ip.size - """ - - vnet_data = VirtualNetwork(vnet_dict, strict=False) - vnet_resource = VirtualNetworkResource( - { - "data": vnet_data, - "region_code": vnet_data.location, - "reference": ReferenceModel(vnet_data.reference()), - "name": vnet_data.name, - "account": vnet_data.subscription_id, - "tags": vnet_dict.get("tags", {}), - } - ) - - # Must set_region_code method for region collection - self.set_region_code(vnet_data["location"]) - # _LOGGER.debug(f'[VNET INFO] {vnet_resource.to_primitive()}') - virtual_network_responses.append( - VirtualNetworkResponse({"resource": vnet_resource}) + virtual_network_dict.update({"dhcp_options": dhcp_option_dict}) + + self.set_region_code(virtual_network_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=virtual_network_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=virtual_network_dict, + account=virtual_network_dict["subscription_id"], + region_code=virtual_network_dict["location"], + reference=self.make_reference(virtual_network_dict.get("id")), + tags=virtual_network_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error( - f"[list_instances] {virtual_network_id} {e}", exc_info=True - ) - error_resource_response = self.generate_resource_error_response( - e, "Network", "VirtualNetwork", virtual_network_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - - _LOGGER.debug( - f"** Virtual Network Finished {time.time() - start_time} Seconds **" - ) - return virtual_network_responses, error_responses + return cloud_services, error_responses def get_azure_firewall(self, vnet_conn, subnet_list, resource_group_name): # Get Azure firewall information @@ -139,7 +123,7 @@ def get_azure_firewall(self, vnet_conn, subnet_list, resource_group_name): if subnet.get("connected_devices_list"): for device in subnet["connected_devices_list"]: if ( - device["type"] == "azureFirewalls" + device["type"] == "azureFirewalls" ): # The subnet which has 'AzureFirewall' is typed as 'azureFirewalls' firewall_obj = vnet_conn.list_all_firewalls( resource_group_name @@ -149,7 +133,7 @@ def get_azure_firewall(self, vnet_conn, subnet_list, resource_group_name): for ip_configuration in firewall_dict["ip_configurations"]: if ip_configuration.get("subnet") is not None: if ( - subnet["id"] in ip_configuration["subnet"]["id"] + subnet["id"] in ip_configuration["subnet"]["id"] ): # If subnet id matches the firewall's subnet id firewall_dict["subnet"] = subnet["id"].split( "/" @@ -175,34 +159,6 @@ def change_subnet_object_to_ids_list(subnets_dict): @staticmethod def update_subnet_info(subnet_list): - """ - : subnets_dict = { - ip_configurations= [ - { - 'id': '/subscriptions/xxx/resourceGroups/xxx/Microsoft.Network/[DeviceType]/[DeviceName] - }, - ... - ] - } - :return - subnets_dict = { - connected_devices_list = [ - { - 'device' :, - 'type' :, - 'ip_address' : , - 'subnet': - } - ] - - 'network_security_group' : { - 'id' : , - 'name' : - } - } - ... - """ - for subnet in subnet_list: # Get network security group's name if subnet.get("network_security_group") is not None: diff --git a/src/plugin/manager/vm_scale_sets/__init__.py b/src/plugin/manager/vm_scale_sets/__init__.py new file mode 100644 index 00000000..e91926b2 --- /dev/null +++ b/src/plugin/manager/vm_scale_sets/__init__.py @@ -0,0 +1 @@ +from .scale_set_manager import VMScaleSetsManager diff --git a/src/spaceone/inventory/manager/vm_scale_sets/scale_set_manager.py b/src/plugin/manager/vm_scale_sets/scale_set_manager.py similarity index 72% rename from src/spaceone/inventory/manager/vm_scale_sets/scale_set_manager.py rename to src/plugin/manager/vm_scale_sets/scale_set_manager.py index 92463cb4..93857e8f 100644 --- a/src/spaceone/inventory/manager/vm_scale_sets/scale_set_manager.py +++ b/src/plugin/manager/vm_scale_sets/scale_set_manager.py @@ -1,51 +1,48 @@ -import time import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.vm_scale_sets import VmScaleSetsConnector -from spaceone.inventory.model.vm_scale_sets.cloud_service import * -from spaceone.inventory.model.vm_scale_sets.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.vm_scale_sets.data import * + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.vm_scale_sets.vm_scale_sets_connector import VMScaleSetsConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager _LOGGER = logging.getLogger(__name__) -class VmScaleSetsManager(AzureManager): - connector_name = "VmScaleSetsConnector" - 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) : dictionary of azure vm scale set data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug("** VmScaleSet START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - vm_scale_set_conn: VmScaleSetsConnector = self.locator.get_connector( - self.connector_name, **params +class VMScaleSetsManager(AzureBaseManager): + cloud_service_group = "VMScaleSets" + cloud_service_type = "ScaleSet" + service_code = "/Microsoft.Compute/virtualMachineScaleSets" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Compute"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-vm-scale-set.svg" + } ) - vm_scale_set_responses = [] + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] error_responses = [] - vm_scale_sets = vm_scale_set_conn.list_vm_scale_sets() + vm_scale_sets_conn = VMScaleSetsConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + vm_scale_sets = vm_scale_sets_conn.list_vm_scale_sets() for vm_scale_set in vm_scale_sets: - vm_scale_set_id = "" try: vm_scale_set_dict = self.convert_nested_dictionary(vm_scale_set) @@ -58,13 +55,13 @@ def collect_cloud_service(self, params): vm_scale_set_id ), # parse resource_group from ID "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], + "subscription_name": subscription_info["display_name"], "azure_monitor": {"resource_id": vm_scale_set_id}, } ) if vm_scale_set_dict.get( - "proximity_placement_group" + "proximity_placement_group" ): # if it has a key -> get value -> check if it isn't None / if no 'Key' -> return None vm_scale_set_dict.update( { @@ -77,10 +74,10 @@ def collect_cloud_service(self, params): # Get Instance termination notification display if vm_scale_set_dict.get("virtual_machine_profile") is not None: if ( - vm_scale_set_dict["virtual_machine_profile"].get( - "scheduled_events_profile" - ) - is not None + vm_scale_set_dict["virtual_machine_profile"].get( + "scheduled_events_profile" + ) + is not None ): if vm_scale_set.virtual_machine_profile[ "scheduled_events_profile" @@ -88,19 +85,17 @@ def collect_cloud_service(self, params): terminate_notification_display = "On" else: terminate_notification_display = "Off" - vm_scale_set_dict.update( { "terminate_notification_display": terminate_notification_display } ) - # Convert disks' sku-dict to string display if ( - vm_scale_set_dict["virtual_machine_profile"].get( - "storage_profile" - ) - is not None + vm_scale_set_dict["virtual_machine_profile"].get( + "storage_profile" + ) + is not None ): if vm_scale_set_dict["virtual_machine_profile"][ "storage_profile" @@ -109,18 +104,17 @@ def collect_cloud_service(self, params): "virtual_machine_profile" ]["storage_profile"]["image_reference"] image_reference_str = ( - str(image_reference_dict["publisher"]) - + " / " - + str(image_reference_dict["offer"]) - + " / " - + str(image_reference_dict["sku"]) - + " / " - + str(image_reference_dict["version"]) + str(image_reference_dict["publisher"]) + + " / " + + str(image_reference_dict["offer"]) + + " / " + + str(image_reference_dict["sku"]) + + " / " + + str(image_reference_dict["version"]) ) vm_scale_set_dict["virtual_machine_profile"][ "storage_profile" ].update({"image_reference_display": image_reference_str}) - # switch storage_account_type to storage_account_type for user-friendly words. # (ex.Premium LRS -> Premium SSD, Standard HDD..) if vm_scale_set_dict["virtual_machine_profile"][ @@ -140,8 +134,8 @@ def collect_cloud_service(self, params): ) # Get VM Profile's operating_system type (Linux or Windows) if ( - vm_scale_set_dict["virtual_machine_profile"].get("os_profile") - is not None + vm_scale_set_dict["virtual_machine_profile"].get("os_profile") + is not None ): vm_scale_set_dict["virtual_machine_profile"][ "os_profile" @@ -154,22 +148,20 @@ def collect_cloud_service(self, params): ) } ) - # Get VM Profile's primary Vnet\ if ( - vm_scale_set_dict["virtual_machine_profile"].get( - "network_profile" - ) - is not None + vm_scale_set_dict["virtual_machine_profile"].get( + "network_profile" + ) + is not None ): vmss_vm_network_profile_dict = vm_scale_set_dict[ "virtual_machine_profile" ]["network_profile"] - if primary_vnet := self.get_primary_vnet( - vmss_vm_network_profile_dict[ - "network_interface_configurations" - ] + vmss_vm_network_profile_dict[ + "network_interface_configurations" + ] ): vmss_vm_network_profile_dict.update( {"primary_vnet": primary_vnet} @@ -181,14 +173,14 @@ def collect_cloud_service(self, params): resource_group = vm_scale_set_dict["resource_group"] name = vm_scale_set_dict["name"] - for vm_instance in vm_scale_set_conn.list_vm_scale_set_vms( + for vm_instance in vm_scale_sets_conn.list_vm_scale_set_vms( resource_group, name ): instance_count += 1 vm_scale_set_dict.update({"instance_count": instance_count}) vm_instance_dict = self.get_vm_instance_dict( - vm_instance, vm_scale_set_conn, resource_group, name + vm_instance, vm_scale_sets_conn, resource_group, name ) vm_instances_list.append(vm_instance_dict) @@ -198,7 +190,7 @@ def collect_cloud_service(self, params): vm_scale_set_dict.update( { "autoscale_settings": self.list_auto_scale_settings_obj( - vm_scale_set_conn, resource_group, vm_scale_set_id + vm_scale_sets_conn, resource_group, vm_scale_set_id ) } ) @@ -218,7 +210,7 @@ def collect_cloud_service(self, params): auto_scale_setting_resource_col_dict.update( { "value": self.list_auto_scale_settings( - vm_scale_set_conn, resource_group, vm_scale_set_id + vm_scale_sets_conn, resource_group, vm_scale_set_id ) } ) @@ -229,37 +221,36 @@ def collect_cloud_service(self, params): } ) - vm_scale_set_data = VirtualMachineScaleSet( - vm_scale_set_dict, strict=False - ) - vm_scale_set_resource = VmScaleSetResource( - { - "data": vm_scale_set_data, - "region_code": vm_scale_set_data.location, - "reference": ReferenceModel(vm_scale_set_data.reference()), - "tags": vm_scale_set_dict.get("tags", {}), - "name": vm_scale_set_data.name, - "account": vm_scale_set_data.subscription_id, - "instance_type": vm_scale_set_data.sku.name, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(vm_scale_set_data["location"]) - # _LOGGER.debug(f'[VM_SCALE_SET_INFO] {vm_scale_set_resource.to_primitive()}') - vm_scale_set_responses.append( - VmScaleSetResponse({"resource": vm_scale_set_resource}) + self.set_region_code(vm_scale_set_dict["location"]) + + cloud_services.append( + make_cloud_service( + name=vm_scale_set_dict["name"], + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=vm_scale_set_dict, + account=vm_scale_set_dict["subscription_id"], + instance_type=vm_scale_set_dict["sku"]["name"], + region_code=vm_scale_set_dict["location"], + reference=self.make_reference(vm_scale_set_dict.get("id")), + tags=vm_scale_set_dict.get("tags", {}), + data_format="dict" + ) ) except Exception as e: - _LOGGER.error(f"[list_instances] {vm_scale_set_id} {e}", exc_info=True) - error_resource_response = self.generate_resource_error_response( - e, "Compute", "VMScaleSet", vm_scale_set_id + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) ) - error_responses.append(error_resource_response) - _LOGGER.debug(f"** VmScaleSet Finished {time.time() - start_time} Seconds **") - return vm_scale_set_responses, error_responses + return cloud_services, error_responses def get_autoscale_rules(self, rules_dict): rule_list = list() @@ -270,7 +261,7 @@ def get_autoscale_rules(self, rules_dict): # Get instances of a virtual machine from a VM scale set def get_vm_instance_dict( - self, vm_instance, vm_instance_conn, resource_group, vm_scale_set_name + self, vm_instance, vm_instance_conn, resource_group, vm_scale_set_name ): vm_instance_dict = self.convert_nested_dictionary(vm_instance) @@ -290,8 +281,8 @@ def get_vm_instance_dict( # ) if vm_instance_dict.get("vm_instance_status_profile") is not None: if ( - vm_instance_dict["vm_instance_status_profile"].get("vm_agent") - is not None + vm_instance_dict["vm_instance_status_profile"].get("vm_agent") + is not None ): vm_instance_dict.update( { @@ -304,9 +295,9 @@ def get_vm_instance_dict( # Get Primary Vnet display if getattr(vm_instance, "network_profile_configuration") is not None: if primary_vnet := self.get_primary_vnet( - vm_instance_dict["network_profile_configuration"][ - "network_interface_configurations" - ] + vm_instance_dict["network_profile_configuration"][ + "network_interface_configurations" + ] ): vm_instance_dict.update({"primary_vnet": primary_vnet}) @@ -314,7 +305,7 @@ def get_vm_instance_dict( # Get Instance view of a virtual machine from a VM scale set Instance def get_vm_instance_view_dict( - self, vm_instance_conn, resource_group, vm_scale_set_name, instance_id + self, vm_instance_conn, resource_group, vm_scale_set_name, instance_id ): vm_instance_status_profile = vm_instance_conn.get_vm_scale_set_instance_view( resource_group, vm_scale_set_name, instance_id @@ -327,7 +318,7 @@ def get_vm_instance_view_dict( status_str = None for status in vm_instance_status_profile_dict.get("vm_agent").get( - "statuses" + "statuses" ): status_str = status["display_status"] @@ -339,10 +330,10 @@ def get_vm_instance_view_dict( return vm_instance_status_profile_dict def list_auto_scale_settings( - self, vm_scale_set_conn, resource_group_name, vm_scale_set_id + self, vm_scale_sets_conn, resource_group_name, vm_scale_set_id ): auto_scale_settings_list = list() - auto_scale_settings_obj = vm_scale_set_conn.list_auto_scale_settings( + auto_scale_settings_obj = vm_scale_sets_conn.list_auto_scale_settings( resource_group=resource_group_name ) # List all of the Auto scaling Rules in this resource group @@ -357,8 +348,8 @@ def list_auto_scale_settings( } ) if ( - auto_scale_setting_dict["target_resource_uri"].lower() - == vm_scale_set_id.lower() + auto_scale_setting_dict["target_resource_uri"].lower() + == vm_scale_set_id.lower() ): # Compare resources' id auto_scale_settings_list.append(auto_scale_setting_dict) @@ -452,18 +443,18 @@ def get_primary_vnet(network_interface_configurations): @staticmethod def list_auto_scale_settings_obj( - vm_scale_set_conn, resource_group_name, vm_scale_set_id + vm_scale_sets_conn, resource_group_name, vm_scale_set_id ): auto_scale_settings_obj_list = list() # all List of the Auto scaling Rules in this resource group - auto_scale_settings_obj = vm_scale_set_conn.list_auto_scale_settings( + auto_scale_settings_obj = vm_scale_sets_conn.list_auto_scale_settings( resource_group=resource_group_name ) for auto_scale_setting in auto_scale_settings_obj: if ( - auto_scale_setting.target_resource_uri.lower() - == vm_scale_set_id.lower() + auto_scale_setting.target_resource_uri.lower() + == vm_scale_set_id.lower() ): auto_scale_settings_obj_list.append(auto_scale_setting) diff --git a/src/plugin/manager/web_pub_sub_service/__init__.py b/src/plugin/manager/web_pub_sub_service/__init__.py new file mode 100644 index 00000000..f852770b --- /dev/null +++ b/src/plugin/manager/web_pub_sub_service/__init__.py @@ -0,0 +1,2 @@ +from .service_manager import WebPubSubServiceManager +from .hub_manager import WebPubSubHubManager diff --git a/src/plugin/manager/web_pub_sub_service/hub_manager.py b/src/plugin/manager/web_pub_sub_service/hub_manager.py new file mode 100644 index 00000000..81694ed6 --- /dev/null +++ b/src/plugin/manager/web_pub_sub_service/hub_manager.py @@ -0,0 +1,37 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.web_pub_sub_service.web_pubsub_service_connector import WebPubSubServiceConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager + +_LOGGER = logging.getLogger(__name__) + + +class WebPubSubHubManager(AzureBaseManager): + cloud_service_group = "WebPubSubService" + cloud_service_type = "Hub" + service_code = "/Microsoft.SignalRService/WebPubSub/hubs" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Application Integration"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-web-pubsub-service.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + return cloud_services, error_responses diff --git a/src/plugin/manager/web_pub_sub_service/service_manager.py b/src/plugin/manager/web_pub_sub_service/service_manager.py new file mode 100644 index 00000000..96046699 --- /dev/null +++ b/src/plugin/manager/web_pub_sub_service/service_manager.py @@ -0,0 +1,207 @@ +import logging + +from spaceone.inventory.plugin.collector.lib import * + +from plugin.conf.cloud_service_conf import ICON_URL +from plugin.connector.web_pub_sub_service.web_pubsub_service_connector import WebPubSubServiceConnector +from plugin.connector.subscriptions.subscriptions_connector import SubscriptionsConnector +from plugin.manager.base import AzureBaseManager +from plugin.manager.web_pub_sub_service.hub_manager import WebPubSubHubManager + +_LOGGER = logging.getLogger(__name__) + + +class WebPubSubServiceManager(AzureBaseManager): + cloud_service_group = "WebPubSubService" + cloud_service_type = "Service" + service_code = "/Microsoft.SignalRService/WebPubSub" + + def create_cloud_service_type(self): + return make_cloud_service_type( + name=self.cloud_service_type, + group=self.cloud_service_group, + provider=self.provider, + service_code=self.service_code, + metadata_path=self.get_metadata_path(), + is_primary=True, + is_major=True, + labels=["Application Integration"], + tags={ + "spaceone:icon": f"{ICON_URL}/azure-web-pubsub-service.svg" + } + ) + + def create_cloud_service(self, options, secret_data, schema): + cloud_services = [] + error_responses = [] + + web_pubsub_service_conn = WebPubSubServiceConnector(secret_data=secret_data) + subscription_conn = SubscriptionsConnector(secret_data=secret_data) + + subscription_obj = subscription_conn.get_subscription(secret_data["subscription_id"]) + subscription_info = self.convert_nested_dictionary(subscription_obj) + + web_pubsub_services = web_pubsub_service_conn.list_by_subscription() + + for web_pubsub_service in web_pubsub_services: + + try: + web_pubsub_service_dict = self.convert_nested_dictionary( + web_pubsub_service + ) + web_pubsub_service_id = web_pubsub_service_dict["id"] + resource_group_name = self.get_resource_group_from_id( + web_pubsub_service_id + ) + resource_name = web_pubsub_service_dict["name"] + + # Update data info in Container Instance's Raw Data + + # Make private endpoint name + if private_endpoints := web_pubsub_service_dict.get( + "private_endpoint_connections", [] + ): + for private_endpoint in private_endpoints: + private_endpoint["private_endpoint"][ + "private_endpoint_name_display" + ] = self.get_resource_name_from_id( + private_endpoint["private_endpoint"]["id"] + ) + + # Collect Web PubSub Hub resource + web_pubsub_hubs = web_pubsub_service_conn.list_hubs( + resource_group_name=resource_group_name, resource_name=resource_name + ) + web_pubsub_hubs_dict = [ + self.convert_nested_dictionary(hub) for hub in web_pubsub_hubs + ] + + _hub_responses, _hub_errors = self._collect_web_pubsub_hub( + web_pubsub_hubs_dict, + subscription_info, + web_pubsub_service_dict["location"], + secret_data["tenant_id"] + ) + + cloud_services.extend(_hub_responses) + error_responses.extend(_hub_errors) + + # Add Web PubSub Key info in data + # web_pubsub_key = web_pubsub_service_conn.list_keys( + # resource_group_name=resource_group_name, resource_name=resource_name + # ) + # web_pubsub_key = {} + # if web_pubsub_key: + # web_pubsub_service_dict["web_pubsub_key"] = ( + # self.convert_nested_dictionary(web_pubsub_key) + # ) + + web_pubsub_service_dict.update( + { + "resource_group": resource_group_name, + "subscription_id": subscription_info["subscription_id"], + "subscription_name": subscription_info["display_name"], + "azure_monitor": {"resource_id": web_pubsub_service_id}, + "web_pubsub_hubs": web_pubsub_hubs_dict, + "web_pubsub_hub_count_display": len(web_pubsub_hubs_dict), + } + ) + + cloud_services.append( + make_cloud_service( + name=resource_name, + cloud_service_type=self.cloud_service_type, + cloud_service_group=self.cloud_service_group, + provider=self.provider, + data=web_pubsub_service_dict, + account=web_pubsub_service_dict["subscription_id"], + region_code=web_pubsub_service_dict["location"], + reference=self.make_reference(web_pubsub_service_dict.get("id")), + tags=web_pubsub_service_dict.get("tags", {}), + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + def _collect_web_pubsub_hub( + self, web_pubsub_hubs_dict, subscription_info, location, tenant_id + ): + cloud_services = [] + error_responses = [] + + web_pubsub_hub_manager = WebPubSubHubManager() + + for web_pubsub_hub_dict in web_pubsub_hubs_dict: + + try: + web_pubsub_hub_id = web_pubsub_hub_dict["id"] + resource_group_name = self.get_resource_group_from_id(web_pubsub_hub_id) + + web_pubsub_hub_dict.update( + { + "tenant_id": tenant_id, + "location": location, + "resource_group": resource_group_name, + "subscription_id": subscription_info["subscription_id"], + "subscription_name": subscription_info["display_name"], + "azure_monitor": {"resource_id": web_pubsub_hub_id}, + "web_pubsub_svc_name": self.get_web_pubsub_name_from_id( + web_pubsub_hub_id + ), + "web_pubsub_hub_evnet_handler_count_display": len( + web_pubsub_hub_dict.get("properties", {}).get( + "event_handlers", [] + ) + ), + } + ) + + cloud_services.append( + make_cloud_service( + name=web_pubsub_hub_dict["name"], + cloud_service_type=web_pubsub_hub_manager.cloud_service_type, + cloud_service_group=web_pubsub_hub_manager.cloud_service_group, + provider=self.provider, + data=web_pubsub_hub_dict, + account=web_pubsub_hub_dict["subscription_id"], + region_code=web_pubsub_hub_dict["location"], + reference=self.make_reference(web_pubsub_hub_dict.get("id")), + tags=web_pubsub_hub_dict.get("tags", {}), + data_format="dict" + ) + ) + + except Exception as e: + _LOGGER.error(f"[create_cloud_service] Error {self.service} {e}", exc_info=True) + error_responses.append( + make_error_response( + error=e, + provider=self.provider, + cloud_service_group=self.cloud_service_group, + cloud_service_type=self.cloud_service_type, + ) + ) + + return cloud_services, error_responses + + @staticmethod + def get_resource_name_from_id(dict_id): + resource_name = dict_id.split("/")[-1] + return resource_name + + @staticmethod + def get_web_pubsub_name_from_id(dict_id): + svc_name = dict_id.split("/")[-3] + return svc_name diff --git a/src/plugin/metadata/application_gateways/instance.yaml b/src/plugin/metadata/application_gateways/instance.yaml new file mode 100644 index 00000000..38a4f281 --- /dev/null +++ b/src/plugin/metadata/application_gateways/instance.yaml @@ -0,0 +1,351 @@ +search: + fields: + - Subscription ID: data.subscription_id + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Public IP Address: data.public_ip_address.ip_address + - Private IP Address: data.private_ip_address + - Capacity: data.sku.tier + - Minimum Instance Count: data.autoscale_configuration.min_capacity + data_type: integer + - Maximum Instance Count: data.autoscale_configuration.max_capacity + data_type: integer + - Enable HTTP2: data.enable_http2 + data_type: integer + - Firewall Mode: data.web_application_firewall_configuration.firewall_mode + - Firewall Rule Set Type: data.web_application_firewall_configuration.rule_set_type + - Firewall Rule Set Version: data.web_application_firewall_configuration.rule_set_version + - Backend Address Pool Name: data.backend_address_pools.name + - Backend Address Rule Associated: data.backend_address_pools.associated_rules + - HTTP Backend Name: data.backend_http_settings_collection.name + - HTTP Backend Port: data.backend_http_settings_collection.port + - HTTP Backend Protocol: data.backend_http_settings_collection.protocol + - SSL Profile Name: data.ssl_profiles.name + - SSL Client Certificates: data.ssl_profiles.trusted_client_certificates.id + - SSL Policy Type: data.ssl_profiles.ssl_policy.policy_type + - Frontend IP Type: data.frontend_ip_configurations.ip_type + - Frontend IP Configuration Name: data.frontend_ip_configurations.name + - Frontend IP Address: data.frontend_ip_configurations.ip_address + - Frontend Associated Listeners: data.frontend_ip_configurations.associated_listeners + - HTTP Listener Name: data.http_listeners.name + - HTTP Listener Protocol: data.http_listeners.protocol + - HTTP Listener Port: data.http_listeners.port + - HTTP Listener Associated Rule: data.http_listeners.associated_rules + - HTTP Listener Host name: data.http_listeners.host_name + - Request Routing Rule Name: data.request_routing_rules.name + - Request Routing Rule Type: data.request_routing_rules.rule_type + - Request Routing Rule Listener: data.request_routing_rules.http_listener_name + - Health Probes Name: data.probes.name + - Health Probes Protocol: data.probes.protocol + - Health Probes Host: data.probes.host + - Health Probes Path: data.probes.path + - Health Probes Timeout(Seconds): data.probes.timeout + data_type: integer + + + +table: + sort: + key: data.id + desc: false + fields: + - Public IP Address: data.public_ip_address.ip_address + - Private IP Address: data.private_ip_address + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: data.subscription_id + is_optional: true + - Capacity: data.sku.tier + is_optional: true + - Minimum Instance Count: data.autoscale_configuration.min_capacity + is_optional: true + - Maximum Instance Count: data.autoscale_configuration.max_capacity + is_optional: true + - Enable HTTP2: data.enable_http2 + is_optional: true + - Firewall Mode: data.web_application_firewall_configuration.firewall_mode + is_optional: true + - Firewall Max Request Body Size(KB): data.web_application_firewall_configuration.max_request_body_size_in_kb + is_optional: true + - Firewall File Upload Limit(MB): data.web_application_firewall_configuration.file_upload_limit_in_mb + is_optional: true + - Firewall Rule Set Type: data.web_application_firewall_configuration.rule_set_type + is_optional: true + - Firewall Rule Set Version: data.web_application_firewall_configuration.rule_set_version + is_optional: true + - Backend Address Pool Name: data.backend_address_pools.name + is_optional: true + - Backend Address Rule Associated: data.backend_address_pools.associated_rules + type: list + options: + delimiter: ', ' + is_optional: true + - HTTP Backend Name: data.backend_http_settings_collection.name + is_optional: true + - HTTP Backend Port: data.backend_http_settings_collection.port + is_optional: true + - HTTP Backend Protocol: data.backend_http_settings_collection.protocol + is_optional: true + - SSL Profile Name: data.ssl_profiles.name + is_optional: true + - SSL Client Certificates: data.ssl_profiles.trusted_client_certificates.id + type: list + options: + delimiter: ', ' + is_optional: true + - SSL Policy Type: data.ssl_profiles.ssl_policy.policy_type + is_optional: true + - Frontend IP Type: data.frontend_ip_configurations.ip_type + is_optional: true + - Frontend IP Configuration Name: data.frontend_ip_configurations.name + is_optional: true + - Frontend IP Address: data.frontend_ip_configurations.ip_address + is_optional: true + - Frontend Associated Listeners: data.frontend_ip_configurations.associated_listeners + is_optional: true + - HTTP Listener Name: data.http_listeners.name + is_optional: true + - HTTP Listener Protocol: data.http_listeners.protocol + is_optional: true + - HTTP Listener Port: data.http_listeners.port + is_optional: true + - HTTP Listener Associated Rule: data.http_listeners.associated_rules + is_optional: true + - HTTP Listener Host name: data.http_listeners.host_name + is_optional: true + - Request Routing Rule Name: data.request_routing_rules.name + is_optional: true + - Request Routing Rule Type: data.request_routing_rules.rule_type + is_optional: true + - Request Routing Rule Listener: data.request_routing_rules.http_listener_name + is_optional: true + - Health Probes Name: data.probes.name + is_optional: true + - Health Probes Protocol: data.probes.protocol + is_optional: true + - Health Probes Host: data.probes.host + is_optional: true + - Health Probes Path: data.probes.path + is_optional: true + - Health Probes Timeout(Seconds): data.probes.timeout + is_optional: true + + + +tabs.0: + name: Application Gateway + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: data.subscription_id + - Virtual Network: data.virtual_network + - Subnet: data.subnet + - Frontend public IP Address: data.public_ip_address.ip_address + - Frontend private IP Address: data.private_ip_address + - Tier: data.sku.tier + + + +tabs.1: + name: Configuration + type: item + fields: + - Capacity: data.sku.tier + - Minimum Instance Count: data.autoscale_configuration.min_capacity + - Maximum Instance Count: data.autoscale_configuration.max_capacity + - Enable HTTP2: data.enable_http2 + + + +tabs.2: + name: Subnets + items: + - name: Web Application Firewall + type: item + fields: + - Firewall Status Enabled: data.web_application_firewall_configuration.enabled + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Firewall Mode: data.web_application_firewall_configuration.firewall_mode + - Inspect Request Body: data.web_application_firewall_configuration.request_body_check + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Max Request Body Size(KB): data.web_application_firewall_configuration.max_request_body_size_in_kb + - File Upload Limit(MB): data.web_application_firewall_configuration.file_upload_limit_in_mb + - Rule Set Type: data.web_application_firewall_configuration.rule_set_type + - Rule Set Version: data.web_application_firewall_configuration.rule_set_version + - name: Exclusions + type: simple-table + root_path: data.web_application_firewall_configuration.exclusions + fields: + - Field: match_variable + - Operator: selector_match_operator + - Selector: selector + + + +tabs.3: + name: Backend Pools + type: simple-table + root_path: data.backend_address_pools + fields: + - Name: name + - Rule Associated: associated_rules + type: list + options: + delimiter: ', ' + - Targets: backend_addresses_display + type: list + options: + delimiter: ', ' + +tabs.4: + name: Backend HTTP Settings + type : simple-table + root_path: data.backend_http_settings_collection + fields: + - Name: name + - Port: port + - Protocol: protocol + - Cookie Based Affinity: cookie_based_affinity + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Custom Probe: custom_probe + - Connection draining: connection_draining.enabled + - Request time-out: request_timeout + - Override backend path: path + - Override with new host name: pick_host_name_from_backend_address + - Host name: host_name + + + +tabs.5: + name: SSL Settings + type: simple-table + root_path: data.ssl_profiles + fields: + - Name: name + - Client Certificates: trusted_client_certificates.id + - SSL Policy Type: ssl_policy.policy_type + is_optional: true + + + +tabs.6: + name: Frontend IP Configurations + type: simple-table + root_path: data.frontend_ip_configurations + fields: + - Type: ip_type + - Name: name + - IP Address: ip_address + - Associated Listeners: associated_listener + type: list + options: + delimiter: ', ' + + + +tabs.7: + name: Listeners + items: + - name: Listeners + type: simple-table + root_path: data.http_listeners + fields: + - Name: name + - Protocol: protocol + - Port: port + - Associated Rule: associated_rules + - Host name: host_name + - name: Custom Error Configurations + type: simple-table + root_path: data.custom_error_configurations + fields: + - Listener Name: listener_name + - Status Code: status_code + - Custom Error Page URL: custom_error_page_url + + + +tabs.8: + name: Rules + type: simple-table + root_path: data.request_routing_rules + fields: + - Name: name + - Type: rule_type + - Listener: http_listener_name + - Priority: priority + + + +tabs.9: + name: Rewrites + type: simple-table + root_path: data.rewrite_rule_sets + fields: + - Rewrite Sets: name + - Rules Applied: rules_applied + - Rewrite Rule Configuration: rewrite_rules_display + type: list + options: + delimiter: ', ' + + + +tabs.10: + name: Health Probes + type: simple-table + root_path: data.probes + fields: + - Name: name + - Protocol: protocol + - Host: host + - Path: path + - Timeout(Seconds): timeout + + + +tabs.11: + name: Managed Identity + type: item + fields: + - Type: data.identity.type + - Principal ID: data.identity.principal_id + - Tenant ID: data.identity.tenant_id + - User Assigned Identities: data.identity.output_display + popup_key: data.identity.user_assigned_identities + popup_name: User Assigned Identities + popup_type: raw + type: more \ No newline at end of file diff --git a/src/plugin/metadata/container_instances/container.yaml b/src/plugin/metadata/container_instances/container.yaml new file mode 100644 index 00000000..7ab1840e --- /dev/null +++ b/src/plugin/metadata/container_instances/container.yaml @@ -0,0 +1,198 @@ +search: + fields: + - Status: data.instance_view.state + - Resource Group: data.resource_group + - OS type: data.os_type + - Subscription ID: account + - Subscription Name: data.subscription_name + - Provisioning State: data.provisioning_state + - Restart Policy: data.restart_policy + - IP Address: data.ip_address.ip + - FQDN: data.ip_address.fqdn + - Location: data.location + - SKU: data.sku + - Container count: data.container_count_display + data_type: integer + - vCPU: data.cpu_count_display + data_type: integer + - Memory size(GB): data.memory_size_display + data_type: float + - GPU count: data.gpu_count_display + data_type: integer + - Volume count: data.volume_count_display + data_type: integer + - DNS name label: data.ip_address.dns_name_label + - DNS name label scope reuse: data.ip_address.auto_generated_domain_name_label_scope + + + +table: + sort: + key: data.id + desc: false + fields: + - State: data.instance_view.state + type: enum + enums: + - Running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Pending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Failed: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Resource Group: data.resource_group + - Location: data.location + - OS type: data.os_type + - Container count: data.container_count_display + - vCPU count: data.container_count_display + - Memory size(GB): data.memory_size_display + - Volume count: data.volume_count_display + - GPU count: data.gpu_count_display + - Provisioning State: data.provisioning_state + is_optional: true + - Restart Policy: data.restart_policy + is_optional: true + - IP Address: data.ip_address.ip + is_optional: true + - IP Address Type: data.ip_address.type + is_optional: true + - FQDN: data.ip_address.fqdn + is_optional: true + - DNS name label: data.ip_address.dns_name_label + is_optional: true + - DNS name label scope reuse: data.ip_address.auto_generated_domain_name_label_scope + is_optional: true + + + +tabs.0: + name: Container Instances + type: item + fields: + - Name: name + - State: data.instance_view.state + type: enum + enums: + - Running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Pending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Failed: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Resource ID: data.id + - Resource Group: data.resource_group + - Subscription: data.subscription_name + - Subscription ID: account + - Region: region_code + - SKU: data.sku + - OS type: data.os_type + - Container count: data.container_count_display + - vCPU count: data.container_count_display + - Memory size(GB): data.memory_size_display + - GPU count: data.gpu_count_display + - Volume count: data.volume_count_display + - IP Address: data.ip_address.ip + - IP Address Type: data.ip_address.type + - FQDN: data.ip_address.fqdn + - DNS name label: data.ip_address.dns_name_label + - DNS name label scope reuse: data.ip_address.auto_generated_domain_name_label_scope + - Ports: data.ip_address.ports.port + type: list + options: + delimiter: '
' + + + +tabs.1: + name: Container + type: table + root_path: data.containers + fields: + - Name: name + - State: instance_view.current_state.state + type: enum + enums: + - Running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Waiting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Terminated: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Previous state: instance_view.previous_state.state + - Restart count: instance_view.restart_count + - Volume count: volume_mount_count_display + - CPU cores: resources.requests.cpu + - Memory(GB): resources.requests.memory_in_gb + - Image: image + - Start time: instance_view.current_state.start_time + source_type: iso8601 + type: datetime + - Finish time: instance_view.current_state.finish + source_type: iso8601 + type: datetime + - GPU SKU: resources.requests.gpu.sku + - GPU count: resources.requests.gpu.count + - Ports: ports.port + type: list + options: + delimiter: '
' + - Commands: command + type: list + options: + delimiter: '
' + + + +tabs.2: + name: Volume + type: table + root_path: data.volumes + fields: + - Name: name + - Volume type: volume_type + - Mount path: mount_path + - Git repository: git_repo.repository + - Container name: container_name + diff --git a/src/plugin/metadata/cosmos_db/instance.yaml b/src/plugin/metadata/cosmos_db/instance.yaml new file mode 100644 index 00000000..12195a8d --- /dev/null +++ b/src/plugin/metadata/cosmos_db/instance.yaml @@ -0,0 +1,254 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Backup Policy: data.backup_policy.type + - Read Locations: data.read_locations.location_name + - Write Locations: data.write_locations.location_name + - Document Endpoint: data.document_endpoint + - Capacity Mode: data.capability_display + - Enable Automatic Failover: data.enable_automatic_failover + - Enable Free Tier: data.enable_free_tier + - Enable Analytical Storage: data.enable_analytical_storage + - CORS: data.cors_display + - Default Consistency: data.consistency_policy.default_consistency_level + - Backup Interval (Minutes): data.backup_policy.periodic_mode_properties.backup_interval_in_minutes + data_type: integer + - Backup Retention (Hours): data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours + - Backup storage redundancy: data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy + - Enable Public Network Access: data.public_network_access + - Virtual Networks: data.virtual_network_display + - Private Endpoint Connection Name: data.private_endpoint_connections.name + - Private Endpoint State: data.private_endpoint_connections.private_link_service_connection_state.status + - Private Endpoint Name: data.private_endpoint_connections.name + - Private Endpoint: data.private_endpoint_connections.name + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Resource ID: data.id + - Subscription ID: data.subscription_id + - Backup Policy: data.backup_policy.type + is_optional: true + - Read Locations: data.read_locations.location_name + type: list + options: + delimiter: ', ' + is_optional: true + - Write Locations: data.write_locations.location_name + type: list + options: + delimiter: ', ' + is_optional: true + - Document Endpoint: data.document_endpoint + is_optional: true + - Capacity Mode: data.capability_display + is_optional: true + - Enable Automatic Failover: data.enable_automatic_failover + is_optional: true + - Enable Free Tier: data.enable_free_tier + is_optional: true + - Enable Analytical Storage: data.enable_analytical_storage + is_optional: true + - Backup Policy: data.backup_policy.type + is_optional: true + - CORS: data.cors_display + type: list + options: + delimiter: ', ' + is_optional: true + - Default Consistency: data.consistency_policy.default_consistency_level + is_optional: true + - Backup Interval (Minutes): data.backup_policy.periodic_mode_properties.backup_interval_in_minutes + is_optional: true + - Backup Retention (Hours): data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours + is_optional: true + - Backup storage redundancy: data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy + is_optional: true + - Enable Public Network Access: data.public_network_access + is_optional: true + - Virtual Networks: data.virtual_network_display + type: list + options: + delimiter: ', ' + is_optional: true + - Connection Name: data.private_endpoint_connections.name + is_optional: true + - Connection State: data.private_endpoint_connections.private_link_service_connection_state.status + is_optional: true + - Private Endpoint: data.private_endpoint_connections.private_endpoint.name + is_optional: true + - Description: data.private_endpoint_connections.private_link_service_connection_state.description + is_optional: true + - Private Endpoint Connection Name: data.cors.name + is_optional: true + - Private Endpoint State: data.cors.private_link_service_connection_state.status + is_optional: true + - Private Endpoint: data.cors.private_endpoint.name + is_optional: true + - COR Private Link Description: data.cors.private_link_service_connection_state.description + is_optional: true + + + +tabs.0: + name: Cosmos DB + type: item + fields: + - Name: data.name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: data.subscription_id + - Backup Policy: data.backup_policy.type + - Read Locations: data.read_locations.location_name + type: list + options: + delimiter: ', ' + - Write Locations: data.write_locations.location_name + type: list + options: + delimiter: ', ' + - URI: data.document_endpoint + - Public Network Access: data.public_network_access + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Capacity Mode: data.capability_display + + + +tabs.1: + name: Features + type: item + fields: + - Enable Automatic Failover: data.enable_automatic_failover + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Enable Free Tier: data.enable_free_tier + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Enable Analytical Storage: data.enable_analytical_storage + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Backup Policy: data.backup_policy.type + - CORS: data.cors_display + type: list + options: + delimiter: ', ' + + + +tabs.2: + name: Default Consistency + type: item + fields: + - Default Consistency: data.consistency_policy.default_consistency_level + + + +tabs.3: + name: Backup & Restore + type: item + fields: + - Backup Interval (Minutes): data.backup_policy.periodic_mode_properties.backup_interval_in_minutes + - Backup Retention (Hours): data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours + - Backup storage redundancy: data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy + + + +tabs.4: + name: Firewall and Virtual Networks + type: item + fields: + - Enable Public Network Access: data.public_network_access + - Virtual Networks: data.virtual_network_display + type: list + options: + delimiter: ', ' + + + +tabs.5: + name: Private Endpoint Connections + type: table + root_path: data.private_endpoint_connections + fields: + - Connection Name: name + - Connection State: private_link_service_connection_state.status + - Private Endpoint: private_endpoint.name + - Description: private_link_service_connection_state.description + + + +tabs.6: + name: Cors + type: table + root_path: data.cors + fields: + - Connection Name: private_endpoint_connections.name + - Connection State: private_endpoint_connections.private_link_service_connection_state.status + - Private Endpoint: private_endpoint_connections.private_endpoint.name + - Description: private_endpoint_connections.private_link_service_connection_state.description + + + +tabs.7: + name: Keys + type: item + fields: + - Primary Readonly Master Key: data.keys.primary_readonly_master_key + - Secondary Readonly Master Key: data.keys.secondary_readonly_master_key + - Primary Master Key: data.keys.primary_master_key + - Primary Master Key: data.keys.secondary_master_key + + + +tabs.8: + name: Database + type: simple-table + root_path: data.sql_databases + fields: + - Database: name + - ID: id \ No newline at end of file diff --git a/src/plugin/metadata/disks/disk.yaml b/src/plugin/metadata/disks/disk.yaml new file mode 100644 index 00000000..fbc3342c --- /dev/null +++ b/src/plugin/metadata/disks/disk.yaml @@ -0,0 +1,161 @@ +search: + fields: + - Tier: data.tier + - Subscription Name: data.subscription_name + - Subscription ID: data.subscription_id + - Resource Group: data.resource_group + - Location: data.location + - Zone: data.zones + - Last updated at: data.last_updated + - Storage Account Type: data.sku.name + - Disk Size (Bytes): data.disk_size_bytes + data_type: integer + - Disk Size (GB): data.disk_size_gb + data_type: integer + - Disk IOPS: data.disk_iops_read_write + data_type: integer + - OS Type: data.os_type + - Provisioning State: data.provisioning_state + - Time Created: data.time_created + data_type: datetime + + + +table: + sort: + key: data.id + desc: false + fields: + - Storage Account Type: data.sku.name + - Size: data.size + display_unit: GB + source_unit: BYTES + type: size + - Disk State: data.disk_state + type: enum + enums: + - ActiveSAS: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ActiveUpload: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Attached: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Reserved: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ReadyToUpload: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Unattached: + icon_image: ic_circle-filled + icon_color: blue.400 + type: state + - Owner: data.managed_by + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: data.subscription_id + is_optional: true + - Zone: data.zones + type: list + options: + delimiter: ", " + is_optional: true + - Encryption Type: data.encryption.type + is_optional: true + - Networking: data.network_access_policy_display + is_optional: true + - Max Shares: data.max_shares + is_optional: true + - Time Created: data.time_created + is_optional: true + + + +tabs.0: + name: Disks + type: item + fields: + - Name: name + - Storage Account Type: instance_type + - Size: data.size + display_unit: GB + source_unit: BYTES + type: size + - Disk State: data.disk_state + type: enum + enums: + - ActiveSAS: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ActiveUpload: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Attached: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Reserved: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ReadyToUpload: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Unattached: + icon_image: ic_circle-filled + icon_color: blue.400 + type: state + - Attached VM: data.managed_by + - Location: data.location + - Resource Group: data.resource_group + - Resource ID: data.id + - Zones: data.zones + - Subscription ID: data.subscription_id + - Subscription Name: data.subscription_name + - Encryption Type: data.encryption.type + - Networking: data.network_access_policy_display + - Os Type: data.os_type + - Max Shares: data.max_shares + - VM Generation: data.hyper_v_generation + - VM architecture: data.supported_capabilities.architecture + - DateTimeDyField.data_sourceTime Created: data.time_created + source_type: iso8601 + type: datetime + + + +tabs.1: + name: Configuration + items: + - name: Shared Disk + type: item + fields: + - Enable shared disk: data.enable_shared_disk_display + - Max shares: data.max_shares + - name: On-demand bursting + type: item + fields: + - Enable bursting: data.bursting_enabled + - Enable bursting time: data.bursting_enabled_time + source_type: iso8601 + type: datetime + + + +tabs.2: + name: Networking + type: item + fields: + - Network access: data.network_access_policy_display diff --git a/src/plugin/metadata/key_vaults/instance.yaml b/src/plugin/metadata/key_vaults/instance.yaml new file mode 100644 index 00000000..2cddf66e --- /dev/null +++ b/src/plugin/metadata/key_vaults/instance.yaml @@ -0,0 +1,203 @@ +search: + fields: + - Type: instance_type + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Public IP Address: data.public_ip_addresses.name + - Vault URI: data.properties.vault_uri + - SKU (Pricing Tier): data.sku.name + - Directory ID: data.properties.tenant_id + - Soft-delete: data.properties.enable_soft_delete + - Purge Protection: data.properties.enable_purge_protection + - Key Name: data.keys.name + - Key Type: data.keys.type + - Key Location: data.keys.location + - Key Status: data.keys.attributes.enabled + - Key Expiration Date: data.keys.attributes.expires + - Key Creation Date: data.keys.attributes.created + - Key URI: data.keys.key_uri + - Enable for Azure VM Deployment: data.properties.enabled_for_deployment + - Enable for Disk Encryption: data.properties.enabled_for_disk_encryption + - Enable for Template Deployment: data.properties.enabled_for_template_deployment + - Enable RBAC Authorization: data.properties.enable_rbac_authorization + - Private Endpoint Connection Name: data.properties.private_endpoint_connections.name + - Private Endpoint Connection State: data.properties.private_endpoint_connections.private_link_service_connection_state.status + - Private Endpoint ID: data.properties.private_endpoint_connections.private_endpoint.id + + + +table: + sort: + key: data.id + desc: false + fields: + - Type: instance_type + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + - Public IP Address: data.public_ip_addresses.name + is_optional: true + - Vault URI: data.properties.vault_uri + is_optional: true + - SKU (Pricing Tier): data.sku.name + is_optional: true + - Directory ID: data.properties.tenant_id + is_optional: true + - Soft-delete: data.properties.enable_soft_delete + is_optional: true + - Purge Protection: data.properties.enable_purge_protection + is_optional: true + - Key Name: data.keys.name + is_optional: true + - Key Type: data.keys.type + is_optional: true + - Key Location: data.keys.location + is_optional: true + - Key Status: data.keys.attributes.enabled + is_optional: true + - Key Expiration Date: data.keys.attributes.expires + source_type: iso8601 + type: datetime + is_optional: true + - Key Creation Date: data.keys.attributes.created + source_type: iso8601 + type: datetime + is_optional: true + - Key URI: data.keys.key_uri + is_optional: true + - Enable for Azure VM Deployment: data.properties.enabled_for_deployment + is_optional: true + - Enable for Disk Encryption: data.properties.enabled_for_disk_encryption + is_optional: true + - Enable for Template Deployment: data.properties.enabled_for_template_deployment + is_optional: true + - Enable RBAC Authorization: data.properties.enable_rbac_authorization + is_optional: true + - Private Connection Name: data.properties.private_endpoint_connections.name + is_optional: true + - Private Connection State: data.properties.private_endpoint_connections.private_link_service_connection_state.status + is_optional: true + - Private Endpoint ID: data.properties.private_endpoint_connections.private_endpoint.id + is_optional: true + + + +tabs.0: + name: Key Vault + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Vault URI: data.properties.vault_uri + - Sku (Pricing Tier): instance_type + - Directory ID: data.properties.tenant_id + - Soft-delete: data.properties.enable_soft_delete + - Purge Protection: data.properties.enable_purge_protection_str + - Total Credentials Count: data.total_credentials_count + - Keys Count: data.key_count + - Secrets Count: data.secret_count + - Certificates Count: data.certificate_count + + + +tabs.1: + name: Permissions description + type: item + fields: + - Keys: data.keys_permissions_description_display + - Secrets: data.secrets_permissions_description_display + - Certificates: data.certificates_permissions_description_display + + + +tabs.2: + name: Keys + type: query-search-table + root_path: data.keys + fields: + - Name: name + - Type: instance_type + - Location: location + - Status: attributes.enabled + - Expiration Date: attributes.expires + source_type: iso8601 + type: datetime + - Creation Date: attributes.created + source_type: iso8601 + type: datetime + - Key URI: key_uri + + + +tabs.3: + name: Secrets + type: query-search-table + root_path: data.secrets + fields: + - ID: _id + - Type: _content_type + - Status: _attributes.enabled + - Updated Date: _attributes.updated + source_type: iso8601 + type: datetime + - Creation Date: _attributes.created + source_type: iso8601 + type: datetime + - Recoverable Days: _attributes.recoverable_days + + + +tabs.4: + name: Certificates + type: query-search-table + root_path: data.certificates + fields: + - ID: _id + - Status: _attributes.enabled + - Updated Date: _attributes.updated + source_type: iso8601 + type: datetime + - Creation Date: _attributes.created + source_type: iso8601 + type: datetime + - Recoverable Days: _attributes.recoverable_days + + + +tabs.5: + name: Access Policies + type: item + fields: + - Enable for Azure VM Deployment: data.properties.enabled_for_deployment + - Enable for Disk Encryption: data.properties.enabled_for_disk_encryption + - Enable for Template Deployment: data.properties.enabled_for_template_deployment + - Enable RBAC Authorization: data.properties.enable_rbac_authorization + + + +tabs.6: + name: Private Endpoint Connections + type: query-search-table + root_path: data.properties.private_endpoint_connections + fields: + - Connection Name: name + - Connection State: private_link_service_connection_state.status + - Provisioning State: provisioning_state + type: enum + enums: + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - RegisteringDns: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Private Endpoint: private_endpoint.id \ No newline at end of file diff --git a/src/plugin/metadata/load_balancers/instance.yaml b/src/plugin/metadata/load_balancers/instance.yaml new file mode 100644 index 00000000..177be907 --- /dev/null +++ b/src/plugin/metadata/load_balancers/instance.yaml @@ -0,0 +1,282 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Load Balancer Type: instance_type + - SKU: instance_type + - Health Probe: data.probes_display + - Load Balancing Rule: data.load_balancing_rules_display + - NAT Rules: data.inbound_nat_rules_display + - Private IP Address: data.private_ip_address_display + - Frontend Name: data.frontend_ip_configurations.name + - Frontend IP Address: data.frontend_ip_configurations.private_ip_address + - Frontend IP Version: data.frontend_ip_configurations.private_ip_address_version + - Frontend IP Used By: data.frontend_ip_configurations_used_by_display + - Backend Pool Name: data.backend_address_pools.name + - Backend Pool ID: data.backend_address_pools.id + - Health Probe Name: data.probes.name + - Health Probes Protocol: data.probes.protocol + - Health Probes Port: data.probes.port + data_type: integer + - Health Probes Interval: data.probes.interval_in_seconds + data_type: integer + - Health Probes Unhealthy Threshold: data.probes.number_of_probes + - LB Rule Name: data.load_balancing_rules.name + - LB Rule Frontend IP Address: data.load_balancing_rules.frontend_ip_configuration_display + - LB Rule Protocol: data.load_balancing_rules.protocol + - LB Rule Frontend Port: data.load_balancing_rules.frontend_port + data_type: integer + - LB Rule Backend Port: data.load_balancing_rules.backend_port + data_type: integer + - LB Rule Backend Pool: data.load_balancing_rules.backend_address_pool_display + - LB Rule Session Persistence: data.load_balancing_rules.load_distribution_display + - LB Rule Idle Timeout (minutes): data.load_balancing_rules.idle_timeout_in_minutes + data_type: integer + - LB Rule Floating IP: data.load_balancing_rules.enable_floating_ip + - LB Rule TCP Reset: data.load_balancing_rules.enable_tcp_reset + - Inbound NAT Rules Name: data.inbound_nat_rules.name + - Inbound NAT Rule Protocol: data.inbound_nat_rules.protocol + - Inbound NAT Rule Idle timeout (minutes): data.inbound_nat_rules.idle_timeout_in_minutes + data_type: integer + - Inbound NAT Rule TCP Reset: data.load_balancing_rules.enable_tcp_reset + - Inbound NAT Rule Port: data.inbound_nat_rules.frontend_port + data_type: integer + - Inbound NAT Rule Target Virtual Machine: data.inbound_nat_rules.target_virtual_machine + - Inbound NAT Rule Network IP Configuration: data.inbound_nat_rules.frontend_ip_configuration_display + - Inbound NAT Rule Port mapping: data.inbound_nat_rules.port_mapping_display + - Inbound NAT Rule Floating IP: data.inbound_nat_rules.enable_floating_ip + - Inbound NAT Rule Target Port: data.inbound_nat_rules.backend_port + data_type: integer + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: data.subscription_id + is_optional: true + - SKU: instance_type + is_optional: true + - Health Probe: data.probes_display + type: list + options: + delimiter: '
' + is_optional: true + - Load Balancing Rule: data.load_balancing_rules_display + type: list + options: + delimiter: '
' + is_optional: true + - NAT Rules: data.inbound_nat_rules_display + type: list + options: + delimiter: '
' + is_optional: true + - Private IP Address: data.private_ip_address_display + type: list + options: + delimiter: '
' + is_optional: true + - Frontend Name: data.frontend_ip_configurations.name + is_optional: true + - Frontend IP Address: data.frontend_ip_configurations.private_ip_address + is_optional: true + - Frontend IP Version: data.frontend_ip_configurations.private_ip_address_version + is_optional: true + - Frontend IP Used By: data.frontend_ip_configurations_used_by_display + type: list + options: + delimiter: '
' + is_optional: true + - Backend Pool Name: data.backend_address_pools.name + is_optional: true + - Backend Pool ID: data.backend_address_pools.id + is_optional: true + - Health Probe Name: data.probes.name + is_optional: true + - Health Probes Protocol: data.probes.protocol + is_optional: true + - Health Probes Port: data.probes.port + is_optional: true + - Health Probes Interval: data.probes.interval_in_seconds + is_optional: true + - Health Probes Unhealthy Threshold: data.probes.number_of_probes + is_optional: true + - LB Rule Name: data.load_balancing_rules.name + is_optional: true + - LB Rule Frontend IP Address: data.load_balancing_rules.frontend_ip_configuration_display + is_optional: true + - LB Rule Protocol: data.load_balancing_rules.protocol + is_optional: true + - LB Rule Frontend Port: data.load_balancing_rules.frontend_port + is_optional: true + - LB Rule Backend Port: data.load_balancing_rules.backend_port + is_optional: true + - LB Rule Backend Pool: data.load_balancing_rules.backend_address_pool_display + type: list + options: + delimiter: ', ' + is_optional: true + - LB Rule Session Persistence: data.load_balancing_rules.load_distribution_display + is_optional: true + - LB Rule Idle Timeout (minutes): data.load_balancing_rules.idle_timeout_in_minutes + is_optional: true + - LB Rule Floating IP: data.load_balancing_rules.enable_floating_ip + is_optional: true + - LB Rule TCP Reset: data.load_balancing_rules.enable_tcp_reset + is_optional: true + - Inbound NAT Rules Name: data.inbound_nat_rules.name + is_optional: true + - Inbound NAT Rule Protocol: data.inbound_nat_rules.protocol + is_optional: true + - Inbound NAT Rule Idle timeout (minutes): data.inbound_nat_rules.idle_timeout_in_minutes + is_optional: true + - Inbound NAT Rule TCP Reset: data.inbound_nat_rules.enable_tcp_reset + is_optional: true + - Inbound NAT Rule Port: data.inbound_nat_rules.frontend_port + is_optional: true + - Inbound NAT Rule Target Virtual Machine: data.inbound_nat_rules.target_virtual_machine + type: list + options: + delimiter: ', ' + is_optional: true + - Inbound NAT Rule Network IP Configuration: data.inbound_nat_rules.frontend_ip_configuration_display + is_optional: true + - Inbound NAT Rule Port mapping: data.inbound_nat_rules.port_mapping_display + is_optional: true + - Inbound NAT Rule Floating IP: data.inbound_nat_rules.enable_floating_ip + is_optional: true + - Inbound NAT Rule Target Port: data.inbound_nat_rules.backend_port + is_optional: true + + + +tabs.0: + name: LoadBalancers + type: item + fields: + - Name: name + - Resource Group: data.resource_group + - Resource ID: data.id + - Location: data.location + - Subscription: account + - SKU: type + - Backend pools: data.backend_address_pools_count_display + - Health Probe: data.probes_display + type: list + options: + delimiter: '
' + - Load Balancing Rule: data.load_balancing_rules_display + type: list + options: + delimiter: '
' + - NAT Rules: data.inbound_nat_rules_display + type: list + options: + delimiter: '
' + - Private IP Address: data.private_ip_address_display + type: list + options: + delimiter: '
' + + + +tabs.1: + name: Frontend IP Configurations + items: + - name: Frontend IP Configurations + type: simple-table + root_path: data.frontend_ip_configurations + fields: + - Name: name + - IP Address: private_ip_address + - IP Version: private_ip_address_version + - name: Used By + type: item + fields: + - Used By: data.frontend_ip_configurations_used_by_display + type: list + options: + delimiter: '
' + + + +tabs.2: + name: Backend Pools + items: + - name: Backend Pools + type: simple-table + root_path: data.backend_address_pools + fields: + - Name: name + - ID: id + - name: Backend Pools VM information + type: simple-table + root_path: data.network_interfaces + fields: + - Backend Pool: load_balancer_backend_address_pools_name_display + - VM Name: virtual_machine_name_display + - Network Interface: name + - Private IP Address: private_ip_display + type: list + options: + delimiter: '
' + + + +tabs.3: + name: Health Probes + type: table + root_path: data.probes + fields: + - Name: name + - Protocol: protocol + - Port: port + - Interval: interval_in_seconds + - Unhealthy Threshold: number_of_probes + + + +tabs.4: + name: Load Balancing Rules + type: table + root_path: data.load_balancing_rules + fields: + - Name: name + - Frontend IP Address: frontend_ip_configuration_display + - Protocol: protocol + - Frontend Port: frontend_port + - Backend Port: backend_port + - Backend Pool: backend_address_pool_display + - Session Persistence: load_distribution_display + - Idle Timeout (minutes): idle_timeout_in_minutes + - Floating IP: enable_floating_ip + - TCP Reset: enable_tcp_reset + + + +tabs.5: + name: Inbound NAT Rules + type: table + root_path: data.inbound_nat_rules + fields: + - Name: name + - Protocol: protocol + - Idle timeout (minutes): idle_timeout_in_minutes + - TCP Reset: enable_tcp_reset + - Port: frontend_port + - Target Virtual Machine: target_virtual_machine + type: list + options: + delimiter: ', ' + - Network IP Configuration: frontend_ip_configuration_display + - Port mapping: port_mapping_display + - Floating IP: enable_floating_ip + - Target Port: backend_port \ No newline at end of file diff --git a/src/plugin/metadata/my_sql_servers/flexible_server.yaml b/src/plugin/metadata/my_sql_servers/flexible_server.yaml new file mode 100644 index 00000000..e8e65d5c --- /dev/null +++ b/src/plugin/metadata/my_sql_servers/flexible_server.yaml @@ -0,0 +1,249 @@ +search: + fields: + - Type: instance_type + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Server Admin Login Name: data.administrator_login + - MySQL Version: data.version + - Zone: data.availability_zone + - High Availability Mode: data.high_availability.mode + - High Availability State: data.high_availability.state + - Performance Configuration (Tier): instance_type + - Performance Configuration (Name): data.sku.name + - Firewall Rule Name: data.firewall_rules.name + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + - Firewall Rule End IP: data.firewall_rules.end_ip_address + - Allow Access To Azure Services: data.allow_azure_services_access + - Storage: data.storage.storage_size_gb + data_type: integer + - Backup Retention Period (Days): data.backup.backup_retention_days + + + +table: + sort: + key: data.id + desc: false + fields: + - Type: instance_type + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Starting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - High Availability Mode: data.high_availability.mode + - High Availability State: data.high_availability.state + is_optional: true + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Server Admin Login Name: data.administrator_login + is_optional: true + - MySQL Version: data.version + is_optional: true + - Zone: data.availability_zone + is_optional: true + - Performance Configuration (Tier): data.sku.tier + is_optional: true + - Performance Configuration (Name): data.sku.name + is_optional: true + - Firewall Rule Name: data.firewall_rules.name + is_optional: true + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + is_optional: true + - Firewall Rule End IP: data.firewall_rules.end_ip_address + is_optional: true + - Allow Access To Azure Services: data.allow_azure_services_access + is_optional: true + - Storage: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + is_optional: true + - Backup Retention Period (Days): data.backup.backup_retention_days + is_optional: true + + + +tabs.0: + name: MySQL Server + type: item + fields: + - Name: name + - Server Name: data.fully_qualified_domain_name + - Type: instance_type + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Starting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Server Admin Login Name: data.administrator_login + - Performance Configuration (Tier): data.sku.tier + - Performance Configuration (Name): data.sku.name + - Storage: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + is_optional: true + - MySQL Version: data.version + - Zone: data.availability_zone + + + +tabs.1: + name: Compute & Storage + items: + - name: Compute + type: item + fields: + - Compute Tier: data.sku.tier + - Compute Size: data.sku.name + - name: Storage + type: item + fields: + - Storage Size: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + - Storage Auto-growth: data.storage.auto_grow + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - name: High Availability + type: item + fields: + - High Availability State: data.high_availability.state + type: enum + enums: + - Healthy: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - CreatingStandby: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - RemovingStandby: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - FailOver: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - NotEnabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - High Availability Mode: data.high_availability.mode + - name: Backup + type: item + fields: + - Backup Retention Period (Days): data.backup.backup_retention_days + - Geo Redundant Backup: data.backup.geo_redundant_backup + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + + + +tabs.2: + name: Networking + items: + - name: Public Network Access + type: items + fields: + - Public Network Access: data.network.public_network_access + type: enum + enums: + - Enabled: indigo.500 + type: badge + - Disabled: coral.600 + type: badge + - name: Firewall Rules + type: table + root_path: data.firewall_rules + fields: + - Firewall rule Name: name + - Start IP: start_ip_address + - End IP: end_ip_address \ No newline at end of file diff --git a/src/plugin/metadata/my_sql_servers/server.yaml b/src/plugin/metadata/my_sql_servers/server.yaml new file mode 100644 index 00000000..a27fc6e3 --- /dev/null +++ b/src/plugin/metadata/my_sql_servers/server.yaml @@ -0,0 +1,192 @@ +search: + fields: + - Type: instance_type + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Server Admin Login Name: data.administrator_login + - MySQL Version: data.version + - Performance Configuration (Tier): instance_type + - Performance Configuration (Name): data.sku.name + - SSL Enforce Status: data.ssl_enforcement + - Firewall Rule Name: data.firewall_rules.name + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + - Firewall Rule End IP: data.firewall_rules.end_ip_address + - Allow Access To Azure Services: data.allow_azure_services_access + - Enforce SSL Connection: data.ssl_enforcement + - Minimum TLS Version: data.minimal_tls_version + - Compute Generation: data.sku.family + - vCore: data.sku.capacity + data_type: integer + - Storage: data.storage_profile.storage_gb + data_type: integer + - Backup Retention Period: data.storage_profile.backup_retention_days + + + +table: + sort: + key: data.id + desc: false + fields: + - Type: instance_type + - Status: data.user_visible_state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Server Admin Login Name: data.administrator_login + is_optional: true + - MySQL Version: data.version + is_optional: true + - Performance Configuration (Tier): instance_type + is_optional: true + - Performance Configuration (Name): data.sku.name + is_optional: true + - SSL Enforce Status: data.ssl_enforcement + is_optional: true + - Firewall Rule Name: data.firewall_rules.name + is_optional: true + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + is_optional: true + - Firewall Rule End IP: data.firewall_rules.end_ip_address + is_optional: true + - Allow Access To Azure Services: data.allow_azure_services_access + is_optional: true + - Enforce SSL Connection: data.ssl_enforcement + is_optional: true + - Minimum TLS Version: data.minimal_tls_version + is_optional: true + - Compute Generation: data.sku.family + is_optional: true + - vCore: data.sku.capacity + is_optional: true + - Storage: data.storage_profile.storage_gb + is_optional: true + - Backup Retention Period: data.storage_profile.backup_retention_days + is_optional: true + + + +tabs.0: + name: MySQL Server + type: item + fields: + - Name: name + - Server Name: data.fully_qualified_domain_name + - Type: instance_type + - Status: data.user_visible_state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Server Admin Login Name: data.administrator_login + - MySQL Version: data.version + - Performance Configuration (Tier): data.sku.tier + - Performance Configuration (Name): data.sku.name + - SSL Enforce Status: data.ssl_enforcement + + + +tabs.1: + name: Connection Security + items: + - name: Firewall Rules + type: table + root_path: data.firewall_rules + fields: + - Firewall Rule Name: name + - Start IP: start_ip_address + - End IP: end_ip_address + - name: MySQL Server + type: item + fields: + - Allow Access To Azure Services: data.allow_azure_services_access + - Enforce SSL Connection: data.ssl_enforcement + - Minimum TLS Version: data.minimal_tls_version + + + +tabs.2: + name: MySQL Parameters + type: table + fields: + - Allow Access To Azure Services: data.allow_azure_services_access + - Enforce SSL Connection: data.ssl_enforcement + - Minimum TLS Version: data.minimal_tls_version + + + +tabs.3: + name: Pricing Tier + type: item + fields: + - Tier: data.sku.tier + - Compute Generation: data.sku.family + - vCore: data.sku.capacity + - Storage: data.storage_profile.storage_gb + - Storage Auto-Growth: data.storage_profile.storage_autogrow + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Geo Redundant Backup: data.storage_profile.geo_redundant_backup + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Backup Retention Period: data.storage_profile.backup_retention_days \ No newline at end of file diff --git a/src/plugin/metadata/nat_gateways/instance.yaml b/src/plugin/metadata/nat_gateways/instance.yaml new file mode 100644 index 00000000..ad2e2db0 --- /dev/null +++ b/src/plugin/metadata/nat_gateways/instance.yaml @@ -0,0 +1,115 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Public IP Name: data.public_ip_addresses.name + - Public IP Address: data.public_ip_addresses.ip_address + - Public DNS Name: data.public_ip_addresses.dns_settings.domain_name_label + - Public IP Prefix Name: data.public_ip_prefixes.name + - Public IP Prefix: data.public_ip_prefixes.ip_prefix + - Subnet Name: data.subnets.name + - Subnet Addresses: data.subnets.address_prefixes + - Virtual Network: data.subnets.virtual_network + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + - Subnets (count): data.subnets_count + - Public IP Addresses (count): data.public_ip_addresses_count + - Public IP Prefixes (count): data.public_ip_prefixes_count + - Public IP Name (optional): data.public_ip_addresses.name + is_optional: true + - Public IP Address (optional): data.public_ip_addresses.ip_address + is_optional: true + - Public DNS Name (optional): data.public_ip_addresses.dns_settings.domain_name_label + is_optional: true + - Public IP Prefix Name (optional): data.public_ip_prefixes.name + is_optional: true + - Public IP Prefix (optional): data.public_ip_prefixes.ip_prefix + is_optional: true + - Subnet Name (optional): data.subnets.name + is_optional: true + - Subnet Addresses (optional): data.subnets.address_prefixes + is_optional: true + - Virtual Network (optional): data.subnets.virtual_network + is_optional: true + + + +tabs.0: + name: NAT Gateway + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Subnets: data.subnets_count + - Public IP Addresses: data.public_ip_addresses_count + - Public IP Prefixes: data.public_ip_prefixes_count + - Idle Timeout (minutes): data.idle_timeout_in_minutes + + + +tabs.1: + name: Outbound IP + items: + - name: Public IP Addresses + type: simple-table + root_path: data.public_ip_addresses + fields: + - Name: name + - IP Address: ip_address + - DNS Name: dns_settings.domain_name_label + - name: Public IP Prefixes + type: simple-table + root_path: data.public_ip_prefixes + fields: + - Name: name + - IP Prefix: ip_prefix + + + +tabs.2: + name: Subnets + type: simple-table + root_path: data.subnets + fields: + - Subnet Name: name + - Subnet Address: address_prefix + - Subnet Addresses: address_prefixes + - Virtual Network: virtual_network + - Private Endpoint Network Policies: private_endpoint_network_policies + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Private Link Service Network Policies: private_link_service_network_policies + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state \ No newline at end of file diff --git a/src/plugin/metadata/network_security_groups/instance.yaml b/src/plugin/metadata/network_security_groups/instance.yaml new file mode 100644 index 00000000..6f37aab4 --- /dev/null +++ b/src/plugin/metadata/network_security_groups/instance.yaml @@ -0,0 +1,148 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Virtual Machines: data.virtual_machines_display + - Inbound Rule Priority: data.inbound_security_rules.priority + data_type: integer + - Inbound Rule Name: data.inbound_security_rules.name + - Inbound Rule Port: data.inbound_security_rules.destination_port_range + - Inbound Rule Protocol: data.inbound_security_rules.protocol + - Inbound Rule Source: data.inbound_security_rules.source_address_prefix + - Inbound Rule Destination: data.inbound_security_rules.destination_address_prefix + - Inbound Rule Action: data.inbound_security_rules.access + - Outbound Rule Priority: data.outbound_security_rules.priority + data_type: integer + - Outbound Rule Name: data.outbound_security_rules.name + - Outbound Rule Port: data.outbound_security_rules.destination_port_range + - Outbound Rule Protocol: data.outbound_security_rules.protocol + - Outbound Rule Source: data.outbound_security_rules.source_address_prefix + - Outbound Rule Destination: data.outbound_security_rules.destination_address_prefix + - Outbound Rule Action: data.outbound_security_rules.access + - Network Interface Name: data.network_interfaces.name + - Network Interface Public IP Address: data.network_interfaces.public_ip_address + - Network Interface Private IP Address: data.network_interfaces.private_ip_address + - Subnet Name: data.subnets.name + - Subnet Address Range: data.subnets.address_prefix + - Virtual Network: data.subnets.virtual_network + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription ID: account + - Subscription Name: data.subscription_name + - Virtual Machines: data.virtual_machines_display + - Inbound Rule Priority: data.inbound_security_rules.priority + is_optional: true + - Inbound Rule Name: data.inbound_security_rules.name + is_optional: true + - Inbound Rule Port: data.inbound_security_rules.destination_port_range + is_optional: true + - Inbound Rule Protocol: data.inbound_security_rules.protocol + is_optional: true + - Inbound Rule Source: data.inbound_security_rules.source_address_prefix + is_optional: true + - Inbound Rule Destination: data.inbound_security_rules.destination_address_prefix + is_optional: true + - Inbound Rule Action: data.inbound_security_rules.access + is_optional: true + - Outbound Rule Priority: data.outbound_security_rules.priority + is_optional: true + - Outbound Rule Name: data.outbound_security_rules.name + is_optional: true + - Outbound Rule Port: data.outbound_security_rules.destination_port_range + is_optional: true + - Outbound Rule Protocol: data.outbound_security_rules.protocol + is_optional: true + - Outbound Rule Source: data.outbound_security_rules.source_address_prefix + is_optional: true + - Outbound Rule Destination: data.outbound_security_rules.destination_address_prefix + is_optional: true + - Outbound Rule Action: data.outbound_security_rules.access + is_optional: true + - Network Interface Name: data.network_interfaces.name + is_optional: true + - Network Interface Public IP Address: data.network_interfaces.public_ip_address + is_optional: true + - Network Interface Private IP Address: data.network_interfaces.private_ip_address + is_optional: true + - Subnet Name: data.subnets.name + is_optional: true + - Subnet Address Range: data.subnets.address_prefix + is_optional: true + - Virtual Network: data.subnets.virtual_network + is_optional: true + + + +tabs.0: + name: Network Security Group + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + + + +tabs.1: + name: Inbound Security Rules + type: table + root_path: data.inbound_security_rules + fields: + - Priority: priority + - Name: name + - Port: destination_port_range + - Protocol: protocol + - Source: source_address_prefix + - Destination: destination_address_prefix + - Action: access + + + +tabs.2: + name: Outbound Security Rules + type: table + root_path: data.outbound_security_rules + fields: + - Priority: priority + - Name: name + - Port: destination_port_range + - Protocol: protocol + - Source: source_address_prefix + - Destination: destination_address_prefix + - Action: access + + + +tabs.3: + name: Network Interfaces + type: table + root_path: data.network_interfaces + fields: + - Name: name + - Public IP Address: public_ip_address + - Private IP Address: private_ip_address + - Virtual Machine: virtual_machine_display + + + +tabs.4: + name: Subnets + type: table + root_path: data.subnets + fields: + - Name: name + - Address Range: address_prefix + - Virtual Network: virtual_network \ No newline at end of file diff --git a/src/plugin/metadata/postgre_sql_servers/flexible_server.yaml b/src/plugin/metadata/postgre_sql_servers/flexible_server.yaml new file mode 100644 index 00000000..eb474f07 --- /dev/null +++ b/src/plugin/metadata/postgre_sql_servers/flexible_server.yaml @@ -0,0 +1,221 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Server Name: data.fully_qualified_domain_name + - Server Admin Login Name: data.administrator_login + - PostgreSQL Version: data.version_display + - Zone: data.availability_zone + - High Availability Mode: data.high_availability.mode + - High Availability State: data.high_availability.state + - Performance Configuration (Tier): instance_type + - Performance Configuration (Name): data.sku.name + - Public Network Access: data.network.public_network_access + - Firewall Rule Name: data.firewall_rules.name + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + - Firewall Rule End IP: data.firewall_rules.end_ip_address + - Storage Size: data.storage.storage_size_gb + data_type: integer + - Backup Retention Period (Days): data.backup.backup_retention_days + + + +table: + sort: + key: data.id + desc: false + fields: + - Type: instance_type + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Starting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource Group: data.resource_group + is_optional: true + - Location: data.location + is_optional: true + - Subscription Name: data.subscription_name + is_optional: true + - Subscription ID: account + is_optional: true + - Server Name: data.fully_qualified_domain_name + is_optional: true + - Server Admin Login Name: data.administrator_login + is_optional: true + - PostgreSQL Version: data.version_display + is_optional: true + - Zone: data.availability_zone + is_optional: true + - Performance Configuration (Tier): instance_type + is_optional: true + - Performance Configuration (Name): data.sku.name + is_optional: true + - Public Network Access: data.network.public_network_access + is_optional: true + - Firewall Rule Name: data.firewall_rules.name + is_optional: true + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + is_optional: true + - Firewall Rule End IP: data.firewall_rules.end_ip_address + is_optional: true + - Compute Generation: data.sku.name + is_optional: true + - Compute Tier: data.sku.tier + is_optional: true + - Storage Size: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + is_optional: true + - Backup Retention Period (Days): data.backup.backup_retention_days + is_optional: true + + + +tabs.0: + name: PostgreSQL Servers + type: item + fields: + - Name: name + - Server Name: data.fully_qualified_domain_name + - Type: instance_type + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Starting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Stopped: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Server Admin Login Name: data.administrator_login + - Performance Configuration (Tier): data.sku.tier + - Performance Configuration (Name): data.sku.name + - Storage Size: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + is_optional: true + - PostgreSQL Version: data.version_display + - Zone: data.availability_zone + + + +tabs.1: + name: Compute & Storage + items: + - name: Compute + type: item + fields: + - Compute Tier: data.sku.tier + - Compute Size: data.sku.name + - name: Storage + type: item + fields: + - Storage Size: data.storage.storage_size_gb + display_unit: GB + source_unit: GB + type: size + - name: High Availability + type: item + fields: + - High Availability State: data.high_availability.state + type: enum + enums: + - Healthy: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - CreatingStandby: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - RemovingStandby: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - FailOver: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - NotEnabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - High Availability Mode: data.high_availability.mode + - name: Backup + type: item + fields: + - Backup Retention Period (Days): data.backup.backup_retention_days + - Geo Redundant Backup: data.backup.geo_redundant_backup + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state diff --git a/src/plugin/metadata/postgre_sql_servers/server.yaml b/src/plugin/metadata/postgre_sql_servers/server.yaml new file mode 100644 index 00000000..46885faf --- /dev/null +++ b/src/plugin/metadata/postgre_sql_servers/server.yaml @@ -0,0 +1,289 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Server Name: data.fully_qualified_domain_name + - Admin Username: data.administrator_login + - PostgreSQL Version: data.version + - Performance Configuration Tier: instance_type + - Performance Configuration Name: data.sku.name + - Performance Configuration Capacity: data.sku.capacity + data_type: integer + - SSL Enforce Status: data.ssl_enforcement + - SSL Enforcement: data.ssl_enforcement + - Public Network Access: data.public_network_access + - TLS Setting: data.minimal_tls_version + - Firewall Rule Name: data.firewall_rules.name + - Firewall Rule Start IP: data.firewall_rules.start_ip_address + - Firewall Rule End IP: data.firewall_rules.end_ip_address + + + +table: + sort: + key: data.id + desc: false + fields: + - Type: instance_type + - Status: data.user_visible_state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Resource Group: data.resource_group + is_optional: true + - Location: data.location + is_optional: true + - Subscription Name: data.subscription_name + is_optional: true + - Subscription ID: account + is_optional: true + - Server Name: data.fully_qualified_domain_name + is_optional: true + - Admin Username: data.administrator_login + is_optional: true + - PostgreSQL Version: data.version + is_optional: true + - Performance Configuration Tier: instance_type + is_optional: true + - Performance Configuration Name: data.sku.name + is_optional: true + - Performance Configuration Capacity: data.sku.capacity + is_optional: true + - SSL Enforce Status: data.ssl_enforcement + is_optional: true + - Public Network Access: data.public_network_access + is_optional: true + - SSL Enforcement: data.ssl_enforcement + is_optional: true + - TLS Setting: data.minimal_tls_version + is_optional: true + - Firewall Rule Name: data.firewall_rules.name + is_optional: true + - Start IP: data.firewall_rules.start_ip_address + is_optional: true + - End IP: data.firewall_rules.end_ip_address + is_optional: true + - Virtual Network Rule Name: data.virtual_network_rules.name + is_optional: true + - Virtual Network: data.virtual_network_rules.virtual_network_name_display + is_optional: true + - Subnet: data.virtual_network_rules.subnet_name + is_optional: true + - Replicas Name: data.replicas.name + is_optional: true + - Replicas Location: data.replicas.location + is_optional: true + - Replicas Master Server Name: data.replicas.master_server_name + is_optional: true + - Active Directory Name: data.server_administrators.name + is_optional: true + - Login: data.server_administrators.login + is_optional: true + - SID: data.server_administrators.sid + is_optional: true + - Tenant ID: data.server_administrators.tenant_id + is_optional: true + - Compute Generation: data.sku.name + is_optional: true + - Compute Tier: instance_type + is_optional: true + - vCore: data.sku.capacity + is_optional: true + - Backup Retention Period (Days): data.storage_profile.backup_retention_days + is_optional: true + + + +tabs.0: + name: PostgreSQL Servers + type: item + fields: + - Name: name + - Resource Group: data.resource_group + - Resource ID: data.id + - Status: data.user_visible_state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Server Name: data.fully_qualified_domain_name + - Admin Username: data.administrator_login + - PostgreSQL Version: data.version + - Performance Configuration Tier: data.sku.tier + - Performance Configuration Name: data.sku.name + - Performance Configuration Capacity: data.sku.capacity + - SSL Enforce Status: data.ssl_enforcement + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + + + +tabs.1: + name: Connection Security + items: + - name: Connection Security + type: item + fields: + - Public Network Access: data.public_network_access + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - SSL Enforcement: data.ssl_enforcement + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - TLS Setting: data.minimal_tls_version + - name: Firewall Rules + type: simple-table + root_path: data.firewall_rules + fields: + - Firewall Rule Name: name + - Start IP: start_ip_address + - End IP: end_ip_address + - name: VNET Rules + type: simple-table + root_path: data.virtual_network_rules + fields: + - Rule Name: name + - Virtual Network: virtual_network_name_display + - Subnet: subnet_name + - Endpoint Status: state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - InProgress: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Deleting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Initializing: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Unknown: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + + +tabs.2: + name: Replicas + type: simple-table + root_path: data.replicas + fields: + - Name: name + - Location: location + - Status: user_visible_state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Dropping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + + + +tabs.3: + name: Active Directory Admin + type: simple-table + root_path: data.server_administrators + fields: + - Name: name + - Login: login + - SID: sid + - Tenant ID: tenant_id + + + +tabs.4: + name: Pricing Tier + type: item + fields: + - Compute Generation: data.sku.name + - vCore: data.sku.capacity + - Storage Auto Grow: data.storage_profile.storage_autogrow + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Backup Retention Period (Days): data.storage_profile.backup_retention_days \ No newline at end of file diff --git a/src/plugin/metadata/public_ip_addresses/ip_address.yaml b/src/plugin/metadata/public_ip_addresses/ip_address.yaml new file mode 100644 index 00000000..ee2ae845 --- /dev/null +++ b/src/plugin/metadata/public_ip_addresses/ip_address.yaml @@ -0,0 +1,72 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - SKU: instance_type + - Tier: data.sku.tier + - IP Address: data.ip_address + - DNS Name: data.dns_settings.fqdn + - IP Address Assignment: data.public_ip_allocation_method + - Idle Timeout(Minutes): data.idle_timeout_in_minutes + - DNS Name Label(Optional): data.dns_settings.domain_name_label + data_type: integer + - Associated To: data.associated_to + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Associated To: data.associated_to + - Subscription ID: account + is_optional: true + - SKU: instance_type + is_optional: true + - Tier: data.sku.tier + is_optional: true + - IP Address: data.ip_address + is_optional: true + - DNS Name: data.dns_settings.fqdn + is_optional: true + - IP Address Assignment: data.public_ip_allocation_method + is_optional: true + - Idle Timeout(Minutes): data.idle_timeout_in_minutes + is_optional: true + - DNS Name Label(Optional): data.dns_settings.domain_name_label + is_optional: true + + + +tabs.0: + name: Public IP Address + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - SKU: instance_type + - Tier: data.sku.tier + - IP Address: data.ip_address + - DNS Name: data.dns_settings.fqdn + - Associated To: data.associated_to + + + +tabs.1: + name: Configuration + type: item + fields: + - IP Address Assignment: data.public_ip_allocation_method + - Idle Timeout(Minutes): data.idle_timeout_in_minutes + - DNS Name Label(Optional): data.dns_settings.domain_name_label + diff --git a/src/plugin/metadata/snapshots/instance.yaml b/src/plugin/metadata/snapshots/instance.yaml new file mode 100644 index 00000000..4cc7f0e3 --- /dev/null +++ b/src/plugin/metadata/snapshots/instance.yaml @@ -0,0 +1,91 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Storage Account Type: instance_type + - Snapshot Type: data.incremental_display + - Disk Size (Bytes): data.disk_size_bytes + - Disk Size (GB): instance_size + data_type: float + - Encryption: data.encryption.type_display + - Network Access Policy: data.network_access_policy + - Provisioning State: data.provisioning_state + - Launched: data.time_created + data_type: datetime + + + +table: + sort: + key: data.id + desc: false + fields: + - Source disk: data.source_disk_name + - Snapshot type: data.incremental_display + - Source disk size: data.disk_size_bytes + display_unit: GB + source_unit: BYTES + type: size + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Launched: data.time_created + source_type: iso8601 + type: datetime + - Subscription ID: account + - Encryption Type: data.encryption.type_display + - Network Access Policy: data.network_access_policy_display + + + +tabs.0: + name: Snapshots + type: item + fields: + - Name: name + - Storage Type: instance_type + - Size: data.size + display_unit: GB + source_unit: BYTES + type: size + - Source Disk: data.source_disk_name + - Location: data.location + - Resource ID: data.id + - Resource Group: data.resource_group + - Snapshot state: data.disk_state + type: enum + enums: + - ActiveSAS: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ActiveUpload: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Attached: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Reserved: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - ReadyToUpload: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Unattached: + icon_image: ic_circle-filled + icon_color: blue.400 + type: state + - Snapshot Type: data.incremental_display + - Subscription ID: account + - Subscription Name: data.subscription_name + - Encryption Type: data.encryption.type_display + - Network Access Policy: data.network_access_policy_display + - Created Time: launched_at + source_type: iso8601 + type: datetime \ No newline at end of file diff --git a/src/plugin/metadata/sql_databases/database.yaml b/src/plugin/metadata/sql_databases/database.yaml new file mode 100644 index 00000000..f8c689cf --- /dev/null +++ b/src/plugin/metadata/sql_databases/database.yaml @@ -0,0 +1,404 @@ +search: + fields: + - Database ID: data.database_id + - Subscription ID: account + - Resource Group: data.resource_group + - Location: data.location + - Tier: instance_type + - Server Name: data.managed_by + - Status: data.status + - Replication Partner Server: data.replication_link.partner_server + - Pricing Tier: data.pricing_tier_display + - Elastic Pool: data.elastic_pool_id + - Earliest Restore Point: data.earliest_restore_date + - Collation: data.collation + - Server Admin Login: data.administrator_login + - Service Tier: data.service_tier_display + - Compute Tier: data.compute_tier + - Compute Hardware: data.sku.family + - Licence Type: data.license_type + - vCores: data.current_sku.capacity + data_type: integer + - Data max size: instance_size + data_type: integer + - Zone Redundant: data.zone_redundant + - Sync Groups: data.sync_group_display + - Sync Agents: data.sync_agent_display + - Diagnostic Setting Name: data.diagnostic_settings_resource.name + - Diagnostic Setting Storage Account: data.diagnostic_settings_resource.storage_account_id + - Event Hub: data.diagnostic_settings_resource.event_hub_name + - Log Analytics Workspace: data.diagnostic_settings_resource.workspace_id + - Creation Date: data.creation_date + type: datetime + + + +table: + sort: + key: data.id + desc: false + fields: + - Status: data.status + type: enum + enums: + - Online: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Copying: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - OnlineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Restoring: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Resuming: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Scaling: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Standby: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - AutoClosed: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Offline: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineSecondary: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Pausing: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Recovering: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - RecoveryPending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Suspect: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Paused: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Shutdown: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - EmergencyMode: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Replication Partner Server: data.replication_link.partner_server + - Server: data.server_name + - Pricing Tier: data.pricing_tier_display + - Location: data.location + - Subscription ID: account + - Resource Group: data.resource_group + - Elastic Pool: data.elastic_pool_id + is_optional: true + - Earliest Restore Point: data.earliest_restore_date + source_type: iso8601 + type: datetime + is_optional: true + - Collation: data.collation + is_optional: true + - Creation Date: data.creation_date + source_type: iso8601 + type: datetime + is_optional: true + - Server Admin Login: data.administrator_login + is_optional: true + - Service Tier: data.service_tier_display + is_optional: true + - Compute Tier: data.compute_tier + is_optional: true + - Compute Hardware: data.sku.family + is_optional: true + - Licence Type: data.license_type + is_optional: true + - vCores: data.current_sku.capacity + is_optional: true + - Data max size: instance_size + is_optional: true + - Zone Redundant: data.zone_redundant + is_optional: true + - Sync Groups: data.sync_group_display + type: list + options: + delimiter: ', ' + is_optional: true + - Sync Agents: data.sync_agent_display + type: list + options: + delimiter: ', ' + is_optional: true + - Diagnostic Setting Name: data.diagnostic_settings_resource.name + is_optional: true + - Diagnostic Setting Storage Account: data.diagnostic_settings_resource.storage_account_id + is_optional: true + - Event Hub: data.diagnostic_settings_resource.event_hub_name + is_optional: true + - Log Analytics Workspace: data.diagnostic_settings_resource.workspace_id + is_optional: true + + + +tabs.0: + name: SQL Databases + type: item + fields: + - Name: name + - Status: data.status + type: enum + enums: + - Online: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Copying: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - OnlineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Restoring: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Resuming: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Scaling: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Standby: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - AutoClosed: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Offline: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineSecondary: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Pausing: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Recovering: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - RecoveryPending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Suspect: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Paused: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Shutdown: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - EmergencyMode: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription ID: account + - Server Name: data.server_name + - Elastic Pool: data.elastic_pool_id + - Pricing Tier: data.pricing_tier_display + - Earliest Restore Point: data.earliest_restore_date + source_type: iso8601 + type: datetime + - Collation: data.collation + - Creation Date: data.creation_date + source_type: iso8601 + type: datetime + - Server Admin Login: data.administrator_login + + + +tabs.1: + name: Configure + type: item + fields: + - Service Tier: data.service_tier_display + - Compute Tier: data.compute_tier + - Compute Hardware: data.sku.family + - Licence Type: data.license_type + - vCores: data.current_sku.capacity + - Data max size: instance_size + - Zone Redundant: data.zone_redundant + - Sync Groups: data.sync_group_display + type: list + options: + delimiter: ', ' + - Sync Agents: data.sync_agent_display + type: list + options: + delimiter: ', ' + - Collation: data.collation + - Creation Date: data.creation_date + source_type: iso8601 + type: datetime + + + +tabs.2: + name: Backups + type: table + root_path: data + fields: + - Database: name + - Earliest PITR Restore Point (UTC): earliest_restore_date + - Available LTR backups: long_term_retention_backup_resource_id + + + +tabs.3: + name: Replication + type: table + root_path: data.replication_link + fields: + - Name: name + - linkType: link_type + - Region: partner_location + - Replica state: replica_state + + + +tabs.4: + name: Sync to other databases + items: + - name: Sync Group + type: table + root_path: data.sync_group + fields: + - Name: name + - Status: sync_state + - Use private link: use_private_link_connection + - Automatic Sync: automatic_sync + - Conflict Resolution: conflict_resolution_policy + - Interval: interval + - name: Sync Agent + type: table + root_path: data.sync_agent + fields: + - Name: name + - Status: state + - version: version + + + +tabs.5: + name: Auditing + type: item + fields: + - Enable SQL Auditing: data.database_auditing_settings.state + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Audit Log Destination: data.database_auditing_settings.storage_endpoint + - Storage Account ID: data.database_auditing_settings.storage_account_subscription_id + - Retention days: data.database_auditing_settings.retention_days + - Secondary Storage access key used: data.database_auditing_settings.is_storage_secondary_key_in_use + - Storage Authentication Type: data.database_auditing_settings.storage_account_access_key + + + +tabs.6: + name: Diagnostic Settings + type: simple-table + root_path: data.diagnostic_settings_resource + fields: + - Name: name + - Storage Account: storage_account_id + - Event Hub: event_hub_name + - Log Analytics Workspace: workspace_id \ No newline at end of file diff --git a/src/plugin/metadata/sql_servers/server.yaml b/src/plugin/metadata/sql_servers/server.yaml new file mode 100644 index 00000000..1bf996c7 --- /dev/null +++ b/src/plugin/metadata/sql_servers/server.yaml @@ -0,0 +1,538 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Server Admin: data.administrator_login + - Active Directory Admin: data.azure_ad_admin_name + - Server Name: data.fully_qualified_domain_name + - Failover Group ID: data.failover_groups.id + - Failover Group Name: data.failover_groups.name + - Failover Groups Primary Server: data.failover_groups.primary_server + - Failover Groups Secondary Server: data.failover_groups.secondary_server + - Read/Write Failover Policy: data.failover_groups.failover_policy_display + - Grace Period (minutes): data.failover_groups.grace_period_display + data_type: integer + - Backup Database: data.databases.name + - Backup Earliest PITR Restore Point (UTC): data.databases.earliest_restore_date + type: datetime + - Backup Available LTR backups: data.databases.long_term_retention_backup_resource_id + - '# of SQL DBs': number_of_databases + data_type: integer + - Elastic Pool Name: data.elastic_pools.name + - Elastic Pool Resource Group: data.elastic_pools.resource_group_display + - Per DB Settings: data.elastic_pools.per_db_settings_display + - Pricing Tier: data.elastic_pools.pricing_tier_display + - 'Elastic Pool # of DBs': data.elastic_pools.number_of_databases + data_type: integer + - Elastic Pool Unit: data.elastic_pools.unit_display + - Elastic Pool Server Name: data.elastic_pools.server_name_display + - Elastic Pool Resource Configuration: data.elastic_pools.pricing_tier_display + - Elastic Pool Maximum Storage Size: data.elastic_pools.max_size_gb + - Deleted Database: data.deleted_databases.database_name + - Deletion Time (UTC): data.deleted_databases.deletion_date + type: datetime + - Deleted Databases Creation Time (UTC): data.deleted_databases.creation_date + type: datetime + - Deleted Databases Edition Time (UTC): data.deleted_databases.edition + type: datetime + - Audit Log Destination: data.server_auditing_settings.storage_endpoint + - Audit Storage Account ID: data.server_auditing_settings.storage_account_subscription_id + - Minimum TLS Version: data.minimal_tls_version + - Connection Policy: data.server_auditing_settings.name + - Allow Azure Services and Resources to Access this server: data.server_auditing_settings.is_azure_monitor_target_enabled + - Firewall Rule Name: data.firewall_rules.name + - Firewall Start IP: data.firewall_rules.start_ip_address + - Firewall End IP: data.firewall_rules.end_ip_address + - Private Endpoint Connection ID: data.private_endpoint_connections.connection_id + - Private Endpoint State: data.private_endpoint_connections.status + - Private Endpoint Name: data.private_endpoint_connections.private_endpoint_name + - Request / Response Message: data.private_endpoint_connections.description + - Transparent Data Encryption: data.encryption_protectors.kind + - Encryption Key: data.encryption_protectors.server_key_name + - Encryption Key Type: data.encryption_protectors.server_key_type + - Encryption URI: data.encryption_protectors.uri + - Tuning Type: data.server_automatic_tuning.options.tuning_type + - Tuning Desired State: data.server_automatic_tuning.options.desired_state + - Tuning Current State: data.server_automatic_tuning.options.actual_state + + + +table: + sort: + key: data.id + desc: false + fields: + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Server Admin: data.administrator_login + is_optional: true + - Active Directory Admin: data.azure_ad_admin_name + is_optional: true + - Server Name: data.fully_qualified_domain_name + is_optional: true + - Failover Group ID: data.failover_groups.id + is_optional: true + - Failover Group Name: data.failover_groups.name + is_optional: true + - Failover Groups Primary Server: data.failover_groups.primary_server + is_optional: true + - Failover Groups Secondary Server: data.failover_groups.secondary_server + is_optional: true + - Read/Write Failover Policy: data.failover_groups.failover_policy_display + is_optional: true + - Grace Period (minutes): data.failover_groups.grace_period_display + is_optional: true + - Backup Database: data.databases.name + is_optional: true + - Backup Earliest PITR Restore Point (UTC): data.databases.earliest_restore_date + is_optional: true + - Backup Available LTR backups: data.databases.long_term_retention_backup_resource_id + is_optional: true + - '# of SQL DBs': data.number_of_databases + is_optional: true + - Elastic Pool Name: data.elastic_pools.name + is_optional: true + - Elastic Pool Resource Group: data.elastic_pools.resource_group_display + is_optional: true + - Per DB Settings: data.elastic_pools.per_db_settings_display + is_optional: true + - Pricing Tier: data.elastic_pools.pricing_tier_display + is_optional: true + - 'Elastic Pool # of DBs': data.elastic_pools.number_of_databases + is_optional: true + - Elastic Pool Unit: data.elastic_pools.unit_display + is_optional: true + - Elastic Pool Server Name: data.elastic_pools.server_name_display + is_optional: true + - Elastic Pool Resource Configuration: data.elastic_pools.pricing_tier_display + is_optional: true + - Elastic Pool Maximum Storage Size: data.elastic_pools.max_size_gb + is_optional: true + - Deleted Database: data.deleted_databases.database_name + is_optional: true + - Deletion Time (UTC): data.deleted_databases.deletion_date + is_optional: true + - Deleted Databases Creation Time (UTC): data.deleted_databases.creation_date + is_optional: true + - Deleted Databases Edition Time (UTC): data.deleted_databases.edition + is_optional: true + - Audit Log Destination: data.server_auditing_settings.storage_endpoint + is_optional: true + - Audit Storage Account ID: data.server_auditing_settings.storage_account_subscription_id + is_optional: true + - Minimum TLS Version: data.minimal_tls_version + is_optional: true + - Connection Policy: data.server_auditing_settings.name + is_optional: true + - Allow Azure Services and Resources to Access this server: data.server_auditing_settings.is_azure_monitor_target_enabled + is_optional: true + - Firewall Rule Name: data.firewall_rules.name + is_optional: true + - Firewall Start IP: data.firewall_rules.start_ip_address + is_optional: true + - Firewall End IP: data.firewall_rules.end_ip_address + is_optional: true + - Private Endpoint Connection ID: data.private_endpoint_connections.connection_id + is_optional: true + - Private Endpoint State: data.private_endpoint_connections.status + is_optional: true + - Private Endpoint Name: data.private_endpoint_connections.private_endpoint_name + is_optional: true + - Request / Response Message: data.private_endpoint_connections.description + is_optional: true + - Transparent Data Encryption: data.encryption_protectors.kind + is_optional: true + - Encryption Key: data.encryption_protectors.server_key_name + is_optional: true + - Encryption Key Type: data.encryption_protectors.server_key_type + is_optional: true + - Encryption URI: data.encryption_protectors.uri + is_optional: true + - Tuning Type: data.server_automatic_tuning.options.tuning_type + is_optional: true + - Tuning Desired State: data.server_automatic_tuning.options.desired_state + is_optional: true + - Tuning Current State: data.server_automatic_tuning.options.actual_state + is_optional: true + + + +tabs.0: + name: SQL Servers + type: item + fields: + - Name: name + - Resource Group: data.resource_group + - Resource ID: data.id + - Status: data.state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Server Admin: data.administrator_login + - Active Directory Admin: data.azure_ad_admin_name + - Server Name: data.fully_qualified_domain_name + + + +tabs.1: + name: Failover Groups + type: table + root_path: data.failover_groups + fields: + - ID: id + - Name: name + - Primary Server: primary_server + - Secondary Server: secondary_server + - Read/Write Failover Policy: failover_policy_display + - Grace Period (minutes): grace_period_display + + + +tabs.2: + name: Backups + type: table + root_path: data.databases + fields: + - Database: name + - Earliest PITR Restore Point (UTC): earliest_restore_date + - Available LTR backups: long_term_retention_backup_resource_id + + + +tabs.3: + name: Active Directory Admin + type: item + fields: + - Active Directory Admin: data.azure_ad_admin_name + + + +tabs.4: + name: SQL Databases + items: + - name: Databases + type: table + root_path: data.databases + fields: + - Database: name + - Resource ID: id + - Status: status + type: enum + enums: + - Online: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Copying: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - OnlineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Restoring: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Resuming: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Scaling: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Standby: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - AutoClosed: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Inaccessible: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Offline: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineChangingDwPerformanceTiers: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - OfflineSecondary: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Pausing: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Recovering: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - RecoveryPending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Suspect: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Paused: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Shutdown: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - EmergencyMode: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Resource Group: resource_group + - Subscription ID: subscription_id + - Location: location + - Server Name: server_name + - Pricing Tier: pricing_tier_display + - Earliest Restore Point: earliest_restore_date + - name: Databases Configure + type: table + root_path: data.databases + fields: + - Service Tier: service_tier_display + - Compute Tier: compute_tier + - Compute Hardware: sku.family + - License Type: license_type + - vCores: sku.capacity + - Data Max Size: max_size_gb + - Zone Redundant: zone_redundant + - Sync Groups: sync_group_display + type: list + options: + delimiter: ', ' + - Sync Agents: sync_agent_display + type: list + options: + delimiter: ', ' + - Collation: collation + - Creation Date: creation_date + source_type: iso8601 + type: datetime + - name: Tags + type: table + root_path: data.tags + fields: + - Key: key + - Value: value + + + +tabs.5: + name: Elastic Pools + type: table + root_path: data.elastic_pools + fields: + - Name: name + - Resource Group: resource_group_display + - Per DB Settings: per_db_settings_display + - Pricing Tier: pricing_tier_display + - '# of SQL DBs': number_of_databases + - Unit: unit_display + - Status: state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Server Name: server_name_display + - Resource Configuration: pricing_tier_display + - Maximum Storage Size: max_size_gb + - Tags: tags + type: list + options: + delimiter: ', ' + + +tabs.6: + name: Auditing + type: item + fields: + - Enable SQL Auditing: data.server_auditing_settings.state + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Audit Log Destination: data.server_auditing_settings.storage_endpoint + - Storage Account ID: data.server_auditing_settings.storage_account_subscription_id + + + +tabs.7: + name: Deleted Databases + type: table + root_path: data.deleted_databases + fields: + - Database: database_name + - Deletion Time (UTC): deletion_date + source_type: iso8601 + type: datetime + - Creation Time (UTC): creation_date + source_type: iso8601 + type: datetime + - Edition Time (UTC): edition + + + +tabs.8: + name: Firewalls and Network + items: + - name: Network + type: item + fields: + - Public Network Access: data.public_network_access + type: enum + enums: + - Enabled: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disabled: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Minimum TLS Version: data.minimal_tls_version + - Connection Policy: data.server_auditing_settings.name + - Allow Azure Services and Resources to Access this server: data.server_auditing_settings.is_azure_monitor_target_enabled + - name: Firewall Rules + type: table + root_path: data.firewall_rules + fields: + - Rule Name: name + - Start IP: start_ip_address + - End IP: end_ip_address + - name: Virtual Network Rules + type: table + root_path: data.virtual_network_rules + fields: + - Rule Name: name + - Virtual Network: virtual_network_name_display + - Subnet ID: virtual_network_subnet_id + - Resource Group: resource_group + - Subscription: subscription_id + - State: state + type: enum + enums: + - Ready: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - InProgress: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Initializing: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Deleting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Unknown: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + + + +tabs.9: + name: Private Endpoint Connections + type: table + root_path: data.private_endpoint_connections + fields: + - Connection ID: connection_id + - State: status + - Private Endpoint Name: private_endpoint_name + - Request / Response Message: description + + + +tabs.10: + name: Transparent Data Encryption + type: table + root_path: data.encryption_protectors + fields: + - Transparent Data Encryption: kind + - Key: server_key_name + - Key Type: server_key_type + - Uri: uri + + + +tabs.11: + name: Tuning Options + type: table + root_path: data.server_automatic_tuning.options + fields: + - Tuning Type: tuning_type + - Desired State: desired_state + - Current State: actual_state \ No newline at end of file diff --git a/src/plugin/metadata/storage_accounts/instance.yaml b/src/plugin/metadata/storage_accounts/instance.yaml new file mode 100644 index 00000000..ef19380c --- /dev/null +++ b/src/plugin/metadata/storage_accounts/instance.yaml @@ -0,0 +1,229 @@ +search: + fields: + - Container count: data.container_count_display + data_type: integer + - Blob count: data.blob_count_display + data_type: integer + - Blob total size(Bytes): data.blob_size_display + data_type: integer + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - SKU: data.sku.name + - Type: data.type + - State of Primary: data.status_of_primary + - Performance Tier: instance_type + - Access Tier: data.access_tier + - Replication: data.sku.name + - Kind of Account: data.kind + - Provisioning State: data.provisioning_state + - Is Public: data.allow_blob_public_access + - Virtual Network: data.network_acls.virtual_networks + - Firewall Address Range: data.network_acls.firewall_address_range + - Resource Instances: data.network_acls.resource_access_rules_display + - Exceptions: data.network_acls.bypass + - Routing Preference: data.routing_preference_display + - Publish Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + - Publish Internet Endpoints: data.routing_preference.publish_internet_endpoints + - Blob: data.primary_endpoints.blob + - Queue: data.primary_endpoints.queue + - Table: data.primary_endpoints.table + - File: data.primary_endpoints.file + - Web: data.primary_endpoints.web + - DFS: data.primary_endpoints.dfs + - Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + - Internet Endpoints: data.routing_preference.publish_internet_endpoints + - Container Name: data.container_item.name + - Container Last Modified: data.container_item.last_modified_time + data_type: datetime + - Container Public Access Level: data.container_item.public_access + - Container Lease State: data.container_item.lease_state + - Primary Location: data.primary_location + - Secondary Location: data.secondary_location + + + +table: + sort: + key: data.id + desc: false + fields: + - Container count: data.container_count_display + - Blob count: data.blob_count_display + - Blob total size: data.blob_size_display + display_unit: MB + source_unit: BYTES + type: size + - Resource Group: data.resource_group + - Location: data.location + - Subscription ID: account + - Subscription Name: data.subscription_name + - SKU: data.sku.name + - Type: data.type + - State of Primary: data.status_of_primary + is_optional: true + - Performance Tier: instance_type + is_optional: true + - Access Tier: data.access_tier + is_optional: true + - Replication: data.sku.name + is_optional: true + - Kind of Account: data.kind + is_optional: true + - Provisioning State: data.provisioning_state + is_optional: true + - Is Public: data.allow_blob_public_access + is_optional: true + - Virtual Network: data.network_acls.virtual_networks + is_optional: true + - Firewall Address Range: data.network_acls.firewall_address_range + type: list + options: + delimiter: ', ' + is_optional: true + - Resource Instances: data.network_acls.resource_access_rules_display + type: list + options: + delimiter: ', ' + is_optional: true + - Exceptions: data.network_acls.bypass + is_optional: true + - Routing Preference: data.routing_preference_display + is_optional: true + - Publish Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + is_optional: true + - Publish Internet Endpoints: data.routing_preference.publish_internet_endpoints + is_optional: true + - Blob: data.primary_endpoints.blob + is_optional: true + - Queue: data.primary_endpoints.queue + is_optional: true + - Table: data.primary_endpoints.table + is_optional: true + - File: data.primary_endpoints.file + is_optional: true + - Web: data.primary_endpoints.web + is_optional: true + - DFS: data.primary_endpoints.dfs + is_optional: true + - Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + is_optional: true + - Internet Endpoints: data.routing_preference.publish_internet_endpoints + is_optional: true + - Container Name: data.container_item.name + is_optional: true + - Container Last Modified: data.container_item.last_modified_time + is_optional: true + - Container Public Access Level: data.container_item.public_access + is_optional: true + - Container Lease State: data.container_item.lease_state + is_optional: true + - Primary Location: data.primary_location + is_optional: true + - Secondary Location: data.secondary_location + is_optional: true + + + +tabs.0: + name: Storage Account + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - State of Primary: data.status_of_primary + - Performance Tier: instance_type + - Access Tier: data.access_tier + - Replication: data.sku.name + - Account Kind: data.kind + - Provisioning State: data.provisioning_state + - Creation Time: data.creation_time + source_type: iso8601 + type: datetime + - Container count: data.container_count_display + - Blob count: data.blob_count_display + - Blob total size: data.blob_size_display + display_unit: MB + source_unit: BYTES + type: size + + + +tabs.1: + name: Networking + type: item + fields: + - Is Public: data.network_rule_set.is_public_access_allowed + - Virtual Network: data.network_rule_set.virtual_networks + - Firewall Address Range: data.network_rule_set.firewall_address_range + type: list + options: + delimiter: ', ' + - Resource Instances: data.network_rule_set.resource_access_rules_display + type: list + options: + delimiter: ', ' + - Exceptions: data.network_rule_set.bypass + - Routing Preference: data.routing_preference_display + - Publish Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + - Publish Internet Endpoints: data.routing_preference.publish_internet_endpoints + + + +tabs.2: + name: Primary Endpoints + type: item + fields: + - Blob: data.primary_endpoints.blob + - Queue: data.primary_endpoints.queue + - Table: data.primary_endpoints.table + - File: data.primary_endpoints.file + - Web: data.primary_endpoints.web + - DFS: data.primary_endpoints.dfs + - Microsoft Endpoints: data.routing_preference.publish_microsoft_endpoints + - Internet Endpoints: data.routing_preference.publish_internet_endpoints + + + +tabs.3: + name: Encryption + type: item + fields: + - Key Source: data.encryption.key_source + - Key Vault URI: data.encryption.key_vault_properties.key_vault_uri + + + +tabs.4: + name: Geo-Replication + type: table + fields: + - Primary Location: 'data.primary_location' + - Status of Primary: data.status_of_primary + type: enum + enums: + - available: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - unavailable: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Secondary Location: data.secondary_location + - Status of Secondary: data.status_of_secondary + type: enum + enums: + - available: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - unavailable: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state \ No newline at end of file diff --git a/src/plugin/metadata/virtual_machines/instance.yaml b/src/plugin/metadata/virtual_machines/instance.yaml new file mode 100644 index 00000000..30d0e6b4 --- /dev/null +++ b/src/plugin/metadata/virtual_machines/instance.yaml @@ -0,0 +1,479 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group.resource_group_name + - IP Address: data.ip_addresses + - Instance ID: data.compute.instance_id + - Instance State: data.compute.instance_state + - Instance Type: data.compute.instance_type + - Key Pair: data.compute.keypair + - Image: data.compute.image + - Availability Zone: data.compute.az + - OS Type: data.os.os_type + - OS Architecture: data.os.os_arch + - MAC Address: data.nics.mac_address + - Public IP Address: data.nics.public_ip_address + - Public DNS: data.nics.tags.public_dns + - VNet ID: data.vnet.vnet_id + - VNet Name: data.vnet.vnet_name + - Subnet ID: data.subnet.subnet_id + - Subnet Name: data.subnet.subnet_name + - ELB Name: data.load_balancer.name + - ELB DNS: data.load_balancer.endpoint + - Auto Scaling Group: data.auto_scaling_group.name + - Core: data.hardware.core + data_type: integer + - Memory: data.hardware.memory + data_type: float + - Management State: state + - Cloud Service Group: cloud_service_group + - Cloud Service Type: cloud_service_type + - Service Account: collection_info.service_accounts + - Launched: data.launched_at + + + +table: + sort: + key: data.activity_log.resource_uri + desc: false + fields: + - Instance State: data.compute.instance_state + type: enum + enums: + - RUNNING: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - PENDING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - REBOOTING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - SHUTTING-DOWN: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STOPPING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STARTING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - PROVISIONING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STAGING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - DEALLOCATING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - REPAIRING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STOPPED: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - DEALLOCATED: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - SUSPENDED: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - TERMINATED: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Cloud Service ID: cloud_service_id + is_optional: true + - Instance Type: data.compute.instance_type + - Core: data.hardware.core + - Memory: data.hardware.memory + - Instance ID: data.compute.instance_id + is_optional: true + - Key Pair: data.compute.keypair + is_optional: true + - Image: data.compute.image + is_optional: true + - Availability Zone: data.compute.az + - OS Type: data.os.os_type + is_optional: true + - OS: data.os.os_distro + - OS Architecture: data.os.os_arch + is_optional: true + - Primary IP: data.primary_ip_address + - Public DNS: data.nics + type: list + options: + sub_key: tags.name + is_optional: true + - Public IP: data.nics + type: list + options: + sub_key: public_ip_address + is_optional: true + - All IP: ip_addresses + is_optional: true + - MAC Address: data.nics.mac_address + is_optional: true + - CIDR: data.vnet.cidr + is_optional: true + - VNet ID: data.vnet.vnet_id + is_optional: true + - VNet Name: data.vnet.vnet_name + is_optional: true + - Subnet ID: data.subnet.subnet_id + is_optional: true + - Subnet Name: data.subnet.subnet_name + is_optional: true + - Load Balancer Name: data.load_balancer.name + is_optional: true + - Load Balancer DNS: data.load_balancer.endpoint + is_optional: true + - Ultra SSD Enabled: data.azure.ultra_ssd_enabled + is_optional: true + - Write Accelerator Enabled: data.azure.write_accelerator_enabled + is_optional: true + - Boot Diagnostics: data.azure.boot_diagnostics + is_optional: true + - Priority: data.azure.priority + is_optional: true + - Auto Scaling Group: data.auto_scaling_group.name + is_optional: true + - CPU Utilization: data.monitoring.cpu.utilization.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Memory Usage: data.monitoring.memory.usage.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Disk Read IOPS: data.monitoring.disk.read_iops.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Disk Write IOPS: data.monitoring.disk.write_iops.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Disk Read Throughput: data.monitoring.disk.read_throughput.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Disk Write Throughput: data.monitoring.disk.write_throughput.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Network Received PPS: data.monitoring.network.received_pps.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Network Send PPS: data.monitoring.network.sent_pps.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Network Received Throughput: data.monitoring.network.received_throughput.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - Network Sent Throughput: data.monitoring.network.sent_throughput.avg + default: 0 + is_optional: true + field_description: (Daily Average) + - CPU Utilization: data.monitoring.cpu.utilization.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Memory Usage: data.monitoring.memory.usage.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Disk Read IOPS: data.monitoring.disk.read_iops.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Disk Write IOPS: data.monitoring.disk.write_iops.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Disk Read Throughput: data.monitoring.disk.read_throughput.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Disk Write Throughput: data.monitoring.disk.write_throughput.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Network Received PPS: data.monitoring.network.received_pps.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Network Send PPS: data.monitoring.network.sent_pps.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Network Received Throughput: data.monitoring.network.received_throughput.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Network Sent Throughput: data.monitoring.network.sent_throughput.max + default: 0 + is_optional: true + field_description: (Daily Max) + - Subscription ID: account + - Launched: launched_at + is_optional: true + + + +tabs.0: + name: Azure VM + items: + - name: Virtual Machine + type: item + fields: + - Resource ID: data.compute.instance_id + - VM ID: data.compute.tags.vm_id + - VM State: data.compute.instance_state + type: enum + enums: + - RUNNING: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - STARTING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - DEALLOCATING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STOPPING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - DEALLOCATING: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - STOPPED: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - DEALLOCATED: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Instance Type: data.compute.instance_type + - Image: data.compute.image + - Azure Priority: data.azure.priority + type: enum + enums: + - Regular: indigo.500 + type: badge + - Low: coral.600 + type: badge + - Spot: peacock.600 + type: badge + - Region: region_code + - Availability Zone: data.compute.az + - Key Pair: data.compute.keypair + - Ultra SSD Enabled: data.azure.ultra_ssd_enabled + type: enum + enums: + - 'true': indigo.500 + type: badge + - 'false': coral.600 + type: badge + - Write Accelerator Enabled: data.azure.write_accelerator_enabled + type: enum + enums: + - 'true': indigo.500 + type: badge + - 'false': coral.600 + type: badge + - Boot Diagnostics: data.azure.boot_diagnostics + type: enum + enums: + - 'true': indigo.500 + type: badge + - 'false': coral.600 + type: badge + - Public IP: data.nics + type: list + options: + sub_key: public_ip_address + delimiter: '
' + - Security Groups: data.compute.security_groups + type: list + options: + sub_key: display + delimiter: '
' + - Launched At: data.compute.launched_at + - name: Virtual Network + type: item + fields: + - VNet ID: data.vnet.vnet_id + - VNet Name: data.vnet.vnet_name + - Subnet ID: data.subnet.subnet_id + - Subnet Name: data.subnet.subnet_name + - name: Operating System + type: item + fields: + - OS Type: data.os.os_type + translation_id: PAGE_SCHEMA.OS_TYPE + - OS Distribution: data.os.os_distro + translation_id: PAGE_SCHEMA.OS_DISTRO + - OS Architecture: data.os.os_arch + translation_id: PAGE_SCHEMA.OS_ARCH + - OS Version Details: data.os.details + translation_id: PAGE_SCHEMA.OS_DETAILS + - OS License: data.os.os_license + translation_id: PAGE_SCHEMA.OS_LICENSE + - name: Hardware + type: item + fields: + - Core: data.hardware.core + translation_id: PAGE_SCHEMA.CPU_CORE + - Memory: data.hardware.memory + translation_id: PAGE_SCHEMA.MEMORY + + + +tabs.1: + name: Disk + type: table + root_path: data.disks + fields: + - Index: device_index + - Name: tags.disk_name + - Size: size + - Disk ID: tags.disk_id + - Storage Account Type: tags.storage_Account_type + - IOPS: tags.iops + - Throughput (mbps): tags.throughput_mbps + - Encryption Set: tags.disk_encryption_set + - Caching: tags.caching + + + +tabs.2: + name: NIC + type: table + root_path: data.nics + fields: + - Index: device_index + - Name: tags.name + - IP Addresses: ip_addresses + type: list + options: + delimiter: '
' + - Public IP: public_ip_address + - MAC Address: mac_address + - CIDR: cidr + - etag: tags.etag + - Enable Accelerated Networking: tags.enable_accelerated_networking + type: enum + enums: + - 'true': indigo.500 + type: badge + - 'false': coral.600 + type: badge + - Enable IP Forwarding: tags.enable_ip_forwarding + type: enum + enums: + - 'true': indigo.500 + type: badge + - 'false': coral.600 + type: badge + + + +tabs.3: + name: Network Security Groups + type: table + root_path: data.security_group + fields: + - Direction: direction + type: enum + enums: + - inbound: indigo.500 + type: badge + - outbound: coral.600 + type: badge + - Name: security_group_name + - Protocol: protocol + type: enum + enums: + - ALL: violet.600 + type: badge + - TCP: indigo.500 + type: badge + - UDP: coral.600 + type: badge + - ICMP: peacock.500 + type: badge + - Port Range: port + - Remote: remote + - Priority: priority + - Action: action + type: enum + enums: + - allow: indigo.500 + type: badge + - deny: coral.600 + type: badge + - Description: description + + + +tabs.4: + name: Load Balancer + type: table + root_path: data.load_balancer + fields: + - Name: name + - Endpoint: endpoint + - Type: type + type: enum + enums: + - network: indigo.500 + type: badge + - application: coral.600 + type: badge + - Protocol: protocol + type: list + options: + delimiter: '
' + - Port: port + type: list + options: + delimiter: '
' + - Scheme: scheme + type: enum + enums: + - internet-facing: indigo.500 + type: badge + - internal: coral.600 + type: badge \ No newline at end of file diff --git a/src/plugin/metadata/virtual_networks/instance.yaml b/src/plugin/metadata/virtual_networks/instance.yaml new file mode 100644 index 00000000..5d509757 --- /dev/null +++ b/src/plugin/metadata/virtual_networks/instance.yaml @@ -0,0 +1,215 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - DNS servers: data.dhcp_options.dns_servers + - Resource GUID: data.resource_guid + - Address Space: data.address_space.address_prefixes + - Connected Device: data.connected_devices.device + - Connected Device Type: data.connected_devices.type + - Connected Subnet: data.connected_devices.name + - Subnet Name: data.subnets.name + - Subnet IP Prefixes: data.subnets.address_prefixes + - Subnet Delegated To: data.subnets.delegations.name + - Subnet Network Security Group: data.subnets.network_security_group.name + + + +table: + sort: + key: data.id + desc: false + fields: + - Resource Group: data.resource_group + - Location: data.location + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - DNS servers: data.dhcp_options.dns_servers + type: list + options: + delimiter: ', ' + is_optional: true + - Resource GUID: data.resource_guid + is_optional: true + - Address Space: data.address_space.address_prefixes + type: list + options: + delimiter: ', ' + is_optional: true + - Connected Device: data.connected_devices.device + is_optional: true + - Connected Device Type: data.connected_devices.type + is_optional: true + - Connected Subnet: data.connected_devices.name + is_optional: true + - Subnet Name: data.subnets.name + is_optional: true + - Subnet IP Prefixes: data.subnets.address_prefixes + type: list + options: + delimiter: ', ' + is_optional: true + - Subnet Delegated To: data.subnets.delegations.name + is_optional: true + - Subnet Network Security Group: data.subnets.network_security_group.name + is_optional: true + - Firewall Name: data.azure_firewall.name + is_optional: true + - Firewall IP Address: data.azure_firewall.ip_configurations.private_ip_address + is_optional: true + - Firewall Subnet: data.azure_firewall.subnet + is_optional: true + - Peering Name: data.virtual_network_peerings.name + is_optional: true + - Peer: data.virtual_network_peerings.remote_virtual_network.id + is_optional: true + - Peer Gateway Transit: data.virtual_network_peerings.allow_gateway_transit + is_optional: true + - Service Endpoint: data.service_endpoints.service + is_optional: true + - Service Endpoint Subnet: data.service_endpoints.subnet + is_optional: true + - Service Endpoint Locations: data.service_endpoints.locations + is_optional: true + - Private Endpoint: data.private_endpoints.name + is_optional: true + - Private Endpoint Subnet: data.private_endpoints.subnet + is_optional: true + + + +tabs.0: + name: Virtual Network + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - DNS Servers: data.dhcp_options.dns_servers + type: list + options: + delimiter: ', ' + - DDoS Protection Standard: data.enable_ddos_protection + type: enum + enums: + - 'True': + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - 'False': + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Resource GUID: data.resource_guid + - Address Space: data.address_space.address_prefixes + + + +tabs.1: + name: Connected Devices + type: simple-table + root_path: data.connected_devices + fields: + - Device: device + - Type: type + - Subnet: name + + + +tabs.2: + name: Subnets + type: simple-table + root_path: data.subnets + fields: + - Name: name + - IP Address Prefix: address_prefix + - IP Address Prefixes: address_prefixes + type: list + options: + delimiter: ', ' + - Delegated To: delegations.name + - Security Group: network_security_group.name + + + +tabs.3: + name: Firewall + type: simple-table + root_path: data.azure_firewall + fields: + - Name: name + - IP Address: ip_configurations.private_ip_address + - Subnet: subnet + + + +tabs.4: + name: Peerings + type: simple-table + root_path: data.virtual_network_peerings + fields: + - Name: name + - Peering Status: peering_state + type: enum + enums: + - Connected: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Disconnected: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Initiated: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Peer: remote_virtual_network.id + - Gateway Transit: allow_gateway_transit + + + +tabs.5: + name: Service Endpoints + type: simple-table + root_path: data.service_endpoints + fields: + - Service: service + - Subnet: subnet + - Status: provisioning_state + type: enum + enums: + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Failed: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Deleting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Locations: locations + + + +tabs.6: + name: Private Endpoints + type: simple-table + root_path: data.private_endpoints + fields: + - Name: name + - Subnet: subnet + - Resource Group: resource_group diff --git a/src/plugin/metadata/vm_scale_sets/scale_set.yaml b/src/plugin/metadata/vm_scale_sets/scale_set.yaml new file mode 100644 index 00000000..e5795291 --- /dev/null +++ b/src/plugin/metadata/vm_scale_sets/scale_set.yaml @@ -0,0 +1,223 @@ +search: + fields: + - Subscription ID: account + - Subscription Name: data.subscription_name + - Resource Group: data.resource_group + - Location: data.location + - Default: data.virtual_machine_scale_set_power_state.profiles.capacity.default + - Max: data.virtual_machine_scale_set_power_state.profiles.capacity.maximum + - Min: data.virtual_machine_scale_set_power_state.profiles.capacity.minimum + - Azure Spot Eviction Policy: data.virtual_machine_profile.eviction_policy + - Azure Spot Max Price: data.virtual_machine_profile.billing_profile.max_price + - Termination Notification: data.virtual_machine_profile.terminate_notification_display + - OverProvisioning: data.overprovision + - Proximity Placement Group: data.proximity_placement_group_display + - Automatic Repairs: data.automatic_repairs_policy.enabled + - Upgrade Policy: data.upgrade_policy.mode + - Fault Domains (count): data.platform_fault_domain_count + data_type: integer + + + +table: + sort: + key: data.id + desc: false + fields: + - Instance Count: data.instance_count + - Resource Group: data.resource_group + - Location: data.location + - Default: data.virtual_machine_scale_set_power_state.profiles.capacity.default + - Max: data.virtual_machine_scale_set_power_state.profiles.capacity.maximum + - Min: data.virtual_machine_scale_set_power_state.profiles.capacity.minimum + - Azure Spot Eviction Policy: data.virtual_machine_profile.eviction_policy + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Virtual network/subnet: data.virtual_machine_profile.network_profile.primary_vnet + is_optional: true + - Host group: data.host_group.id + is_optional: true + - Ephemeral OS Disk: data.virtual_machine_profile.storage_profile.os_disk.diff_disk_settings.option.local + is_optional: true + - Azure Spot Eviction Policy: data.virtual_machine_profile.eviction_policy + is_optional: true + - Azure Spot Max Price: data.virtual_machine_profile.billing_profile.max_price + is_optional: true + - Termination Notification: data.virtual_machine_profile.terminate_notification_display + is_optional: true + - OverProvisioning: data.overprovision + is_optional: true + - Proximity Placement Group: data.proximity_placement_group_display + is_optional: true + - Automatic Repairs: data.automatic_repairs_policy.enabled + is_optional: true + - Upgrade Policy: data.upgrade_policy.mode + is_optional: true + - Fault Domains (count): data.platform_fault_domain_count + is_optional: true + + + +tabs.0: + name: VmScaleSets + type: item + fields: + - Name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Location: data.location + - Subscription: data.subscription_name + - Subscription ID: account + - Instances: data.instance_count + - Operating System: data.virtual_machine_profile.os_profile.operating_system + - Size: instance_type + - Virtual network/subnet: data.virtual_machine_profile.network_profile.primary_vnet + - Host group: data.host_group.id + - Ephemeral OS Disk: data.virtual_machine_profile.storage_profile.os_disk.diff_disk_settings.option.local + - Azure Spot Eviction Policy: data.virtual_machine_profile.eviction_policy + - Azure Spot Max Price: data.virtual_machine_profile.billing_profile.max_price + - Termination Notification: data.terminate_notification_display + - OverProvisioning: data.overprovision + - Proximity Placement Group: data.proximity_placement_group_display + - Automatic Repairs: data.automatic_repairs_policy.enabled + - Upgrade Policy: data.upgrade_policy.mode + - Fault Domains: data.platform_fault_domain_count + + + +tabs.1: + name: Instances + type: table + root_path: data.vm_instances + fields: + - Name: name + - Computer Name: os_profile.computer_name + - Location: location + - Status: vm_instance_status_profile.statuses.code + type: enum + enums: + - PowerState/running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - PowerState/starting: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - PowerState/deallocated: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - PowerState/deallocating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - PowerState/stopped: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - PowerState/stopping: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - PowerState/unknown: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Provisioning State: provisioning_state + - Protection From Scale-in: protection_policy.protect_from_scale_in + - Protection From Scale-set Actions: protection_policy.protect_from_scale_set_actions + - Latest Model: latest_model_applied + - Virtual Network: primary_vnet + + + +tabs.2: + name: Networking + items: + - name: Networking + type: item + fields: + - Virtual Networks: data.virtual_machine_profile.network_profile.primary_vnet + - name: Network Configuration + type: simple-table + root_path: data.virtual_machine_profile.network_profile.network_interface_configurations + fields: + - Name: name + - Network interface: enable_accelerated_networking_display + - Accelerated Networking: enable_accelerated_networking_display + - Primary: primary + - name: IP Configurations + type: simple-table + root_path: data.virtual_machine_profile.network_profile.network_interface_configurations.ip_configurations + fields: + - Public Ip Address Configuration: public_ip_address_configuration + - Private IP Address Version: private_ip_address_version + + + +tabs.3: + name: Scaling + items: + - name: Scaling + type: item + fields: + - Instance Count: data.instance_count + - Scale-in Policy: data.scale_in_policy.rules + type: list + options: + delimiter: "
" + - name: Autoscale Settings + type: simple-table + root_path: data.virtual_machine_scale_set_power_state + fields: + - Name: name + - Profiles: profiles_display + type: list + options: + delimiter: "
" + - Default: profiles.capacity.default + - Max: profiles.capacity.maximum + - Min: profiles.capacity.minimum + + + +tabs.4: + name: Disks + items: + - name: OS Disk + type: item + fields: + - Image Reference: data.virtual_machine_profile.storage_profile.image_reference_display + - Storage Account Type: data.virtual_machine_profile.storage_profile.os_disk.managed_disk.storage_account_type + - Size: data.virtual_machine_profile.storage_profile.os_disk.disk_size_gb + - Host Caching: data.virtual_machine_profile.storage_profile.os_disk.caching + - name: Data Disks + type: simple-table + root_path: data.virtual_machine_profile.storage_profile.data_disks + fields: + - Name: name + - Storage Type: managed_disk.storage_type + - Size: disk_size_gb + display_unit: GB + source_unit: GB + type: size + - Max IOPS: disk_iops_read_write + - MAX Throughput(MBps): disk_m_bps_read_write + - Encryption: disk_encryption_set.id + - Host Caching: caching + - LUN: lun + + + +tabs.5: + name: Operating System + type: item + fields: + - Computer Name Prefix: data.virtual_machine_profile.os_profile.computer_name_prefix + - Administrator Username: data.virtual_machine_profile.os_profile.admin_username + - Operating System: data.virtual_machine_profile.os_profile.operating_system + - VM Agent: data.virtual_machine_profile.os_profile.linux_configuration.provision_vm_agent + - Automatic OS Upgrades: data.upgrade_policy.automatic_os_upgrade_policy.enable_automatic_os_upgrade + - Custom Data: data.virtual_machine_profile.os_profile.custom_data diff --git a/src/plugin/metadata/web_pub_sub_service/hub.yaml b/src/plugin/metadata/web_pub_sub_service/hub.yaml new file mode 100644 index 00000000..b5bd62b9 --- /dev/null +++ b/src/plugin/metadata/web_pub_sub_service/hub.yaml @@ -0,0 +1,85 @@ +search: + fields: + - Anonymous Connect: data.properties.anonymous_connect_policy + - Event Handlers count: data.web_pubsub_hub_evnet_handler_count_display + data_type: integer + - Web SubSub Service: data.web_pubsub_svc_name + - Subscription Name: data.subscription_name + - Subscription ID: account + - Resource Group: data.resource_group + - Location: data.location + + + +table: + sort: + key: data.id + desc: false + fields: + - Anonymous Connect: data.properties.anonymous_connect_policy + type: enum + enums: + - allow: indigo.500 + type: badge + - deny: coral.600 + type: badge + - Event Handlers count: data.web_pubsub_hub_evnet_handler_count_display + - Web SubSub Service: data.web_pubsub_svc_name + - Subscription Name: data.subscription_name + - Subscription ID: account + - Resource Group: data.resource_group + - Location: data.location + + + +tabs.0: + name: Web PubSub Hub + type: item + fields: + - Hub name: name + - Resource ID: data.id + - Resource Group: data.resource_group + - Subscription: data.subscription_name + - Subscription ID: account + - Region: data.location + - Anonymous Connect: data.properties.anonymous_connect_policy + type: enum + enums: + - allow: indigo.500 + type: badge + - deny: coral.600 + type: badge + - EventHandler count: data.web_pubsub_hub_evnet_handler_count_display + + + +tabs.1: + name: Event Handlers + type: table + root_path: data.properties.event_handlers + fields: + - Url template: url_template + - User events: user_event_pattern + - System events: system_events + type: list + options: + delimiter: ', ' + - Authentication: auth.type + + + +tabs.2: + name: System data + type: item + root_path: data.system_data + fields: + - Created at: created_at + source_type: iso8601 + type: datetime + - Created by: created_by + - Created by type: created_by_type + - Last modified at: last_modified_at + source_type: iso8601 + type: datetime + - Last modified by: last_modified_by + - Last modified by type: last_modified_by_type \ No newline at end of file diff --git a/src/plugin/metadata/web_pub_sub_service/service.yaml b/src/plugin/metadata/web_pub_sub_service/service.yaml new file mode 100644 index 00000000..e185d5e5 --- /dev/null +++ b/src/plugin/metadata/web_pub_sub_service/service.yaml @@ -0,0 +1,333 @@ +search: + fields: + - Service State: data.provisioning_state + - Subscription Name: data.subscription_name + - Subscription ID: account + - Resource Group: data.resource_group + - Location: data.location + - Hub count: data.web_pubsub_hub_count_display + data_type: integer + - SKU: data.sku.tier + - Unit: data.sku.capacity + data_type: integer + - Version: data.version + data_type: float + - Host name: data.host_name + - Host name prefix: data.host_name_prefix + - Public IP: data.external_ip + - Public access: data.public_network_access + - Public port: data.public_port + - Server port: data.server_port + - TLS: data.tls.client_cert_enabled + + + +table: + sort: + key: data.id + desc: false + fields: + - Service State: data.provisioning_state + type: enum + enums: + - Running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Deleting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Moving: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Failed: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Canceled: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Unknown: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Subscription Name: data.subscription_name + - Subscription ID: account + is_optional: true + - Resource Group: data.resource_group + - Location: data.location + - Hub count: data.web_pubsub_hub_count_display + - SKU: data.sku.tier + - Unit: data.sku.capacity + - Version: data.version + is_optional: true + - Host name: data.host_name + - Host name prefix: data.host_name_prefix + is_optional: true + - Public IP: data.external_ip + - Public access: data.public_network_access + - Public port: data.public_port + is_optional: true + - Server port: data.server_port + is_optional: true + - TLS: data.tls.client_cert_enabled + is_optional: true + + + +tabs.0: + name: Web PubSub Service + type: item + fields: + - Name: name + - Service State: data.provisioning_state + type: enum + enums: + - Running: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Succeeded: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Creating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Deleting: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Moving: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Updating: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Failed: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Canceled: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Unknown: + icon_image: ic_circle-filled + icon_color: gray.400 + text_color: gray.400 + type: state + - Resource ID: data.id + - Resource Group: data.resource_group + - Subscription: data.subscription_name + - Subscription ID: account + - Region: data.location + - Hub count: data.web_pubsub_hub_count_display + - SKU: data.sku.tier + - Unit: data.sku.capacity + - Version: data.version + - Host name: data.host_name + - Host name prefix: data.host_name_prefix + - Public IP: data.external_ip + - Public access: data.public_network_access + - Public port: data.public_port + - Server port: data.server_port + - Disable add auth: data.disable_aad_auth + - Disable local auth: data.disable_local_auth + - TLS: data.tls.client_cert_enabled + + + +tabs.1: + name: Keys + type: item + fields: + - Host name: data.host_name + - Access Key: data.disable_local_auth + - Primary Key: data.web_pubsub_key.primary_key + - Primary Connection string: data.web_pubsub_key.primary_connection_string + - Secondary Key: data.web_pubsub_key.secondary_key + - Secondary Connection string: data.web_pubsub_key.secondary_connection_string + + + +tabs.2: + name: Hubs + type: table + root_path: data.web_pubsub_hubs + fields: + - Hub name: name + - Anonymous Connect: properties.anonymous_connect_policy + type: enum + enums: + - allow: indigo.500 + type: badge + - deny: coral.600 + type: badge + - Event Handlers: properties.event_handlers.url_template + type: list + options: + delimiter: '
' + + + +tabs.3: + name: Public access + type: item + fields: + - Public network access: data.public_network_access + type: enum + enums: + - Enabled: indigo.500 + type: badge + - Disabled: coral.600 + type: badge + + + +tabs.4: + name: Private access + items: + - name: Private endpoint connections + type: table + root_path: data.private_endpoint_connections + fields: + - Connection name: name + - Connection state: private_link_service_connection_state.status + type: enum + enums: + - Approved: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Pending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disconnected: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Rejected: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Private Endpoint: private_endpoint.private_endpoint_name_display + - Description: private_link_service_connection_state.status + - Group ids: group_ids + type: list + options: + delimiter: '
' + - Provisioning state: provisioning_state + - name: Shared private endpoints + type: table + root_path: data.shared_private_link_resources + fields: + - Name: name + - Private link resource ID: private_link_resource_id + - Group ID: group_id + - Connection state: status + type: enum + enums: + - Approved: + icon_image: ic_circle-filled + icon_color: green.500 + type: state + - Pending: + icon_image: ic_circle-filled + icon_color: yellow.500 + type: state + - Disconnected: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Rejected: + text_color: red.500 + icon_image: ic_circle-filled + icon_color: red.500 + type: state + - Description: request_message + - Provisioning state: provisioning_state + + + +tabs.5: + name: Access control rules + items: + - name: Default action + type: item + fields: + - Default action: data.network_ac_ls.default_action + type: enum + enums: + - Allow: indigo.500 + type: badge + - Deny: coral.600 + type: badge + - name: Public network + type: item + fields: + - Allow: data.network_ac_ls.public_network.allow + type: list + options: + delimiter: ', ' + - name: Private endpoint connections + type: table + root_path: data.network_ac_ls.private_endpoints + fields: + - Connection name: name + - Allow: allow + type: list + options: + delimiter: ', ' + + + +tabs.6: + name: System data + type: item + fields: + - Created at: data.system_data.created_at + source_type: iso8601 + type: datetime + - Created by: data.system_data.created_by + - Created by type: data.system_data.created_by_type + - Last modified at: data.system_data.last_modified_at + source_type: iso8601 + type: datetime + - Last modified by: data.system_data.last_modified_by + - Last modified by type: data.system_data.last_modified_by_type \ No newline at end of file diff --git a/src/spaceone/inventory/metrics/ApplicationGateways/Instance/instance_count.yaml b/src/plugin/metrics/ApplicationGateways/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ApplicationGateways/Instance/instance_count.yaml rename to src/plugin/metrics/ApplicationGateways/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/ApplicationGateways/Instance/namespace.yaml b/src/plugin/metrics/ApplicationGateways/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ApplicationGateways/Instance/namespace.yaml rename to src/plugin/metrics/ApplicationGateways/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/ContainerInstances/Container/container_count.yaml b/src/plugin/metrics/ContainerInstances/Container/container_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ContainerInstances/Container/container_count.yaml rename to src/plugin/metrics/ContainerInstances/Container/container_count.yaml diff --git a/src/spaceone/inventory/metrics/ContainerInstances/Container/gpu_size.yaml b/src/plugin/metrics/ContainerInstances/Container/gpu_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ContainerInstances/Container/gpu_size.yaml rename to src/plugin/metrics/ContainerInstances/Container/gpu_size.yaml diff --git a/src/spaceone/inventory/metrics/ContainerInstances/Container/memory_size.yaml b/src/plugin/metrics/ContainerInstances/Container/memory_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ContainerInstances/Container/memory_size.yaml rename to src/plugin/metrics/ContainerInstances/Container/memory_size.yaml diff --git a/src/spaceone/inventory/metrics/ContainerInstances/Container/namespace.yaml b/src/plugin/metrics/ContainerInstances/Container/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ContainerInstances/Container/namespace.yaml rename to src/plugin/metrics/ContainerInstances/Container/namespace.yaml diff --git a/src/spaceone/inventory/metrics/ContainerInstances/Container/vcpu_count.yaml b/src/plugin/metrics/ContainerInstances/Container/vcpu_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/ContainerInstances/Container/vcpu_count.yaml rename to src/plugin/metrics/ContainerInstances/Container/vcpu_count.yaml diff --git a/src/spaceone/inventory/metrics/CosmosDB/Instance/instance_count.yaml b/src/plugin/metrics/CosmosDB/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/CosmosDB/Instance/instance_count.yaml rename to src/plugin/metrics/CosmosDB/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/CosmosDB/Instance/namespace.yaml b/src/plugin/metrics/CosmosDB/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/CosmosDB/Instance/namespace.yaml rename to src/plugin/metrics/CosmosDB/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/CosmosDB/Instance/sql_database_count.yaml b/src/plugin/metrics/CosmosDB/Instance/sql_database_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/CosmosDB/Instance/sql_database_count.yaml rename to src/plugin/metrics/CosmosDB/Instance/sql_database_count.yaml diff --git a/src/spaceone/inventory/metrics/Disks/Disk/disk_count.yaml b/src/plugin/metrics/Disks/Disk/disk_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Disks/Disk/disk_count.yaml rename to src/plugin/metrics/Disks/Disk/disk_count.yaml diff --git a/src/spaceone/inventory/metrics/Disks/Disk/disk_size.yaml b/src/plugin/metrics/Disks/Disk/disk_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Disks/Disk/disk_size.yaml rename to src/plugin/metrics/Disks/Disk/disk_size.yaml diff --git a/src/spaceone/inventory/metrics/Disks/Disk/namespace.yaml b/src/plugin/metrics/Disks/Disk/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Disks/Disk/namespace.yaml rename to src/plugin/metrics/Disks/Disk/namespace.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/certificates_count.yaml b/src/plugin/metrics/KeyVaults/Instance/certificates_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/certificates_count.yaml rename to src/plugin/metrics/KeyVaults/Instance/certificates_count.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/credentials_count.yaml b/src/plugin/metrics/KeyVaults/Instance/credentials_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/credentials_count.yaml rename to src/plugin/metrics/KeyVaults/Instance/credentials_count.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/instance_count.yaml b/src/plugin/metrics/KeyVaults/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/instance_count.yaml rename to src/plugin/metrics/KeyVaults/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/key_count.yaml b/src/plugin/metrics/KeyVaults/Instance/key_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/key_count.yaml rename to src/plugin/metrics/KeyVaults/Instance/key_count.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/namespace.yaml b/src/plugin/metrics/KeyVaults/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/namespace.yaml rename to src/plugin/metrics/KeyVaults/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/KeyVaults/Instance/secret_count.yaml b/src/plugin/metrics/KeyVaults/Instance/secret_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/KeyVaults/Instance/secret_count.yaml rename to src/plugin/metrics/KeyVaults/Instance/secret_count.yaml diff --git a/src/spaceone/inventory/metrics/LoadBalancers/Instance/instance_count.yaml b/src/plugin/metrics/LoadBalancers/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/LoadBalancers/Instance/instance_count.yaml rename to src/plugin/metrics/LoadBalancers/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/LoadBalancers/Instance/namespace.yaml b/src/plugin/metrics/LoadBalancers/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/LoadBalancers/Instance/namespace.yaml rename to src/plugin/metrics/LoadBalancers/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/MySQLServers/Server/namespace.yaml b/src/plugin/metrics/MySQLServers/FlexibleServer/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/MySQLServers/Server/namespace.yaml rename to src/plugin/metrics/MySQLServers/FlexibleServer/namespace.yaml diff --git a/src/spaceone/inventory/metrics/MySQLServers/Server/server_count.yaml b/src/plugin/metrics/MySQLServers/FlexibleServer/server_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/MySQLServers/Server/server_count.yaml rename to src/plugin/metrics/MySQLServers/FlexibleServer/server_count.yaml diff --git a/src/plugin/metrics/MySQLServers/Server/namespace.yaml b/src/plugin/metrics/MySQLServers/Server/namespace.yaml new file mode 100644 index 00000000..fc075c5b --- /dev/null +++ b/src/plugin/metrics/MySQLServers/Server/namespace.yaml @@ -0,0 +1,8 @@ +--- +namespace_id: ns-azure-mysql-servers-server +name: MySQLServers/Server +resource_type: inventory.CloudService:azure.MySQLServers.Server +group: azure +category: ASSET +icon: https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure/azure-mysql-servers.svg +version: '1.0' diff --git a/src/plugin/metrics/MySQLServers/Server/server_count.yaml b/src/plugin/metrics/MySQLServers/Server/server_count.yaml new file mode 100644 index 00000000..852f3834 --- /dev/null +++ b/src/plugin/metrics/MySQLServers/Server/server_count.yaml @@ -0,0 +1,29 @@ +--- +metric_id: metric-azure-mysql-servers-server-count +name: Server Count +metric_type: GAUGE +resource_type: inventory.CloudService:azure.MySQLServers.Server +query_options: + group_by: + - key: region_code + name: Region + reference: + resource_type: inventory.Region + reference_key: region_code + - key: data.tenant_id + name: Tenant ID + - key: data.subscription_name + name: Subscription Name + - key: account + name: Subscription ID + - key: data.resource_group + name: Resource Group + - key: data.provisioning_state + name: Provisioning State + default: true + fields: + value: + operator: count +unit: Count +namespace_id: ns-azure-mysql-servers-server +version: '1.0' \ No newline at end of file diff --git a/src/spaceone/inventory/metrics/NATGateways/Instance/instance_count.yaml b/src/plugin/metrics/NATGateways/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/NATGateways/Instance/instance_count.yaml rename to src/plugin/metrics/NATGateways/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/NATGateways/Instance/namespace.yaml b/src/plugin/metrics/NATGateways/Instance/namespace.yaml similarity index 85% rename from src/spaceone/inventory/metrics/NATGateways/Instance/namespace.yaml rename to src/plugin/metrics/NATGateways/Instance/namespace.yaml index dc841110..65ddbf55 100644 --- a/src/spaceone/inventory/metrics/NATGateways/Instance/namespace.yaml +++ b/src/plugin/metrics/NATGateways/Instance/namespace.yaml @@ -1,5 +1,5 @@ --- -namespace_id: ns-azure-nat-gateways-instance +namespace_id: ns-azure-nat-gateways-Instance name: NATGateways/Instance resource_type: inventory.CloudService:azure.NATGateways.Instance group: azure diff --git a/src/spaceone/inventory/metrics/NetworkSecurityGroups/Instance/instance_count.yaml b/src/plugin/metrics/NetworkSecurityGroups/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/NetworkSecurityGroups/Instance/instance_count.yaml rename to src/plugin/metrics/NetworkSecurityGroups/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/NetworkSecurityGroups/Instance/namespace.yaml b/src/plugin/metrics/NetworkSecurityGroups/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/NetworkSecurityGroups/Instance/namespace.yaml rename to src/plugin/metrics/NetworkSecurityGroups/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/PostgreSQLServers/Server/namespace.yaml b/src/plugin/metrics/PostgreSQLServers/FlexibleServer/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/PostgreSQLServers/Server/namespace.yaml rename to src/plugin/metrics/PostgreSQLServers/FlexibleServer/namespace.yaml diff --git a/src/spaceone/inventory/metrics/PostgreSQLServers/Server/server_count.yaml b/src/plugin/metrics/PostgreSQLServers/FlexibleServer/server_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/PostgreSQLServers/Server/server_count.yaml rename to src/plugin/metrics/PostgreSQLServers/FlexibleServer/server_count.yaml diff --git a/src/plugin/metrics/PostgreSQLServers/Server/namespace.yaml b/src/plugin/metrics/PostgreSQLServers/Server/namespace.yaml new file mode 100644 index 00000000..cd6ff421 --- /dev/null +++ b/src/plugin/metrics/PostgreSQLServers/Server/namespace.yaml @@ -0,0 +1,8 @@ +--- +namespace_id: ns-azure-postgresql-servers-server +name: PostgreSQL/Server +resource_type: inventory.CloudService:azure.PostgreSQLServers.Server +group: azure +category: ASSET +icon: https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure/azure-sql-postgresql-server.svg +version: '1.0' diff --git a/src/plugin/metrics/PostgreSQLServers/Server/server_count.yaml b/src/plugin/metrics/PostgreSQLServers/Server/server_count.yaml new file mode 100644 index 00000000..2b3cee47 --- /dev/null +++ b/src/plugin/metrics/PostgreSQLServers/Server/server_count.yaml @@ -0,0 +1,29 @@ +--- +metric_id: metric-azure-postgersql-servers-server-count +name: Server Count +metric_type: GAUGE +resource_type: inventory.CloudService:azure.PostgreSQLServers.Server +query_options: + group_by: + - key: region_code + name: Region + reference: + resource_type: inventory.Region + reference_key: region_code + - key: data.tenant_id + name: Tenant ID + - key: data.subscription_name + name: Subscription Name + - key: account + name: Subscription ID + - key: data.resource_group + name: Resource Group + - key: data.provisioning_state + name: Provisioning State + default: true + fields: + value: + operator: count +unit: Count +namespace_id: ns-azure-postgresql-servers-server +version: '1.0' \ No newline at end of file diff --git a/src/spaceone/inventory/metrics/PublicIPAddresses/IpAddress/ip_addresses_count.yaml b/src/plugin/metrics/PublicIPAddresses/IPAddress/ip_addresses_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/PublicIPAddresses/IpAddress/ip_addresses_count.yaml rename to src/plugin/metrics/PublicIPAddresses/IPAddress/ip_addresses_count.yaml diff --git a/src/spaceone/inventory/metrics/PublicIPAddresses/IpAddress/namespace.yaml b/src/plugin/metrics/PublicIPAddresses/IPAddress/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/PublicIPAddresses/IpAddress/namespace.yaml rename to src/plugin/metrics/PublicIPAddresses/IPAddress/namespace.yaml diff --git a/src/spaceone/inventory/metrics/SQLDatabases/Database/database_count.yaml b/src/plugin/metrics/SQLDatabases/Database/database_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/SQLDatabases/Database/database_count.yaml rename to src/plugin/metrics/SQLDatabases/Database/database_count.yaml diff --git a/src/spaceone/inventory/metrics/SQLDatabases/Database/database_size.yaml b/src/plugin/metrics/SQLDatabases/Database/database_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/SQLDatabases/Database/database_size.yaml rename to src/plugin/metrics/SQLDatabases/Database/database_size.yaml diff --git a/src/spaceone/inventory/metrics/SQLDatabases/Database/namespace.yaml b/src/plugin/metrics/SQLDatabases/Database/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/SQLDatabases/Database/namespace.yaml rename to src/plugin/metrics/SQLDatabases/Database/namespace.yaml diff --git a/src/spaceone/inventory/metrics/SQLServers/Server/namespace.yaml b/src/plugin/metrics/SQLServers/Server/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/SQLServers/Server/namespace.yaml rename to src/plugin/metrics/SQLServers/Server/namespace.yaml diff --git a/src/spaceone/inventory/metrics/SQLServers/Server/server_count.yaml b/src/plugin/metrics/SQLServers/Server/server_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/SQLServers/Server/server_count.yaml rename to src/plugin/metrics/SQLServers/Server/server_count.yaml diff --git a/src/spaceone/inventory/metrics/Snapshots/Instance/instance_count.yaml b/src/plugin/metrics/Snapshots/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Snapshots/Instance/instance_count.yaml rename to src/plugin/metrics/Snapshots/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/Snapshots/Instance/instance_size.yaml b/src/plugin/metrics/Snapshots/Instance/instance_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Snapshots/Instance/instance_size.yaml rename to src/plugin/metrics/Snapshots/Instance/instance_size.yaml diff --git a/src/spaceone/inventory/metrics/Snapshots/Instance/namespace.yaml b/src/plugin/metrics/Snapshots/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/Snapshots/Instance/namespace.yaml rename to src/plugin/metrics/Snapshots/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/StorageAccounts/Instance/blob_count.yaml b/src/plugin/metrics/StorageAccounts/Instance/blob_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/StorageAccounts/Instance/blob_count.yaml rename to src/plugin/metrics/StorageAccounts/Instance/blob_count.yaml diff --git a/src/spaceone/inventory/metrics/StorageAccounts/Instance/blob_size.yaml b/src/plugin/metrics/StorageAccounts/Instance/blob_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/StorageAccounts/Instance/blob_size.yaml rename to src/plugin/metrics/StorageAccounts/Instance/blob_size.yaml diff --git a/src/spaceone/inventory/metrics/StorageAccounts/Instance/container_count.yaml b/src/plugin/metrics/StorageAccounts/Instance/container_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/StorageAccounts/Instance/container_count.yaml rename to src/plugin/metrics/StorageAccounts/Instance/container_count.yaml diff --git a/src/spaceone/inventory/metrics/StorageAccounts/Instance/instance_count.yaml b/src/plugin/metrics/StorageAccounts/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/StorageAccounts/Instance/instance_count.yaml rename to src/plugin/metrics/StorageAccounts/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/StorageAccounts/Instance/namespace.yaml b/src/plugin/metrics/StorageAccounts/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/StorageAccounts/Instance/namespace.yaml rename to src/plugin/metrics/StorageAccounts/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/VMScaleSets/ScaleSet/namespace.yaml b/src/plugin/metrics/VMScaleSets/ScaleSet/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VMScaleSets/ScaleSet/namespace.yaml rename to src/plugin/metrics/VMScaleSets/ScaleSet/namespace.yaml diff --git a/src/spaceone/inventory/metrics/VMScaleSets/ScaleSet/sacle_set_count.yaml b/src/plugin/metrics/VMScaleSets/ScaleSet/sacle_set_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VMScaleSets/ScaleSet/sacle_set_count.yaml rename to src/plugin/metrics/VMScaleSets/ScaleSet/sacle_set_count.yaml diff --git a/src/spaceone/inventory/metrics/VirtualMachines/Instance/instance_count.yaml b/src/plugin/metrics/VirtualMachines/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualMachines/Instance/instance_count.yaml rename to src/plugin/metrics/VirtualMachines/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/VirtualMachines/Instance/memory_size.yaml b/src/plugin/metrics/VirtualMachines/Instance/memory_size.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualMachines/Instance/memory_size.yaml rename to src/plugin/metrics/VirtualMachines/Instance/memory_size.yaml diff --git a/src/spaceone/inventory/metrics/VirtualMachines/Instance/namespace.yaml b/src/plugin/metrics/VirtualMachines/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualMachines/Instance/namespace.yaml rename to src/plugin/metrics/VirtualMachines/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/VirtualMachines/Instance/vcpu_count.yaml b/src/plugin/metrics/VirtualMachines/Instance/vcpu_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualMachines/Instance/vcpu_count.yaml rename to src/plugin/metrics/VirtualMachines/Instance/vcpu_count.yaml diff --git a/src/spaceone/inventory/metrics/VirtualNetworks/instance/instance_count.yaml b/src/plugin/metrics/VirtualNetworks/Instance/instance_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualNetworks/instance/instance_count.yaml rename to src/plugin/metrics/VirtualNetworks/Instance/instance_count.yaml diff --git a/src/spaceone/inventory/metrics/VirtualNetworks/instance/namespace.yaml b/src/plugin/metrics/VirtualNetworks/Instance/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/VirtualNetworks/instance/namespace.yaml rename to src/plugin/metrics/VirtualNetworks/Instance/namespace.yaml diff --git a/src/spaceone/inventory/metrics/WebPubSubService/Hub/hub_count.yaml b/src/plugin/metrics/WebPubSubService/Hub/hub_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/WebPubSubService/Hub/hub_count.yaml rename to src/plugin/metrics/WebPubSubService/Hub/hub_count.yaml diff --git a/src/spaceone/inventory/metrics/WebPubSubService/Hub/namespace.yaml b/src/plugin/metrics/WebPubSubService/Hub/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/WebPubSubService/Hub/namespace.yaml rename to src/plugin/metrics/WebPubSubService/Hub/namespace.yaml diff --git a/src/spaceone/inventory/metrics/WebPubSubService/Service/namespace.yaml b/src/plugin/metrics/WebPubSubService/Service/namespace.yaml similarity index 100% rename from src/spaceone/inventory/metrics/WebPubSubService/Service/namespace.yaml rename to src/plugin/metrics/WebPubSubService/Service/namespace.yaml diff --git a/src/spaceone/inventory/metrics/WebPubSubService/Service/service_count.yaml b/src/plugin/metrics/WebPubSubService/Service/service_count.yaml similarity index 100% rename from src/spaceone/inventory/metrics/WebPubSubService/Service/service_count.yaml rename to src/plugin/metrics/WebPubSubService/Service/service_count.yaml diff --git a/src/setup.py b/src/setup.py index 96eff2e2..a2789788 100644 --- a/src/setup.py +++ b/src/setup.py @@ -21,9 +21,9 @@ f.close() setup( - name="plugin-azure-cloud-services", + name="plugin-azure-inven-v2-collector-migration-test", version=VERSION, - description="MS Azure cloud service inventory collector", + description="MS Azure cloud service inventory v2 collector", long_description="", url="https://cloudforet.io/", author="Cloudforet Admin", @@ -32,28 +32,13 @@ packages=find_packages(), install_requires=[ "spaceone-api", - "schematics", - "adal", - "msrestazure", "azure-identity", "azure-mgmt-resource", - "azure-mgmt-compute", - "azure-mgmt-network", - "azure-mgmt-sql", - "azure-mgmt-monitor", - "azure-mgmt-storage", - "azure-mgmt-keyvault", - "azure-keyvault-certificates", - "azure-keyvault-secrets", - "azure-mgmt-rdbms", - "azure-mgmt-cosmosdb", - "azure-mgmt-containerinstance", - "azure-mgmt-webpubsub", ], package_data={ - "spaceone": [ - "inventory/model/*/widget/*.yaml", - "inventory/metrics/**/**/*.yaml", + "plugin": [ + "metadata/*/*.yaml", + "metrics/**/**/*.yaml", ] }, zip_safe=False, diff --git a/src/spaceone/__init__.py b/src/spaceone/__init__.py deleted file mode 100644 index 0260537a..00000000 --- a/src/spaceone/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/src/spaceone/inventory/__init__.py b/src/spaceone/inventory/__init__.py deleted file mode 100644 index 03e14242..00000000 --- a/src/spaceone/inventory/__init__.py +++ /dev/null @@ -1 +0,0 @@ -name = 'inventory' diff --git a/src/spaceone/inventory/conf/cloud_service_conf.py b/src/spaceone/inventory/conf/cloud_service_conf.py deleted file mode 100644 index 213486c0..00000000 --- a/src/spaceone/inventory/conf/cloud_service_conf.py +++ /dev/null @@ -1,33 +0,0 @@ -MAX_WORKER = 20 -SUPPORTED_FEATURES = ["garbage_collection"] -SUPPORTED_SCHEDULES = ["hours"] -SUPPORTED_RESOURCE_TYPE = [ - "inventory.CloudService", - "inventory.CloudServiceType", - "inventory.Region", -] -FILTER_FORMAT = [] - -ASSET_URL = "https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure" - -CLOUD_SERVICE_GROUP_MAP = { - "VirtualMachines": "VirtualMachinesManager", - "ApplicationGateways": "ApplicationGatewaysManager", - "ContainerInstances": "ContainerInstancesManager", - "CosmosDB": "CosmosDBManager", - "Disks": "DisksManager", - "KeyVaults": "KeyVaultsManager", - "LoadBalancers": "LoadBalancersManager", - "MySQLServers": "MySQLServersManager", - "SQLServers": "SQLServersManager", - "SQLDatabases": "SQLDatabasesManager", - "NATGateways": "NATGatewaysManager", - "NetworkSecurityGroups": "NetworkSecurityGroupsManager", - "PostgreSQLServers": "PostgreSQLServersManager", - "PublicIPAddresses": "PublicIPAddressesManager", - "Snapshots": "SnapshotsManager", - "StorageAccounts": "StorageAccountsManager", - "VirtualNetworks": "VirtualNetworksManager", - "VMScaleSets": "VmScaleSetsManager", - "WebPubSubService": "WebPubSubServiceManager", -} diff --git a/src/spaceone/inventory/conf/global_conf.py b/src/spaceone/inventory/conf/global_conf.py deleted file mode 100644 index 9f5fe214..00000000 --- a/src/spaceone/inventory/conf/global_conf.py +++ /dev/null @@ -1,23 +0,0 @@ -CONNECTORS = { - 'AzureConnector': { - 'backend': 'spaceone.inventory.libs.connector.AzureConnector', - }, -} - -LOG = { - 'filters': { - 'masking': { - 'rules': { - 'Collector.collect': [ - 'secret_data' - ] - } - } - } -} - -HANDLERS = { -} - -ENDPOINTS = { -} diff --git a/src/spaceone/inventory/conf/proto_conf.py b/src/spaceone/inventory/conf/proto_conf.py deleted file mode 100644 index 8b47c389..00000000 --- a/src/spaceone/inventory/conf/proto_conf.py +++ /dev/null @@ -1,3 +0,0 @@ -PROTO = { - 'spaceone.inventory.api.plugin.collector': ['Collector'] -} diff --git a/src/spaceone/inventory/connector/__init__.py b/src/spaceone/inventory/connector/__init__.py deleted file mode 100644 index f115e398..00000000 --- a/src/spaceone/inventory/connector/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -from spaceone.inventory.connector.disks import DisksConnector -from spaceone.inventory.connector.subscriptions import SubscriptionsConnector -from spaceone.inventory.connector.snapshots import SnapshotsConnector -from spaceone.inventory.connector.vm_scale_sets import VmScaleSetsConnector -from spaceone.inventory.connector.load_balancers import LoadBalancersConnector -from spaceone.inventory.connector.monitor import MonitorConnector -from spaceone.inventory.connector.virtual_networks import VirtualNetworksConnector -from spaceone.inventory.connector.application_gateways import ( - ApplicationGatewaysConnector, -) -from spaceone.inventory.connector.public_ip_addresses import PublicIPAddressesConnector -from spaceone.inventory.connector.network_security_groups import ( - NetworkSecurityGroupsConnector, -) -from spaceone.inventory.connector.nat_gateways import NATGatewaysConnector -from spaceone.inventory.connector.storage_accounts import StorageAccountsConnector -from spaceone.inventory.connector.key_vaults import KeyVaultsConnector -from spaceone.inventory.connector.mysql_servers import MySQLServersConnector -from spaceone.inventory.connector.cosmos_db import CosmosDBConnector -from spaceone.inventory.connector.postgresql_servers import PostgreSQLServersConnector -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector -from spaceone.inventory.connector.sql_servers import SQLServersConnector -from spaceone.inventory.connector.sql_databases import SQLDatabasesConnector -from spaceone.inventory.connector.container_instances import ContainerInstancesConnector -from spaceone.inventory.connector.web_pubsub_service import WebPubSubServiceConnector -from spaceone.inventory.connector.resources import ResourcesConnector diff --git a/src/spaceone/inventory/connector/application_gateways/__init__.py b/src/spaceone/inventory/connector/application_gateways/__init__.py deleted file mode 100644 index ab761c67..00000000 --- a/src/spaceone/inventory/connector/application_gateways/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.application_gateways.connector import ApplicationGatewaysConnector diff --git a/src/spaceone/inventory/connector/container_instances/__init__.py b/src/spaceone/inventory/connector/container_instances/__init__.py deleted file mode 100644 index 365e445f..00000000 --- a/src/spaceone/inventory/connector/container_instances/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.container_instances.connector import ContainerInstancesConnector \ No newline at end of file diff --git a/src/spaceone/inventory/connector/cosmos_db/__init__.py b/src/spaceone/inventory/connector/cosmos_db/__init__.py deleted file mode 100644 index 5c953b3c..00000000 --- a/src/spaceone/inventory/connector/cosmos_db/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.cosmos_db.connector import CosmosDBConnector diff --git a/src/spaceone/inventory/connector/disks/__init__.py b/src/spaceone/inventory/connector/disks/__init__.py deleted file mode 100644 index ffe994ec..00000000 --- a/src/spaceone/inventory/connector/disks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.disks.connector import DisksConnector diff --git a/src/spaceone/inventory/connector/disks/connector.py b/src/spaceone/inventory/connector/disks/connector.py deleted file mode 100644 index 7e8ab93b..00000000 --- a/src/spaceone/inventory/connector/disks/connector.py +++ /dev/null @@ -1,17 +0,0 @@ -import logging - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * -from spaceone.inventory.error.custom import * -__all__ = ['DisksConnector'] -_LOGGER = logging.getLogger(__name__) - - -class DisksConnector(AzureConnector): - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.set_connect(kwargs.get('secret_data')) - - def list_disks(self): - return self.compute_client.disks.list() diff --git a/src/spaceone/inventory/connector/key_vaults/__init__.py b/src/spaceone/inventory/connector/key_vaults/__init__.py deleted file mode 100644 index 85ef27b4..00000000 --- a/src/spaceone/inventory/connector/key_vaults/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.key_vaults.connector import KeyVaultsConnector diff --git a/src/spaceone/inventory/connector/load_balancers/__init__.py b/src/spaceone/inventory/connector/load_balancers/__init__.py deleted file mode 100644 index d0cba497..00000000 --- a/src/spaceone/inventory/connector/load_balancers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.load_balancers.connector import LoadBalancersConnector diff --git a/src/spaceone/inventory/connector/monitor/__init__.py b/src/spaceone/inventory/connector/monitor/__init__.py deleted file mode 100644 index bb96c8c2..00000000 --- a/src/spaceone/inventory/connector/monitor/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.monitor.connector import MonitorConnector diff --git a/src/spaceone/inventory/connector/mysql_servers/__init__.py b/src/spaceone/inventory/connector/mysql_servers/__init__.py deleted file mode 100644 index 57c79cc4..00000000 --- a/src/spaceone/inventory/connector/mysql_servers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.mysql_servers.connector import MySQLServersConnector \ No newline at end of file diff --git a/src/spaceone/inventory/connector/nat_gateways/__init__.py b/src/spaceone/inventory/connector/nat_gateways/__init__.py deleted file mode 100644 index 7916f095..00000000 --- a/src/spaceone/inventory/connector/nat_gateways/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.nat_gateways.connector import NATGatewaysConnector diff --git a/src/spaceone/inventory/connector/network_security_groups/__init__.py b/src/spaceone/inventory/connector/network_security_groups/__init__.py deleted file mode 100644 index d58bcd6f..00000000 --- a/src/spaceone/inventory/connector/network_security_groups/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.network_security_groups.connector import NetworkSecurityGroupsConnector diff --git a/src/spaceone/inventory/connector/postgresql_servers/__init__.py b/src/spaceone/inventory/connector/postgresql_servers/__init__.py deleted file mode 100644 index 8352c38a..00000000 --- a/src/spaceone/inventory/connector/postgresql_servers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.postgresql_servers.connector import PostgreSQLServersConnector diff --git a/src/spaceone/inventory/connector/public_ip_addresses/__init__.py b/src/spaceone/inventory/connector/public_ip_addresses/__init__.py deleted file mode 100644 index 9506c9de..00000000 --- a/src/spaceone/inventory/connector/public_ip_addresses/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.public_ip_addresses.connector import PublicIPAddressesConnector diff --git a/src/spaceone/inventory/connector/public_ip_addresses/connector.py b/src/spaceone/inventory/connector/public_ip_addresses/connector.py deleted file mode 100644 index 113c9c23..00000000 --- a/src/spaceone/inventory/connector/public_ip_addresses/connector.py +++ /dev/null @@ -1,19 +0,0 @@ -import logging - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * -from spaceone.inventory.error.custom import * - -__all__ = ['PublicIPAddressesConnector'] -_LOGGER = logging.getLogger(__name__) - - -class PublicIPAddressesConnector(AzureConnector): - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.set_connect(kwargs.get('secret_data')) - - def list_all_public_ip_addresses(self): - return self.network_client.public_ip_addresses.list_all() - diff --git a/src/spaceone/inventory/connector/resources/__init__.py b/src/spaceone/inventory/connector/resources/__init__.py deleted file mode 100644 index a9bfc517..00000000 --- a/src/spaceone/inventory/connector/resources/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.resources.connector import ResourcesConnector diff --git a/src/spaceone/inventory/connector/resources/connector.py b/src/spaceone/inventory/connector/resources/connector.py deleted file mode 100644 index 042cccc7..00000000 --- a/src/spaceone/inventory/connector/resources/connector.py +++ /dev/null @@ -1,16 +0,0 @@ -import logging - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * - -__all__ = ["ResourcesConnector"] -_LOGGER = logging.getLogger(__name__) - - -class ResourcesConnector(AzureConnector): - def __init__(self, **kwargs): - super().__init__() - self.set_connect(kwargs.get("secret_data")) - - def list_resources(self) -> list: - return self.resource_client.resources.list() diff --git a/src/spaceone/inventory/connector/snapshots/__init__.py b/src/spaceone/inventory/connector/snapshots/__init__.py deleted file mode 100644 index fb929336..00000000 --- a/src/spaceone/inventory/connector/snapshots/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.snapshots.connector import SnapshotsConnector diff --git a/src/spaceone/inventory/connector/snapshots/connector.py b/src/spaceone/inventory/connector/snapshots/connector.py deleted file mode 100644 index 2ae34560..00000000 --- a/src/spaceone/inventory/connector/snapshots/connector.py +++ /dev/null @@ -1,17 +0,0 @@ -import logging - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * -from spaceone.inventory.error.custom import * -__all__ = ['SnapshotsConnector'] -_LOGGER = logging.getLogger(__name__) - - -class SnapshotsConnector(AzureConnector): - - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.set_connect(kwargs.get('secret_data')) - - def list_snapshots(self): - return self.compute_client.snapshots.list() diff --git a/src/spaceone/inventory/connector/sql_databases/__init__.py b/src/spaceone/inventory/connector/sql_databases/__init__.py deleted file mode 100644 index 7a3fa935..00000000 --- a/src/spaceone/inventory/connector/sql_databases/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.sql_databases.connector import SQLDatabasesConnector diff --git a/src/spaceone/inventory/connector/sql_servers/__init__.py b/src/spaceone/inventory/connector/sql_servers/__init__.py deleted file mode 100644 index 80e74dda..00000000 --- a/src/spaceone/inventory/connector/sql_servers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.sql_servers.connector import SQLServersConnector diff --git a/src/spaceone/inventory/connector/storage_accounts/__init__.py b/src/spaceone/inventory/connector/storage_accounts/__init__.py deleted file mode 100644 index 0aeda247..00000000 --- a/src/spaceone/inventory/connector/storage_accounts/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.storage_accounts.connector import StorageAccountsConnector diff --git a/src/spaceone/inventory/connector/subscriptions/__init__.py b/src/spaceone/inventory/connector/subscriptions/__init__.py deleted file mode 100644 index 0e17f88a..00000000 --- a/src/spaceone/inventory/connector/subscriptions/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.subscriptions.connector import SubscriptionsConnector diff --git a/src/spaceone/inventory/connector/subscriptions/connector.py b/src/spaceone/inventory/connector/subscriptions/connector.py deleted file mode 100644 index dd4ef91b..00000000 --- a/src/spaceone/inventory/connector/subscriptions/connector.py +++ /dev/null @@ -1,20 +0,0 @@ -import logging - -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.error import * - -__all__ = ['SubscriptionsConnector'] -_LOGGER = logging.getLogger(__name__) - - -class SubscriptionsConnector(AzureConnector): - - def __init__(self, **kwargs): - super().__init__() - self.set_connect(kwargs.get('secret_data')) - - def get_subscription_info(self, subscription_id): - return self.subscription_client.subscriptions.get(subscription_id) - - def list_location_info(self, subscription_id): - return self.subscription_client.subscriptions.list_locations(subscription_id) diff --git a/src/spaceone/inventory/connector/virtual_machines/__init__.py b/src/spaceone/inventory/connector/virtual_machines/__init__.py deleted file mode 100644 index 1d16d2db..00000000 --- a/src/spaceone/inventory/connector/virtual_machines/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.virtual_machines.connector import VirtualMachinesConnector diff --git a/src/spaceone/inventory/connector/virtual_networks/__init__.py b/src/spaceone/inventory/connector/virtual_networks/__init__.py deleted file mode 100644 index ae6d5ec0..00000000 --- a/src/spaceone/inventory/connector/virtual_networks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.virtual_networks.connector import VirtualNetworksConnector diff --git a/src/spaceone/inventory/connector/vm_scale_sets/__init__.py b/src/spaceone/inventory/connector/vm_scale_sets/__init__.py deleted file mode 100644 index e5b0b6ab..00000000 --- a/src/spaceone/inventory/connector/vm_scale_sets/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.vm_scale_sets.connector import VmScaleSetsConnector diff --git a/src/spaceone/inventory/connector/web_pubsub_service/__init__.py b/src/spaceone/inventory/connector/web_pubsub_service/__init__.py deleted file mode 100644 index e7f37c08..00000000 --- a/src/spaceone/inventory/connector/web_pubsub_service/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from spaceone.inventory.connector.web_pubsub_service.connector import WebPubSubServiceConnector \ No newline at end of file diff --git a/src/spaceone/inventory/error/__init__.py b/src/spaceone/inventory/error/__init__.py deleted file mode 100644 index 47e6a897..00000000 --- a/src/spaceone/inventory/error/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -import inspect, pkgutil - -__all__ = [] - -for loader, module_name, is_pkg in pkgutil.walk_packages(__path__): - module = loader.find_module(module_name).load_module(module_name) - if hasattr(module, '__all__'): - for target in getattr(module, '__all__'): - globals()[target] = getattr(module, target) - __all__.append(target) - else: - for name, object in inspect.getmembers(module): - if inspect.isclass(object) or inspect.isfunction(object): - globals()[name] = object - __all__.append(name) diff --git a/src/spaceone/inventory/error/custom.py b/src/spaceone/inventory/error/custom.py deleted file mode 100644 index c3d9ff0c..00000000 --- a/src/spaceone/inventory/error/custom.py +++ /dev/null @@ -1,56 +0,0 @@ -from spaceone.core.error import ERROR_BASE - - -class ERROR_REPOSITORY_BACKEND(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Repository backend has problem. ({host})' - - -class ERROR_DRIVER(ERROR_BASE): - status_code = 'INTERNAL' - message = '{message}' - - -class ERROR_NOT_INITIALIZED_EXCEPTION(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Collector is not initialized. Please call initialize() method before using it.' - - -class ERROR_CONNECTOR_INITIALIZE(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Connector is failed to initialized. Connector = {field}.' - - -class ERROR_CONNECTOR(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Connector is failed to connect. Connector = {field}.' - - -class ERROR_KEY_VAULTS(ERROR_BASE): - status_code = 'INTERNAL' - message = 'KeyVault manager is failed to get sub resources. {field}.' - - -class ERROR_KEY_VAULTS_PERMISSION(ERROR_BASE): - status_code = 'INTERNAL' - message = 'KeyVault secret and certification information is failed. Please check the permission.' - - -class ERROR_PARSE_ID_FROM_RESOURCE_GROUP(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Parse resource name from resource ID is failed. Please check the variation.' - - -class ERROR_MANAGER_GET_ADDITIONAL_RESOURCE_INFO(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Get an additional information of the resource is failed. Please check the variation. Manager = {field}' - - -class ERROR_GET_RESOURCE_NAME_FROM_ID(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Get resource name from id is failed. field = {e}.' - - -class ERROR_CONNECTOR_GET_ADDITIONAL_RESOURCE_INFO(ERROR_BASE): - status_code = 'INTERNAL' - message = 'Get an additional information of the resource is failed. Please check the variation. Connector = {field}' diff --git a/src/spaceone/inventory/info/__init__.py b/src/spaceone/inventory/info/__init__.py deleted file mode 100644 index 93b875f7..00000000 --- a/src/spaceone/inventory/info/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from spaceone.inventory.info.collector_info import * -from spaceone.inventory.info.job_info import * -from spaceone.inventory.info.common_info import * diff --git a/src/spaceone/inventory/info/collector_info.py b/src/spaceone/inventory/info/collector_info.py deleted file mode 100644 index f073c936..00000000 --- a/src/spaceone/inventory/info/collector_info.py +++ /dev/null @@ -1,24 +0,0 @@ -__all__ = ['PluginInfo', 'ResourceInfo'] - -import functools -from spaceone.api.inventory.plugin import collector_pb2 -from spaceone.core.pygrpc.message_type import * - - -def PluginInfo(result): - result['metadata'] = change_struct_type(result['metadata']) - return collector_pb2.PluginInfo(**result) - - -def ResourceInfo(resource_dict): - if 'resource' in resource_dict: - resource_dict.update({ - 'resource': change_struct_type(resource_dict['resource']) - }) - - if 'match_rules' in resource_dict: - resource_dict.update({ - 'match_rules': change_struct_type(resource_dict['match_rules']) - }) - - return collector_pb2.ResourceInfo(**resource_dict) diff --git a/src/spaceone/inventory/info/common_info.py b/src/spaceone/inventory/info/common_info.py deleted file mode 100644 index ae10b58c..00000000 --- a/src/spaceone/inventory/info/common_info.py +++ /dev/null @@ -1,7 +0,0 @@ -__all__ = ['EmptyInfo'] - -from google.protobuf.empty_pb2 import Empty - -def EmptyInfo(): - return Empty() - diff --git a/src/spaceone/inventory/info/job_info.py b/src/spaceone/inventory/info/job_info.py deleted file mode 100644 index 18f24ab8..00000000 --- a/src/spaceone/inventory/info/job_info.py +++ /dev/null @@ -1,18 +0,0 @@ -__all__ = ["TasksInfo", "TaskInfo"] - -import functools -from spaceone.api.inventory.plugin import job_pb2 -from spaceone.core.pygrpc.message_type import * - - -def TaskInfo(task_data): - info = {"task_options": change_struct_type(task_data["task_options"])} - return job_pb2.TaskInfo(**info) - - -def TasksInfo(result, **kwargs): - tasks_data = result.get("tasks", []) - - return job_pb2.TasksInfo( - tasks=list(map(functools.partial(TaskInfo, **kwargs), tasks_data)), - ) diff --git a/src/spaceone/inventory/interface/grpc/__init__.py b/src/spaceone/inventory/interface/grpc/__init__.py deleted file mode 100644 index edf6ec13..00000000 --- a/src/spaceone/inventory/interface/grpc/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from spaceone.core.pygrpc.server import GRPCServer -from spaceone.inventory.interface.grpc.collector import Collector -from spaceone.inventory.interface.grpc.job import Job - -_all_ = ["app"] - -app = GRPCServer() -app.add_service(Collector) -app.add_service(Job) diff --git a/src/spaceone/inventory/interface/grpc/collector.py b/src/spaceone/inventory/interface/grpc/collector.py deleted file mode 100644 index 05b6ddef..00000000 --- a/src/spaceone/inventory/interface/grpc/collector.py +++ /dev/null @@ -1,41 +0,0 @@ -from spaceone.api.inventory.plugin import collector_pb2_grpc, collector_pb2 -from spaceone.core.pygrpc import BaseAPI -from spaceone.core.pygrpc.message_type import * -from spaceone.inventory.service import CollectorService -import traceback -import logging - -_LOGGER = logging.getLogger(__name__) - - -class Collector(BaseAPI, collector_pb2_grpc.CollectorServicer): - pb2 = collector_pb2 - pb2_grpc = collector_pb2_grpc - - def init(self, request, context): - params, metadata = self.parse_request(request, context) - - with self.locator.get_service("CollectorService", metadata) as collector_svc: - data = collector_svc.init(params) - return self.locator.get_info("PluginInfo", data) - - def verify(self, request, context): - params, metadata = self.parse_request(request, context) - - collector_svc: CollectorService = self.locator.get_service( - "CollectorService", metadata - ) - - with collector_svc: - collector_svc.verify(params) - return self.locator.get_info("EmptyInfo") - - def collect(self, request, context): - params, metadata = self.parse_request(request, context) - collector_svc: CollectorService = self.locator.get_service( - "CollectorService", metadata - ) - - with collector_svc: - for resource in collector_svc.collect(params): - yield self.locator.get_info("ResourceInfo", resource) diff --git a/src/spaceone/inventory/interface/grpc/job.py b/src/spaceone/inventory/interface/grpc/job.py deleted file mode 100644 index df496f25..00000000 --- a/src/spaceone/inventory/interface/grpc/job.py +++ /dev/null @@ -1,19 +0,0 @@ -from spaceone.api.inventory.plugin import job_pb2_grpc, job_pb2 -from spaceone.core.pygrpc import BaseAPI -from spaceone.core.pygrpc.message_type import * -from spaceone.inventory.service import JobService -import traceback -import logging - -_LOGGER = logging.getLogger(__name__) - - -class Job(BaseAPI, job_pb2_grpc.JobServicer): - pb2 = job_pb2 - pb2_grpc = job_pb2_grpc - - def get_tasks(self, request, context): - params, metadata = self.parse_request(request, context) - - with self.locator.get_service("JobService", metadata) as job_svc: - return self.locator.get_info("TasksInfo", job_svc.get_tasks(params)) diff --git a/src/spaceone/inventory/libs/__init__.py b/src/spaceone/inventory/libs/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/src/spaceone/inventory/libs/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/spaceone/inventory/libs/connector.py b/src/spaceone/inventory/libs/connector.py deleted file mode 100644 index c92ff1e7..00000000 --- a/src/spaceone/inventory/libs/connector.py +++ /dev/null @@ -1,107 +0,0 @@ -import os -import logging - -from azure.identity import DefaultAzureCredential -from azure.mgmt.compute import ComputeManagementClient -from azure.mgmt.resource import ResourceManagementClient -from azure.mgmt.resource import SubscriptionClient -from azure.mgmt.network import NetworkManagementClient -from azure.mgmt.sql import SqlManagementClient -from azure.mgmt.monitor import MonitorManagementClient -from azure.mgmt.storage import StorageManagementClient -from azure.mgmt.keyvault import KeyVaultManagementClient -from azure.mgmt.rdbms.mysql import MySQLManagementClient -from azure.mgmt.cosmosdb import CosmosDBManagementClient -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 - -DEFAULT_SCHEMA = "azure_client_secret" -_LOGGER = logging.getLogger(__name__) - - -class AzureConnector(BaseConnector): - def __init__(self, *args, **kwargs): - """ - kwargs - - schema - - options - - secret_data - - secret_data(dict) - - type: .. - - project_id: ... - - token_uri: ... - - ... - """ - - super().__init__(*args, **kwargs) - self.compute_client = None - self.resource_client = None - self.subscription_client = None - self.network_client = None - self.sql_client = None - self.monitor_client = None - self.storage_client = None - self.blob_client = None - self.key_vault_client = None - self.mysql_client = None - self.cosmosdb_client = None - self.postgre_sql_client = None - self.container_instance_client = None - self.web_pubsub_service_client = None - - def set_connect(self, secret_data): - subscription_id = secret_data["subscription_id"] - - os.environ["AZURE_SUBSCRIPTION_ID"] = subscription_id - os.environ["AZURE_TENANT_ID"] = secret_data["tenant_id"] - os.environ["AZURE_CLIENT_ID"] = secret_data["client_id"] - os.environ["AZURE_CLIENT_SECRET"] = secret_data["client_secret"] - - credential = DefaultAzureCredential() - - self.compute_client = ComputeManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.resource_client = ResourceManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.network_client = NetworkManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.subscription_client: SubscriptionClient = SubscriptionClient( - credential=credential - ) - self.sql_client = SqlManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.monitor_client = MonitorManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.storage_client = StorageManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.key_vault_client = KeyVaultManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.mysql_client = MySQLManagementClient( - credential=credential, subscription_id=subscription_id - ) - self.cosmosdb_client = CosmosDBManagementClient( - credential=credential, subscription_id=subscription_id - ) - 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 - ) - - def verify(self, **kwargs): - self.set_connect(kwargs["secret_data"]) - return "ACTIVE" diff --git a/src/spaceone/inventory/libs/manager.py b/src/spaceone/inventory/libs/manager.py deleted file mode 100644 index 75e91033..00000000 --- a/src/spaceone/inventory/libs/manager.py +++ /dev/null @@ -1,233 +0,0 @@ -import logging -import json -import os - -from spaceone.core.manager import BaseManager -from spaceone.inventory.libs.connector import AzureConnector -from spaceone.inventory.libs.schema.region import RegionResource, RegionResponse -from spaceone.inventory.libs.schema.resource import RegionResourceResponse -from spaceone.inventory.libs.schema.resource import ErrorResourceResponse -from spaceone.inventory.error.custom import * -from collections.abc import Iterable - -_LOGGER = logging.getLogger(__name__) - - -class AzureManager(BaseManager): - connector_name = None - cloud_service_types = [] - response_schema = None - collected_region_codes = [] - region_info = {} - - def verify(self, options, secret_data, **kwargs): - """Check collector's status.""" - connector = AzureConnector() - params = {"secret_data": secret_data} - connector.verify(**params) - - def collect_cloud_service_type(self, params): - options = params.get("options", {}) - - for cloud_service_type in self.cloud_service_types: - if "service_code_mappers" in options: - svc_code_maps = options["service_code_mappers"] - if ( - getattr(cloud_service_type.resource, "service_code") - and cloud_service_type.resource.service_code in svc_code_maps - ): - cloud_service_type.resource.service_code = svc_code_maps[ - cloud_service_type.resource.service_code - ] - - if "custom_asset_url" in options: - _tags = cloud_service_type.resource.tags - - if "spaceone:icon" in _tags: - _icon = _tags["spaceone:icon"] - _tags[ - "spaceone:icon" - ] = f'{options["custom_asset_url"]}/{_icon.split("/")[-1]}' - - yield cloud_service_type - - def collect_cloud_service(self, params) -> list: - raise NotImplemented - - def collect_resources(self, params) -> list: - total_resources = [] - - try: - subscription_manager = self.locator.get_manager("SubscriptionsManager") - self.region_info = subscription_manager.list_location_info(params) - - total_resources.extend(self.collect_cloud_service_type(params)) - resources, error_resources = self.collect_cloud_service(params) - - total_resources.extend(resources) - total_resources.extend(error_resources) - - regions = self.collect_region() - total_resources.extend(regions) - - except Exception as e: - error_resource_response = self.generate_error_response( - e, - self.cloud_service_types[0].resource.group, - self.cloud_service_types[0].resource.name, - ) - total_resources.append(error_resource_response) - _LOGGER.error(f"[collect] {e}", exc_info=True) - - return total_resources - - def collect_region(self): - results = [] - try: - for region_code in self.collected_region_codes: - if region := self.match_region_info(region_code): - results.append(RegionResourceResponse({"resource": region})) - - except Exception as e: - _LOGGER.error(f"[collect] {e}", exc_info=True) - - if type(e) is dict: - error_resource_response = ErrorResourceResponse( - { - "message": json.dumps(e), - "resource": {"resource_type": "inventory.Region"}, - } - ) - else: - error_resource_response = ErrorResourceResponse( - { - "message": str(e), - "resource": {"resource_type": "inventory.Region"}, - } - ) - results.append(error_resource_response) - - return results - - def set_region_code(self, region): - if region not in self.region_info: - region = "global" - - if region not in self.collected_region_codes: - self.collected_region_codes.append(region) - - def convert_nested_dictionary(self, cloud_svc_object): - cloud_svc_dict = {} - if hasattr( - cloud_svc_object, "__dict__" - ): # if cloud_svc_object is not a dictionary type but has dict method - cloud_svc_dict = cloud_svc_object.__dict__ - elif isinstance(cloud_svc_object, dict): - cloud_svc_dict = cloud_svc_object - elif not isinstance( - cloud_svc_object, list - ): # if cloud_svc_object is one of type like int, float, char, ... - return cloud_svc_object - - # if cloud_svc_object is dictionary type - for key, value in cloud_svc_dict.items(): - if hasattr(value, "__dict__") or isinstance(value, dict): - cloud_svc_dict[key] = self.convert_nested_dictionary(value) - if "azure" in str(type(value)): - cloud_svc_dict[key] = self.convert_nested_dictionary(value) - elif isinstance(value, list): - value_list = [] - for v in value: - value_list.append(self.convert_nested_dictionary(v)) - cloud_svc_dict[key] = value_list - - return cloud_svc_dict - - def match_region_info(self, region_code): - match_region_info = self.region_info.get(region_code) - - if match_region_info: - region_info = match_region_info.copy() - region_info.update({"region_code": region_code}) - return RegionResource(region_info, strict=False) - - return None - - @staticmethod - def convert_tag_format(tags): - convert_tags = [] - - if tags: - for k, v in tags.items(): - convert_tags.append({"key": k, "value": v}) - - return convert_tags - - @staticmethod - def convert_dictionary(obj): - return vars(obj) - - @staticmethod - def get_resource_group_from_id(dict_id): - resource_group = dict_id.split("/")[4] - return resource_group - - @staticmethod - def generate_error_response(e, cloud_service_group, cloud_service_type): - if type(e) is dict: - error_resource_response = ErrorResourceResponse( - { - "message": json.dumps(e), - "resource": { - "cloud_service_group": cloud_service_group, - "cloud_service_type": cloud_service_type, - }, - } - ) - else: - error_resource_response = ErrorResourceResponse( - { - "message": str(e), - "resource": { - "cloud_service_group": cloud_service_group, - "cloud_service_type": cloud_service_type, - }, - } - ) - return error_resource_response - - @staticmethod - def generate_resource_error_response( - e, cloud_service_group, cloud_service_type, resource_id - ): - if type(e) is dict: - error_resource_response = ErrorResourceResponse( - { - "message": json.dumps(e), - "resource": { - "cloud_service_group": cloud_service_group, - "cloud_service_type": cloud_service_type, - "resource_id": resource_id, - }, - } - ) - else: - error_resource_response = ErrorResourceResponse( - { - "message": str(e), - "resource": { - "cloud_service_group": cloud_service_group, - "cloud_service_type": cloud_service_type, - "resource_id": resource_id, - }, - } - ) - return error_resource_response - - @staticmethod - def update_tenant_id_from_secret_data( - cloud_service_data: dict, secret_data: dict - ) -> dict: - if tenant_id := secret_data.get("tenant_id"): - cloud_service_data.update({"tenant_id": tenant_id}) - return cloud_service_data diff --git a/src/spaceone/inventory/libs/schema/base.py b/src/spaceone/inventory/libs/schema/base.py deleted file mode 100644 index 085bb5dc..00000000 --- a/src/spaceone/inventory/libs/schema/base.py +++ /dev/null @@ -1,40 +0,0 @@ -from schematics import Model -from schematics.types import ListType, StringType, PolyModelType, DictType, ModelType -from spaceone.inventory.libs.schema.metadata.dynamic_layout import BaseLayoutField -from spaceone.inventory.libs.schema.metadata.dynamic_search import BaseDynamicSearch -from spaceone.inventory.libs.schema.metadata.dynamic_widget import BaseDynamicWidget - - -class MetaDataViewSubData(Model): - layouts = ListType(PolyModelType(BaseLayoutField)) - - -class MetaDataViewTable(Model): - layout = PolyModelType(BaseLayoutField) - - -class MetaDataView(Model): - table = PolyModelType(MetaDataViewTable, serialize_when_none=False) - sub_data = PolyModelType(MetaDataViewSubData, serialize_when_none=False) - search = ListType(PolyModelType(BaseDynamicSearch), serialize_when_none=False) - widget = ListType(PolyModelType(BaseDynamicWidget), serialize_when_none=False) - - -class BaseMetaData(Model): - view = ModelType(MetaDataView) - - -class BaseResponse(Model): - state = StringType(default='SUCCESS', choices=('SUCCESS', 'FAILURE', 'TIMEOUT')) - resource_type = StringType(required=True) - match_rules = DictType(ListType(StringType), default={}) - resource = PolyModelType(Model, default={}) - - -class ReferenceModel(Model): - class Option: - serialize_when_none = False - - resource_id = StringType(required=False, serialize_when_none=False) - external_link = StringType(required=False, serialize_when_none=False) - diff --git a/src/spaceone/inventory/libs/schema/cloud_service.py b/src/spaceone/inventory/libs/schema/cloud_service.py deleted file mode 100644 index 4d9a898e..00000000 --- a/src/spaceone/inventory/libs/schema/cloud_service.py +++ /dev/null @@ -1,45 +0,0 @@ -from schematics import Model -from schematics.types import ListType, StringType, PolyModelType, DictType, ModelType, IntType, DateTimeType, FloatType -from .base import BaseMetaData, BaseResponse, MetaDataView, MetaDataViewSubData, ReferenceModel - - -class CloudServiceMeta(BaseMetaData): - @classmethod - def set(cls): - sub_data = MetaDataViewSubData() - return cls({'view': MetaDataView({'sub_data': sub_data})}) - - @classmethod - def set_layouts(cls, layouts=[]): - sub_data = MetaDataViewSubData({'layouts': layouts}) - return cls({'view': MetaDataView({'sub_data': sub_data})}) - - -class Tags(Model): - key = StringType() - value = StringType() - - -class CloudServiceResource(Model): - provider = StringType(default="azure") - cloud_service_type = StringType() - cloud_service_group = StringType() - name = StringType(default='') - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - account = StringType(serialize_when_none=False) - launched_at = DateTimeType(serialize_when_none=False) - tags = DictType(StringType, serialize_when_none=False) - data = PolyModelType(Model, default=lambda: {}) - reference = ModelType(ReferenceModel) - region_code = StringType() - _metadata = PolyModelType(CloudServiceMeta, serialize_when_none=False, serialized_name='metadata') - - -class CloudServiceResponse(BaseResponse): - state = StringType(default='SUCCESS') - match_rules = DictType(ListType(StringType), default={ - '1': ['reference.resource_id', 'provider', 'cloud_service_type', 'cloud_service_group', 'account'] - }) - resource_type = StringType(default='inventory.CloudService') - resource = PolyModelType(CloudServiceResource) diff --git a/src/spaceone/inventory/libs/schema/cloud_service_type.py b/src/spaceone/inventory/libs/schema/cloud_service_type.py deleted file mode 100644 index d2f63066..00000000 --- a/src/spaceone/inventory/libs/schema/cloud_service_type.py +++ /dev/null @@ -1,36 +0,0 @@ -from schematics import Model -from schematics.types import ListType, StringType, PolyModelType, DictType, BooleanType -from spaceone.inventory.libs.schema.metadata.dynamic_layout import QuerySearchTableDynamicLayout -from .base import BaseMetaData, BaseResponse, MetaDataViewTable, MetaDataView - - -class CloudServiceTypeMeta(BaseMetaData): - @classmethod - def set_fields(cls, name='', fields=[]): - _table = MetaDataViewTable({'layout': QuerySearchTableDynamicLayout.set_fields(name, fields)}) - return cls({'view': MetaDataView({'table': _table})}) - - @classmethod - def set_meta(cls, name='', fields=[], search=[], widget=[]): - table_meta = MetaDataViewTable({'layout': QuerySearchTableDynamicLayout.set_fields(name, fields)}) - return cls({'view': MetaDataView({'table': table_meta, 'search': search, 'widget': widget})}) - - -class CloudServiceTypeResource(Model): - name = StringType() - provider = StringType(default='azure') - group = StringType() - _metadata = PolyModelType(CloudServiceTypeMeta, serialize_when_none=False, serialized_name='metadata') - labels = ListType(StringType(), serialize_when_none=False) - tags = DictType(StringType, serialize_when_none=False) - is_primary = BooleanType(default=False) - is_major = BooleanType(default=False) - resource_type = StringType(default='inventory.CloudService') - service_code = StringType(serialize_when_none=False) - - -class CloudServiceTypeResponse(BaseResponse): - resource_type = StringType(default='inventory.CloudServiceType') - match_rules = DictType(ListType(StringType), default={'1': ['name', 'group', 'provider']}) - resource = PolyModelType(CloudServiceTypeResource) - diff --git a/src/spaceone/inventory/libs/schema/metadata/dynamic_field.py b/src/spaceone/inventory/libs/schema/metadata/dynamic_field.py deleted file mode 100644 index 04caa8bf..00000000 --- a/src/spaceone/inventory/libs/schema/metadata/dynamic_field.py +++ /dev/null @@ -1,563 +0,0 @@ -import math -from schematics import Model -from schematics.types import ( - ModelType, - StringType, - PolyModelType, - DictType, - BooleanType, - BaseType, -) -from spaceone.inventory.libs.schema.metadata.dynamic_search import BaseDynamicSearch - -BACKGROUND_COLORS = [ - "black", - "white", - "gray", - "gray.100", - "gray.200", - "gray.300", - "gray.400", - "gray.500", - "gray.600", - "gray.700", - "gray.800", - "gray.900", - "red", - "red.100", - "red.200", - "red.300", - "red.400", - "red.500", - "red.600", - "red.700", - "red.800", - "red.900", - "coral", - "coral.100", - "coral.200", - "coral.300", - "coral.400", - "coral.500", - "coral.600", - "coral.700", - "coral.800", - "coral.900", - "yellow", - "yellow.100", - "yellow.200", - "yellow.300", - "yellow.400", - "yellow.500", - "yellow.600", - "yellow.700", - "yellow.800", - "yellow.900", - "green", - "green.100", - "green.200", - "green.300", - "green.400", - "green.500", - "green.600", - "green.700", - "green.800", - "green.900", - "blue", - "blue.100", - "blue.200", - "blue.300", - "blue.400", - "blue.500", - "blue.600", - "blue.700", - "blue.800", - "blue.900", - "violet", - "violet.100", - "violet.200", - "violet.300", - "violet.400", - "violet.500", - "violet.600", - "violet.700", - "violet.800", - "violet.900", - "peacock", - "peacock.100", - "peacock.200", - "peacock.300", - "peacock.400", - "peacock.500", - "peacock.600", - "peacock.700", - "peacock.800", - "peacock.900", - "indigo", - "indigo.100", - "indigo.200", - "indigo.300", - "indigo.400", - "indigo.500", - "indigo.600", - "indigo.700", - "indigo.800", - "indigo.900", -] - -TYPE_BADGE = ["primary", "indigo.500", "coral.600", "peacock.500", "green.500"] - - -class FieldReference(Model): - resource_type = StringType() - reference_key = StringType(serialize_when_none=False) - - -class Icon(Model): - image = StringType(serialize_when_none=False) - color = StringType(default="green", choices=BACKGROUND_COLORS) - - -class BaseField(Model): - type = StringType( - choices=[ - "text", - "state", - "badge", - "list", - "dict", - "datetime", - "image", - "enum", - "progress", - "size", - ], - serialize_when_none=False, - ) - options = PolyModelType( - [Model, DictType(PolyModelType(Model))], serialize_when_none=False - ) - - -class FieldViewOption(Model): - link = StringType(serialize_when_none=False) - variables = StringType(serialize_when_none=False) - sortable = BooleanType(serialize_when_none=False) - sort_key = StringType(serialize_when_none=False) - translation_id = StringType(serialize_when_none=False) - default = StringType(serialize_when_none=False) - is_optional = BooleanType(serialize_when_none=False) - postfix = StringType(serialize_when_none=False) - prefix = StringType(serialize_when_none=False) - field_description = StringType(serialize_when_none=False) - - -class BaseDynamicField(BaseField): - name = StringType(serialize_when_none=False) - key = StringType(serialize_when_none=False) - reference = ModelType(FieldReference, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - return cls({"key": key, "name": name, **kwargs}) - - -class TextDyFieldOptions(FieldViewOption): - pass - - -class BadgeDyFieldOptions(FieldViewOption): - text_color = StringType(serialize_when_none=False) - shape = StringType(serialize_when_none=False, choices=["SQUARE", "ROUND"]) - outline_color = StringType(serialize_when_none=False, choices=BACKGROUND_COLORS) - background_color = StringType(serialize_when_none=False, choices=BACKGROUND_COLORS) - - -class StateDyFieldOptions(FieldViewOption): - text_color = StringType(serialize_when_none=False) - icon = ModelType(Icon, serialize_when_none=False) - - -class ImageDyFieldOptions(FieldViewOption): - image_url = StringType(default="") - width = StringType(serialize_when_none=False) - height = StringType(serialize_when_none=False) - - -class DateTimeDyFieldOptions(FieldViewOption): - source_type = StringType(default="timestamp", choices=["iso8601", "timestamp"]) - source_format = StringType(serialize_when_none=False) - display_format = StringType(serialize_when_none=False) - - -class ProgressFieldOptions(FieldViewOption): - unit = StringType(serialize_when_none=False) - - -class SizeFieldOptions(FieldViewOption): - display_unit = StringType( - serialize_when_none=False, choices=("BYTES", "KB", "MB", "GB", "TB", "PB") - ) - source_unit = StringType( - serialize_when_none=False, choices=("BYTES", "KB", "MB", "GB", "TB", "PB") - ) - - -class TextDyField(BaseDynamicField): - type = StringType(default="text") - options = PolyModelType(TextDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - if "options" in kwargs: - _data_source.update({"options": TextDyFieldOptions(kwargs.get("options"))}) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class StateDyField(BaseDynamicField): - type = StringType(default="state") - options = PolyModelType(StateDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - if "options" in kwargs: - _data_source.update({"options": StateDyFieldOptions(kwargs.get("options"))}) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class BadgeDyField(BaseDynamicField): - type = StringType(default="badge") - options = PolyModelType(BadgeDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - - if "options" in kwargs: - _data_source.update({"options": BadgeDyFieldOptions(kwargs.get("options"))}) - else: - _data_source.update( - { - "options": BadgeDyFieldOptions( - {"background_color": "gray.200", "text_color": "gray.900"} - ) - } - ) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class ImageDyField(BaseDynamicField): - type = StringType(default="image") - options = PolyModelType(ImageDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - if "options" in kwargs: - _data_source.update({"options": ImageDyFieldOptions(kwargs.get("options"))}) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class DateTimeDyField(BaseDynamicField): - type = StringType(default="datetime") - options = PolyModelType(DateTimeDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - if "options" in kwargs: - _data_source.update( - {"options": DateTimeDyFieldOptions(kwargs.get("options"))} - ) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class DictDyField(BaseDynamicField): - type = StringType(default="dict") - options = PolyModelType(FieldViewOption, serialize_when_none=False) - - -class StateItemDyField(BaseField): - type = StringType(default="state") - options = PolyModelType(StateDyFieldOptions, serialize_when_none=False) - - @classmethod - def set(cls, options): - return cls({"options": StateDyFieldOptions(options)}) - - -class BadgeItemDyField(BaseField): - type = StringType(default="badge") - options = PolyModelType(BadgeDyFieldOptions, serialize_when_none=False) - - @classmethod - def set(cls, options): - return cls({"options": BadgeDyFieldOptions(options)}) - - -class ImageItemDyField(BaseField): - type = StringType(default="image") - options = PolyModelType(ImageDyFieldOptions, serialize_when_none=False) - - @classmethod - def set(cls, options): - return cls({"options": ImageDyFieldOptions(options)}) - - -class DatetimeItemDyField(BaseField): - type = StringType(default="datetime") - options = PolyModelType(DateTimeDyFieldOptions, serialize_when_none=False) - - @classmethod - def set(cls, options): - return cls({"options": DateTimeDyFieldOptions(options)}) - - -class ListDyFieldOptions(FieldViewOption): - item = PolyModelType( - [BadgeItemDyField, StateDyField, DateTimeDyField, DictDyField], - serialize_when_none=False, - ) - sub_key = StringType(serialize_when_none=False) - delimiter = StringType(serialize_when_none=False) - - -class ListDyField(BaseDynamicField): - type = StringType(default="list") - options = PolyModelType(ListDyFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - if "default_badge" in kwargs: - _default_badge = kwargs.get("default_badge") - _list_options = {"delimiter": " "} - - if "type" in _default_badge and _default_badge.get("type") == "outline": - _list_options.update( - {"item": BadgeItemDyField.set({"outline_color": "violet.500"})} - ) - elif "type" in _default_badge and _default_badge.get("type") == "inline": - _list_options.update( - {"item": BadgeItemDyField.set({"background_color": "violet.500"})} - ) - - if "sub_key" in _default_badge: - _list_options.update({"sub_key": _default_badge.get("sub_key")}) - - if "delimiter" in _default_badge: - _list_options.update({"delimiter": _default_badge.get("delimiter")}) - - _data_source.update({"options": ListDyFieldOptions(_list_options)}) - - if "options" in kwargs: - _data_source.update({"options": ListDyFieldOptions(kwargs.get("options"))}) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - - return cls(_data_source) - - -class EnumOptionDyField(FieldViewOption): - items = DictType( - PolyModelType( - [StateItemDyField, BadgeItemDyField, ImageItemDyField, DatetimeItemDyField] - ), - serialize_when_none=False, - default={}, - ) - - -class EnumDyField(BaseDynamicField): - type = StringType(default="enum") - options = DictType( - PolyModelType( - [ - StateItemDyField, - BadgeItemDyField, - ImageItemDyField, - DatetimeItemDyField, - EnumOptionDyField, - ] - ), - serialize_when_none=False, - default={}, - ) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - _default_badge = kwargs.get("default_badge", {}) - _default_state = kwargs.get("default_state", {}) - _default_outline_badge = kwargs.get("default_outline_badge", []) - - _options_dic = {} - - for _key in _default_outline_badge: - _round_index = len(TYPE_BADGE) - _index = _default_outline_badge.index(_key) - _num = math.floor(_index / len(TYPE_BADGE)) - - if _num > 0: - _round_index = len(TYPE_BADGE) * _num - - if _round_index - 1 < _index: - _index = _index - _round_index - - _options_dic[_key] = BadgeItemDyField.set( - {"outline_color": TYPE_BADGE[_index]} - ) - - for _key in _default_badge: - for _badge in _default_badge[_key]: - _options_dic[_badge] = BadgeItemDyField.set({"background_color": _key}) - - for _key in _default_state: - for _state in _default_state[_key]: - _state_options = {"icon": {"color": "gray.400"}} - - if _key == "safe": - _state_options = {"icon": {"color": "green.500"}} - elif _key == "disable": - _state_options.update({"text_color": "gray.400"}) - elif _key == "warning": - _state_options = {"icon": {"color": "yellow.500"}} - elif _key == "available": - _state_options = {"icon": {"color": "blue.400"}} - elif _key == "alert": - _state_options = { - "text_color": "red.500", - "icon": {"color": "red.500"}, - } - - _options_dic[_state] = StateItemDyField.set(_state_options) - - _data_source.update({"options": _options_dic}) - - if "options" in kwargs: - _data_source.update({"options": kwargs.get("options")}) - - if "reference" in kwargs: - _data_source.update({"reference": kwargs.get("reference")}) - return cls(_data_source) - - -class ProgressField(BaseDynamicField): - type = StringType(default="progress") - options = PolyModelType( - ProgressFieldOptions, - serialize_when_none=False, - ) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - - if "options" in kwargs: - _data_source.update({"options": kwargs.get("options")}) - - return cls(_data_source) - - -class SizeField(BaseDynamicField): - type = StringType(default="size") - options = PolyModelType(SizeFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - - if "options" in kwargs: - _data_source.update({"options": kwargs.get("options")}) - - return cls(_data_source) - - -class SearchEnumField(Model): - label = StringType(serialize_when_none=False) - icon = ModelType(Icon, serialize_when_none=False) - - @classmethod - def set_field(cls, label=None, icon=None): - return_dic = {} - - if label is not None: - return_dic.update({"label": label}) - - if icon is not None: - return_dic.update({"icon": Icon(icon)}) - - return cls(return_dic) - - -class SearchField(BaseDynamicSearch): - enums = DictType(ModelType(SearchEnumField), serialize_when_none=False) - reference = StringType(serialize_when_none=False) - - @classmethod - def set(cls, name="", key="", data_type=None, enums=None, reference=None): - return_dic = {"name": name, "key": key} - - if data_type is not None: - return_dic.update({"data_type": data_type}) - - if reference is not None: - return_dic.update({"reference": reference}) - - if enums is not None: - convert_enums = {} - for enum_key in enums: - enum_v = enums[enum_key] - convert_enums[enum_key] = SearchEnumField.set_field(**enum_v) - - return_dic.update({"enums": convert_enums}) - - return cls(return_dic) - - -class MoreLayoutField(Model): - name = StringType(default="") - type = StringType(default="popup") - options = DictType(BaseType, serialize_when_none=False) - - -class MoreFieldOptions(FieldViewOption): - sub_key = StringType(serialize_when_none=False) - layout = PolyModelType(MoreLayoutField, serialize_when_none=False) - - -class MoreField(BaseDynamicField): - type = StringType(default="more") - options = PolyModelType(MoreFieldOptions, serialize_when_none=False) - - @classmethod - def data_source(cls, name, key, **kwargs): - _data_source = {"key": key, "name": name} - - if "options" in kwargs: - _data_source.update({"options": kwargs.get("options")}) - - return cls(_data_source) diff --git a/src/spaceone/inventory/libs/schema/metadata/dynamic_layout.py b/src/spaceone/inventory/libs/schema/metadata/dynamic_layout.py deleted file mode 100644 index 2c9987f9..00000000 --- a/src/spaceone/inventory/libs/schema/metadata/dynamic_layout.py +++ /dev/null @@ -1,186 +0,0 @@ -from schematics import Model -from schematics.types import StringType, PolyModelType, ListType -from spaceone.inventory.libs.schema.metadata.dynamic_field import ( - BaseDynamicField, - TextDyField, -) - - -class LayoutOptions(Model): - class Options: - serialize_when_none = False - - root_path = StringType(serialize_when_none=False) - - -class BaseLayoutField(Model): - @staticmethod - def _set_fields(fields=[], **kwargs): - _options = {"fields": fields} - for k, v in kwargs.items(): - if v is not None: - _options[k] = v - return _options - - name = StringType(default="") - type = StringType( - default="item", - choices=( - "item", - "table", - "query-search-table", - "simple-table", - "list", - "raw", - "html", - ), - ) - options = PolyModelType(LayoutOptions, serialize_when_none=False) - - -class ItemLayoutOption(LayoutOptions): - fields = ListType(PolyModelType(BaseDynamicField)) - - -class SimpleTableLayoutOption(LayoutOptions): - fields = ListType(PolyModelType(BaseDynamicField)) - - -class TableLayoutOption(LayoutOptions): - fields = ListType(PolyModelType(BaseDynamicField)) - - -class QuerySearchTableLayoutOption(LayoutOptions): - fields = ListType(PolyModelType(BaseDynamicField)) - - -class RawLayoutOption(LayoutOptions): - class Options: - serialize_when_none = False - - -class HTMLLayoutOption(LayoutOptions): - class Options: - serialize_when_none = False - - -class ListLayoutOption(LayoutOptions): - layouts = ListType(PolyModelType(BaseLayoutField)) - - -class ItemDynamicLayout(BaseLayoutField): - type = StringType(default="item") - options = PolyModelType(ItemLayoutOption) - - @classmethod - def set(cls, name="", root_path=""): - return cls( - {"name": name, "options": ItemLayoutOption({"root_path": root_path})} - ) - - @classmethod - def set_fields(cls, name="", root_path=None, fields=[]): - _options = cls._set_fields(fields, root_path=root_path) - return cls({"name": name, "options": ItemLayoutOption(_options)}) - - -class TableDynamicLayout(BaseLayoutField): - type = StringType(default="table") - options = PolyModelType(TableLayoutOption) - - @classmethod - def set(cls, name="", root_path=""): - return cls( - name=name, - root_path=root_path, - options=TableLayoutOption({"root_path": root_path}), - ) - - @classmethod - def set_fields(cls, name="", root_path=None, fields=[]): - _options = cls._set_fields(fields, root_path=root_path) - return cls({"name": name, "options": TableLayoutOption(_options)}) - - -class QuerySearchTableDynamicLayout(BaseLayoutField): - type = StringType(default="query-search-table") - options = PolyModelType(QuerySearchTableLayoutOption) - - @classmethod - def set(cls, name="", root_path=""): - return cls( - name=name, options=QuerySearchTableLayoutOption({"root_path": root_path}) - ) - - @classmethod - def set_fields(cls, name, fields: list = None, root_path=None): - if fields is None: - fields = [] - _options = cls._set_fields(fields, root_path=root_path) - return cls({"name": name, "options": QuerySearchTableLayoutOption(_options)}) - - -class SimpleTableDynamicLayout(BaseLayoutField): - type = StringType(default="simple-table") - options = PolyModelType(SimpleTableLayoutOption) - - @classmethod - def set(cls, name="", root_path=""): - return cls( - {"name": name, "options": SimpleTableLayoutOption({"root_path": root_path})} - ) - - @classmethod - def set_fields(cls, name="", root_path=None, fields=[]): - _options = cls._set_fields(fields, root_path=root_path) - return cls({"name": name, "options": SimpleTableLayoutOption(_options)}) - - @classmethod - def set_tags(cls, name="Tags", root_path="data.tags", fields=None): - if fields is None: - fields = [ - TextDyField.data_source("Key", "key"), - TextDyField.data_source("Value", "value"), - ] - return cls.set_fields(name, root_path, fields) - - -class ListDynamicLayout(BaseLayoutField): - type = StringType(default="list") - options = PolyModelType(ListLayoutOption) - - @classmethod - def set(cls, name="", layouts=[]): - return cls(name=name, options=ListLayoutOption({"layouts": layouts})) - - @classmethod - def set_layouts(cls, name="", layouts=[]): - return cls({"name": name, "options": ListLayoutOption({"layouts": layouts})}) - - -class RawDynamicLayout(BaseLayoutField): - type = StringType(default="raw") - options = PolyModelType(RawLayoutOption) - - @classmethod - def set(cls, name="", root_path=None): - if root_path is None: - _options = RawLayoutOption() - else: - _options = RawLayoutOption({"root_path": root_path}) - - return cls({"name": name, "options": _options}) - - -class HTMLDynamicLayout(BaseLayoutField): - type = StringType(default="html") - options = PolyModelType(HTMLLayoutOption) - - @classmethod - def set(cls, name="", root_path=None): - if root_path is None: - _options = HTMLLayoutOption() - else: - _options = HTMLLayoutOption({"root_path": root_path}) - - return cls({"name": name, "options": _options}) diff --git a/src/spaceone/inventory/libs/schema/metadata/dynamic_search.py b/src/spaceone/inventory/libs/schema/metadata/dynamic_search.py deleted file mode 100644 index c8d28edf..00000000 --- a/src/spaceone/inventory/libs/schema/metadata/dynamic_search.py +++ /dev/null @@ -1,14 +0,0 @@ -from schematics import Model -from schematics.types import StringType, ListType, PolyModelType - - -class BaseDynamicSearch(Model): - name = StringType() - key = StringType() - data_type = StringType(choices=['string', 'integer', 'float', 'boolean', 'datetime'], - serialize_when_none=False) - - -class BaseDynamicSearchItem(Model): - title = StringType(default="Properties") - items = ListType(PolyModelType(BaseDynamicSearch), serialize_when_none=False) diff --git a/src/spaceone/inventory/libs/schema/metadata/dynamic_widget.py b/src/spaceone/inventory/libs/schema/metadata/dynamic_widget.py deleted file mode 100644 index 2c20172b..00000000 --- a/src/spaceone/inventory/libs/schema/metadata/dynamic_widget.py +++ /dev/null @@ -1,212 +0,0 @@ -from schematics import Model -from schematics.types import StringType, ListType, BooleanType, ModelType, PolyModelType, BaseType -from .dynamic_field import TextDyField, StateDyField, BadgeDyField, ListDyField, DictDyField, DateTimeDyField, \ - ImageDyField, EnumDyField, SizeField, ProgressField - - -class BaseDynamicWidgetKeyFields(Model): - key = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetGroupCondition(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - operator = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateUnwind(Model): - path = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateGroupKeys(BaseDynamicWidgetKeyFields): - date_format = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateGroupFields(Model): - key = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - operator = StringType(serialize_when_none=False) - _fields = ListType(ModelType(BaseDynamicWidgetKeyFields), serialize_when_none=False, serialized_name='fields') - condition = ModelType(BaseDynamicWidgetGroupCondition, serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateGroup(Model): - keys = ListType(ModelType(BaseDynamicWidgetQueryAggregateGroupKeys), serialize_when_none=False) - _fields = ListType(ModelType(BaseDynamicWidgetQueryAggregateGroupFields), serialize_when_none=False, serialized_name='fields') - - -class BaseDynamicWidgetQueryAggregateCount(Model): - name = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateSortKey(Model): - key = StringType(serialize_when_none=False) - desc = BooleanType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateSort(Model): - key = StringType(serialize_when_none=False) - desc = BooleanType(serialize_when_none=False) - keys = ListType(ModelType(BaseDynamicWidgetQueryAggregateSortKey), serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateProjectField(Model): - key = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - operator = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQueryAggregateProject(Model): - _fields = ListType(ModelType(BaseDynamicWidgetQueryAggregateProjectField), serialize_when_none=False, serialized_name='fields') - - -class BaseDynamicWidgetQueryAggregate(Model): - unwind = ModelType(BaseDynamicWidgetQueryAggregateUnwind, serialize_when_none=False) - group = ModelType(BaseDynamicWidgetQueryAggregateGroup, serialize_when_none=False) - count = ModelType(BaseDynamicWidgetQueryAggregateCount, serialize_when_none=False) - sort = ModelType(BaseDynamicWidgetQueryAggregateSort, serialize_when_none=False) - project = ModelType(BaseDynamicWidgetQueryAggregateProject, serialize_when_none=False) # add - - -class BaseDynamicWidgetQueryFilter(Model): - key = StringType(serialize_when_none=False) - # value = PolyModelType([StringType], serialize_when_none=False) - # change StringType -> BaseType - value = BaseType(serialize_when_none=False) - operator = StringType(serialize_when_none=False) - - -class BaseDynamicWidgetQuery(Model): - aggregate = ListType(ModelType(BaseDynamicWidgetQueryAggregate), serialize_when_none=False) - filter = ListType(ModelType(BaseDynamicWidgetQueryFilter), serialize_when_none=False) - - -class BaseDynamicWidgetOptions(Model): - value_options = PolyModelType([TextDyField, StateDyField, BadgeDyField, ListDyField, DictDyField, DateTimeDyField, - ImageDyField, EnumDyField, SizeField, ProgressField], serialize_when_none=False) - name_options = PolyModelType([TextDyField, StateDyField, BadgeDyField, ListDyField, DictDyField, DateTimeDyField, - ImageDyField, EnumDyField, SizeField, ProgressField], serialize_when_none=False) - chart_type = StringType(choices=('COLUMN', 'DONUT', 'TREEMAP'), serialize_when_none=False) - - -class BaseDynamicWidget(Model): - name = StringType(serialize_when_none=False) - type = StringType(choices=('card', 'chart'), serialize_when_none=False) - options = ModelType(BaseDynamicWidgetOptions, serialize_when_none=False) - query = ModelType(BaseDynamicWidgetQuery, serialize_when_none=False) - - @classmethod - def set(cls, cloud_service_group, cloud_service_type, name, query, options={}): - # Query : aggregate - query_aggrs = [] - for _aggregate in query.get('aggregate', []): - _aggr_dict = {} - if 'unwind' in _aggregate: - _aggr_dict['unwind'] = BaseDynamicWidgetQueryAggregateUnwind(_aggregate['unwind']) - - if 'group' in _aggregate: - _aggr_group = _aggregate['group'] - _aggr_group_keys = [BaseDynamicWidgetQueryAggregateGroupKeys(_aggr_group_key) - for _aggr_group_key in _aggr_group.get('keys', [])] - - _aggr_group_fields = [] - for _aggr_group_field in _aggr_group.get('fields', []): - _aggr_group_field_fields = [BaseDynamicWidgetKeyFields(_aggr_group_field_fields) for - _aggr_group_field_fields in _aggr_group_field.get('fields', [])] - - if _aggr_group_field_fields: - _aggr_group_field['fields'] = _aggr_group_field_fields - - if 'condition' in _aggr_group_field: - _aggr_group_field['condition'] = BaseDynamicWidgetGroupCondition(_aggr_group_field['condition']) - - _aggr_group_fields.append(BaseDynamicWidgetQueryAggregateGroupFields(_aggr_group_field)) - - if _aggr_group_keys: - _aggr_group['keys'] = _aggr_group_keys - - if _aggr_group_fields: - _aggr_group['fields'] = _aggr_group_fields - - _aggr_dict['group'] = BaseDynamicWidgetQueryAggregateGroup(_aggr_group) - - if 'count' in _aggregate: - _aggr_dict['count'] = BaseDynamicWidgetQueryAggregateCount(_aggregate['count']) - - if 'sort' in _aggregate: - _aggr_sort = _aggregate['sort'] - - _aggr_sort_keys = [BaseDynamicWidgetQueryAggregateSortKey(_aggr_sort_key) - for _aggr_sort_key in _aggr_sort.get('keys', [])] - - if _aggr_sort_keys: - _aggr_sort['keys'] = _aggr_sort_keys - - _aggr_dict['sort'] = BaseDynamicWidgetQueryAggregateSort(_aggr_sort) - - if 'project' in _aggregate: - _aggr_project = _aggregate['project'] - _aggr_project_fields = [BaseDynamicWidgetQueryAggregateProjectField(_aggr_project_field) - for _aggr_project_field in _aggr_project.get('fields', [])] - - _aggr_dict['project'] = BaseDynamicWidgetQueryAggregateProject({'fields': _aggr_project_fields}) - query_aggrs.append(BaseDynamicWidgetQueryAggregate(_aggr_dict)) - - query['aggregate'] = query_aggrs - - # Query : filter - filter = [{'key': 'provider', 'value': 'azure', 'operator': 'eq'}, - {'key': 'cloud_service_group', 'value': cloud_service_group, 'operator': 'eq'}, - {'key': 'cloud_service_type', 'value': cloud_service_type, 'operator': 'eq'}] - - if 'filter' in query: - query['filter'].extend(filter) - else: - query.update({'filter': filter}) - - query['filter'] = [BaseDynamicWidgetQueryFilter(_filter) for _filter in query['filter']] - - if options: - field_type_maps = { - 'text': TextDyField, - 'state': StateDyField, - 'badge': BadgeDyField, - 'list': ListDyField, - 'dict': DictDyField, - 'datetime': DateTimeDyField, - 'image': ImageDyField, - 'enum': EnumDyField, - 'size': SizeField, - 'progress': ProgressField - } - - if 'name_options' in options: - _name_options = options['name_options'] - _type = _name_options.get('type', 'text') - - if _type in field_type_maps: - options['name_options'] = field_type_maps[_type](_name_options) - - if 'value_options' in options: - _value_options = options['value_options'] - _type = _value_options.get('type', 'text') - - if _type in field_type_maps: - options['value_options'] = field_type_maps[_type](_value_options) - - _dic = { - 'name': name, - 'query': BaseDynamicWidgetQuery(query), - 'options': BaseDynamicWidgetOptions(options) - } - - return cls(_dic) - - -class CardWidget(BaseDynamicWidget): - type = StringType(default='card') - - -class ChartWidget(BaseDynamicWidget): - type = StringType(default='chart') diff --git a/src/spaceone/inventory/libs/schema/region.py b/src/spaceone/inventory/libs/schema/region.py deleted file mode 100644 index 6079fa0e..00000000 --- a/src/spaceone/inventory/libs/schema/region.py +++ /dev/null @@ -1,16 +0,0 @@ -from schematics import Model -from schematics.types import ListType, StringType, PolyModelType, DictType -from .base import BaseResponse - - -class RegionResource(Model): - name = StringType(default="") - region_code = StringType() - provider = StringType(default="azure") - tags = DictType(StringType) - - -class RegionResponse(BaseResponse): - resource_type = StringType(default='inventory.Region') - match_rules = DictType(ListType(StringType), default={'1': ['region_code', 'provider']}) - resource = PolyModelType(RegionResource) \ No newline at end of file diff --git a/src/spaceone/inventory/libs/schema/resource.py b/src/spaceone/inventory/libs/schema/resource.py deleted file mode 100644 index 3da160c9..00000000 --- a/src/spaceone/inventory/libs/schema/resource.py +++ /dev/null @@ -1,78 +0,0 @@ -from schematics import Model -from schematics.types import StringType, DictType, ListType, ModelType, PolyModelType -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource -from spaceone.inventory.libs.schema.region import RegionResource - - -class ErrorResource(Model): - resource_type = StringType(default="inventory.CloudService") - provider = StringType(default="azure") - cloud_service_group = StringType(default="") - cloud_service_type = StringType(default="") - resource_id = StringType(serialize_when_none=False) - - -class ResourceResponse(Model): - state = StringType() - message = StringType(default="") - resource_type = StringType() - match_rules = DictType(ListType(StringType), serialize_when_none=False) - resource = DictType(StringType, default={}) - - -class CloudServiceResourceResponse(ResourceResponse): - state = StringType(default="SUCCESS") - resource_type = StringType(default="inventory.CloudService") - match_rules = DictType( - ListType(StringType), - default={ - "1": [ - "reference.resource_id", - "provider", - "cloud_service_type", - "cloud_service_group", - ] - }, - ) - resource = PolyModelType(CloudServiceTypeResource) - - -class RegionResourceResponse(ResourceResponse): - state = StringType(default="SUCCESS") - resource_type = StringType(default="inventory.Region") - match_rules = DictType( - ListType(StringType), default={"1": ["region_code", "provider"]} - ) - resource = PolyModelType(RegionResource) - - -class CloudServiceTypeResourceResponse(ResourceResponse): - state = StringType(default="SUCCESS") - resource_type = StringType(default="inventory.CloudServiceType") - match_rules = DictType( - ListType(StringType), default={"1": ["name", "group", "provider"]} - ) - resource = PolyModelType(CloudServiceTypeResource) - - -class ErrorResourceResponse(ResourceResponse): - state = StringType(default="FAILURE") - resource_type = StringType(default="inventory.ErrorResource") - resource = ModelType(ErrorResource, default={}) - - -class AzureMonitorModel(Model): - resource_id = StringType() - - -class AzureTags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class AzureCloudService(Model): - tenant_id = StringType(serialized_name=False) - subscription_id = StringType(serialize_when_none=False) - subscription_name = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - azure_monitor = ModelType(AzureMonitorModel, serialize_when_none=False) diff --git a/src/spaceone/inventory/libs/schema/stackdriver.py b/src/spaceone/inventory/libs/schema/stackdriver.py deleted file mode 100644 index 65ba6a69..00000000 --- a/src/spaceone/inventory/libs/schema/stackdriver.py +++ /dev/null @@ -1,15 +0,0 @@ -from schematics import Model -from schematics.types import ListType, StringType, ModelType - - -class StackDriverFilters(Model): - key = StringType() - value = StringType() - - -class StackDriverModel(Model): - class Option: - serialize_when_none = False - - type = StringType() - filters = ListType(ModelType(StackDriverFilters), default=[]) diff --git a/src/spaceone/inventory/libs/utils.py b/src/spaceone/inventory/libs/utils.py deleted file mode 100644 index 5c1eafc6..00000000 --- a/src/spaceone/inventory/libs/utils.py +++ /dev/null @@ -1,7 +0,0 @@ -import yaml - -def get_data_from_yaml(file_path): - with open(file_path) as f: - dict = yaml.load(f, Loader=yaml.FullLoader) - - return dict diff --git a/src/spaceone/inventory/manager/__init__.py b/src/spaceone/inventory/manager/__init__.py deleted file mode 100644 index c6b75e21..00000000 --- a/src/spaceone/inventory/manager/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -from spaceone.inventory.manager.disks.disk_manager import DisksManager -from spaceone.inventory.manager.subscriptions.subscription_manager import ( - SubscriptionsManager, -) -from spaceone.inventory.manager.snapshots.instance_manager import SnapshotsManager -from spaceone.inventory.manager.vm_scale_sets.scale_set_manager import ( - VmScaleSetsManager, -) -from spaceone.inventory.manager.load_balancers.instance_manager import ( - LoadBalancersManager, -) -from spaceone.inventory.manager.sql_databases.database_manager import ( - SQLDatabasesManager, -) -from spaceone.inventory.manager.sql_servers.server_manager import SQLServersManager -from spaceone.inventory.manager.virtual_networks.instance_manager import ( - VirtualNetworksManager, -) -from spaceone.inventory.manager.application_gateways.instance_manager import ( - ApplicationGatewaysManager, -) -from spaceone.inventory.manager.public_ip_addresses.ip_address_manager import ( - PublicIPAddressesManager, -) -from spaceone.inventory.manager.network_security_groups.instance_manager import ( - NetworkSecurityGroupsManager, -) -from spaceone.inventory.manager.nat_gateways.instance_manager import NATGatewaysManager -from spaceone.inventory.manager.storage_accounts.instance_manager import ( - StorageAccountsManager, -) -from spaceone.inventory.manager.key_vaults.instance_manager import KeyVaultsManager -from spaceone.inventory.manager.mysql_servers.server_manager import MySQLServersManager -from spaceone.inventory.manager.cosmos_db.instance_manager import CosmosDBManager -from spaceone.inventory.manager.postgresql_servers.server_manager import ( - PostgreSQLServersManager, -) -from spaceone.inventory.manager.virtual_machines.instnace_manger import ( - VirtualMachinesManager, -) -from spaceone.inventory.manager.container_instances.container_manager import ( - ContainerInstancesManager, -) -from spaceone.inventory.manager.web_pubsub_service.service_manager import ( - WebPubSubServiceManager, -) -from spaceone.inventory.manager.resources_manager.resource_manager import ( - ResourcesManager, -) diff --git a/src/spaceone/inventory/manager/public_ip_addresses/ip_address_manager.py b/src/spaceone/inventory/manager/public_ip_addresses/ip_address_manager.py deleted file mode 100644 index 17873a44..00000000 --- a/src/spaceone/inventory/manager/public_ip_addresses/ip_address_manager.py +++ /dev/null @@ -1,114 +0,0 @@ -import time -import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.connector.public_ip_addresses import PublicIPAddressesConnector -from spaceone.inventory.model.public_ip_addresses.cloud_service import * -from spaceone.inventory.model.public_ip_addresses.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.public_ip_addresses.data import * - -_LOGGER = logging.getLogger(__name__) - - -class PublicIPAddressesManager(AzureManager): - connector_name = "PublicIPAddressesConnector" - 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) : dictionary of azure public ip address data resource information - ErrorResourceResponse (list) : list of error resource information - - """ - _LOGGER.debug("** Public IP Address START **") - start_time = time.time() - - subscription_info = params["subscription_info"] - - public_ip_address_conn: PublicIPAddressesConnector = self.locator.get_connector( - self.connector_name, **params - ) - public_ip_address_responses = [] - error_responses = [] - - public_ip_addresses_list = public_ip_address_conn.list_all_public_ip_addresses() - - for public_ip_address in public_ip_addresses_list: - public_ip_address_id = "" - - try: - public_ip_address_dict = self.convert_nested_dictionary( - public_ip_address - ) - public_ip_address_id = public_ip_address_dict["id"] - - # update application_gateway_dict - public_ip_address_dict.update( - { - "resource_group": self.get_resource_group_from_id( - public_ip_address_id - ), - # parse resource_group from ID - "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], - "azure_monitor": {"resource_id": public_ip_address_id}, - } - ) - - if public_ip_address_dict.get("ip_configuration") is not None: - associated_to = public_ip_address_dict["ip_configuration"][ - "id" - ].split("/")[8] - if associated_to: - public_ip_address_dict.update({"associated_to": associated_to}) - - public_ip_address_dict = self.update_tenant_id_from_secret_data( - public_ip_address_dict, params.get("secret_data", {}) - ) - - public_ip_address_data = PublicIPAddress( - public_ip_address_dict, strict=False - ) - public_ip_address_resource = PublicIPAddressResource( - { - "data": public_ip_address_data, - "tags": public_ip_address_dict.get("tags", {}), - "region_code": public_ip_address_data.location, - "reference": ReferenceModel(public_ip_address_data.reference()), - "name": public_ip_address_data.name, - "account": public_ip_address_data.subscription_id, - "instance_type": public_ip_address_data.sku.name, - } - ) - - # Must set_region_code method for region collection - self.set_region_code(public_ip_address_data["location"]) - # _LOGGER.debug(f'[PUBLIC IP ADDRESS INFO IN PIP MANAGER] {public_ip_address_resource.to_primitive()}') - public_ip_address_responses.append( - PublicIPAddressResponse({"resource": public_ip_address_resource}) - ) - - except Exception as e: - _LOGGER.error( - f"[list_instances] {public_ip_address_id} {e}", exc_info=True - ) - error_resource_response = self.generate_resource_error_response( - e, "Network", "PublicIPAddress", public_ip_address_id - ) - error_responses.append(error_resource_response) - - _LOGGER.debug( - f"** Public IP Address Finished {time.time() - start_time} Seconds **" - ) - return public_ip_address_responses, error_responses diff --git a/src/spaceone/inventory/manager/resources_manager/__init__.py b/src/spaceone/inventory/manager/resources_manager/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/src/spaceone/inventory/manager/resources_manager/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/spaceone/inventory/manager/resources_manager/resource_manager.py b/src/spaceone/inventory/manager/resources_manager/resource_manager.py deleted file mode 100644 index 86372dd0..00000000 --- a/src/spaceone/inventory/manager/resources_manager/resource_manager.py +++ /dev/null @@ -1,27 +0,0 @@ -import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.connector.resources import ResourcesConnector - -_LOGGER = logging.getLogger(__name__) - - -class ResourcesManager(AzureManager): - connector_name = "ResourcesConnector" - - def collect_exist_resources(self, params: dict) -> list: - """ " """ - - resources_info = [] - resources_conn: ResourcesConnector = self.locator.get_connector( - self.connector_name, **params - ) - - resources_obj = resources_conn.list_resources() - - for resource_obj in resources_obj: - resource_info = self.convert_nested_dictionary(resource_obj) - type = resource_info.get("type").split("/")[1] - if type not in resources_info: - resources_info.append(type) - - return resources_info diff --git a/src/spaceone/inventory/manager/virtual_machines/__init__.py b/src/spaceone/inventory/manager/virtual_machines/__init__.py deleted file mode 100644 index 5296d8a4..00000000 --- a/src/spaceone/inventory/manager/virtual_machines/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -from spaceone.inventory.manager.virtual_machines.disk_manager import ( - VirtualMachineDiskManager, -) -from spaceone.inventory.manager.virtual_machines.load_balancer_manager import ( - VirtualMachineLoadBalancerManager, -) -from spaceone.inventory.manager.virtual_machines.network_security_group_manager import ( - VirtualMachineNetworkSecurityGroupManager, -) -from spaceone.inventory.manager.virtual_machines.nic_manager import ( - VirtualMachineNICManager, -) -from spaceone.inventory.manager.virtual_machines.vm_manager import ( - VirtualMachineVmManager, -) -from spaceone.inventory.manager.virtual_machines.vnet_manager import ( - VirtualMachineVNetManager, -) diff --git a/src/spaceone/inventory/manager/virtual_machines/instnace_manger.py b/src/spaceone/inventory/manager/virtual_machines/instnace_manger.py deleted file mode 100644 index ff715fff..00000000 --- a/src/spaceone/inventory/manager/virtual_machines/instnace_manger.py +++ /dev/null @@ -1,285 +0,0 @@ -import logging -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.connector.virtual_machines import VirtualMachinesConnector -from spaceone.inventory.manager.virtual_machines import ( - VirtualMachineDiskManager, - VirtualMachineLoadBalancerManager, - VirtualMachineNetworkSecurityGroupManager, - VirtualMachineNICManager, - VirtualMachineVmManager, - VirtualMachineVNetManager, -) -from spaceone.inventory.libs.schema.base import ReferenceModel -from spaceone.inventory.model.virtual_machines.data import * -from spaceone.inventory.libs.schema.resource import ( - ErrorResourceResponse, - CloudServiceResourceResponse, - AzureMonitorModel, -) -from spaceone.core.utils import * -from spaceone.inventory.model.virtual_machines.cloud_service_type import ( - CLOUD_SERVICE_TYPES, -) -from spaceone.inventory.model.virtual_machines.cloud_service import * - -_LOGGER = logging.getLogger(__name__) - - -class VirtualMachinesManager(AzureManager): - connector_name = "VirtualMachinesConnector" - cloud_service_types = CLOUD_SERVICE_TYPES - - # refactoring - 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) : dictionary of azure vm scale set data resource information - ErrorResourceResponse (list) : list of error resource information - """ - - _LOGGER.debug("** VirtualMachine START **") - start_time = time.time() - - servers = [] - errors = [] - - azure_vm_connector: VirtualMachinesConnector = self.locator.get_connector( - self.connector_name, **params - ) - - # call all managers - vm_manager: VirtualMachineVmManager = VirtualMachineVmManager( - params, azure_vm_connector=azure_vm_connector - ) - disk_manager: VirtualMachineDiskManager = VirtualMachineDiskManager( - params, azure_vm_connector=azure_vm_connector - ) - load_balancer_manager: VirtualMachineLoadBalancerManager = ( - VirtualMachineLoadBalancerManager( - params, azure_vm_connector=azure_vm_connector - ) - ) - network_security_group_manager: VirtualMachineNetworkSecurityGroupManager = ( - VirtualMachineNetworkSecurityGroupManager( - params, azure_vm_connector=azure_vm_connector - ) - ) - nic_manager: VirtualMachineNICManager = VirtualMachineNICManager( - params, azure_vm_connector=azure_vm_connector - ) - vnet_manager: VirtualMachineVNetManager = VirtualMachineVNetManager( - params, azure_vm_connector=azure_vm_connector - ) - - vms = list(azure_vm_connector.list_all_vms()) - resource_groups = list(azure_vm_connector.list_resource_groups()) - load_balancers = list(azure_vm_connector.list_load_balancers()) - network_security_groups = list( - azure_vm_connector.list_network_security_groups() - ) - network_interfaces = list(azure_vm_connector.list_network_interfaces()) - disks = list(azure_vm_connector.list_disks()) - public_ip_addresses = list(azure_vm_connector.list_public_ip_addresses()) - virtual_networks = list(azure_vm_connector.list_virtual_networks()) - skus = list(azure_vm_connector.list_skus()) - - subscription_id = params["secret_data"].get("subscription_id") - subscription_info = azure_vm_connector.get_subscription_info(subscription_id) - subscription_data = { - "subscription_id": subscription_info.subscription_id, - "subscription_name": subscription_info.display_name, - "tenant_id": subscription_info.tenant_id, - } - - for vm in vms: - try: - vnet_data = None - subnet_data = None - lb_vos = [] - resource_group, resource_group_name = self.get_resource_info_in_vm( - vm, resource_groups - ) - skus_dict = self.get_skus_resource(skus) - - disk_vos = disk_manager.get_disk_info(vm, disks) - nic_vos, primary_ip = nic_manager.get_nic_info( - vm, network_interfaces, public_ip_addresses, virtual_networks - ) - - vm_resource = vm_manager.get_vm_info( - vm, - disk_vos, - nic_vos, - resource_group, - subscription_id, - network_security_groups, - primary_ip, - skus_dict, - ) - - if load_balancers is not None: - lb_vos = load_balancer_manager.get_load_balancer_info( - vm, load_balancers, public_ip_addresses - ) - - nsg_vos = ( - network_security_group_manager.get_network_security_group_info( - vm, network_security_groups, network_interfaces - ) - ) - - nic_name = vm.network_profile.network_interfaces[0].id.split("/")[-1] - - if nic_name is not None: - vnet_subnet_dict = vnet_manager.get_vnet_subnet_info( - nic_name, network_interfaces, virtual_networks - ) - - if vnet_subnet_dict.get("vnet_info"): - vnet_data = vnet_subnet_dict["vnet_info"] - - if vnet_subnet_dict.get("subnet_info"): - subnet_data = vnet_subnet_dict["subnet_info"] - - vm_resource.update({"tags": self.get_tags(vm.tags)}) - - resource_id = f'/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Compute/virtualMachines/{vm_resource["name"]}' - - # update vm_resource data - vm_resource["data"].update( - { - "tenant_id": subscription_data["tenant_id"], - "subscription_name": subscription_data["subscription_name"], - "subscription_id": subscription_data["subscription_id"], - "resource_group": resource_group_name, - } - ) - - vm_resource["data"].update( - { - "load_balancer": lb_vos, - "security_group": nsg_vos, - "vnet": vnet_data, - "subnet": subnet_data, - "azure_monitor": AzureMonitorModel( - {"resource_id": resource_id}, strict=False - ), - "activity_log": ActivityLog( - {"resource_uri": resource_id}, strict=False - ), - } - ) - - vm_resource["data"]["compute"]["account"] = subscription_data[ - "subscription_name" - ] - vm_resource.update( - { - "reference": ReferenceModel( - { - "resource_id": vm_resource["data"]["compute"][ - "instance_id" - ], - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Compute/virtualMachines/{vm_resource['data']['compute']['instance_name']}/overview", - } - ), - "account": subscription_data["subscription_id"], - "instance_type": vm_resource["data"]["compute"][ - "instance_type" - ], - "launched_at": datetime_to_iso8601( - vm_resource["data"]["compute"]["launched_at"] - ), - "tags": vm.tags, - } - ) - - self.set_region_code(vm_resource["region_code"]) - - vm_resource_vo = VirtualMachineResource(vm_resource, strict=False) - servers.append(VirtualMachineResponse({"resource": vm_resource_vo})) - except Exception as e: - _LOGGER.error(f"[list_instances] [{vm.id}] {e}") - - if type(e) is dict: - error_resource_response = ErrorResourceResponse( - {"message": json.dumps(e)} - ) - else: - error_resource_response = ErrorResourceResponse( - {"message": str(e), "resource": {"resource_id": vm.id}} - ) - - errors.append(error_resource_response) - - _LOGGER.debug( - f"** VirtualMachine Finished {time.time() - start_time} Seconds **" - ) - return servers, errors - - @staticmethod - def get_tags(tags): - tags_result = [] - if tags: - for k, v in tags.items(): - tags_result.append({"key": k, "value": v}) - - return tags_result - - @staticmethod - def get_resource_info_in_vm(vm, resource_groups): - for rg in resource_groups: - vm_info = vm.id.split("/") - for info in vm_info: - if info == rg.name.upper(): - resource_group = rg - resource_group_name = rg.name - return resource_group, resource_group_name - - @staticmethod - def get_resources_in_resource_group(resources, resource_group_name): - infos = [] - for resource in resources: - id_info = resource.id.split("/") - for info in id_info: - if info == resource_group_name.upper(): - infos.append(resource) - return infos - - @staticmethod - def get_skus_resource(skus): - skus_dict = {} - for sku in skus: - if sku.resource_type == "virtualMachines": - location = sku.locations[0].lower() - if location not in skus_dict: - skus_dict[location] = [] - info = {} - # get sku information for discriminating Instance type - info.update( - { - "resource_type": sku.resource_type, - "name": sku.name, - "tier": sku.tier, - "size": sku.size, - "family": sku.family, - } - ) - - # get cpu and memory information - for capa in sku.capabilities: - if capa.name == "vCPUs": - info["core"] = capa.value - elif capa.name == "MemoryGB": - info["memory"] = capa.value - skus_dict[location].append(info) - - return skus_dict diff --git a/src/spaceone/inventory/manager/web_pubsub_service/service_manager.py b/src/spaceone/inventory/manager/web_pubsub_service/service_manager.py deleted file mode 100644 index dd3fc5f2..00000000 --- a/src/spaceone/inventory/manager/web_pubsub_service/service_manager.py +++ /dev/null @@ -1,221 +0,0 @@ -import copy -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, -) -from spaceone.inventory.connector.web_pubsub_service.connector import ( - WebPubSubServiceConnector, -) -from spaceone.inventory.model.web_pubsub_service.cloud_service import * -from spaceone.inventory.model.web_pubsub_service.data import * - -_LOGGER = logging.getLogger(__name__) - - -class WebPubSubServiceManager(AzureManager): - connector_name = "WebPubSubServiceConnector" - 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 web pubsub service data resource information - ErrorResourceResponse (list) : list of error resource information - """ - - _LOGGER.debug(f"** Web PubSub Service START **") - start_time = time.time() - subscription_info = params["subscription_info"] - web_pubsub_responses = [] - error_responses = [] - - web_pubsub_service_conn: WebPubSubServiceConnector = self.locator.get_connector( - self.connector_name, **params - ) - web_pubsub_services = web_pubsub_service_conn.list_by_subscription() - - for web_pubsub_service in web_pubsub_services: - web_pubsub_service_id = "" - try: - web_pubsub_service_dict = self.convert_nested_dictionary( - web_pubsub_service - ) - web_pubsub_service_id = web_pubsub_service_dict["id"] - resource_group_name = self.get_resource_group_from_id( - web_pubsub_service_id - ) - resource_name = web_pubsub_service_dict["name"] - - # Update data info in Container Instance's Raw Data - - # Make private endpoint name - if private_endpoints := web_pubsub_service_dict.get( - "private_endpoint_connections", [] - ): - for private_endpoint in private_endpoints: - private_endpoint["private_endpoint"][ - "private_endpoint_name_display" - ] = self.get_resource_name_from_id( - private_endpoint["private_endpoint"]["id"] - ) - - # Collect Web PubSub Hub resource - web_pubsub_hubs = web_pubsub_service_conn.list_hubs( - resource_group_name=resource_group_name, resource_name=resource_name - ) - web_pubsub_hubs_dict = [ - self.convert_nested_dictionary(hub) for hub in web_pubsub_hubs - ] - - _hub_responses, _hub_errors = self._collect_web_pubsub_hub( - web_pubsub_hubs_dict, - subscription_info, - web_pubsub_service_dict["location"], - params["secret_data"]["tenant_id"], - ) - web_pubsub_responses.extend(_hub_responses) - error_responses.extend(_hub_errors) - - # Add Web PubSub Hub info in data - web_pubsub_hub_datas = [ - WebPubSubHub(hub_dict, strict=False) - for hub_dict in web_pubsub_hubs_dict - ] - - # Add Web PubSub Key info in data - # web_pubsub_key = web_pubsub_service_conn.list_keys( - # resource_group_name=resource_group_name, resource_name=resource_name - # ) - web_pubsub_key = {} - if web_pubsub_key: - web_pubsub_service_dict["web_pubsub_key"] = ( - WebPubSubKey( - self.convert_nested_dictionary(web_pubsub_key), strict=False - ), - ) - - web_pubsub_service_dict = self.update_tenant_id_from_secret_data( - web_pubsub_service_dict, params["secret_data"] - ) - web_pubsub_service_dict.update( - { - "resource_group": resource_group_name, - "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], - "azure_monitor": {"resource_id": web_pubsub_service_id}, - "web_pubsub_hubs": web_pubsub_hub_datas, - "web_pubsub_hub_count_display": len(web_pubsub_hub_datas), - } - ) - - web_pubsub_service_data = WebPubSubService( - web_pubsub_service_dict, strict=False - ) - - # Update resource info of Container Instance - web_pubsub_service_resource = WebPubSubServiceResource( - { - "name": resource_name, - "account": web_pubsub_service_dict["subscription_id"], - "data": web_pubsub_service_data, - "tags": web_pubsub_service_dict.get("tags", {}), - "region_code": web_pubsub_service_data.location, - "reference": ReferenceModel( - web_pubsub_service_data.reference() - ), - } - ) - - self.set_region_code(web_pubsub_service_data["location"]) - web_pubsub_responses.append( - WebPubSubServiceResponse({"resource": web_pubsub_service_resource}) - ) - except Exception as e: - _LOGGER.error( - f"[list_instances] {web_pubsub_service_id} {e}", exc_info=True - ) - error_response = self.generate_resource_error_response( - e, "Service", "WebPubSubService", web_pubsub_service_id - ) - error_responses.append(error_response) - - _LOGGER.debug( - f"** Web PubSub Service Finished {time.time() - start_time} Seconds **" - ) - return web_pubsub_responses, error_responses - - def _collect_web_pubsub_hub( - self, web_pubsub_hubs_dict, subscription_info, location, tenant_id - ): - web_pubsub_hub_responses = [] - error_responses = [] - for web_pubsub_hub_dict in web_pubsub_hubs_dict: - web_pubsub_hub_id = "" - try: - web_pubsub_hub_id = web_pubsub_hub_dict["id"] - resource_group_name = self.get_resource_group_from_id(web_pubsub_hub_id) - - web_pubsub_hub_dict.update( - { - "tenant_id": tenant_id, - "location": location, - "resource_group": resource_group_name, - "subscription_id": subscription_info["subscription_id"], - "subscription_name": subscription_info["subscription_name"], - "azure_monitor": {"resource_id": web_pubsub_hub_id}, - "web_pubsub_svc_name": self.get_web_pubsub_name_from_id( - web_pubsub_hub_id - ), - "web_pubsub_hub_evnet_handler_count_display": len( - web_pubsub_hub_dict.get("properties", {}).get( - "event_handlers", [] - ) - ), - } - ) - web_pubsub_hub_data = WebPubSubHub(web_pubsub_hub_dict, strict=False) - web_pubsub_hub_resource = WebPubSubHubResource( - { - "name": web_pubsub_hub_data.name, - "account": web_pubsub_hub_dict["subscription_id"], - "data": web_pubsub_hub_data, - "tags": web_pubsub_hub_dict.get("tags", {}), - "region_code": web_pubsub_hub_data.location, - "reference": ReferenceModel(web_pubsub_hub_data.reference()), - } - ) - web_pubsub_hub_responses.append( - WebPubSubHubResponse({"resource": web_pubsub_hub_resource}) - ) - except Exception as e: - _LOGGER.error( - f"[list_instances] {web_pubsub_hub_id} {e}", exc_info=True - ) - error_response = self.generate_resource_error_response( - e, "Hub", "WebPubSubService", web_pubsub_hub_id - ) - error_responses.append(error_response) - return web_pubsub_hub_responses, error_responses - - @staticmethod - def get_resource_name_from_id(dict_id): - resource_name = dict_id.split("/")[-1] - return resource_name - - @staticmethod - def get_web_pubsub_name_from_id(dict_id): - svc_name = dict_id.split("/")[-3] - return svc_name diff --git a/src/spaceone/inventory/model/__init__.py b/src/spaceone/inventory/model/__init__.py deleted file mode 100644 index 567780d7..00000000 --- a/src/spaceone/inventory/model/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from spaceone.inventory.model.disks import * -from spaceone.inventory.model.snapshots import * -from spaceone.inventory.model.vm_scale_sets import * - diff --git a/src/spaceone/inventory/model/application_gateways/cloud_service.py b/src/spaceone/inventory/model/application_gateways/cloud_service.py deleted file mode 100644 index e41315e6..00000000 --- a/src/spaceone/inventory/model/application_gateways/cloud_service.py +++ /dev/null @@ -1,197 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, MoreField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.application_gateways.data import ApplicationGateway - -''' -APPLICATION_GATEWAY -''' -# TAB - Default -application_gateway_info_meta = ItemDynamicLayout.set_fields('Application Gateway', fields=[ - TextDyField.data_source('Name', 'name', options={ - 'is_optional': True - }), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'data.subscription_id'), - TextDyField.data_source('Virtual Network', 'data.virtual_network'), - TextDyField.data_source('Subnet', 'data.subnet'), - TextDyField.data_source('Frontend public IP Address', 'data.public_ip_address.ip_address'), - TextDyField.data_source('Frontend private IP Address', 'data.private_ip_address'), - TextDyField.data_source('Tier', 'data.sku.tier') -]) - -# TAB - Configuration -application_gateway_configuration = ItemDynamicLayout.set_fields('Configuration', fields=[ - TextDyField.data_source('Capacity ', 'data.sku.tier'), - # TextDyField.data_source('Capacity Type', ''), - TextDyField.data_source('Minimum Instance Count', 'data.autoscale_configuration.min_capacity'), - TextDyField.data_source('Maximum Instance Count', 'data.autoscale_configuration.max_capacity'), - TextDyField.data_source('Enable HTTP2', 'data.enable_http2') -]) - -# TAB - Subnets -# Name, IPv4, IPv6, Available Ips, Delegated To, Security Group -application_gateway_web_app_firewall = ItemDynamicLayout.set_fields('Web Application Firewall', 'data.web_application_firewall_configuration', fields=[ - EnumDyField.data_source('Firewall Status Enabled', 'enabled', default_state={ - 'safe': [True], - 'warning': [False] - }), - TextDyField.data_source('Firewall Mode', 'firewall_mode'), - EnumDyField.data_source('Inspect Request Body', 'request_body_check', default_state={ - 'safe': [True], - 'warning':[False] - }), - TextDyField.data_source('Max Request Body Size(KB)', 'max_request_body_size_in_kb'), - TextDyField.data_source('File Upload Limit(MB)', 'file_upload_limit_in_mb'), - TextDyField.data_source('Rule Set Type', 'rule_set_type'), - TextDyField.data_source('Rule Set Version', 'rule_set_version') - # TextDyField.data_source('Advanced Rule Configuration', ''), - -]) - -application_gateway_web_app_firewall_exclusions = SimpleTableDynamicLayout.set_fields('Exclusions', 'data.web_application_firewall_configuration.exclusions', fields=[ - TextDyField.data_source('Field', 'match_variable'), - TextDyField.data_source('Operator', 'selector_match_operator'), - TextDyField.data_source('Selector', 'selector') -]) - -application_gateway_web_app_firewall_meta = ListDynamicLayout.set_layouts('Web Application Firewall', layouts=[ - application_gateway_web_app_firewall, - application_gateway_web_app_firewall_exclusions - ]) - -# TAB - Backend Pools -# Name,Rule Associated, Targets -application_gateway_backend_pools = SimpleTableDynamicLayout.set_fields('Backend Pools', 'data.backend_address_pools', fields=[ - TextDyField.data_source('Name', 'name'), - ListDyField.data_source('Rule Associated', 'associated_rules'), - ListDyField.data_source('Targets', 'backend_addresses_display', ) -]) - -# TAB - Backend HTTP Settings -application_gateway_http_settings = SimpleTableDynamicLayout.set_fields('Backend HTTP Settings', 'data.backend_http_settings_collection', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Port', 'port'), - TextDyField.data_source('Protocol', 'protocol'), - EnumDyField.data_source('Cookie Based Affinity', 'cookie_based_affinity', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - TextDyField.data_source('Custom Probe', 'custom_probe'), - TextDyField.data_source('Connection draining', 'connection_draining.enabled'), - TextDyField.data_source('Request time-out', 'request_timeout'), - TextDyField.data_source('Override backend path', 'path'), - TextDyField.data_source('Override with new host name', 'pick_host_name_from_backend_address'), - TextDyField.data_source('Host name', 'host_name') -]) - -# TAB - SSL Settings -application_gateway_ssl_settings = SimpleTableDynamicLayout.set_fields('SSL Settings', 'data.ssl_profiles', fields=[ - TextDyField.data_source('Name', 'name'), - ListDyField.data_source('Client Certificates', 'trusted_client_certificates.id'), - TextDyField.data_source('SSL Policy Type', 'ssl_policy.policy_type', options={ - 'is_optional': True - }), -]) - -# TAB - Frontend IP Configurations -application_gateway_frontend_ip_configurations = SimpleTableDynamicLayout.set_fields('Frontend IP Configurations', 'data.frontend_ip_configurations', fields=[ - TextDyField.data_source('Type', 'ip_type'), - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Address', 'ip_address'), - ListDyField.data_source('Associated Listeners', 'associated_listener') -]) - -# TAB - Listeners -application_gateway_listeners = SimpleTableDynamicLayout.set_fields('Listeners', 'data.http_listeners', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Port', 'port'), - TextDyField.data_source('Associated Rule', 'associated_rules'), - TextDyField.data_source('Host name', 'host_name') -]) - -application_gateway_listeners_custom = SimpleTableDynamicLayout.set_fields('Custom Error Configurations', 'data.custom_error_configurations', fields=[ - TextDyField.data_source('Listener Name', 'listener_name'), - TextDyField.data_source('Status Code', 'status_code'), - TextDyField.data_source('Custom Error Page URL', 'custom_error_page_url') -]) - -# 1 + 2) TAB - Listeners -application_gateway_listeners_info = ListDynamicLayout.set_layouts('Listeners', layouts=[ - application_gateway_listeners, - application_gateway_listeners_custom]) - -# TAB - Rules -application_gateway_rules = SimpleTableDynamicLayout.set_fields('Rules', 'data.request_routing_rules', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Type', 'rule_type'), - TextDyField.data_source('Listener', 'http_listener_name'), - TextDyField.data_source('Priority', 'priority') -]) - -# TAB - Rewrites -application_gateway_rewrites = SimpleTableDynamicLayout.set_fields('Rewrites', 'data.rewrite_rule_sets', fields=[ - TextDyField.data_source('Rewrite Sets', 'name'), - TextDyField.data_source('Rules Applied', 'rules_applied'), - ListDyField.data_source('Rewrite Rule Configuration', 'rewrite_rules_display') -]) - -# TAB - Health Probes -application_gateway_health_probes = SimpleTableDynamicLayout.set_fields('Health Probes', 'data.probes', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Host', 'host'), - TextDyField.data_source('Path', 'path'), - TextDyField.data_source('Timeout(Seconds)', 'timeout') -]) - -# TAB - Managed Identity -application_gateway_managed_identity = ItemDynamicLayout.set_fields('Managed Identity', 'data.identity', fields=[ - TextDyField.data_source('Type', 'type'), - TextDyField.data_source('Principal ID', 'principal_id'), - TextDyField.data_source('Tenant ID', 'tenant_id'), - MoreField.data_source('User Assigned Identities', 'output_display', options={ - 'sub_key': 'user_assigned_identities', - 'layout': { - 'name': 'User Assigned Identities', - 'type': 'popup', - 'options': { - 'layout': { - 'type': 'raw' - } - } - } - }) -]) - -application_gateway_meta = CloudServiceMeta.set_layouts( - [application_gateway_info_meta, application_gateway_configuration, - application_gateway_web_app_firewall_meta, application_gateway_backend_pools, application_gateway_http_settings, - application_gateway_frontend_ip_configurations, application_gateway_listeners_info, application_gateway_rules, - application_gateway_rewrites, application_gateway_health_probes, application_gateway_managed_identity]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='ApplicationGateways') - - -class ApplicationGatewayResource(NetworkResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(ApplicationGateway) - _metadata = ModelType(CloudServiceMeta, default=application_gateway_meta, serialized_name='metadata') - name = StringType() - account = StringType() - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - - -class ApplicationGatewayResponse(CloudServiceResponse): - resource = PolyModelType(ApplicationGatewayResource) diff --git a/src/spaceone/inventory/model/application_gateways/cloud_service_type.py b/src/spaceone/inventory/model/application_gateways/cloud_service_type.py deleted file mode 100644 index 67e4cad0..00000000 --- a/src/spaceone/inventory/model/application_gateways/cloud_service_type.py +++ /dev/null @@ -1,237 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -ag_count_by_account_conf = os.path.join(current_dir, 'widget/application_gateways_count_by_account.yaml') -ag_count_by_subscription_conf = os.path.join(current_dir, 'widget/application_gateways_count_by_subscription.yaml') -ag_count_by_location_conf = os.path.join(current_dir, 'widget/application_gateways_count_by_region.yaml') -ag_total_count_conf = os.path.join(current_dir, 'widget/application_gateways_total_count.yaml') - -cst_application_gateways = CloudServiceTypeResource() -cst_application_gateways.name = 'Instance' -cst_application_gateways.group = 'ApplicationGateways' -cst_application_gateways.service_code = 'Microsoft.Network/applicationGateways' -cst_application_gateways.labels = ['Networking'] -cst_application_gateways.is_major = True -cst_application_gateways.is_primary = True -cst_application_gateways.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-application-gateways.svg', -} - -cst_application_gateways._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Public IP Address', 'data.public_ip_address.ip_address'), - TextDyField.data_source('Private IP Address', 'data.private_ip_address'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'data.subscription_id', options={ - 'is_optional': True - }), - # is_optional fields - Configuration - TextDyField.data_source('Capacity', 'data.sku.tier', options={ - 'is_optional': True - }), - TextDyField.data_source('Minimum Instance Count', 'data.autoscale_configuration.min_capacity', options={ - 'is_optional': True - }), - TextDyField.data_source('Maximum Instance Count', 'data.autoscale_configuration.max_capacity', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable HTTP2', 'data.enable_http2', options={ - 'is_optional': True - }), - # is_optional fields - Firewall - TextDyField.data_source('Firewall Mode', 'data.web_application_firewall_configuration.firewall_mode', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Max Request Body Size(KB)', - 'data.web_application_firewall_configuration.max_request_body_size_in_kb', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall File Upload Limit(MB)', 'data.web_application_firewall_configuration.file_upload_limit_in_mb', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Rule Set Type', 'data.web_application_firewall_configuration.rule_set_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Rule Set Version', 'data.web_application_firewall_configuration.rule_set_version', options={ - 'is_optional': True - }), - # is_optional fields - Firewall - TextDyField.data_source('Backend Address Pool Name', 'data.backend_address_pools.name', options={ - 'is_optional': True - }), - ListDyField.data_source('Backend Address Rule Associated', 'data.backend_address_pools.associated_rules', options={ - 'is_optional': True - }), - # is_optional fields - HTTP Settings - TextDyField.data_source('HTTP Backend Name', 'data.backend_http_settings_collection.name', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Backend Port', 'data.backend_http_settings_collection.port', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Backend Protocol', 'data.backend_http_settings_collection.protocol', options={ - 'is_optional': True - }), - # is_optional fields - SSL settings - TextDyField.data_source('SSL Profile Name', 'data.ssl_profiles.name', options={ - 'is_optional': True - }), - ListDyField.data_source('SSL Client Certificates', 'data.ssl_profiles.trusted_client_certificates.id', options={ - 'is_optional': True - }), - TextDyField.data_source('SSL Policy Type', 'data.ssl_profiles.ssl_policy.policy_type', options={ - 'is_optional': True - }), - # is_optional fields - Frontend IP Configurations - TextDyField.data_source('Frontend IP Type', 'data.frontend_ip_configurations.ip_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Frontend IP Configuration Name', 'data.frontend_ip_configurations.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Frontend IP Address', 'data.frontend_ip_configurations.ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Frontend Associated Listeners', 'data.frontend_ip_configurations.associated_listeners', options={ - 'is_optional': True - }), - # is_optional fields - Listeners - TextDyField.data_source('HTTP Listener Name', 'data.http_listeners.name', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Listener Protocol', 'data.http_listeners.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Listener Port', 'data.http_listeners.port', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Listener Associated Rule', 'data.http_listeners.associated_rules', options={ - 'is_optional': True - }), - TextDyField.data_source('HTTP Listener Host name', 'data.http_listeners.host_name', options={ - 'is_optional': True - }), - # is_optional fields - Rules - TextDyField.data_source('Request Routing Rule Name', 'data.request_routing_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Request Routing Rule Type', 'data.request_routing_rules.rule_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Request Routing Rule Listener', 'data.request_routing_rules.http_listener_name', options={ - 'is_optional': True - }), - # is_optional fields - Health Probes - TextDyField.data_source('Health Probes Name', 'data.probes.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Protocol', 'data.probes.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Host', 'data.probes.host', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Path', 'data.probes.path', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Timeout(Seconds)', 'data.probes.timeout', options={ - 'is_optional': True - }) - - ], - search=[ - SearchField.set(name='Subscription ID', key='data.subscription_id'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Public IP Address', key='data.public_ip_address.ip_address'), - SearchField.set(name='Private IP Address', key='data.private_ip_address'), - SearchField.set(name='Capacity', key='data.sku.tier'), - SearchField.set(name='Minimum Instance Count', - key='data.autoscale_configuration.min_capacity', - data_type='integer'), - SearchField.set(name='Maximum Instance Count', - key='data.autoscale_configuration.max_capacity', - data_type='integer'), - SearchField.set(name='Enable HTTP2', - key='data.enable_http2', - data_type='boolean'), - SearchField.set(name='Firewall Mode', - key='data.web_application_firewall_configuration.firewall_mode'), - SearchField.set(name='Firewall Rule Set Type', - key='data.web_application_firewall_configuration.rule_set_type'), - SearchField.set(name='Firewall Rule Set Version', - key='data.web_application_firewall_configuration.rule_set_version'), - SearchField.set(name='Backend Address Pool Name', - key='data.backend_address_pools.name'), - SearchField.set(name='Backend Address Rule Associated', - key='data.backend_address_pools.associated_rules'), - SearchField.set(name='HTTP Backend Name', - key='data.backend_http_settings_collection.name'), - SearchField.set(name='HTTP Backend Port', - key='data.backend_http_settings_collection.port'), - SearchField.set(name='HTTP Backend Protocol', - key='data.backend_http_settings_collection.protocol'), - SearchField.set(name='SSL Profile Name', - key='data.ssl_profiles.name'), - SearchField.set(name='SSL Client Certificates', - key='data.ssl_profiles.trusted_client_certificates.id'), - SearchField.set(name='SSL Policy Type', - key='data.ssl_profiles.ssl_policy.policy_type'), - SearchField.set(name='Frontend IP Type', - key='data.frontend_ip_configurations.ip_type'), - SearchField.set(name='Frontend IP Configuration Name', - key='data.frontend_ip_configurations.name'), - SearchField.set(name='Frontend IP Address', - key='data.frontend_ip_configurations.ip_address'), - SearchField.set(name='Frontend Associated Listeners', - key='data.frontend_ip_configurations.associated_listeners'), - SearchField.set(name='HTTP Listener Name', - key='data.http_listeners.name'), - SearchField.set(name='HTTP Listener Protocol', - key='data.http_listeners.protocol'), - SearchField.set(name='HTTP Listener Port', - key='data.http_listeners.port'), - SearchField.set(name='HTTP Listener Associated Rule', - key='data.http_listeners.associated_rules'), - SearchField.set(name='HTTP Listener Host name', - key='data.http_listeners.host_name'), - SearchField.set(name='Request Routing Rule Name', - key='data.request_routing_rules.name'), - SearchField.set(name='Request Routing Rule Type', - key='data.request_routing_rules.rule_type'), - SearchField.set(name='Request Routing Rule Listener', - key='data.request_routing_rules.http_listener_name'), - SearchField.set(name='Health Probes Name', - key='data.probes.name'), - SearchField.set(name='Health Probes Protocol', - key='data.probes.protocol'), - SearchField.set(name='Health Probes Host', - key='data.probes.host'), - SearchField.set(name='Health Probes Path', - key='data.probes.path'), - SearchField.set(name='Health Probes Timeout(Seconds)', - key='data.probes.timeout', - data_type='integer'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(ag_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(ag_count_by_location_conf)), - ChartWidget.set(**get_data_from_yaml(ag_count_by_account_conf)), - CardWidget.set(**get_data_from_yaml(ag_total_count_conf)) - ] -) - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_application_gateways}), -] diff --git a/src/spaceone/inventory/model/application_gateways/data.py b/src/spaceone/inventory/model/application_gateways/data.py deleted file mode 100644 index 0de3e05f..00000000 --- a/src/spaceone/inventory/model/application_gateways/data.py +++ /dev/null @@ -1,983 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, DateTimeType, FloatType, DictType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class ApplicationGatewayAuthenticationCertificate(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - data = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayAutoscaleConfiguration(Model): - max_capacity = IntType(serialize_when_none=False) - min_capacity = IntType(serialize_when_none=False) - - -class Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties(Model): - client_id = StringType(serialize_when_none=False) - principal_id = StringType(serialize_when_none=False) - - -class ManagedServiceIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(choices=('None', 'SystemAssigned', 'SystemAssigned, UserAssigned', 'UserAssigned'), - serialize_when_none=False) - user_assigned_identities = DictType(ModelType(Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties)) - output_display = StringType(default='show', serialize_when_none=False) - - -class ApplicationGatewayBackendAddress(Model): - fqdn = StringType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - -###### Firewall Classes ###### -class AzureFirewallRCAction(Model): - type = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - - -class AzureFirewallApplicationRuleProtocol(Model): - port = IntType(serialize_when_none=False) - protocol_type = StringType(choices=('Http', 'Https', 'Mssql'), serialize_when_none=False) - - -class AzureFirewallApplicationRule(Model): - description = StringType(serialize_when_none=False) - fqdn_tags = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(ModelType(AzureFirewallApplicationRuleProtocol), serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - target_fqdns = ListType(StringType, serialize_when_none=False) - - -class AzureFirewallApplicationRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallApplicationRule), serialize_when_none=False) - - -class AzureFirewallIPConfiguration(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(SubResource, serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AzureFirewallPublicIPAddress(Model): - address = StringType(serialize_when_none=False) - - -class HubPublicIPAddresses(Model): - address = ListType(ModelType(AzureFirewallPublicIPAddress), serialize_when_none=False) - count = IntType(serialize_when_none=False) - - -class HubIPAddresses(Model): - private_ip_address = StringType(serialize_when_none=False) - public_ips = ModelType(HubPublicIPAddresses, serialize_when_none=False) - - -class AzureFirewallIpGroups(Model): - change_number = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - - -class AzureFirewallNatRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNetworkRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - destination_fqdns = ListType(StringType, serialize_when_none=False) - destination_ip_groups = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNatRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = StringType(choices=('Dnat', 'Snat'), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallNatRule), serialize_when_none=False) - - -class AzureFirewallNetworkRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallNetworkRule), serialize_when_none=False) - - -class AzureFirewallSku(Model): - name = StringType(choices=('AZFW_Hub', 'AZFW_VNet'), serialize_when_none=False) - tier = StringType(choices=('Premium', 'Standard'), serialize_when_none=False) - - -class AzureFirewall(Model): - etag = StringType() - id = StringType() - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - application_rule_collections = ListType(ModelType(AzureFirewallApplicationRuleCollection), serialize_when_none=False) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - hub_ip_addresses = ModelType(HubIPAddresses, serialize_when_none=False) - ip_configurations = ListType(ModelType(AzureFirewallIPConfiguration), serialize_when_none=False) - ip_groups = ListType(ModelType(AzureFirewallIpGroups), serialize_when_none=False) - management_ip_configuration = ModelType(AzureFirewallIPConfiguration, serialize_when_none=False) - nat_rule_collections = ListType(ModelType(AzureFirewallNatRuleCollection), serialize_when_none=False) - network_rule_collections = ListType(ModelType(AzureFirewallNetworkRuleCollection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - sku = ModelType(AzureFirewallSku, serialize_when_none=False) - threat_intel_mode = StringType(choices=('Alert', 'Deny', 'Off'), serialize_when_none=False) - virtual_hub = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(Model): - fqdns = ListType(StringType, serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - required_member_name = StringType(serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = StringType(serialize_when_none=False) # Change to PublicIPAddress ID - subnet = StringType(serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class NatGatewaySku(Model): - name = StringType(choices=('Standard', None), serialize_when_none=False) - - -class NatGateway(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - - -class PublicIPAddress(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nat_gateway = ModelType(NatGateway, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class Delegation(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(default='-', serialize_when_none=False) - actions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service_name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfigurationProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class SecurityRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - access = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - description = StringType(serialize_when_none=False) - destination_address_prefix = StringType(serialize_when_none=False) - destination_address_prefixes = ListType(StringType, serialize_when_none=False) - destination_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - destination_port_range = StringType(serialize_when_none=False) - destination_port_ranges = ListType(StringType, serialize_when_none=False) - direction = StringType(choices=('Inbound', 'Outbound'), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - protocol = StringType(choices=('*', 'Ah', 'Esp', 'Icmp', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - source_address_prefix = StringType(serialize_when_none=False) - source_address_prefixes = ListType(StringType, serialize_when_none=False) - source_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - source_port_range = StringType(serialize_when_none=False) - source_port_ranges = ListType(StringType, serialize_when_none=False) - - -class RetentionPolicyParameters(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class TrafficAnalyticsConfigurationProperties(Model): - enabled = BooleanType(serialize_when_none=False) - traffic_analytics_interval = IntType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - workspace_region = StringType(serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class TrafficAnalyticsProperties(Model): - network_watcher_flow_analytics_configuration = ModelType(TrafficAnalyticsConfigurationProperties, - serialize_when_none=False) - - -class FlowLogFormatType(Model): - json = StringType(serialize_when_none=False) - - -class FlowLogFormatParameters(Model): - type = ModelType(FlowLogFormatType, serialize_when_none=False) - version = IntType(serialize_when_none=False) - - -class FlowLog(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - enable = BooleanType(serialize_when_none=False) - flow_analytics_configuration = ModelType(TrafficAnalyticsProperties, serialize_when_none=False) - format = ModelType(FlowLogFormatParameters, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - retention_policy = ModelType(RetentionPolicyParameters, serialize_when_none=False) - storage_id = StringType(serialize_when_none=False) - target_resource_guid = StringType(serialize_when_none=False) - target_resource_id = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - default_security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = StringType(serialize_when_none=False) # Change to Network interfaces' Id - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) # Change to Subnet IDs - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class CustomDnsConfigPropertiesFormat(Model): - fqdn = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType, serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState, serialize_when_none=False) - private_link_service_id = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - request_message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpoint(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) - manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), - serialize_when_none=False) - network_interfaces = ListType(StringType, serialize_when_none=False) # Change to network interface ids - private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ResourceNavigationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Route(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - next_hop_ip_address = StringType(serialize_when_none=False) - next_hop_type = StringType(choices=('Internet', 'None', 'VirtualAppliance', 'VirtualNetworkGateway', 'VnetLocal'), - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - - -class RouteTable(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - disable_bgp_route_propagation = BooleanType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - routes = ListType(ModelType(Route), serialize_when_none=False) - subnets = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceAssociationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allow_delete = BooleanType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - locations = ListType(ModelType(ExtendedLocation), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class ServiceEndpointPolicy(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - service_endpoint_policy_definitions = ListType(ModelType(ServiceEndpointPolicyDefinition), - serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPropertiesFormat(Model): - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - - -class Subnet(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - address_prefixes = ListType(StringType, serialize_when_none=False) - application_gateway_ip_configurations = ListType(StringType, serialize_when_none=False) # Change to ip configurations id - delegations = ListType(ModelType(Delegation), serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource), serialize_when_none=False) - ip_configuration_profiles = ListType(ModelType(IPConfigurationProfile), serialize_when_none=False) - ip_configurations = ListType(ModelType(IPConfiguration), serialize_when_none=False) - azure_firewall = ListType(ModelType(AzureFirewall), serialize_when_none=False) - nat_gateway = ModelType(SubResource, serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroup, serialize_when_none=False) - private_endpoint_network_policies = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - private_endpoints = ListType(ModelType(PrivateEndpoint), serialize_when_none=False) - private_link_service_network_policies = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - purpose = StringType(serialize_when_none=False) - resource_navigation_links = ListType(ModelType(ResourceNavigationLink, serialize_when_none=False)) - route_table = ModelType(RouteTable, serialize_when_none=False) - service_association_links = ListType(ModelType(ServiceAssociationLink), serialize_when_none=False) - service_endpoint_policies = ListType(ModelType(ServiceEndpointPolicy), serialize_when_none=False) - service_endpoints = ListType(ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(SubResource), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(SubResource), serialize_when_none=False) - load_balancing_rules = ListType(ModelType(SubResource), serialize_when_none=False) - outbound_rules = ListType(ModelType(SubResource), serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class VirtualNetworkTap(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - destination_load_balancer_front_end_ip_configuration = ModelType(FrontendIPConfiguration, serialize_when_none=False) - destination_network_interface_ip_configuration = StringType(serialize_when_none=False) # Change to networkinterface ip configuration - destination_port = IntType(serialize_when_none=False) - network_interface_tap_configurations = ListType(StringType,serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ListType(ModelType(Tags)) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfiguration(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_gateway_backend_address_pools = ListType(StringType, serialize_when_none=False) # Change to ApplicationGatewayBackendAddressPool's ID - application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - load_balancer_backend_address_pools = ListType(StringType, serialize_when_none=False) # Change to backend address pools id - load_balancer_inbound_nat_rules = ListType(StringType, serialize_when_none=False) # Change to inbound NAT rules id - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - private_link_connection_properties = ModelType(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - subnet = ModelType(Subnet, serialize_when_none=False) - virtual_network_taps = ListType(ModelType(VirtualNetworkTap), serialize_when_none=False) - - -class ApplicationGatewayBackendAddressPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_addresses = ListType(ModelType(ApplicationGatewayBackendAddress), serialize_when_none=False) - backend_addresses_display = ListType(StringType, serialize_when_none=False) - backend_ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - associated_rules = ListType(StringType, serialize_when_none=False) - - -class ApplicationGatewayConnectionDraining(Model): - drain_timeout_in_sec = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class ApplicationGatewayBackendHttpSettings(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - affinity_cookie_name = StringType(serialize_when_none=False) - authentication_certificates = ListType(ModelType(SubResource), serialize_when_none=False) - connection_draining = ModelType(ApplicationGatewayConnectionDraining, serialize_when_none=False) - cookie_based_affinity = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - host_name = StringType(serialize_when_none=False) - path = StringType(serialize_when_none=False) - pick_host_name_from_backend_address = BooleanType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - probe = ModelType(SubResource, serialize_when_none=False) - probe_enabled = BooleanType(serialize_when_none=False) - custom_probe = StringType(serialize_when_none=False) - protocol = StringType(choices=('Http', 'Https'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - request_timeout = IntType(serialize_when_none=False) - trusted_root_certificates = ListType(ModelType(SubResource), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayCustomError(Model): - listener_name = StringType(serialize_when_none=False) - custom_error_page_url = StringType(serialize_when_none=False) - status_code = StringType(choices=('HttpStatus403', 'HttpStatus502')) - - -class ApplicationGatewayFrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - type = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - private_link_configuration = ModelType(SubResource, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(SubResource, serialize_when_none=False) - ip_type = StringType(choices=('Public', 'Private'), serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - associated_listener = ListType(StringType, serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - - -class ApplicationGatewayFrontendPort(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayHttpListener(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_error_configurations = ListType(ModelType(ApplicationGatewayCustomError), serialize_when_none=False) - firewall_policy = ModelType(SubResource) - frontend_ip_configuration = ModelType(SubResource) - frontend_port = ModelType(SubResource) - port = IntType(serialize_when_none=False) - host_name = StringType(default='-') - host_names = ListType(StringType, serialize_when_none=False) - protocol = StringType(choices=('Http', 'Https'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - require_server_name_indication = BooleanType(serialize_when_none=False) - ssl_certificate = ModelType(SubResource, serialize_when_none=False) - ssl_profile = ModelType(SubResource, serialize_when_none=False) - associated_rules = ListType(StringType, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayPrivateEndpointConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link_identifier = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpoint, serialize_when_none=False) - private_link_service_connection_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayPrivateLinkIpConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayPrivateLinkConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - ip_configurations = ListType(ModelType(ApplicationGatewayPrivateLinkIpConfiguration), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayProbeHealthResponseMatch(Model): - body = StringType(serialize_when_none=False) - status_codes = ListType(StringType, serialize_when_none=False) - - -class ApplicationGatewayProbe(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - host = StringType(serialize_when_none=False) - interval = IntType(serialize_when_none=False) - match = ModelType(ApplicationGatewayProbeHealthResponseMatch, serialize_when_none=False) - min_servers = IntType(serialize_when_none=False) - path = StringType(serialize_when_none=False) - pick_host_name_from_backend_http_settings = BooleanType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - protocol = StringType(choices=('Http', 'Https'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - timeout = IntType(serialize_when_none=False) - unhealthy_threshold = IntType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayRedirectConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - include_path = BooleanType(serialize_when_none=False) - include_query_string = BooleanType(serialize_when_none=False) - path_rules = ListType(ModelType(SubResource), serialize_when_none=False) - redirect_type = StringType(choices=('Found', 'Permanent', 'SeeOther', 'Temporary'), serialize_when_none=False) - request_routing_rules = ListType(ModelType(SubResource), serialize_when_none=False) - target_listener = ModelType(SubResource, serialize_when_none=False) - target_url = StringType(serialize_when_none=False) - url_path_maps = ListType(ModelType(SubResource), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayRequestRoutingRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_http_settings = ModelType(SubResource, serialize_when_none=False) - http_listener = ModelType(SubResource, serialize_when_none=False) - http_listener_name = StringType(default='-') - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - redirect_configuration = ModelType(SubResource, serialize_when_none=False) - rewrite_rule_set = ModelType(SubResource, serialize_when_none=False) - rule_type = StringType(choices=('Basic', 'PathBasedRouting'), serialize_when_none=False) - url_path_map = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayHeaderConfiguration(Model): - header_name = StringType(serialize_when_none=False) - header_value = StringType(serialize_when_none=False) - - -class ApplicationGatewayUrlConfiguration(Model): - modified_path = StringType(serialize_when_none=False) - modified_query_string = StringType(serialize_when_none=False) - reroute = BooleanType(serialize_when_none=False) - - -class ApplicationGatewayRewriteRuleActionSet(Model): - request_header_configurations = ListType(ModelType(ApplicationGatewayHeaderConfiguration), serialize_when_none=False) - response_header_configurations = ListType(ModelType(ApplicationGatewayHeaderConfiguration), serialize_when_none=False) - url_configuration = ModelType(ApplicationGatewayUrlConfiguration, serialize_when_none=False) - - -class ApplicationGatewayRewriteRuleCondition(Model): - ignore_case = BooleanType(serialize_when_none=False) - negate = BooleanType(serialize_when_none=False) - pattern = StringType(serialize_when_none=False) - variable = StringType(serialize_when_none=False) - - -class ApplicationGatewayRewriteRule(Model): - action_set = ModelType(ApplicationGatewayRewriteRuleActionSet, serialize_when_none=False) - conditions = ListType(ModelType(ApplicationGatewayRewriteRuleCondition), serialize_when_none=False) - name = StringType(serialize_when_none=False) - rule_sequence = IntType(serialize_when_none=False) - - -class ApplicationGatewayRewriteRuleSet(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rewrite_rules = ListType(ModelType(ApplicationGatewayRewriteRule), serialize_when_none=False) - rewrite_rules_display = ListType(StringType, serialize_when_none=False) - rules_applied = ListType(StringType, serialize_when_none=False) - - -class ApplicationGatewaySku(Model): - capacity = IntType(serialize_when_none=False) - name = StringType(choices=('Standard_Large', 'Standard_Medium', 'Standard_Small', 'Standard_v2', - 'WAF_Large', 'WAF_Medium', 'WAF_v2'), serialize_when_none=False) - tier = StringType(choices=('Standard', 'Standard_v2', 'WAF', 'WAF_v2'), serialize_when_none=False) - - -class ApplicationGatewaySslCertificate(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - data = StringType(serialize_when_none=False) - key_vault_secret_id = StringType(serialize_when_none=False) - password = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_cert_data = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewaySslPolicy(Model): - cipher_suites = ListType(StringType, serialize_when_none=False) - disabled_ssl_protocols = ListType(StringType, serialize_when_none=False) - min_protocol_version = StringType(choices=('TLSv1_0', 'TLSv1_1', 'TLSv1_2'), serialize_when_none=False) - policy_name = StringType(choices=('AppGwSslPolicy20150501', 'AppGwSslPolicy20170401', 'AppGwSslPolicy20170401S'), - serialize_when_none=False) - policy_type = StringType(choices=('Custom', 'Predefined'), serialize_when_none=False) - - -class ApplicationGatewayClientAuthConfiguration(Model): - verify_client_cert_issuer_dn = BooleanType(serialize_when_none=False) - - -class ApplicationGatewaySslProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - client_auth_configuration = ModelType(ApplicationGatewayClientAuthConfiguration, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - ssl_policy = ModelType(ApplicationGatewaySslPolicy, serialize_when_none=False) - trusted_client_certificates = ListType(ModelType(SubResource), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayTrustedClientCertificate(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - data = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayTrustedRootCertificate(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - data = StringType(serialize_when_none=False) - key_vault_secret_id = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayPathRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_http_settings = ModelType(SubResource, serialize_when_none=False) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - paths = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - redirect_configuration = ModelType(SubResource, serialize_when_none=False) - rewrite_rule_set = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayUrlPathMap(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - default_backend_address_pool = ModelType(SubResource, serialize_when_none=False) - default_backend_http_settings = ModelType(SubResource, serialize_when_none=False) - default_redirect_configuration = ModelType(SubResource, serialize_when_none=False) - default_rewrite_rule_set = ModelType(SubResource, serialize_when_none=False) - path_rules = ListType(ModelType(ApplicationGatewayPathRule), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayFirewallExclusion(Model): - match_variable = StringType(serialize_when_none=False) - selector = StringType(serialize_when_none=False) - selector_match_operator = StringType(serialize_when_none=False) - - -class ApplicationGatewayFirewallDisabledRuleGroup(Model): - rule_group_name = StringType(serialize_when_none=False) - rules = ListType(IntType, serialize_when_none=False) - - -class ApplicationGatewayWebApplicationFirewallConfiguration(Model): - disabled_rule_groups = ListType(ModelType(ApplicationGatewayFirewallDisabledRuleGroup), serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - exclusions = ListType(ModelType(ApplicationGatewayFirewallExclusion), serialize_when_none=False) - file_upload_limit_in_mb = IntType(serialize_when_none=False) - firewall_mode = StringType(choices=('Detection', 'Prevention'), serialize_when_none=False) - max_request_body_size = IntType(serialize_when_none=False) - max_request_body_size_in_kb = IntType(serialize_when_none=False) - request_body_check = BooleanType(serialize_when_none=False) - rule_set_type = StringType(serialize_when_none=False) - rule_set_version = StringType(serialize_when_none=False) - - -class ApplicationGateway(AzureCloudService): # Main Class - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - identity = ModelType(ManagedServiceIdentity, serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - authentication_certificates = ListType(ModelType(ApplicationGatewayAuthenticationCertificate), - serialize_when_none=False) - autoscale_configuration = ModelType(ApplicationGatewayAutoscaleConfiguration, serialize_when_none=False) - backend_address_pools = ListType(ModelType(ApplicationGatewayBackendAddressPool), serialize_when_none=False) - backend_http_settings_collection = ListType(ModelType(ApplicationGatewayBackendHttpSettings), - serialize_when_none=False) - custom_error_configurations = ListType(ModelType(ApplicationGatewayCustomError), serialize_when_none=False) - enable_fips = BooleanType(serialize_when_none=False) - enable_http2 = BooleanType(serialize_when_none=False) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - force_firewall_policy_association = BooleanType(serialize_when_none=False) - frontend_ip_configurations = ListType(ModelType(ApplicationGatewayFrontendIPConfiguration), - serialize_when_none=False) - frontend_ports = ListType(ModelType(ApplicationGatewayFrontendPort), serialize_when_none=False) - gateway_ip_configurations = ListType(ModelType(ApplicationGatewayIPConfiguration), serialize_when_none=False) - http_listeners = ListType(ModelType(ApplicationGatewayHttpListener), serialize_when_none=False) - operational_state = StringType(choices=('Running', 'Starting', 'Stopped', 'Stopping'), serialize_when_none=False) - private_endpoint_connections = ListType(ModelType(ApplicationGatewayPrivateEndpointConnection), - serialize_when_none=False) - private_link_configurations = ListType(ModelType(ApplicationGatewayPrivateLinkConfiguration), - serialize_when_none=False) - probes = ListType(ModelType(ApplicationGatewayProbe), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), - serialize_when_none=False) - redirect_configurations = ListType(ModelType(ApplicationGatewayRedirectConfiguration), - serialize_when_none=False) - request_routing_rules = ListType(ModelType(ApplicationGatewayRequestRoutingRule), - serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - rewrite_rule_sets = ListType(ModelType(ApplicationGatewayRewriteRuleSet), serialize_when_none=False) - sku = ModelType(ApplicationGatewaySku, serialize_when_none=False) - ssl_certificates = ListType(ModelType(ApplicationGatewaySslCertificate), serialize_when_none=False) - ssl_policy = ModelType(ApplicationGatewaySslPolicy, serialize_when_none=False) - ssl_profiles = ListType(ModelType(ApplicationGatewaySslProfile), serialize_when_none=False) - trusted_client_certificates = ListType(ModelType(ApplicationGatewayTrustedClientCertificate), - serialize_when_none=False) - trusted_root_certificates = ListType(ModelType(ApplicationGatewayTrustedRootCertificate), serialize_when_none=False) - url_path_maps = ListType(ModelType(ApplicationGatewayUrlPathMap), serialize_when_none=False) - web_application_firewall_configuration = ModelType(ApplicationGatewayWebApplicationFirewallConfiguration, - serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - virtual_network = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - launched_at = DateTimeType(serialize_when_none=False) - zones = ListType(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", - } diff --git a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_account.yaml b/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_account.yaml deleted file mode 100644 index cc39f16c..00000000 --- a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: ApplicationGateways -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_region.yaml b/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_region.yaml deleted file mode 100644 index 8f045b76..00000000 --- a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: ApplicationGateways -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_subscription.yaml b/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_subscription.yaml deleted file mode 100644 index 40184c03..00000000 --- a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: ApplicationGateways -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_total_count.yaml b/src/spaceone/inventory/model/application_gateways/widget/application_gateways_total_count.yaml deleted file mode 100644 index 267c4805..00000000 --- a/src/spaceone/inventory/model/application_gateways/widget/application_gateways_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: ApplicationGateways -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/container_instances/__init__.py b/src/spaceone/inventory/model/container_instances/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/container_instances/cloud_service.py b/src/spaceone/inventory/model/container_instances/cloud_service.py deleted file mode 100644 index da09e6e0..00000000 --- a/src/spaceone/inventory/model/container_instances/cloud_service.py +++ /dev/null @@ -1,95 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType -from spaceone.inventory.model.container_instances.data import ContainerInstance -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, ListDyField - -''' -CONTAINER_INSTANCES -''' - -# TAB - Default -container_instances_info_meta = ItemDynamicLayout.set_fields('Container Instances', fields=[ - TextDyField.data_source('Name', 'name'), - EnumDyField.data_source('State', 'data.instance_view.state', default_state={ - 'safe': ['Running', 'Succeeded'], - 'warning': ['Pending'], - 'alert': ['Stopped', 'Failed'], - 'disable': []}), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Region', 'region_code'), - TextDyField.data_source('SKU', 'data.sku'), - TextDyField.data_source('OS type', 'data.os_type'), - TextDyField.data_source('Container count', 'data.container_count_display'), - TextDyField.data_source('vCPU count', 'data.container_count_display'), - TextDyField.data_source('Memory size(GB)', 'data.memory_size_display'), - TextDyField.data_source('GPU count', 'data.gpu_count_display'), - TextDyField.data_source('Volume count', 'data.volume_count_display'), - TextDyField.data_source('IP Address', 'data.ip_address.ip'), - TextDyField.data_source('IP Address Type', 'data.ip_address.type'), - TextDyField.data_source('FQDN', 'data.ip_address.fqdn'), - TextDyField.data_source('DNS name label', 'data.ip_address.dns_name_label'), - TextDyField.data_source('DNS name label scope reuse', 'data.ip_address.auto_generated_domain_name_label_scope'), - ListDyField.data_source('Ports', 'data.ip_address.ports.port', options={'delimiter': '
'}), -]) - -# TAB -Container -container_instances_info_container = TableDynamicLayout.set_fields('Containers', root_path='data.containers', fields=[ - TextDyField.data_source('Name', 'name'), - EnumDyField.data_source('State', 'instance_view.current_state.state', default_state={ - 'safe': ['Running'], - 'warning': ['Waiting'], - 'alert': ['Terminated'], - 'disable': []}), - TextDyField.data_source('Previous state', 'instance_view.previous_state.state'), - TextDyField.data_source('Restart count', 'instance_view.restart_count'), - TextDyField.data_source('Volume count', 'volume_mount_count_display'), - TextDyField.data_source('CPU cores', 'resources.requests.cpu', options={ - 'translation_id': 'PAGE_SCHEMA.CPU_CORE', - }), - TextDyField.data_source('Memory(GB)', 'resources.requests.memory_in_gb', options={ - 'translation_id': 'PAGE_SCHEMA.MEMORY', - }), - TextDyField.data_source('Image', 'image'), - DateTimeDyField.data_source('Start time', 'instance_view.current_state.start_time'), - DateTimeDyField.data_source('Finish time', 'instance_view.current_state.finish'), - TextDyField.data_source('GPU SKU', 'resources.requests.gpu.sku'), - TextDyField.data_source('GPU count', 'resources.requests.gpu.count'), - ListDyField.data_source('Ports', 'ports.port', options={'delimiter': '
'}), - ListDyField.data_source('Commands', 'command', options={'delimiter': '
'}), - -]) - -# TAB - Volume -container_instances_info_volumes = TableDynamicLayout.set_fields('Volumes', root_path='data.volumes', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Volume type', 'volume_type'), - TextDyField.data_source('Mount path', 'mount_path'), - TextDyField.data_source('Git repository', 'git_repo.repository'), - TextDyField.data_source('Container name', 'container_name') -]) - -container_instances_meta = CloudServiceMeta.set_layouts( - [container_instances_info_meta, container_instances_info_container, container_instances_info_volumes] -) - - -class ContainerResource(CloudServiceResource): - cloud_service_group = StringType(default='ContainerInstances') - - -class ContainerInstanceResource(ContainerResource): - cloud_service_type = StringType(default='Container') - data = ModelType(ContainerInstance) - _metadata = ModelType(CloudServiceMeta, default=container_instances_meta, serialized_name='metadata') - name = StringType(serialize_when_none=False) - account = StringType(serialize_when_none=False) - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - - -class ContainerInstanceResponse(CloudServiceResponse): - resource = PolyModelType(ContainerInstanceResource) diff --git a/src/spaceone/inventory/model/container_instances/cloud_service_type.py b/src/spaceone/inventory/model/container_instances/cloud_service_type.py deleted file mode 100644 index 8b313c6e..00000000 --- a/src/spaceone/inventory/model/container_instances/cloud_service_type.py +++ /dev/null @@ -1,105 +0,0 @@ -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, EnumDyField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -container_instances_count_by_account_conf = os.path.join(current_dir, 'widget/container_instances_count_by_account.yaml') -container_instances_count_by_region_conf = os.path.join(current_dir, 'widget/container_instances_count_by_region.yaml') -container_instances_count_by_subscription_conf = os.path.join(current_dir, 'widget/container_Instances_count_by_subscription.yaml') -container_instances_total_container_conf = os.path.join(current_dir, 'widget/container_instances_total_container_count.yaml') -container_instances_total_count_conf = os.path.join(current_dir, 'widget/container_instances_total_count.yaml') -container_instances_total_gpu_conf = os.path.join(current_dir, 'widget/container_instances_total_gpu_count.yaml') -container_instances_total_memory_conf = os.path.join(current_dir, 'widget/container_instances_total_memory_size.yaml') -container_instances_total_vcpu_conf = os.path.join(current_dir, 'widget/container_instances_total_vcpu_count.yaml') - -cst_container_instances = CloudServiceTypeResource() -cst_container_instances.name = 'Container' -cst_container_instances.group = 'ContainerInstances' -cst_container_instances.service_code = 'Microsoft.ContainerInstance/containerGroups' -cst_container_instances.labels = ['Container'] -cst_container_instances.is_major = True -cst_container_instances.is_primary = True -cst_container_instances.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-container-instances.svg', -} -cst_container_instances._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source('State', 'data.instance_view.state', default_state={ - 'safe': ['Running', 'Succeeded'], - 'warning': ['Pending'], - 'alert': ['Stopped', 'Failed'], - 'disable': []}), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('OS type', 'data.os_type'), - TextDyField.data_source('Container count', 'data.container_count_display'), - TextDyField.data_source('vCPU count', 'data.container_count_display'), - TextDyField.data_source('Memory size(GB)', 'data.memory_size_display'), - TextDyField.data_source('Volume count', 'data.volume_count_display'), - TextDyField.data_source('GPU count', 'data.gpu_count_display'), - TextDyField.data_source('Provisioning State', 'data.provisioning_state', options={ - 'is_optional': True - }), - TextDyField.data_source('Restart Policy', 'data.restart_policy', options={ - 'is_optional': True - }), - TextDyField.data_source('IP Address', 'data.ip_address.ip', options={ - 'is_optional': True - }), - TextDyField.data_source('IP Address Type', 'data.ip_address.type', options={ - 'is_optional': True - }), - TextDyField.data_source('FQDN', 'data.ip_address.fqdn', options={ - 'is_optional': True - }), - TextDyField.data_source('DNS name label', 'data.ip_address.dns_name_label', options={ - 'is_optional': True}), - TextDyField.data_source('DNS name label scope reuse', 'data.ip_address.auto_generated_domain_name_label_scope', - options={'is_optional': True}), - - ], - search=[ - SearchField.set(name='Status', key='data.instance_view.state'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='OS type', key='data.os_type'), - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Provisioning State', key='data.provisioning_state'), - SearchField.set(name='Restart Policy', key='data.restart_policy'), - SearchField.set(name='IP Address', key='data.ip_address.ip'), - SearchField.set(name='FQDN', key='data.ip_address.fqdn'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='SKU', key='data.sku'), - SearchField.set(name='Container count', key='data.container_count_display', data_type='integer'), - SearchField.set(name='vCPU', key='data.cpu_count_display', data_type='integer'), - SearchField.set(name='Memory size(GB)', key='data.memory_size_display', data_type='float'), - SearchField.set(name='GPU count', key='data.gpu_count_display', data_type='integer'), - SearchField.set(name='Volume count', key='data.volume_count_display', data_type='integer'), - SearchField.set(name='DNS name label', key='data.ip_address.dns_name_label'), - SearchField.set(name='DNS name label scope reuse', key='data.ip_address.auto_generated_domain_name_label_scope') - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(container_instances_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(container_instances_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(container_instances_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(container_instances_total_count_conf)), - CardWidget.set(**get_data_from_yaml(container_instances_total_container_conf)), - CardWidget.set(**get_data_from_yaml(container_instances_total_vcpu_conf)), - CardWidget.set(**get_data_from_yaml(container_instances_total_memory_conf)), - CardWidget.set(**get_data_from_yaml(container_instances_total_gpu_conf)) - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_container_instances}), -] \ No newline at end of file diff --git a/src/spaceone/inventory/model/container_instances/data.py b/src/spaceone/inventory/model/container_instances/data.py deleted file mode 100644 index a8028515..00000000 --- a/src/spaceone/inventory/model/container_instances/data.py +++ /dev/null @@ -1,268 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, DictType, StringType, ListType, IntType, BooleanType, DateTimeType, FloatType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -# ContainerGroupIdentity -class UserAssignedIdentity(Model): - client_id = StringType(serialize_when_none=False) - principal_id = StringType(serialize_when_none=False) - - -class ContainerGroupIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(choices=('NONE', 'SYSTEM_ASSIGNED', 'SYSTEM_ASSIGNED_USER_ASSIGNED', 'USER_ASSIGNED'), - serialize_when_none=False) - user_assigned_identities = DictType(StringType(), ModelType(UserAssignedIdentity), serialize_when_none=False) - - -# Container -class ContainerPort(Model): - protocol = StringType(choices=('TCP', 'UDP'), default='TCP') - port = StringType(serialize_when_none=False) - - -class EnvironmentVariable(Model): - name = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - secure_value = StringType(serialize_when_none=False) - - -# Container - ContainerPropertiesInstanceView -class ContainerState(Model): - state = StringType(serialize_when_none=False) - start_time = DateTimeType(serialize_when_none=False) - exit_code = IntType(serialize_when_none=False) - finish_time = DateTimeType(serialize_when_none=False) - detail_status = StringType(serialize_when_none=False) - - -class Event(Model): - count = IntType(serialize_when_none=False) - first_timestamp = DateTimeType(serialize_when_none=False) - last_timestamp = DateTimeType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ContainerPropertiesInstanceView(Model): - restart_count = IntType(serialize_when_none=False) - current_state = ModelType(ContainerState, serialize_when_none=False) - previous_state = ModelType(ContainerState, serialize_when_none=False) - events = ListType(ModelType(Event), serialize_when_none=False) - - -# Container - ResourceRequirements -class GpuResource(Model): - count = IntType(serialize_when_none=False) - sku = StringType(choices=('K80', 'P100', 'V100'), serialize_when_none=False) - - -class ResourceRequests(Model): - memory_in_gb = FloatType(serialize_when_none=False) - cpu = FloatType(serialize_when_none=False) - gpu = ModelType(GpuResource, serialize_when_none=False) - - -class ResourceLimits(Model): - memory_in_gb = FloatType(serialize_when_none=False) - cpu = FloatType(serialize_when_none=False) - gpu = ModelType(GpuResource, serialize_when_none=False) - - -class ResourceRequirements(Model): - requests = ModelType(ResourceRequests, serialize_when_none=False) - limits = ModelType(ResourceLimits, serialize_when_none=False) - - -# Container - VolumeMount -class VolumeMount(Model): - name = StringType(serialize_when_none=False) - mount_path = StringType(serialize_when_none=False) - read_only = BooleanType(serialize_when_none=False) - - -# Container - ContainerProbe -class ContainerExec(Model): - command = ListType(StringType(serialize_when_none=False)) - - -class HttpHeader(Model): - name = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class ContainerHttpGet(Model): - path = StringType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - scheme = StringType(choices=('HTTP', 'HTTPS'), serialize_when_none=False) - http_headers = ListType(ModelType(HttpHeader), serialize_when_none=False) - - -class ContainerProbe(Model): - exec_property = ModelType(ContainerExec, serialize_when_none=False) - http_get = ModelType(ContainerHttpGet, serialize_when_none=False) - initial_delay_seconds = IntType(serialize_when_none=False) - period_seconds = IntType(serialize_when_none=False) - failure_threshold = IntType(serialize_when_none=False) - success_threshold = IntType(serialize_when_none=False) - timeout_seconds = IntType(serialize_when_none=False) - - -class Container(Model): - name = StringType(serialize_when_none=False) - image = StringType(serialize_when_none=False) - command = ListType(StringType, serialize_when_none=False) - ports = ListType(ModelType(ContainerPort), serialize_when_none=False) - environment_variables = ListType(ModelType(EnvironmentVariable), serialize_when_none=False) - instance_view = ModelType(ContainerPropertiesInstanceView) - resources = ModelType(ResourceRequirements, serialize_when_none=False) - volume_mounts = ListType(ModelType(VolumeMount), serialize_when_none=None) - volume_mount_count_display = IntType(default=0) - liveness_probe = ModelType(ContainerProbe, serialize_when_none=False) - readiness_probe = ModelType(ContainerProbe, serialize_when_none=False) - - -# ImageRegistryCredential -class ImageRegistryCredential(Model): - server = StringType(serialize_when_none=False) - username = StringType(serialize_when_none=False) - password = StringType(serialize_when_none=False) - identity = StringType(serialize_when_none=False) - identity_url = StringType(serialize_when_none=False) - - -# IpAddress -class Port(ContainerPort): - pass - - -class IpAddress(Model): - ports = ListType(ModelType(Port), serialize_when_none=False) - type = StringType(choices=('PRIVATE', 'PUBLIC')) - ip = StringType(serialize_when_none=False) - dns_name_label = StringType(serialize_when_none=False) - auto_generated_domain_name_label_scope = StringType(choices=('NOREUSE', 'RESOURCE_GROUP_REUSE', 'SUBSCRIPTION_REUSE', - 'TENANT_REUSE', 'UNSECURE')) - fqdn = StringType(serialize_when_none=False) - - -# Volume - -# Volume - AzureFileVolume -class AzureFileVolume(Model): - share_name = StringType(serialize_when_none=False) - read_only = BooleanType(serialize_when_none=False) - storage_account_name = StringType(serialize_when_none=False) - storage_account_key = StringType(serialize_when_none=False) - - -# Volume - GitRepoVolume -class GitRepoVolume(Model): - directory = StringType(serialize_when_none=False) - repository = StringType(serialize_when_none=False) - revision = StringType(serialize_when_none=False) - - -class Volume(Model): - name = StringType(serialize_when_none=False) - azure_file = ModelType(AzureFileVolume, serialize_when_none=False) - empty_dir = DictType(StringType, serialize_when_none=False) - secret = DictType(StringType, serialize_when_none=False) - git_repo = ModelType(GitRepoVolume, serialize_when_none=False) - volume_type = StringType(serialize_when_none=False) - mount_path = StringType(serialize_when_none=False) - container_name = StringType(serialize_when_none=False) - - -# ContainerGroupPropertiesInstanceView -class ContainerGroupPropertiesInstanceView(Model): - events = ListType(ModelType(Event)) - state = StringType(serialize_when_none=False) - -# ContainerGroupDiagnostics - - -# ContainerGroupDiagnostics LogAnalytics -class LogAnalytics(Model): - workspace_id = StringType(serialize_when_none=False) - workspace_key = StringType(serialize_when_none=False) - log_type = StringType(choices=('CONTAINER_INSIGHTS', 'CONTAINER_INSTANCE_LOGS')) - metadata = DictType(StringType(), StringType(), serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class ContainerGroupDiagnostics(Model): - log_analytics = ModelType(LogAnalytics, serialize_when_none=False) - - -# ContainerGroupSubnetId -class ContainerGroupSubnetId(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -# DnsConfiguration -class DnsConfiguration(Model): - name_servers = ListType(StringType, serialize_when_none=False) - search_domains = StringType(serialize_when_none=False) - options = StringType(serialize_when_none=False) - - -# EncryptionProperties -class EncryptionProperties(Model): - vault_base_url = StringType(serialize_when_none=False) - key_name = StringType(serialize_when_none=False) - key_version = StringType(serialize_when_none=False) - -# InitContainerDefinition - - -# InitContainerDefinition - InitContainerPropertiesDefinitionInstanceView -class InitContainerPropertiesDefinitionInstanceView(ContainerPropertiesInstanceView): - pass - - -class InitContainerDefinition(Model): - name = StringType(serialize_when_none=False) - image = StringType(serialize_when_none=False) - command = ListType(StringType, serialize_when_none=False) - environment_variables = ListType(ModelType(EnvironmentVariable), serialize_when_none=False) - instance_view = ModelType(InitContainerPropertiesDefinitionInstanceView, serialize_when_none=False) - volume_mounts = ListType(ModelType(VolumeMount), serialize_when_none=False) - - -class ContainerInstance(AzureCloudService): # Main Class - id = StringType() - location = StringType() - identity = ModelType(ContainerGroupIdentity, serialize_when_none=False) - provisioning_state = StringType(serialize_when_none=False) - containers = ListType(ModelType(Container), serialize_when_none=False) - image_registry_credentials = ListType(ModelType(ImageRegistryCredential), serialize_when_none=False) - restart_policy = StringType(choices=('ALWAYS', 'NEVER', 'ON_FAILURE'), serialize_when_none=False) - ip_address = ModelType(IpAddress, serialize_when_none=False) - os_type = StringType(choices=('LINUX', 'WINDOWS')) - volumes = ListType(ModelType(Volume), serialize_when_none=False) - instance_view = ModelType(ContainerGroupPropertiesInstanceView, serialize_when_none=False) - diagnostics = ModelType(ContainerGroupDiagnostics, serialize_when_none=False) - subnet_ids = ListType(ModelType(ContainerGroupSubnetId), serialize_when_none=False) - dns_config = ModelType(DnsConfiguration, serialize_when_none=False) - sku = StringType(choices=('DEDICATED', 'STANDARD'), serialize_when_none=False) - encryption_properties = ModelType(EncryptionProperties, serialize_when_none=False) - init_containers = ListType(ModelType(InitContainerDefinition), serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - container_count_display = IntType(default=0) - volume_count_display = IntType(default=0) - cpu_count_display = IntType(default=0) - memory_size_display = FloatType(default=0.0) - gpu_count_display = IntType(default=0) - - def reference(self): - return { - "resource_id": self.id, - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", - } diff --git a/src/spaceone/inventory/model/container_instances/widget/container_Instances_count_by_subscription.yaml b/src/spaceone/inventory/model/container_instances/widget/container_Instances_count_by_subscription.yaml deleted file mode 100644 index 9b7cd263..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_Instances_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_account.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_account.yaml deleted file mode 100644 index a865425e..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_region.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_region.yaml deleted file mode 100644 index efef2e2c..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_container_count.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_total_container_count.yaml deleted file mode 100644 index 0429b35d..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_container_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Total Container Count -query: - aggregate: - - group: - fields: - - name: value - key: data.container_count_display - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_count.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_total_count.yaml deleted file mode 100644 index 766ad55e..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_gpu_count.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_total_gpu_count.yaml deleted file mode 100644 index 60c216ca..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_gpu_count.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Total GPU Count -query: - aggregate: - - unwind: - path: data.containers - - group: - fields: - - name: value - key: data.containers.resources.requests.gpu.count - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_memory_size.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_total_memory_size.yaml deleted file mode 100644 index 246e65d2..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_memory_size.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Total Memory Size -query: - aggregate: - - unwind: - path: data.containers - - group: - fields: - - name: value - key: data.containers.resources.requests.memory_in_gb - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 - source_unit: GB diff --git a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_vcpu_count.yaml b/src/spaceone/inventory/model/container_instances/widget/container_instances_total_vcpu_count.yaml deleted file mode 100644 index 7e51c7c6..00000000 --- a/src/spaceone/inventory/model/container_instances/widget/container_instances_total_vcpu_count.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: ContainerInstances -cloud_service_type: Container -name: Total vCPU Count -query: - aggregate: - - unwind: - path: data.containers - - group: - fields: - - name: value - key: data.containers.resources.requests.cpu - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/cosmos_db/__init__.py b/src/spaceone/inventory/model/cosmos_db/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/cosmos_db/cloud_service.py b/src/spaceone/inventory/model/cosmos_db/cloud_service.py deleted file mode 100644 index abf6cac8..00000000 --- a/src/spaceone/inventory/model/cosmos_db/cloud_service.py +++ /dev/null @@ -1,119 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.cosmos_db.data import DatabaseAccountGetResults - -''' -COSMOS DB -''' -# TAB - Default -cosmos_db_info_meta = ItemDynamicLayout.set_fields('Cosmos DB', fields=[ - TextDyField.data_source('Name', 'data.name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'data.subscription_id'), - TextDyField.data_source('Backup Policy', 'data.backup_policy.type'), - ListDyField.data_source('Read Locations', 'data.read_locations.location_name'), - ListDyField.data_source('Write Locations', 'data.write_locations.location_name'), - TextDyField.data_source('URI', 'data.document_endpoint'), - EnumDyField.data_source('Public Network Access', 'data.public_network_access', default_state={ - 'safe': ['Enabled'], - 'warning':['Disabled'] - }), - TextDyField.data_source('Capacity Mode', 'data.capability_display'), -]) - -# TAB - Features -cosmos_db_features = ItemDynamicLayout.set_fields('Features', fields=[ - EnumDyField.data_source('Enable Automatic Failover', 'data.enable_automatic_failover', default_state={ - 'safe': [True], - 'warning':[False] - }), - EnumDyField.data_source('Enable Free Tier', 'data.enable_free_tier', default_state={ - 'safe': [True], - 'warning':[False] - }), - EnumDyField.data_source('Enable Analytical Storage', 'data.enable_analytical_storage', default_state={ - 'safe': [True], - 'warning':[False] - }), - TextDyField.data_source('Backup Policy', 'data.backup_policy.type'), - ListDyField.data_source('CORS', 'data.cors_display') -]) - -# TAB - Default Consistency -cosmos_db_default_consistency = ItemDynamicLayout.set_fields('Default Consistency', fields=[ - TextDyField.data_source('Default Consistency', 'data.consistency_policy.default_consistency_level') -]) - -# TAB - Features -cosmos_db_backup = ItemDynamicLayout.set_fields('Backup & Restore', fields=[ - TextDyField.data_source('Backup Interval (Minutes)', 'data.backup_policy.periodic_mode_properties.backup_interval_in_minutes'), - TextDyField.data_source('Backup Retention (Hours)', 'data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours'), - TextDyField.data_source('Backup storage redundancy', 'data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy'), -]) - -# TAB - Firewall and Virtual Networks -cosmos_db_virtual_network = ItemDynamicLayout.set_fields('Firewall and Virtual Networks', fields=[ - TextDyField.data_source('Enable Public Network Access', 'data.public_network_access'), - ListDyField.data_source('Virtual Networks', 'data.virtual_network_display') -]) - -# TAB - Private Endpoint Connections -cosmos_db_private_endpoint = TableDynamicLayout.set_fields('Private Endpoint Connections', 'data.private_endpoint_connections', fields=[ - TextDyField.data_source('Connection Name', 'name'), - TextDyField.data_source('Connection State', 'private_link_service_connection_state.status'), - TextDyField.data_source('Private Endpoint', 'private_endpoint.name'), - TextDyField.data_source('Description', 'private_link_service_connection_state.description') -]) - -# TAB - Cors -cosmos_db_cors = TableDynamicLayout.set_fields('Cors', 'data.cors', fields=[ - TextDyField.data_source('Connection Name', 'name'), - TextDyField.data_source('Connection State', 'private_link_service_connection_state.status'), - TextDyField.data_source('Private Endpoint', 'private_endpoint.name'), - TextDyField.data_source('Description', 'private_link_service_connection_state.description') -]) - -# TAB - Keys -cosmos_db_keys = ItemDynamicLayout.set_fields('Keys', 'data.keys', fields=[ - TextDyField.data_source('Primary Readonly Master Key', 'primary_readonly_master_key'), - TextDyField.data_source('Secondary Readonly Master Key', 'secondary_readonly_master_key'), - TextDyField.data_source('Primary Master Key', 'primary_master_key'), - TextDyField.data_source('Primary Master Key', 'secondary_master_key') -]) - -# TAB - Database -cosmos_db_database = SimpleTableDynamicLayout.set_fields('Database', 'data.sql_databases', fields=[ - TextDyField.data_source('Database', 'name'), - TextDyField.data_source('ID', 'id') -]) - -cosmos_db_meta = CloudServiceMeta.set_layouts( - [cosmos_db_info_meta, cosmos_db_features, cosmos_db_default_consistency, cosmos_db_backup, - cosmos_db_virtual_network, cosmos_db_private_endpoint, cosmos_db_cors, cosmos_db_database]) - - -class DatabaseResource(CloudServiceResource): - cloud_service_group = StringType(default='CosmosDB') - - -class CosmosDBResource(DatabaseResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(DatabaseAccountGetResults) - _metadata = ModelType(CloudServiceMeta, default=cosmos_db_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class CosmosDBResponse(CloudServiceResponse): - resource = PolyModelType(CosmosDBResource) diff --git a/src/spaceone/inventory/model/cosmos_db/cloud_service_type.py b/src/spaceone/inventory/model/cosmos_db/cloud_service_type.py deleted file mode 100644 index eed37a1e..00000000 --- a/src/spaceone/inventory/model/cosmos_db/cloud_service_type.py +++ /dev/null @@ -1,165 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -cosmosdb_count_by_account_conf = os.path.join(current_dir, 'widget/cosmosdb_count_by_account.yaml') -cosmosdb_count_by_region_conf = os.path.join(current_dir, 'widget/cosmosdb_count_by_region.yaml') -cosmosdb_count_by_subscription_conf = os.path.join(current_dir, 'widget/cosmosdb_count_by_subscription.yaml') -cosmosdb_databases_count_by_subscription_conf = os.path.join(current_dir, - 'widget/cosmosdb_databases_count_by_subscription.yaml') -cosmosdb_total_count_conf = os.path.join(current_dir, 'widget/cosmosdb_total_count.yaml') - -cst_cosmos_db = CloudServiceTypeResource() -cst_cosmos_db.name = 'Instance' -cst_cosmos_db.group = 'CosmosDB' -cst_cosmos_db.service_code = 'Microsoft.DocumentDB/databaseAccounts' -cst_cosmos_db.labels = ['Database'] -cst_cosmos_db.is_major = True -cst_cosmos_db.is_primary = True -cst_cosmos_db.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-cosmos-db.svg', -} - -cst_cosmos_db._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Subscription ID', 'data.subscription_id'), - - # is_optional field - TextDyField.data_source('Backup Policy', 'data.backup_policy.type', options={ - 'is_optional': True - }), - ListDyField.data_source('Read Locations', 'data.read_locations.location_name', options={ - 'is_optional': True - }), - ListDyField.data_source('Write Locations', 'data.write_locations.location_name', options={ - 'is_optional': True - }), - TextDyField.data_source('Document Endpoint', 'data.document_endpoint', options={ - 'is_optional': True - }), - TextDyField.data_source('Capacity Mode', 'data.capability_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable Automatic Failover', 'data.enable_automatic_failover',options={ - 'is_optional': True - }), - TextDyField.data_source('Enable Free Tier', 'data.enable_free_tier', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable Analytical Storage', 'data.enable_analytical_storage', options={ - 'is_optional': True - }), - TextDyField.data_source('Backup Policy', 'data.backup_policy.type', options={ - 'is_optional': True - }), - ListDyField.data_source('CORS', 'data.cors_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Default Consistency', 'data.consistency_policy.default_consistency_level', options={ - 'is_optional': True - }), - TextDyField.data_source('Backup Interval (Minutes)', - 'data.backup_policy.periodic_mode_properties.backup_interval_in_minutes', options={ - 'is_optional': True - }), - TextDyField.data_source('Backup Retention (Hours)', 'data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours', options={ - 'is_optional': True - }), - TextDyField.data_source('Backup storage redundancy', 'data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable Public Network Access', 'data.public_network_access', options={ - 'is_optional': True - }), - ListDyField.data_source('Virtual Networks', 'data.virtual_network_display', options={ - 'is_optional': True - }), - # is_optional - private endpoint connections - TextDyField.data_source('Connection Name', 'data.private_endpoint_connections.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Connection State', 'data.private_endpoint_connections.private_link_service_connection_state.status', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Endpoint', 'data.private_endpoint_connections.private_endpoint.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Description', 'data.private_endpoint_connections.private_link_service_connection_state.description', options={ - 'is_optional': True - }), - # is_optional - cors - TextDyField.data_source('Private Endpoint Connection Name', 'data.cors.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Endpoint State', 'data.cors.private_link_service_connection_state.status', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Endpoint', 'data.cors.private_endpoint.name', options={ - 'is_optional': True - }), - TextDyField.data_source('COR Private Link Description', 'data.cors.private_link_service_connection_state.description', options={ - 'is_optional': True - }), - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Backup Policy', key='data.backup_policy.type'), - SearchField.set(name='Read Locations', key='data.read_locations.location_name'), - SearchField.set(name='Write Locations', key='data.write_locations.location_name'), - SearchField.set(name='Document Endpoint', key='data.document_endpoint'), - SearchField.set(name='Capacity Mode', key='data.capability_display'), - SearchField.set(name='Enable Automatic Failover', key='data.enable_automatic_failover', data_type='boolean'), - SearchField.set(name='Enable Free Tier', key='data.enable_free_tier', data_type='boolean'), - SearchField.set(name='Enable Analytical Storage', key='data.enable_analytical_storage', data_type='boolean'), - SearchField.set(name='Backup Policy', key='data.backup_policy.type'), - SearchField.set(name='CORS', key='data.cors_display'), - SearchField.set(name='Default Consistency', - key='data.consistency_policy.default_consistency_level'), - SearchField.set(name='Backup Interval (Minutes)', - key='data.backup_policy.periodic_mode_properties.backup_interval_in_minutes', - data_type='integer'), - SearchField.set(name='Backup Retention (Hours)', - key='data.backup_policy.periodic_mode_properties.backup_retention_interval_in_hours'), - SearchField.set(name='Backup storage redundancy', - key='data.backup_policy.periodic_mode_properties.additional_properties.backupStorageRedundancy'), - SearchField.set(name='Enable Public Network Access', - key='data.public_network_access'), - SearchField.set(name='Virtual Networks', - key='data.virtual_network_display'), - SearchField.set(name='Private Endpoint Connection Name', - key='data.private_endpoint_connections.name'), - SearchField.set(name='Private Endpoint State', - key='data.private_endpoint_connections.private_link_service_connection_state.status'), - SearchField.set(name='Private Endpoint Name', - key='data.private_endpoint_connections.name'), - SearchField.set(name='Private Endpoint', - key='data.private_endpoint_connections.name'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(cosmosdb_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(cosmosdb_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(cosmosdb_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(cosmosdb_databases_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(cosmosdb_total_count_conf)), - ] - -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_cosmos_db}), -] diff --git a/src/spaceone/inventory/model/cosmos_db/data.py b/src/spaceone/inventory/model/cosmos_db/data.py deleted file mode 100644 index e325137c..00000000 --- a/src/spaceone/inventory/model/cosmos_db/data.py +++ /dev/null @@ -1,245 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - IntType, - BooleanType, - DateTimeType, - UTCDateTimeType, - FloatType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class ApiProperties(Model): - server_version = StringType(serialize_when_none=False) - - -class ManagedServiceIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType( - choices=( - "None", - "SystemAssigned", - "SystemAssigned, UserAssigned", - "UserAssigned", - ), - serialize_when_none=False, - ) - user_assigned_identities = StringType(serialize_when_none=False) - - -class PeriodicModeProperties(Model): - backup_interval_in_minutes = IntType(serialize_when_none=False) - backup_retention_interval_in_hours = IntType(serialize_when_none=False) - backup_storage_redundancy = StringType( - choices=("Geo", "Local", "Zone"), serialize_when_none=False - ) - - -class PeriodicModeBackupPolicy(Model): - periodic_mode_properties = ModelType( - PeriodicModeProperties, serialize_when_none=False - ) - type = StringType(serialize_when_none=False) - - -class Capability(Model): - name = StringType(serialize_when_none=False) - - -class ConsistencyPolicy(Model): - default_consistency_level = StringType( - choices=( - "BoundedStaleness", - "ConsistentPrefix", - "Eventual", - "Session", - "Strong", - ), - serialize_when_none=False, - ) - max_interval_in_seconds = IntType(serialize_when_none=False) - max_staleness_prefix = IntType(serialize_when_none=False) - - -class CorsPolicy(Model): - allowed_headers = StringType(serialize_when_none=False) - allowed_methods = StringType(serialize_when_none=False) - allowed_origins = StringType(serialize_when_none=False) - exposed_headers = StringType(serialize_when_none=False) - max_age_in_seconds = IntType(serialize_when_none=False) - - -class FailoverPolicy(Model): - failover_priority = IntType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location_name = StringType(serialize_when_none=False) - - -class IpAddressOrRange(Model): - ip_address_or_range = StringType(serialize_when_none=False) - - -class Location(Model): - document_endpoint = StringType(serialize_when_none=False) - failover_priority = IntType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - is_zone_redundant = BooleanType(serialize_when_none=False) - location_name = StringType(serialize_when_none=False) - provisioning_state = StringType(serialize_when_none=False) - - -class PrivateEndpointProperty(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionStateProperty(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateEndpointConnection(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointProperty, serialize_when_none=False) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionStateProperty, serialize_when_none=False - ) - provisioning_state = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class DatabaseRestoreResource(Model): - collection_names = ListType(StringType, serialize_when_none=False) - database_name = StringType(serialize_when_none=False) - - -class RestoreMode(Model): - point_in_time = StringType(serialize_when_none=False) - - -class RestoreParameters(Model): - databases_to_restore = ListType( - ModelType(DatabaseRestoreResource), serialize_when_none=False - ) - restore_mode = ModelType(RestoreMode, serialize_when_none=False) - restore_source = StringType(serialize_when_none=False) - restore_timestamp_in_utc = UTCDateTimeType(serialize_when_none=False) - - -class VirtualNetworkRule(Model): - id = StringType(serialize_when_none=False) - ignore_missing_v_net_service_endpoint = BooleanType(serialize_when_none=False) - - -class SystemData(Model): - created_at = DateTimeType(serialize_when_none=False) - created_by = StringType(serialize_when_none=False) - created_by_type = StringType( - choices=("Application", "Key", "ManagedIdentity", "User"), - serialize_when_none=False, - ) - last_modified_at = DateTimeType(serialize_when_none=False) - last_modified_by = StringType(serialize_when_none=False) - last_modified_by_type = StringType( - choices=("Application", "Key", "ManagedIdentity", "User"), - serialize_when_none=False, - ) - - -class DatabaseAccountListKeysResult(Model): - primary_master_key = StringType(serialize_when_none=False) - primary_readonly_master_key = StringType(serialize_when_none=False) - secondary_master_key = StringType(serialize_when_none=False) - secondary_readonly_master_key = StringType(serialize_when_none=False) - - -class SqlDatabaseGetResults(Model): - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class DatabaseAccountGetResults(AzureCloudService): # Main Class - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - identity = ModelType(ManagedServiceIdentity, serialize_when_none=False) - location = StringType(serialize_when_none=False) - kind = StringType( - choices=("GlobalDocumentDB", "MongoDB", "Parse"), serialize_when_none=False - ) - name = StringType(default="-", serialize_when_none=False) - api_properties = ModelType(ApiProperties, serialize_when_none=False) - backup_policy = ModelType(PeriodicModeBackupPolicy, serialize_when_none=False) - capabilities = ListType(ModelType(Capability), serialize_when_none=False) - capability_display = StringType(serialize_when_none=False) - connector_offer = StringType(serialize_when_none=False) - consistency_policy = ModelType(ConsistencyPolicy, serialize_when_none=False) - cors = ListType(ModelType(CorsPolicy), serialize_when_none=False) - cors_display = ListType(StringType, serialize_when_none=False) - create_mode = StringType(choices=("Default", "Restore"), serialize_when_none=False) - database_account_offer_type = StringType(serialize_when_none=False) - default_identity = StringType(serialize_when_none=False) - disable_key_based_metadata_write_access = BooleanType(serialize_when_none=False) - document_endpoint = StringType(serialize_when_none=False) - enable_analytical_storage = BooleanType(serialize_when_none=False) - enable_automatic_failover = BooleanType(serialize_when_none=False) - enable_cassandra_connector = BooleanType(serialize_when_none=False) - enable_free_tier = BooleanType(serialize_when_none=False) - enable_multiple_write_locations = BooleanType(serialize_when_none=False) - failover_policies = ListType(ModelType(FailoverPolicy), serialize_when_none=False) - instance_id = StringType(serialize_when_none=False) - ip_rules = ListType(ModelType(IpAddressOrRange), serialize_when_none=False) - is_virtual_network_filter_enabled = BooleanType(serialize_when_none=False) - key_vault_key_uri = BooleanType(serialize_when_none=False) - keys = ModelType(DatabaseAccountListKeysResult, serialize_when_none=False) - locations = ListType(ModelType(Location), serialize_when_none=False) - network_acl_bypass = StringType( - choices=("AzureServices", "None"), serialize_when_none=False - ) - network_acl_bypass_resource_ids = ListType(StringType, serialize_when_none=False) - private_endpoint_connections = ListType( - ModelType(PrivateEndpointConnection), serialize_when_none=False - ) - provisioning_state = StringType(serialize_when_none=False) - public_network_access = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - read_locations = ListType(ModelType(Location), serialize_when_none=False) - restore_parameters = ModelType(RestoreParameters, serialize_when_none=False) - virtual_network_rules = ListType( - ModelType(VirtualNetworkRule), serialize_when_none=False - ) - virtual_network_display = ListType(StringType, serialize_when_none=False) - sql_databases = ListType( - ModelType(SqlDatabaseGetResults), serialize_when_none=False - ) - sql_databases_count_display = IntType(serialize_when_none=False) - write_locations = ListType(ModelType(Location), serialize_when_none=False) - system_data = ModelType(SystemData, serialize_when_none=False) - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - launched_at = DateTimeType(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", - } diff --git a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_account.yaml b/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_account.yaml deleted file mode 100644 index 8e35d419..00000000 --- a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: CosmosDB -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_region.yaml b/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_region.yaml deleted file mode 100644 index 91e6a419..00000000 --- a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: CosmosDB -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_subscription.yaml b/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_subscription.yaml deleted file mode 100644 index d34683fe..00000000 --- a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: CosmosDB -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_databases_count_by_subscription.yaml b/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_databases_count_by_subscription.yaml deleted file mode 100644 index 0a802fb0..00000000 --- a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_databases_count_by_subscription.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: CosmosDB -cloud_service_type: Instance -name: Databases Count by Region -query: - aggregate: - - unwind: - path: data.sql_databases - - group: - keys: - - name: name - key: data.name - fields: - - name: count - key: data.sql_databases - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_total_count.yaml b/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_total_count.yaml deleted file mode 100644 index 2549036c..00000000 --- a/src/spaceone/inventory/model/cosmos_db/widget/cosmosdb_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: CosmosDB -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/disks/__init__.py b/src/spaceone/inventory/model/disks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/disks/cloud_service.py b/src/spaceone/inventory/model/disks/cloud_service.py deleted file mode 100644 index e3281ae1..00000000 --- a/src/spaceone/inventory/model/disks/cloud_service.py +++ /dev/null @@ -1,77 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.model.disks.data import Disk -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, ListDyField, SizeField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout,ListDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -disk_info_meta = ItemDynamicLayout.set_fields('Disks', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Storage Account Type', 'instance_type'), - SizeField.data_source('Size', 'instance_size'), - EnumDyField.data_source('Disk State', 'data.disk_state', default_state={ - 'safe': ['ActiveSAS', 'ActiveUpload', 'Attached', 'Reserved'], - 'warning':['ReadyToUpload'], - 'available': ['Unattached'] - }), - TextDyField.data_source('Attached VM', 'data.managed_by'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Resource ID', 'data.id'), - ListDyField.data_source('Zones', 'data.zones', options={ - 'delimiter': '
' - }), - TextDyField.data_source('Subscription ID', 'data.subscription_id'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Encryption Type', 'data.encryption.type'), - TextDyField.data_source('Networking', 'data.network_access_policy_display'), - TextDyField.data_source('Os Type', 'data.os_type'), - TextDyField.data_source('Max Shares', 'data.max_shares'), - TextDyField.data_source('VM Generation', 'data.hyper_v_generation'), - TextDyField.data_source('VM architecture', 'data.supported_capabilities.architecture'), - DateTimeDyField.data_source('Time Created', 'data.time_created') - - -]) -''' -DISK -''' -# TAB - Networking -disk_networking_info = ItemDynamicLayout.set_fields('Networking', fields=[ - TextDyField.data_source('Network access', 'data.network_access_policy_display') -]) - -# TAB - Configuration - -shared_disk = ItemDynamicLayout.set_fields('Shared Disk', fields=[ - TextDyField.data_source('Enable shared disk', 'data.enable_shared_disk_display'), - TextDyField.data_source('Max shares', 'data.max_shares'), -]) - -on_demand_bursting = ItemDynamicLayout.set_fields('On-demand bursting', fields=[ - TextDyField.data_source('Enable bursting', 'data.bursting_enabled'), - DateTimeDyField.data_source('Enable bursting time', 'data.bursting_enabled_time'), -]) - -disk_configure_info = ListDynamicLayout.set_layouts('Configuration', layouts=[shared_disk, on_demand_bursting]) - -# TAB - Default -disk_meta = CloudServiceMeta.set_layouts([disk_info_meta, disk_configure_info, disk_networking_info]) - - -class ComputeResource(CloudServiceResource): - cloud_service_group = StringType(default='Disks') - - -class DiskResource(ComputeResource): - cloud_service_type = StringType(default='Disk') - data = ModelType(Disk) - _metadata = ModelType(CloudServiceMeta, default=disk_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 DiskResponse(CloudServiceResponse): - resource = PolyModelType(DiskResource) diff --git a/src/spaceone/inventory/model/disks/cloud_service_type.py b/src/spaceone/inventory/model/disks/cloud_service_type.py deleted file mode 100644 index b78e27aa..00000000 --- a/src/spaceone/inventory/model/disks/cloud_service_type.py +++ /dev/null @@ -1,147 +0,0 @@ -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, - SizeField, -) -from spaceone.inventory.libs.schema.cloud_service_type import ( - CloudServiceTypeResource, - CloudServiceTypeResponse, - CloudServiceTypeMeta, -) -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -""" -DISK -""" -disks_count_by_account_conf = os.path.join( - current_dir, "widget/disks_count_by_account.yaml" -) -disks_count_by_region_conf = os.path.join( - current_dir, "widget/disks_count_by_region.yaml" -) -disks_count_by_resource_group_conf = os.path.join( - current_dir, "widget/disks_count_by_resource_group.yaml" -) -disks_size_by_region_conf = os.path.join( - current_dir, "widget/disks_size_by_region.yaml" -) -disks_size_by_status_conf = os.path.join( - current_dir, "widget/disks_size_by_status.yaml" -) -disks_size_by_subscription_conf = os.path.join( - current_dir, "widget/disks_size_by_subscription.yaml" -) -disks_size_by_type_conf = os.path.join(current_dir, "widget/disks_size_by_type.yaml") -disks_total_size_conf = os.path.join(current_dir, "widget/disks_total_size.yaml") -disks_total_count_conf = os.path.join(current_dir, "widget/disks_total_count.yaml") - -cst_disks = CloudServiceTypeResource() -cst_disks.group = "Disks" -cst_disks.name = "Disk" -cst_disks.provider = "azure" -cst_disks.labels = ["Compute", "Storage"] -cst_disks.service_code = "Microsoft.Compute/disks" -cst_disks.is_major = True -cst_disks.is_primary = True -cst_disks.tags = { - "spaceone:icon": f"{ASSET_URL}/azure-disk.svg", - "spaceone:display_name": "Disk", -} - -cst_disks._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source("Storage Account Type", "data.sku.name"), - SizeField.data_source("Size", "data.size"), - EnumDyField.data_source( - "Disk State", - "data.disk_state", - default_state={ - "safe": ["ActiveSAS", "ActiveUpload", "Attached", "Reserved"], - "warning": ["ReadyToUpload"], - "available": ["Unattached"], - }, - ), - TextDyField.data_source("Owner", "data.managed_by"), - TextDyField.data_source("Resource Group", "data.resource_group"), - TextDyField.data_source("Location", "data.location"), - TextDyField.data_source("Subscription Name", "data.subscription_name"), - # is_optional - Default - TextDyField.data_source( - "Subscription ID", "data.subscription_id", options={"is_optional": True} - ), - ListDyField.data_source( - "Zone", "data.zones", options={"delimiter": "
", "is_optional": True} - ), - TextDyField.data_source( - "Encryption Type", "data.encryption.type", options={"is_optional": True} - ), - TextDyField.data_source( - "Networking", - "data.network_access_policy_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Max Shares", "data.max_shares", options={"is_optional": True} - ), - TextDyField.data_source( - "Time Created", "data.time_created", options={"is_optional": True} - ), - ], - search=[ - SearchField.set(name="Tier", key="data.tier", data_type="string"), - SearchField.set( - name="Subscription ID", key="data.subscription_id", data_type="string" - ), - SearchField.set( - name="Subscription Name", key="data.subscription_name", data_type="string" - ), - SearchField.set( - name="Resource Group", key="data.resource_group", data_type="string" - ), - SearchField.set(name="Location", key="data.location", data_type="string"), - SearchField.set(name="Zone", key="data.zones", data_type="string"), - SearchField.set( - name="Storage Account Type", key="data.sku.name", data_type="string" - ), - SearchField.set( - name="Disk Size (Bytes)", key="data.disk_size_bytes", data_type="integer" - ), - SearchField.set( - name="Disk Size (GB)", key="data.disk_size_gb", data_type="integer" - ), - SearchField.set( - name="Disk IOPS", key="data.disk_iops_read_write", data_type="integer" - ), - SearchField.set(name="OS Type", key="data.os_type", data_type="string"), - SearchField.set( - name="Provisioning State", key="data.provisioning_state", data_type="string" - ), - SearchField.set( - name="Time Created", key="data.time_created", data_type="datetime" - ), - ], - widget=[ - CardWidget.set(**get_data_from_yaml(disks_total_count_conf)), - CardWidget.set(**get_data_from_yaml(disks_total_size_conf)), - ChartWidget.set(**get_data_from_yaml(disks_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(disks_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(disks_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(disks_size_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(disks_size_by_status_conf)), - ChartWidget.set(**get_data_from_yaml(disks_size_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(disks_size_by_type_conf)), - ], -) - -CLOUD_SERVICE_TYPES = [CloudServiceTypeResponse({"resource": cst_disks})] diff --git a/src/spaceone/inventory/model/disks/data.py b/src/spaceone/inventory/model/disks/data.py deleted file mode 100644 index 7f2ac888..00000000 --- a/src/spaceone/inventory/model/disks/data.py +++ /dev/null @@ -1,104 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, FloatType, DateTimeType, IntType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Sku(Model): - name = StringType(choices=('Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS', 'UltraSSD_LRS'), - serialize_when_none=False) - tier = StringType(choices=('Premium', 'Standard'), serialize_when_none=False) - - -class ImageDiskReference(Model): - id = StringType(serialize_when_none=False) - lun = IntType(serialize_when_none=False) - - -class CreationData(Model): - creation_option = StringType(choices=('Attach', 'Copy', 'Empty', 'FromImage', 'Import', 'Restore', 'Upload'), serialize_when_none=False) - gallery_image_reference = ModelType(ImageDiskReference, serialize_when_none=False) - image_reference = ModelType(ImageDiskReference, serialize_when_none=False) - logical_sector_size = IntType(serialize_when_none=False) - source_resource_id = StringType(serialize_when_none=False) - source_unique_id = StringType(serialize_when_none=False) - source_uri = StringType(serialize_when_none=False) - storage_account_id = StringType(serialize_when_none=False) - upload_size_bytes = IntType(serialize_when_none=False) - - -class SourceVault(Model): - id = StringType(serialize_when_none=False) - - -class DiskEncryptionKey(Model): - source_vault = ModelType(SourceVault, serialize_when_none=False) - secret_url = StringType(serialize_when_none=False) - - -class KeyEncryptionKey(Model): - source_vault = ModelType(SourceVault) - key_url = StringType() - - -class EncryptionSettingsCollection(Model): - disk_encryption_key = ModelType(DiskEncryptionKey, serialize_when_none=False) - key_encryption_key = ModelType(KeyEncryptionKey, serialize_when_none=False) - - -class Encryption(Model): - disk_encryption_set_id = StringType(default='', serialize_when_none=False) - type = StringType(choices=('EncryptionAtRestWithCustomerKey', 'EncryptionAtRestWithPlatformAndCustomerKeys', - 'EncryptionAtRestWithPlatformKey'), - default='EncryptionAtRestWithPlatformKey', serialize_when_none=False) - - -class ShareInfoElement(Model): - vm_uri = StringType(serialize_when_none=False) - - -class SupportedCapabilities(Model): - disk_controller_types = StringType(serialize_when_none=False) - accelerated_network = BooleanType(serialize_when_none=False) - architecture = StringType(serialize_when_none=False) - - -class Disk(AzureCloudService): - name = StringType() - id = StringType() - type = StringType() - location = StringType() - managed_by = StringType(default='') - managed_by_extended = ListType(StringType, serialize_when_none=False) - max_shares = IntType(default=0) - enable_shared_disk_display = BooleanType(default=False) - sku = ModelType(Sku) - zones = ListType(StringType(), serialize_when_none=False) - disk_size_gb = IntType() - disk_iops_read_write = IntType() - disk_iops_read_only = IntType(serialize_when_none=False) - disk_size_bytes = IntType() - size = IntType() # disk size for statistics - encryption_settings_collection = ModelType(EncryptionSettingsCollection, serialize_when_none=False) - encryption = ModelType(Encryption) - hyper_v_generation = StringType(serialize_when_none=False) - time_created = DateTimeType() - creation_data = ModelType(CreationData) - os_type = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Failed', 'Succeeded'), serialize_when_none=False) - share_info = ModelType(ShareInfoElement, serialize_when_none=False) - unique_id = StringType() - disk_m_bps_read_write = IntType() - disk_m_bps_read_only = IntType(serialize_when_none=False) - disk_state = StringType(choices=('ActiveSAS', 'ActiveUpload', 'Attached', 'ReadyToUpload', 'Reserved', 'Unattached')) - network_access_policy = StringType(choices=('AllowAll', 'AllowPrivate', 'DenyAll'), serialize_when_none=False) - network_access_policy_display = StringType() - tier_display = StringType(default='') - supported_capabilities = ModelType(SupportedCapabilities, serialize_when_none=False) - bursting_enabled = BooleanType(default=False) - bursting_enabled_time = DateTimeType() - - def reference(self): - return { - "resource_id": self.id, - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", - } \ No newline at end of file diff --git a/src/spaceone/inventory/model/disks/widget/disks_count_by_account.yaml b/src/spaceone/inventory/model/disks/widget/disks_count_by_account.yaml deleted file mode 100644 index 584c3b2d..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/disks/widget/disks_count_by_region.yaml b/src/spaceone/inventory/model/disks/widget/disks_count_by_region.yaml deleted file mode 100644 index 949795e0..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/disks/widget/disks_count_by_resource_group.yaml b/src/spaceone/inventory/model/disks/widget/disks_count_by_resource_group.yaml deleted file mode 100644 index aeda0959..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_count_by_resource_group.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/disks/widget/disks_size_by_region.yaml b/src/spaceone/inventory/model/disks/widget/disks_size_by_region.yaml deleted file mode 100644 index 077d5fac..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_size_by_region.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Size by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - key: instance_size - operator: sum -options: - chart_type: COLUMN - value_options: - key: value - type: size - options: - default: 0 - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/disks/widget/disks_size_by_status.yaml b/src/spaceone/inventory/model/disks/widget/disks_size_by_status.yaml deleted file mode 100644 index 87033655..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_size_by_status.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Size by Status -query: - aggregate: - - group: - keys: - - name: name - key: data.disk_state - fields: - - name: value - key: instance_size - operator: sum -options: - chart_type: DONUT - value_options: - key: value - type: size - options: - default: 0 diff --git a/src/spaceone/inventory/model/disks/widget/disks_size_by_subscription.yaml b/src/spaceone/inventory/model/disks/widget/disks_size_by_subscription.yaml deleted file mode 100644 index 1d8703d5..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_size_by_subscription.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Size by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: instance_size - operator: sum -options: - chart_type: COLUMN - value_options: - key: value - type: size - options: - default: 0 diff --git a/src/spaceone/inventory/model/disks/widget/disks_size_by_type.yaml b/src/spaceone/inventory/model/disks/widget/disks_size_by_type.yaml deleted file mode 100644 index e8155364..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_size_by_type.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Size by Type -query: - aggregate: - - group: - keys: - - name: name - key: instance_type - fields: - - name: value - key: instance_size - operator: sum -options: - chart_type: TREEMAP diff --git a/src/spaceone/inventory/model/disks/widget/disks_total_count.yaml b/src/spaceone/inventory/model/disks/widget/disks_total_count.yaml deleted file mode 100644 index 61461cd7..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/disks/widget/disks_total_size.yaml b/src/spaceone/inventory/model/disks/widget/disks_total_size.yaml deleted file mode 100644 index 01141302..00000000 --- a/src/spaceone/inventory/model/disks/widget/disks_total_size.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -cloud_service_group: Disks -cloud_service_type: Disk -name: Total Size -query: - aggregate: - - group: - fields: - - name: value - key: instance_size - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 \ No newline at end of file diff --git a/src/spaceone/inventory/model/job_model.py b/src/spaceone/inventory/model/job_model.py deleted file mode 100644 index 9ed2ccb7..00000000 --- a/src/spaceone/inventory/model/job_model.py +++ /dev/null @@ -1,18 +0,0 @@ -from schematics.models import Model -from schematics.types import ListType, StringType -from schematics.types.compound import ModelType - -__all__ = ["Tasks"] - - -class TaskOptions(Model): - resource_type = StringType(serialize_when_none=False) - cloud_service_types = ListType(StringType, serialize_when_none=False) - - -class Task(Model): - task_options = ModelType(TaskOptions, required=True) - - -class Tasks(Model): - tasks = ListType(ModelType(Task), required=True) diff --git a/src/spaceone/inventory/model/key_vaults/__init__.py b/src/spaceone/inventory/model/key_vaults/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/key_vaults/cloud_service.py b/src/spaceone/inventory/model/key_vaults/cloud_service.py deleted file mode 100644 index 56add802..00000000 --- a/src/spaceone/inventory/model/key_vaults/cloud_service.py +++ /dev/null @@ -1,182 +0,0 @@ -from schematics.types import ( - ModelType, - StringType, - PolyModelType, - FloatType, - DateTimeType, -) - -from spaceone.inventory.libs.schema.metadata.dynamic_field import ( - TextDyField, - DateTimeDyField, - EnumDyField, - ListDyField, - SizeField, - StateItemDyField, -) -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ( - ItemDynamicLayout, - TableDynamicLayout, - ListDynamicLayout, - SimpleTableDynamicLayout, - QuerySearchTableDynamicLayout, -) -from spaceone.inventory.libs.schema.cloud_service import ( - CloudServiceResource, - CloudServiceResponse, - CloudServiceMeta, -) -from spaceone.inventory.model.key_vaults.data import KeyVault - -""" -KEY_VAULT -""" -# TAB - Default -key_vault_info_meta = ItemDynamicLayout.set_fields( - "Key Vault", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Resource ID", "data.id"), - TextDyField.data_source("Resource Group", "data.resource_group"), - TextDyField.data_source("Location", "data.location"), - TextDyField.data_source("Subscription", "data.subscription_name"), - TextDyField.data_source("Subscription ID", "account"), - TextDyField.data_source("Vault URI", "data.properties.vault_uri"), - TextDyField.data_source("Sku (Pricing Tier)", "instance_type"), - TextDyField.data_source("Directory ID", "data.properties.tenant_id"), - # TextDyField.data_source('Directory Name', 'data.'), - TextDyField.data_source("Soft-delete", "data.properties.enable_soft_delete"), - TextDyField.data_source( - "Purge Protection", "data.properties.enable_purge_protection_str" - ), - TextDyField.data_source( - "Total Credentials Count", "data.total_credentials_count" - ), - TextDyField.data_source("Keys Count", "data.key_count"), - TextDyField.data_source("Secrets Count", "data.secret_count"), - TextDyField.data_source("Certificates Count", "data.certificate_count"), - ], -) - -# TAB - KeyVaults Permissions -key_vault_permissions = ItemDynamicLayout.set_fields( - "Permissions description", - fields=[ - TextDyField.data_source("Keys", "data.keys_permissions_description_display"), - TextDyField.data_source( - "Secrets", "data.secrets_permissions_description_display" - ), - TextDyField.data_source( - "Certificates", "data.certificates_permissions_description_display" - ), - ], -) -# TAB - Keys -key_vault_keys = QuerySearchTableDynamicLayout.set_fields( - "Keys", - root_path="data.keys", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Type", "instance_type"), - TextDyField.data_source("Location", "location"), - TextDyField.data_source("Status", "attributes.enabled"), - DateTimeDyField.data_source("Expiration Date", "attributes.expires"), - DateTimeDyField.data_source("Creation Date", "attributes.created"), - TextDyField.data_source("Key URI", "key_uri"), - ], -) - -# TAB - Secrets -key_vault_secrets = QuerySearchTableDynamicLayout.set_fields( - "Secrets", - root_path="data.secrets", - fields=[ - TextDyField.data_source("ID", "_id"), - TextDyField.data_source("Type", "_content_type"), - TextDyField.data_source("Status", "_attributes.enabled"), - DateTimeDyField.data_source("Updated Date", "_attributes.updated"), - DateTimeDyField.data_source("Creation Date", "_attributes.created"), - TextDyField.data_source("Recoverable Days", "_attributes.recoverable_days"), - ], -) - -# TAB - Certificates -key_vault_certificates = QuerySearchTableDynamicLayout.set_fields( - "Certificates", - root_path="data.certificates", - fields=[ - TextDyField.data_source("ID", "_id"), - TextDyField.data_source("Status", "_attributes.enabled"), - DateTimeDyField.data_source("Updated Date", "_attributes.updated"), - DateTimeDyField.data_source("Creation Date", "_attributes.created"), - TextDyField.data_source("Recoverable Days", "_attributes.recoverable_days"), - ], -) - -# TAB - Access Policies -key_vault_access_policies = ItemDynamicLayout.set_fields( - "Access Policies", - fields=[ - TextDyField.data_source( - "Enable for Azure VM Deployment", "data.properties.enabled_for_deployment" - ), - TextDyField.data_source( - "Enable for Disk Encryption", "data.properties.enabled_for_disk_encryption" - ), - TextDyField.data_source( - "Enable for Template Deployment", - "data.properties.enabled_for_template_deployment", - ), - TextDyField.data_source( - "Enable RBAC Authorization", "data.properties.enable_rbac_authorization" - ), - ], -) - -# TAB - Networking -key_vault_networking = QuerySearchTableDynamicLayout.set_fields( - "Private Endpoint Connections", - root_path="data.properties.private_endpoint_connections", - fields=[ - TextDyField.data_source("Connection Name", "name"), - TextDyField.data_source( - "Connection State", "private_link_service_connection_state.status" - ), - EnumDyField.data_source( - "Provisioning State", - "provisioning_state", - default_state={"safe": ["Succeeded", "RegisteringDns"]}, - ), - TextDyField.data_source("Private Endpoint", "private_endpoint.id"), - ], -) - -key_vault_meta = CloudServiceMeta.set_layouts( - [ - key_vault_info_meta, - key_vault_permissions, - key_vault_keys, - key_vault_secrets, - key_vault_certificates, - key_vault_access_policies, - key_vault_networking, - ] -) - - -class KeyVaultResource(CloudServiceResource): - cloud_service_group = StringType(default="KeyVaults") - cloud_service_type = StringType(default="Instance") - data = ModelType(KeyVault) - _metadata = ModelType( - CloudServiceMeta, default=key_vault_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class KeyVaultResponse(CloudServiceResponse): - resource = PolyModelType(KeyVaultResource) diff --git a/src/spaceone/inventory/model/key_vaults/cloud_service_type.py b/src/spaceone/inventory/model/key_vaults/cloud_service_type.py deleted file mode 100644 index e882b494..00000000 --- a/src/spaceone/inventory/model/key_vaults/cloud_service_type.py +++ /dev/null @@ -1,150 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -key_vaults_count_by_account_conf = os.path.join(current_dir, 'widget/key_vaults_count_by_account.yaml') -key_vaults_count_by_region_conf = os.path.join(current_dir, 'widget/key_vaults_count_by_region.yaml') -key_vaults_count_per_subscription_conf = os.path.join(current_dir, 'widget/key_vaults_count_by_subscription.yaml') -key_vaults_total_count_conf = os.path.join(current_dir, 'widget/key_vaults_total_count.yaml') - -cst_key_vaults = CloudServiceTypeResource() -cst_key_vaults.name = 'Instance' -cst_key_vaults.group = 'KeyVaults' -cst_key_vaults.service_code = 'Microsoft.KeyVault/vaults' -cst_key_vaults.labels = ['Security'] -cst_key_vaults.is_major = True -cst_key_vaults.is_primary = True -cst_key_vaults.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-key-vault.svg', -} - -cst_key_vaults._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Type', 'instance_type'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - - # is_optional fields - Public IP Addresses - TextDyField.data_source('Public IP Address', 'data.public_ip_addresses.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Vault URI', 'data.properties.vault_uri', options={ - 'is_optional': True - }), - TextDyField.data_source('SKU (Pricing Tier)', 'data.sku.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Directory ID', 'data.properties.tenant_id', options={ - 'is_optional': True - }), - TextDyField.data_source('Soft-delete', 'data.properties.enable_soft_delete', options={ - 'is_optional': True - }), - TextDyField.data_source('Purge Protection', 'data.properties.enable_purge_protection', options={ - 'is_optional': True - }), - TextDyField.data_source('Key Name', 'data.keys.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Key Type', 'data.keys.type', options={ - 'is_optional': True - }), - TextDyField.data_source('Key Location', 'data.keys.location', options={ - 'is_optional': True - }), - TextDyField.data_source('Key Status', 'data.keys.attributes.enabled', options={ - 'is_optional': True - }), - DateTimeDyField.data_source('Key Expiration Date', 'data.keys.attributes.expires', options={ - 'is_optional': True - }), - DateTimeDyField.data_source('Key Creation Date', 'data.keys.attributes.created', options={ - 'is_optional': True - }), - TextDyField.data_source('Key URI', 'data.keys.key_uri', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable for Azure VM Deployment', 'data.properties.enabled_for_deployment', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable for Disk Encryption', 'data.properties.enabled_for_disk_encryption', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable for Template Deployment', 'data.properties.enabled_for_template_deployment', options={ - 'is_optional': True - }), - TextDyField.data_source('Enable RBAC Authorization', 'data.properties.enable_rbac_authorization', options={ - 'is_optional': True - }), - - TextDyField.data_source('Private Connection Name', 'data.properties.private_endpoint_connections.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Connection State', 'data.properties.private_endpoint_connections.private_link_service_connection_state.status', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Endpoint ID', 'data.properties.private_endpoint_connections.private_endpoint.id', options={ - 'is_optional': True - }), - ], - search=[ - SearchField.set(name='Type', key='instance_type'), - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Public IP Address', key='data.public_ip_addresses.name'), - SearchField.set(name='Vault URI', key='data.properties.vault_uri'), - SearchField.set(name='SKU (Pricing Tier)', key='data.sku.name'), - SearchField.set(name='Directory ID', key='data.properties.tenant_id'), - SearchField.set(name='Soft-delete', key='data.properties.enable_soft_delete'), - SearchField.set(name='Purge Protection', key='data.properties.enable_purge_protection'), - SearchField.set(name='Key Name', key='data.keys.name'), - SearchField.set(name='Key Type', key='data.keys.type'), - SearchField.set(name='Key Location', key='data.keys.location'), - SearchField.set(name='Key Status', key='data.keys.attributes.enabled'), - SearchField.set(name='Key Expiration Date', key='data.keys.attributes.expires'), - SearchField.set(name='Key Creation Date', key='data.keys.attributes.created'), - SearchField.set(name='Key URI', key='data.keys.key_uri'), - SearchField.set(name='Enable for Azure VM Deployment', - key='data.properties.enabled_for_deployment', - data_type='boolean'), - SearchField.set(name='Enable for Disk Encryption', - key='data.properties.enabled_for_disk_encryption', - data_type='boolean'), - SearchField.set(name='Enable for Template Deployment', - key='data.properties.enabled_for_template_deployment', - data_type='boolean'), - SearchField.set(name='Enable RBAC Authorization', - key='data.properties.enable_rbac_authorization', - data_type='boolean'), - SearchField.set(name='Private Endpoint Connection Name', - key='data.properties.private_endpoint_connections.name'), - SearchField.set(name='Private Endpoint Connection State', - key='data.properties.private_endpoint_connections.private_link_service_connection_state.status'), - SearchField.set(name='Private Endpoint ID', - key='data.properties.private_endpoint_connections.private_endpoint.id'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(key_vaults_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(key_vaults_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(key_vaults_count_per_subscription_conf)), - CardWidget.set(**get_data_from_yaml(key_vaults_total_count_conf)), - - ] - -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_key_vaults}), -] diff --git a/src/spaceone/inventory/model/key_vaults/data.py b/src/spaceone/inventory/model/key_vaults/data.py deleted file mode 100644 index cdddfc1d..00000000 --- a/src/spaceone/inventory/model/key_vaults/data.py +++ /dev/null @@ -1,257 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - IntType, - BooleanType, - DateTimeType, - DictType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class Permissions(Model): - certificates = ListType(StringType, serialize_when_none=False) - keys = ListType(StringType, serialize_when_none=False) - secrets = ListType(StringType, serialize_when_none=False) - storage = ListType(StringType, serialize_when_none=False) - - -class AccessPolicyEntry(Model): - application_id = StringType(serialize_when_none=False) - object_id = StringType(serialize_when_none=False) - permissions = ModelType(Permissions, serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - - -class IPRule(Model): - value = StringType(serialize_when_none=False) - - -class VirtualNetworkRule(Model): - ip = StringType(serialize_when_none=False) - ignore_missing_vnet_service_endpoint = BooleanType(serialize_when_none=False) - - -class NetworkRuleSet(Model): - bypass = StringType(choices=("AzureServices", "None"), serialize_when_none=False) - default_action = StringType(choices=("Allow", "Deny"), serialize_when_none=False) - ip_rules = ListType(ModelType(IPRule), serialize_when_none=False) - virtual_network_rules = ListType( - ModelType(VirtualNetworkRule), serialize_when_none=False - ) - - -class PrivateEndpoint(Model): - id = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType( - choices=("Approved", "Disconnected", "Pending", "Rejected"), - serialize_when_none=False, - ) - - -class PrivateEndpointConnectionItem(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpoint, serialize_when_none=False) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionState, serialize_when_none=False - ) - provisioning_state = StringType( - choices=( - "Creating", - "Deleting", - "Disconnected", - "Failed", - "Succeeded", - "Updating", - ), - serialize_when_none=False, - ) - - -class Sku(Model): - family = StringType(serialize_when_none=False) - name = StringType(choices=("premium", "standard"), serialize_when_none=False) - - -class SecretAttributes(Model): - created = DateTimeType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - exp = DateTimeType(serialize_when_none=False) - nbf = DateTimeType(serialize_when_none=False) - recoverable_days = IntType(serialize_when_none=False) - recovery_level = StringType( - choices=( - "CustomizedRecoverable", - "CustomizedRecoverable+ProtectedSubscription", - "CustomizedRecoverable+Purgeable", - "Purgeable", - "Recoverable", - "Recoverable+ProtectedSubscription", - "Recoverable+Purgeable", - ), - serialize_when_none=False, - ) - updated = DateTimeType(serialize_when_none=False) - - -class ResourceId(Model): - source_id = StringType(serialize_when_none=False) - vault_url = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - - -class VaultId(Model): - resource_id = ModelType(ResourceId, serialize_when_none=False) - - -class SecretItem(Model): - _attributes = ModelType(SecretAttributes, serialize_when_none=False) - _content_type = StringType(serialize_when_none=False) - _id = StringType(serialize_when_none=False) - _managed = BooleanType(serialize_when_none=False) - _tags = ModelType(Tags, serialize_when_none=False) - _vault_id = ModelType(VaultId, serialize_when_none=False) - - -class CertificateAttributes(Model): - created = DateTimeType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - exp = DateTimeType(serialize_when_none=False) - nbf = DateTimeType(serialize_when_none=False) - recoverable_days = IntType(serialize_when_none=False) - recovery_level = StringType( - choices=( - "CustomizedRecoverable", - "CustomizedRecoverable+ProtectedSubscription", - "CustomizedRecoverable+Purgeable", - "Purgeable", - "Recoverable", - "Recoverable+ProtectedSubscription", - "Recoverable+Purgeable", - ), - serialize_when_none=False, - ) - updated = DateTimeType(serialize_when_none=False) - - -class CertificateItem(Model): - _attributes = ModelType(CertificateAttributes, serialize_when_none=False) - _id = StringType(serialize_when_none=False) - _content_type = StringType(serialize_when_none=False) - _tags = ModelType(Tags, serialize_when_none=False) - _vault_id = ModelType(VaultId, serialize_when_none=False) - - -class VaultProperties(Model): - access_policies = ListType(ModelType(AccessPolicyEntry), serialize_when_none=False) - create_mode = StringType(choices=("default", "recover"), serialize_when_none=False) - enable_purge_protection = BooleanType(default=False, serialize_when_none=False) - enable_purge_protection_str = StringType( - serialize_when_none=False, default="Disabled" - ) - enable_rbac_authorization = BooleanType(serialize_when_none=False) - enable_soft_delete = BooleanType(serialize_when_none=False) - enabled_for_deployment = BooleanType(serialize_when_none=False) - enabled_for_disk_encryption = BooleanType(serialize_when_none=False) - enabled_for_template_deployment = BooleanType(serialize_when_none=False) - hsm_pool_resource_id = StringType(serialize_when_none=False) - network_acls = ModelType(NetworkRuleSet, serialize_when_none=False) - private_endpoint_connections = ListType( - ModelType(PrivateEndpointConnectionItem), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("RegisteringDns", "Succeeded"), serialize_when_none=False - ) - sku = ModelType(Sku, serialize_when_none=False) - soft_delete_retention_in_days = IntType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - vault_uri = StringType(serialize_when_none=False) - - -class KeyAttributes(Model): - created = DateTimeType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - exp = DateTimeType(serialize_when_none=False) - nbf = DateTimeType(serialize_when_none=False) - recoverable_days = IntType(serialize_when_none=False) - recovery_level = StringType( - choices=( - "CustomizedRecoverable", - "CustomizedRecoverable+ProtectedSubscription", - "CustomizedRecoverable+Purgeable", - "Purgeable", - "Recoverable", - "Recoverable+ProtectedSubscription", - "Recoverable+Purgeable", - ), - serialize_when_none=False, - ) - updated = DateTimeType(serialize_when_none=False) - - -class KeyItem(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - key_uri = StringType(serialize_when_none=False) - attributes = ModelType(KeyAttributes, serialize_when_none=False) - kid = StringType(serialize_when_none=False) - managed = BooleanType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - - -class SystemData(Model): - created_at = DateTimeType(serialize_when_none=False) - created_by = StringType(serialize_when_none=False) - created_by_type = StringType(serialize_when_none=False) - last_modified_at = DateTimeType(serialize_when_none=False) - last_modified_by = StringType(serialize_when_none=False) - last_modified_by_type = StringType(serialize_when_none=False) - - -class KeyVault(AzureCloudService): # Main class - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - properties = ModelType(VaultProperties, serialize_when_none=False) - keys = ListType(ModelType(KeyItem), serialize_when_none=False) - secrets = ListType(ModelType(SecretItem), serialize_when_none=False) - certificates = ListType(ModelType(CertificateItem), serialize_when_none=False) - key_count = IntType(serialize_when_none=False) - secret_count = IntType(serialize_when_none=False) - certificate_count = IntType(serialize_when_none=False) - total_credentials_count = IntType(serialize_when_none=False) - system_data = ModelType(SystemData, serialize_when_none=False) - type = StringType(serialize_when_none=False) - launched_at = DateTimeType(serialize_when_none=False) - keys_permissions_description_display = StringType(serialize_when_none=False) - secrets_permissions_description_display = StringType(serialize_when_none=False) - certificates_permissions_description_display = 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", - } diff --git a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_account.yaml b/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_account.yaml deleted file mode 100644 index 61e406b2..00000000 --- a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: KeyVaults -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_region.yaml b/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_region.yaml deleted file mode 100644 index d11b1a17..00000000 --- a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: KeyVaults -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_subscription.yaml b/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_subscription.yaml deleted file mode 100644 index 13d7fa38..00000000 --- a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: KeyVaults -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_total_count.yaml b/src/spaceone/inventory/model/key_vaults/widget/key_vaults_total_count.yaml deleted file mode 100644 index cc4b214e..00000000 --- a/src/spaceone/inventory/model/key_vaults/widget/key_vaults_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: KeyVaults -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/load_balancers/__init__.py b/src/spaceone/inventory/model/load_balancers/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/load_balancers/cloud_service.py b/src/spaceone/inventory/model/load_balancers/cloud_service.py deleted file mode 100644 index 7fd9d5d6..00000000 --- a/src/spaceone/inventory/model/load_balancers/cloud_service.py +++ /dev/null @@ -1,163 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.model.load_balancers.data import LoadBalancer -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -''' -LOAD_BALANCER -''' - -# TAB - Default -# Resource Group, Location, Subscription, Subscription ID, SKU, Backend pool, Health probe, -# Load balancing rule, NAT Rules, Public IP Addresses, Load Balancing Type -load_balancer_info_meta = ItemDynamicLayout.set_fields('LoadBalancers', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'account'), - TextDyField.data_source('SKU', 'type'), - TextDyField.data_source('Backend pools', 'data.backend_address_pools_count_display'), - ListDyField.data_source('Health Probe', 'data.probes_display', options={ - 'delimiter': '
' - }), - ListDyField.data_source('Load Balancing Rule', 'data.load_balancing_rules_display', options={ - 'delimiter': '
' - }), - ListDyField.data_source('NAT Rules', 'data.inbound_nat_rules_display', options={ - 'delimiter': '
' - }), - ListDyField.data_source('Private IP Address', 'data.private_ip_address_display', options={ - 'delimiter': '
' - }), -]) - -# TAB - Frontend IP Configurations -# 1) Name, IP Address, Rules Count, Type, Public IP Address -load_balancer_info_frontend_ip_config = SimpleTableDynamicLayout.set_fields('Frontend IP Configurations', - 'data.frontend_ip_configurations', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Address', 'private_ip_address'), - TextDyField.data_source('IP Version', 'private_ip_address_version'), - ]) - - -# 2) Used By -load_balancer_info_frontend_ip_config_rules = ItemDynamicLayout.set_fields('Used By', fields=[ - ListDyField.data_source('Used By', 'data.frontend_ip_configurations_used_by_display', options={ - 'delimiter': '
' - }) -]) - -# 1 + 2) TAB - Frontend IP Configurations Meta -load_balancer_info_frontend_ip_config_meta = ListDynamicLayout.set_layouts('Frontend IP Configurations', - layouts=[ - load_balancer_info_frontend_ip_config, - load_balancer_info_frontend_ip_config_rules]) - -# TAB - Backend Pools -# 3) Backend pool name, Virtual Network, Private IP Address Version -load_balancer_info_backend_pools = SimpleTableDynamicLayout.set_fields('Backend Pools', 'data.backend_address_pools', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('ID', 'id') -]) - -# 4) Virtual machine, Load Balancer, Network interface, private IP address -load_balancer_info_backend_pools_vms = SimpleTableDynamicLayout.set_fields('Backend Pools VM information', - 'data.network_interfaces', fields=[ - TextDyField.data_source('Backend Pool', 'load_balancer_backend_address_pools_name_display'), - TextDyField.data_source('VM Name', 'virtual_machine_name_display'), - TextDyField.data_source('Network Interface', 'name'), - ListDyField.data_source('Private IP Address', 'private_ip_display', options={ - 'delimiter': '
' - }) - ]) - -# 3 + 4) TAB - Backend Pools -load_balancer_info_backend_pools_meta = ListDynamicLayout.set_layouts('Backend Pools', - layouts=[ - load_balancer_info_backend_pools, - load_balancer_info_backend_pools_vms]) -# TAB - Health Probes -# Name, Protocol, Port -load_balancer_info_health_probes = TableDynamicLayout.set_fields('Health Probes', 'data.probes', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Port', 'port'), - TextDyField.data_source('Interval', 'interval_in_seconds'), - TextDyField.data_source('Unhealthy Threshold', 'number_of_probes') -]) - -# TAB _ Load Balancing Rules -# LB rules Name, Load balancing rule, Health probe -> skip -load_balancer_info_load_balancing_rules = TableDynamicLayout.set_fields('Load Balancing Rules', - 'data.load_balancing_rules', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Frontend IP Address', 'frontend_ip_configuration_display'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Frontend Port', 'frontend_port'), - TextDyField.data_source('Backend Port', 'backend_port'), - ListDyField.data_source('Backend Pool', 'backend_address_pool_display'), - TextDyField.data_source('Session Persistence', 'load_distribution_display'), - TextDyField.data_source('Idle Timeout (minutes)', 'idle_timeout_in_minutes'), - TextDyField.data_source('Floating IP', 'enable_floating_ip'), - TextDyField.data_source('TCP Reset', 'enable_tcp_reset'), - - ]) - -# TAB - Inbound NAT Rules -# Forwards incoming traffic sent to a selected IP address and port combination to a specific virtual machine -# NAT rule Name, IP version, destination, target, service -load_balancer_info_inbound_nat_rules = TableDynamicLayout.set_fields('Inbound NAT Rules', 'data.inbound_nat_rules', - fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Protocol', - 'protocol'), - TextDyField.data_source( - 'Idle timeout (minutes)', - 'idle_timeout_in_minutes'), - TextDyField.data_source('TCP Reset', - 'enable_tcp_reset'), - TextDyField.data_source('Port', - 'frontend_port'), - ListDyField.data_source( - 'Target Virtual Machine', 'target_virtual_machine'), # ***** - TextDyField.data_source( - 'Network IP Configuration', - 'frontend_ip_configuration_display'), - TextDyField.data_source('Port mapping', - 'port_mapping_display'), - TextDyField.data_source('Floating IP', - 'enable_floating_ip'), - TextDyField.data_source('Target Port', - 'backend_port') - ]) -# TextDyField.data_source('IP Version', 'frontend_ip_configurations...private_ip_address_version'), -# TextDyField.data_source('Destination', 'private_ip_address'), - -load_balancer_meta = CloudServiceMeta.set_layouts( - [load_balancer_info_meta, load_balancer_info_frontend_ip_config_meta, load_balancer_info_backend_pools_meta, - load_balancer_info_health_probes, load_balancer_info_inbound_nat_rules, load_balancer_info_load_balancing_rules]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='LoadBalancers') - - -class LoadBalancerResource(NetworkResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(LoadBalancer) - _metadata = ModelType(CloudServiceMeta, default=load_balancer_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class LoadBalancerResponse(CloudServiceResponse): - resource = PolyModelType(LoadBalancerResource) diff --git a/src/spaceone/inventory/model/load_balancers/cloud_service_type.py b/src/spaceone/inventory/model/load_balancers/cloud_service_type.py deleted file mode 100644 index 6c2cba9e..00000000 --- a/src/spaceone/inventory/model/load_balancers/cloud_service_type.py +++ /dev/null @@ -1,210 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) -load_balancers_backendpool_vm_count_by_region_conf = os.path.join(current_dir, 'widget/load_balancers_backendpool_vm_count_by_region.yaml') -load_balancers_count_by_account_conf = os.path.join(current_dir, 'widget/load_balancers_count_by_account.yaml') -load_balancers_count_by_region_conf = os.path.join(current_dir, 'widget/load_balancers_count_by_region.yaml') -load_balancers_count_by_subscription_conf = os.path.join(current_dir, 'widget/load_balancers_count_by_subscription.yaml') -load_balancers_total_count_conf = os.path.join(current_dir, 'widget/load_balancers_total_count.yaml') - -cst_load_balancers = CloudServiceTypeResource() -cst_load_balancers.name = 'Instance' -cst_load_balancers.group = 'LoadBalancers' -cst_load_balancers.service_code = 'Microsoft.Network/loadBalancers' -cst_load_balancers.labels = ['Networking'] -cst_load_balancers.is_major = True -cst_load_balancers.is_primary = True -cst_load_balancers.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-loadbalancers.svg', -} - -cst_load_balancers._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'data.subscription_id', options={ - 'is_optional': True - }), - TextDyField.data_source('SKU', 'instance_type', options={ - 'is_optional': True - }), - ListDyField.data_source('Health Probe', 'data.probes_display', options={ - 'delimiter': '
', - 'is_optional': True - }), - ListDyField.data_source('Load Balancing Rule', 'data.load_balancing_rules_display', options={ - 'delimiter': '
', - 'is_optional': True - }), - ListDyField.data_source('NAT Rules', 'data.inbound_nat_rules_display', options={ - 'delimiter': '
', - 'is_optional': True - }), - ListDyField.data_source('Private IP Address', 'data.private_ip_address_display', options={ - 'delimiter': '
', - 'is_optional': True - }), - # is_optional fields- Frontend IP Configurations - TextDyField.data_source('Frontend Name', 'data.frontend_ip_configurations.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Frontend IP Address', 'data.frontend_ip_configurations.private_ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Frontend IP Version', 'data.frontend_ip_configurations.private_ip_address_version', options={ - 'is_optional': True - }), - ListDyField.data_source('Frontend IP Used By', 'data.frontend_ip_configurations_used_by_display', options={ - 'delimiter': '
', - 'is_optional': True - }), - # is_optional fields- Backend Pools - TextDyField.data_source('Backend Pool Name', 'data.backend_address_pools.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Backend Pool ID', 'data.backend_address_pools.id', options={ - 'is_optional': True - }), - # is_optional fields - Health Probes - TextDyField.data_source('Health Probe Name', 'data.probes.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Protocol', 'data.probes.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Port', 'data.probes.port', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Interval', 'data.probes.interval_in_seconds', options={ - 'is_optional': True - }), - TextDyField.data_source('Health Probes Unhealthy Threshold', 'data.probes.number_of_probes', options={ - 'is_optional': True - }), - # is_optional fields - Load Balancing Rules - TextDyField.data_source('LB Rule Name', 'data.load_balancing_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Frontend IP Address', 'data.load_balancing_rules.frontend_ip_configuration_display', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Protocol', 'data.load_balancing_rules.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Frontend Port', 'data.load_balancing_rules.frontend_port', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Backend Port', 'data.load_balancing_rules.backend_port', options={ - 'is_optional': True - }), - ListDyField.data_source('LB Rule Backend Pool', 'data.load_balancing_rules.backend_address_pool_display', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Session Persistence', 'data.load_balancing_rules.load_distribution_display', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Idle Timeout (minutes)', 'data.load_balancing_rules.idle_timeout_in_minutes', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule Floating IP', 'data.load_balancing_rules.enable_floating_ip', options={ - 'is_optional': True - }), - TextDyField.data_source('LB Rule TCP Reset', 'data.load_balancing_rules.enable_tcp_reset', options={ - 'is_optional': True - }), - # is_optional fields - Inbound NAT Rules - TextDyField.data_source('Inbound NAT Rules Name', 'data.inbound_nat_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Protocol', 'data.inbound_nat_rules.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Idle timeout (minutes)', 'data.inbound_nat_rules.idle_timeout_in_minutes', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule TCP Reset', 'data.inbound_nat_rules.enable_tcp_reset', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Port', 'data.inbound_nat_rules.frontend_port', options={ - 'is_optional': True - }), - ListDyField.data_source('Inbound NAT Rule Target Virtual Machine', 'data.inbound_nat_rules.target_virtual_machine', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Network IP Configuration', 'data.inbound_nat_rules.frontend_ip_configuration_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Port mapping', 'data.inbound_nat_rules.port_mapping_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Floating IP', 'data.inbound_nat_rules.enable_floating_ip', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound NAT Rule Target Port', 'data.inbound_nat_rules.backend_port', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Load Balancer Type', key='instance_type'), - SearchField.set(name='SKU', key='instance_type'), - SearchField.set(name='Health Probe', key='data.probes_display'), - SearchField.set(name='Load Balancing Rule', key='data.load_balancing_rules_display'), - SearchField.set(name='NAT Rules', key='data.inbound_nat_rules_display'), - SearchField.set(name='Private IP Address', key='data.private_ip_address_display'), - SearchField.set(name='Frontend Name', key='data.frontend_ip_configurations.name'), - SearchField.set(name='Frontend IP Address', key='data.frontend_ip_configurations.private_ip_address'), - SearchField.set(name='Frontend IP Version', key='data.frontend_ip_configurations.private_ip_address_version'), - SearchField.set(name='Frontend IP Used By', key='data.frontend_ip_configurations_used_by_display'), - SearchField.set(name='Backend Pool Name', key='data.backend_address_pools.name'), - SearchField.set(name='Backend Pool ID', key='data.backend_address_pools.id'), - SearchField.set(name='Health Probe Name', key='data.probes.name'), - SearchField.set(name='Health Probes Protocol', key='data.probes.protocol'), - SearchField.set(name='Health Probes Port', key='data.probes.port', data_type='integer'), - SearchField.set(name='Health Probes Interval', key='data.probes.interval_in_seconds', data_type='integer'), - SearchField.set(name='Health Probes Unhealthy Threshold', key='data.probes.number_of_probes'), - SearchField.set(name='LB Rule Name', key='data.load_balancing_rules.name'), - SearchField.set(name='LB Rule Frontend IP Address', key='data.load_balancing_rules.frontend_ip_configuration_display'), - SearchField.set(name='LB Rule Protocol', key='data.load_balancing_rules.protocol'), - SearchField.set(name='LB Rule Frontend Port', key='data.load_balancing_rules.frontend_port', data_type='integer'), - SearchField.set(name='LB Rule Backend Port', key='data.load_balancing_rules.backend_port', data_type='integer'), - SearchField.set(name='LB Rule Backend Pool', key='data.load_balancing_rules.backend_address_pool_display'), - SearchField.set(name='LB Rule Session Persistence', key='data.load_balancing_rules.load_distribution_display'), - SearchField.set(name='LB Rule Idle Timeout (minutes)', key='data.load_balancing_rules.idle_timeout_in_minutes', data_type='integer'), - SearchField.set(name='LB Rule Floating IP', key='data.load_balancing_rules.enable_floating_ip'), - SearchField.set(name='LB Rule TCP Reset', key='data.load_balancing_rules.enable_tcp_reset'), - SearchField.set(name='Inbound NAT Rules Name', key='data.inbound_nat_rules.name'), - SearchField.set(name='Inbound NAT Rule Protocol', key='data.inbound_nat_rules.protocol'), - SearchField.set(name='Inbound NAT Rule Idle timeout (minutes)', key='data.inbound_nat_rules.idle_timeout_in_minutes', data_type='integer'), - SearchField.set(name='Inbound NAT Rule TCP Reset', key='data.load_balancing_rules.enable_tcp_reset'), - SearchField.set(name='Inbound NAT Rule Port', key='data.inbound_nat_rules.frontend_port', data_type='integer'), - SearchField.set(name='Inbound NAT Rule Target Virtual Machine', key='data.inbound_nat_rules.target_virtual_machine'), - SearchField.set(name='Inbound NAT Rule Network IP Configuration', key='data.inbound_nat_rules.frontend_ip_configuration_display'), - SearchField.set(name='Inbound NAT Rule Port mapping', key='data.inbound_nat_rules.port_mapping_display'), - SearchField.set(name='Inbound NAT Rule Floating IP', key='data.inbound_nat_rules.enable_floating_ip'), - SearchField.set(name='Inbound NAT Rule Target Port', key='data.inbound_nat_rules.backend_port', data_type='integer'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(load_balancers_backendpool_vm_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(load_balancers_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(load_balancers_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(load_balancers_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(load_balancers_total_count_conf)), - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_load_balancers}), -] diff --git a/src/spaceone/inventory/model/load_balancers/data.py b/src/spaceone/inventory/model/load_balancers/data.py deleted file mode 100644 index 1b2aa6e1..00000000 --- a/src/spaceone/inventory/model/load_balancers/data.py +++ /dev/null @@ -1,653 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService - -class Tags(Model): - key = StringType() - value = StringType() - - -class SubResource(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - - -class ExtendedLocationTypes(Model): - edge_zone = StringType(serialize_when_none=False) - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = ModelType(ExtendedLocationTypes, serialize_when_none=False) - - -class TrafficAnalyticsConfigurationProperties(Model): - enabled = BooleanType(serialize_when_none=False) - traffic_analytics_interval = IntType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - workspace_region = StringType(serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class NetworkInterfaceDnsSettings(Model): - applied_dns_servers = ListType(StringType, serialize_when_none=False) - dns_servers = ListType(StringType, serialize_when_none=False) - internal_dns_name_label= StringType(serialize_when_none=False) - internal_domain_name_suffix = StringType(serialize_when_none=False) - internal_fqdn = StringType(serialize_when_none=False) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class TrafficAnalyticsProperties(Model): - network_watcher_flow_analytics_configuration = ModelType(TrafficAnalyticsConfigurationProperties, serialize_when_none=False) - - -class FlowLogFormatType(Model): - json = StringType(serialize_when_none=False) - - -class FlowLogFormatParameters(Model): - type = ModelType(FlowLogFormatType, serialize_when_none=False) - version = IntType(serialize_when_none=False) - - -class RetentionPolicyParameters(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class FlowLog(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - enable = BooleanType(serialize_when_none=False) - flow_analytics_configuration = ModelType(TrafficAnalyticsProperties, serialize_when_none=False) - format = ModelType(FlowLogFormatParameters, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - retention_policy = ModelType(RetentionPolicyParameters, serialize_when_none=False) - storage_id = StringType(serialize_when_none=False) - target_resource_guid = StringType(serialize_when_none=False) - target_resource_id = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceTapConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class CustomDnsConfigPropertiesFormat(Model): - fqdn = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType, serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(Model): # belongs to NetworkInterfaceIPConfiguration - fqdns = ListType(StringType, serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - required_member_name = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfigurationProfileRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ListType(StringType(), default=[], serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class ServiceAssociationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allow_delete = BooleanType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class PrivateLinkServiceConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState, serialize_when_none=False) - private_link_service_id = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - request_message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SecurityRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - access = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - description = StringType(serialize_when_none=False) - destination_address_prefix = StringType(serialize_when_none=False) - destination_address_prefixes = ListType(StringType, serialize_when_none=False) - destination_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - destination_port_range = StringType(serialize_when_none=False) - destination_port_ranges = ListType(StringType, serialize_when_none=False) - direction = StringType(choices=('Inbound', 'Outbound'), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - protocol = StringType(choices=('*', 'Ah', 'Esp', 'Icmp', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - source_address_prefix = StringType(serialize_when_none=False) - source_address_prefixes = ListType(StringType, serialize_when_none=False) - source_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - source_port_range = StringType(serialize_when_none=False) - source_port_ranges = ListType(StringType, serialize_when_none=False) - - -class IPConfigurationRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ListType(StringType(), default=[], serialize_when_none=False) - - -class Delegation(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - actions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service_name = StringType(serialize_when_none=False) - - -class ResourceNavigationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Route(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - next_hop_ip_address = StringType(serialize_when_none=False) - next_hop_type = StringType(choices=('Internet', 'None', 'VirtualAppliance', 'VirtualNetworkGateway', 'VnetLocal'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - - -class RouteTable(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - disable_bgp_route_propagation = BooleanType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - routes = ListType(ModelType(Route), serialize_when_none=False) - subnets = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicy(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - service_endpoint_policy_definitions = ListType(ModelType(ServiceEndpointPolicyDefinition), serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPropertiesFormat(Model): - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - - -class NetworkSecurityGroupRef(Model): - id = StringType() - name = StringType() - - -class PrivateEndpointRef(Model): - id = StringType() - name = StringType() - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - - -class PublicIPAddress(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class Subnet(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - address_prefixes = ListType(StringType, serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource, serialize_when_none=False)) - nat_gateway = ModelType(SubResource, serialize_when_none=False) - private_endpoint_network_policies = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - purpose = StringType(serialize_when_none=False) - delegations = ListType(ModelType(Delegation), serialize_when_none=False) - ip_configuration_profiles = ListType(ModelType(IPConfigurationProfileRef), serialize_when_none=False) - ip_configurations = ListType(ModelType(IPConfigurationRef), serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroupRef, serialize_when_none=False) - private_endpoints = ListType(ModelType(PrivateEndpointRef), serialize_when_none=False) - private_link_service_network_policies = StringType(serialize_when_none=False) - resource_navigation_links = ListType(ModelType(ResourceNavigationLink, serialize_when_none=False)) - route_table = ModelType(RouteTable, serialize_when_none=False) - service_association_links = ListType(ModelType(ServiceAssociationLink), serialize_when_none=False) - service_endpoint_policies = ListType(ModelType(ServiceEndpointPolicy), serialize_when_none=False) - service_endpoints = ListType(ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False) - - -class PrivateEndpoint(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) - manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), - serialize_when_none=False) - network_interfaces = ListType(ModelType(SubResource), serialize_when_none=False) # 아래에 있음 - private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ModelType(Subnet, serialize_when_none=False) # 아래에 있음 - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfiguration(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - private_link_connection_properties = ModelType(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - subnet = ModelType(Subnet, serialize_when_none=False) - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -class NetworkInterface(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - dns_settings = ModelType(NetworkInterfaceDnsSettings, serialize_when_none=False) - dscp_configuration = ModelType(SubResource, serialize_when_none=False) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - hosted_workloads = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) # 아래에 있음 - mac_address = StringType(serialize_when_none=False) - network_security_group = ModelType(SubResource) - load_balancer_backend_address_pools_name_display = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpoint, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tap_configurations = ListType(ModelType(NetworkInterfaceTapConfiguration), serialize_when_none=False) - virtual_machine = ModelType(SubResource, serialize_when_none=False) - virtual_machine_name_display = StringType(serialize_when_none=False, default='-') - private_ip_display = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -# class NetworkSecurityGroupRef(Model): -# etag = StringType(serialize_when_none=False) -# id = StringType(serialize_when_none=False) -# location = StringType(serialize_when_none=False) -# name = StringType(serialize_when_none=False) -# default_security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) -# flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) -# network_interfaces = ListType(ModelType(NetworkInterface), serialize_when_none=False) -# provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) -# resource_guid = StringType(serialize_when_none=False) -# security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) -# subnet = ListType(StringType(), default=[], serialize_when_none=False) -# tags = ModelType(Tags, serialize_when_none=False) -# type = StringType(serialize_when_none=False) - - -# class PrivateEndpointRef(Model): -# etag = StringType(serialize_when_none=False) -# id = StringType(serialize_when_none=False) -# location = StringType(serialize_when_none=False) -# name = StringType(serialize_when_none=False) -# custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) -# manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) -# network_interfaces = ListType(ModelType(NetworkInterface), serialize_when_none=False) # 아래에 있음 -# private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) -# provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) -# subnet = ListType(StringType(), default=[], serialize_when_none=False) -# tags = ModelType(Tags, serialize_when_none=False) -# type = StringType(serialize_when_none=False) - - -class IPConfigurationProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ModelType(Subnet, serialize_when_none=False) # 아래에 있음.. 흠 - type = StringType(serialize_when_none=False) - - -class ApplicationGatewayBackendAddress(Model): - fqdn = StringType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - - -class InboundNatPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_port_range_end = IntType(serialize_when_none=False) - frontend_port_range_start = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - -################################################################################ -################################################################################ - - -class InboundNatRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) - target_virtual_machine = ListType(StringType, serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - port_mapping_display = StringType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class LoadBalancingRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_address_pool_display = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - disable_outbound_s_nat = BooleanType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - load_distribution = StringType(choices=('Default', 'SourceIP', 'SourceIPProtocol'), serialize_when_none=False) - load_distribution_display = StringType(serialize_when_none=False) - probe = ModelType(SubResource, serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class OutboundRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allocated_outbound_ports = IntType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configurations = ListType(ModelType(SubResource), serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Probe(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - interval_in_seconds = IntType(serialize_when_none=False) - load_balancing_rules = ListType(ModelType(SubResource), serialize_when_none=False) - number_of_probes = IntType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - protocol = StringType(choices=('Http', 'Tcp', 'Https'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - request_path = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - default_security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = ListType(ModelType(NetworkInterface), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(ModelType(Subnet), serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(InboundNatPool), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(InboundNatRule), serialize_when_none=False) - load_balancing_rules = ListType(ModelType(LoadBalancingRule), serialize_when_none=False) - outbound_rules = ListType(ModelType(OutboundRule), serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) # 아래에 있음..힝 - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - subnet = ModelType(Subnet, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class VirtualNetworkTap(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - destination_load_balancer_front_end_ip_configuration = ModelType(FrontendIPConfiguration, - serialize_when_none=False) - destination_network_interface_ip_configuration = ModelType(NetworkInterfaceIPConfiguration, - serialize_when_none=False) - destination_port = IntType(serialize_when_none=False) - network_interface_tap_configurations = ListType(ModelType(NetworkInterfaceTapConfiguration)) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), - serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class LoadBalancerBackendAddress(Model): - name = StringType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - load_balancer_frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - network_interface_ip_configuration = ModelType(SubResource, serialize_when_none=False) - virtual_network = ModelType(SubResource, serialize_when_none=False) - - -class BackendAddressPoolRef(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - etag = StringType(serialize_when_none=False) - - -class ApplicationGatewayBackendAddressPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_addresses = ListType(ModelType(ApplicationGatewayBackendAddress), serialize_when_none=False) - backend_ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class BackendAddressPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) - load_balancer_backend_addresses = ListType(ModelType(LoadBalancerBackendAddress), serialize_when_none=False) - load_balancing_rules = ListType(ModelType(SubResource), serialize_when_none=False) - outbound_rule = ModelType(SubResource, serialize_when_none=False) - outbound_rules = ListType(ModelType(SubResource), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - vm_ids = ListType(StringType, serialize_when_none=False) - - -class LoadBalancerSku(Model): - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - name = StringType(choices=('Standard', 'Basic'), serialize_when_none=False) - - -class LoadBalancer(AzureCloudService): - name = StringType() - id = StringType() - location = StringType() - sku = ModelType(LoadBalancerSku, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - backend_address_pools = ListType(ModelType(BackendAddressPool), serialize_when_none=False) - backend_address_pools_count_display = StringType(serialize_when_none=False, default='') - network_interfaces = ListType(ModelType(NetworkInterface), serialize_when_none=False) - frontend_ip_configurations = ListType(ModelType(FrontendIPConfiguration), serialize_when_none=False) - frontend_ip_configurations_used_by_display = ListType(StringType, serialize_when_none=False) - private_ip_address_display = ListType(StringType, serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(InboundNatPool), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(InboundNatRule), serialize_when_none=False) - inbound_nat_rules_display = ListType(StringType, serialize_when_none=False) - load_balancing_rules = ListType(ModelType(LoadBalancingRule), serialize_when_none=False) - load_balancing_rules_display = ListType(StringType, serialize_when_none=False) - outbound_rules = ListType(ModelType(OutboundRule), serialize_when_none=False) - probes = ListType(ModelType(Probe), serialize_when_none=False) - probes_display = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - type = 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", - } \ No newline at end of file diff --git a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_backendpool_vm_count_by_region.yaml b/src/spaceone/inventory/model/load_balancers/widget/load_balancers_backendpool_vm_count_by_region.yaml deleted file mode 100644 index 55dfc5d4..00000000 --- a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_backendpool_vm_count_by_region.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: LoadBalancers -cloud_service_type: Instance -name: Backend Pool VM Count by Region -query: - aggregate: - - unwind: - path: data.network_interfaces - - group: - keys: - - name: name - key: data.network_interfaces.location - fields: - - name: value - key: data.network_interfaces.location - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_account.yaml b/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_account.yaml deleted file mode 100644 index dda270eb..00000000 --- a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: LoadBalancers -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_region.yaml b/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_region.yaml deleted file mode 100644 index 2b250668..00000000 --- a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: LoadBalancers -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_subscription.yaml b/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_subscription.yaml deleted file mode 100644 index f382b446..00000000 --- a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: LoadBalancers -cloud_service_type: Instance -name: Total Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_total_count.yaml b/src/spaceone/inventory/model/load_balancers/widget/load_balancers_total_count.yaml deleted file mode 100644 index 7d2cce27..00000000 --- a/src/spaceone/inventory/model/load_balancers/widget/load_balancers_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: LoadBalancers -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/mysql_servers/__init__.py b/src/spaceone/inventory/model/mysql_servers/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/mysql_servers/cloud_service.py b/src/spaceone/inventory/model/mysql_servers/cloud_service.py deleted file mode 100644 index 62081355..00000000 --- a/src/spaceone/inventory/model/mysql_servers/cloud_service.py +++ /dev/null @@ -1,93 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.mysql_servers.data import MySQLServer -''' -MYSQL SERVERS -''' - -# TAB - Default -mysql_servers_info_meta = ItemDynamicLayout.set_fields('MySQL Server', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Server Name', 'data.fully_qualified_domain_name'), - TextDyField.data_source('Type', 'instance_type'), - EnumDyField.data_source('Status', 'data.user_visible_state', default_state={ - 'safe': ['Ready'], - 'warning': ['Dropping'], - 'disable': ['Disabled', 'Inaccessible'] - }), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Server Admin Login Name', 'data.administrator_login'), - TextDyField.data_source('MySQL Version', 'data.version'), - TextDyField.data_source('Performance Configuration (Tier)', 'data.sku.tier'), - TextDyField.data_source('Performance Configuration (Name)', 'data.sku.name'), - TextDyField.data_source('SSL Enforce Status', 'data.ssl_enforcement'), -]) - - -# TAB - Connection Security -mysql_servers_firewall_rules = TableDynamicLayout.set_fields('Firewall Rules', 'data.firewall_rules', fields=[ - TextDyField.data_source('Firewall Rule Name', 'name'), - TextDyField.data_source('Start IP', 'start_ip_address'), - TextDyField.data_source('End IP', 'end_ip_address') -]) -mysql_servers_ssl_tls = ItemDynamicLayout.set_fields('MySQL Server', fields=[ - TextDyField.data_source('Allow Access To Azure Services', 'data.allow_azure_services_access'), - TextDyField.data_source('Enforce SSL Connection', 'data.ssl_enforcement'), - TextDyField.data_source('Minimum TLS Version', 'data.minimal_tls_version') -]) -# 1 + 2) TAB - Connection Security Meta -mysql_servers_connection_security = ListDynamicLayout.set_layouts('Connection Security', layouts=[ - mysql_servers_firewall_rules, - mysql_servers_ssl_tls]) - - -mysql_servers_parameters = TableDynamicLayout.set_fields('MySQL Parameters', fields=[ - TextDyField.data_source('Allow Access To Azure Services', 'data.allow_azure_services_access'), - TextDyField.data_source('Enforce SSL Connection', 'data.ssl_enforcement'), - TextDyField.data_source('Minimum TLS Version', 'data.minimal_tls_version') -]) - -mysql_servers_pricing_tiers = ItemDynamicLayout.set_fields('Pricing Tier', fields=[ - TextDyField.data_source('Tier', 'data.sku.tier'), - TextDyField.data_source('Compute Generation', 'data.sku.family'), - TextDyField.data_source('vCore', 'data.sku.capacity'), - TextDyField.data_source('Storage', 'data.storage_profile.storage_gb'), - EnumDyField.data_source('Storage Auto-Growth', 'data.storage_profile.storage_autogrow', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - EnumDyField.data_source('Geo Redundant Backup', 'data.storage_profile.geo_redundant_backup', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - TextDyField.data_source('Backup Retention Period', 'data.storage_profile.backup_retention_days'), -]) - -mysql_servers_meta = CloudServiceMeta.set_layouts( - [mysql_servers_info_meta, mysql_servers_connection_security, mysql_servers_parameters, mysql_servers_pricing_tiers]) - - -class DatabaseResource(CloudServiceResource): - cloud_service_group = StringType(default='MySQLServers') - - -class MySQLServerResource(DatabaseResource): - cloud_service_type = StringType(default='Server') - data = ModelType(MySQLServer) - _metadata = ModelType(CloudServiceMeta, default=mysql_servers_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class MySQLServerResponse(CloudServiceResponse): - resource = PolyModelType(MySQLServerResource) diff --git a/src/spaceone/inventory/model/mysql_servers/cloud_service_type.py b/src/spaceone/inventory/model/mysql_servers/cloud_service_type.py deleted file mode 100644 index d25bcc8d..00000000 --- a/src/spaceone/inventory/model/mysql_servers/cloud_service_type.py +++ /dev/null @@ -1,123 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -mysql_servers_count_by_account_conf = os.path.join(current_dir, 'widget/mysql_servers_count_by_account.yaml') -mysql_servers_count_by_region_conf = os.path.join(current_dir, 'widget/mysql_servers_count_by_region.yaml') -mysql_servers_count_by_subscription_conf = os.path.join(current_dir, 'widget/mysql_servers_count_by_subscription.yaml') -mysql_servers_count_by_tier_conf = os.path.join(current_dir, 'widget/mysql_servers_count_by_tier.yaml') -mysql_servers_total_count_conf = os.path.join(current_dir, 'widget/mysql_servers_total_count.yaml') - - -cst_mysql_servers = CloudServiceTypeResource() -cst_mysql_servers.name = 'Server' -cst_mysql_servers.group = 'MySQLServers' -cst_mysql_servers.service_code = 'Microsoft.DBforMySQL/servers' -cst_mysql_servers.labels = ['Database'] -cst_mysql_servers.is_major = True -cst_mysql_servers.is_primary = True -cst_mysql_servers.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-mysql-servers.svg', -} - -cst_mysql_servers._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Type', 'instance_type'), - EnumDyField.data_source('Status', 'data.user_visible_state', default_state={ - 'safe': ['Ready'], - 'warning': ['Dropping'], - 'disable': ['Disabled', 'Inaccessible'] - }), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Server Admin Login Name', 'data.administrator_login', options={ - 'is_optional': True - }), - TextDyField.data_source('MySQL Version', 'data.version', options={ - 'is_optional': True - }), - TextDyField.data_source('Performance Configuration (Tier)', 'instance_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Performance Configuration (Name)', 'data.sku.name', options={ - 'is_optional': True - }), - TextDyField.data_source('SSL Enforce Status', 'data.ssl_enforcement', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Rule Name', 'data.firewall_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Rule Start IP', 'data.firewall_rules.start_ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Rule End IP', 'data.firewall_rules.end_ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Allow Access To Azure Services', 'data.allow_azure_services_access', options={ - 'is_optional': True - }), - TextDyField.data_source('Enforce SSL Connection', 'data.ssl_enforcement', options={ - 'is_optional': True - }), - TextDyField.data_source('Minimum TLS Version', 'data.minimal_tls_version', options={ - 'is_optional': True - }), - TextDyField.data_source('Compute Generation', 'data.sku.family', options={ - 'is_optional': True - }), - TextDyField.data_source('vCore', 'data.sku.capacity', options={ - 'is_optional': True - }), - TextDyField.data_source('Storage', 'data.storage_profile.storage_gb', options={ - 'is_optional': True - }), - TextDyField.data_source('Backup Retention Period', 'data.storage_profile.backup_retention_days', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Type', key='instance_type'), - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Server Admin Login Name', key='data.administrator_login'), - SearchField.set(name='MySQL Version', key='data.version'), - SearchField.set(name='Performance Configuration (Tier)', key='instance_type'), - SearchField.set(name='Performance Configuration (Name)', key='data.sku.name'), - SearchField.set(name='SSL Enforce Status', key='data.ssl_enforcement'), - SearchField.set(name='Firewall Rule Name', key='data.firewall_rules.name'), - SearchField.set(name='Firewall Rule Start IP', key='data.firewall_rules.start_ip_address'), - SearchField.set(name='Firewall Rule End IP', key='data.firewall_rules.end_ip_address'), - SearchField.set(name='Allow Access To Azure Services', key='data.allow_azure_services_access'), - SearchField.set(name='Enforce SSL Connection', key='data.ssl_enforcement'), - SearchField.set(name='Minimum TLS Version', key='data.minimal_tls_version'), - SearchField.set(name='Compute Generation', key='data.sku.family'), - SearchField.set(name='vCore', key='data.sku.capacity', data_type='integer'), - SearchField.set(name='Storage', key='data.storage_profile.storage_gb', data_type='integer'), - SearchField.set(name='Backup Retention Period', key='data.storage_profile.backup_retention_days'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(mysql_servers_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(mysql_servers_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(mysql_servers_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(mysql_servers_count_by_tier_conf)), - CardWidget.set(**get_data_from_yaml(mysql_servers_total_count_conf)), - - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_mysql_servers}), -] diff --git a/src/spaceone/inventory/model/mysql_servers/data.py b/src/spaceone/inventory/model/mysql_servers/data.py deleted file mode 100644 index 96170eb0..00000000 --- a/src/spaceone/inventory/model/mysql_servers/data.py +++ /dev/null @@ -1,95 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, DateTimeType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class ResourceIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpointProperty(Model): - id = StringType(serialize_when_none=False) - - -class ServerPrivateLinkServiceConnectionStateProperty(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(choices=('Approved', 'Disconnected', 'Pending', 'Rejected'), serialize_when_none=False) - - -class ServerPrivateEndpointConnectionProperties(Model): - private_endpoint = ModelType(PrivateEndpointProperty, serialize_when_none=False) - private_link_service_connection_state = ModelType(ServerPrivateLinkServiceConnectionStateProperty, serialize_when_none=False) - provisioning_state = StringType(choices=('Approving', 'Dropping', 'Failed', 'Ready', 'Rejecting'), serialize_when_none=False) - - -class ServerPrivateEndpointConnection(Model): - id = StringType(serialize_when_none=False) - properties = ModelType(ServerPrivateEndpointConnectionProperties, serialize_when_none=False) - - -class StorageProfile(Model): - backup_retention_days = IntType(serialize_when_none=False) - geo_redundant_backup = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_autogrow = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_mb = IntType(serialize_when_none=False) - storage_gb = IntType(serialize_when_none=False) - - -class Sku(Model): - capacity = IntType(serialize_when_none=False) - family = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - size = StringType(serialize_when_none=False) - tier = StringType(choices=('Basic', 'GeneralPurpose', 'MemoryOptimized'), serialize_when_none=False) - - -class FirewallRule(Model): - id = StringType() - name = StringType(serialize_when_none=False) - end_ip_address = StringType(serialize_when_none=False) - start_ip_address = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class MySQLServer(AzureCloudService): # Main class - id = StringType() - identity = ModelType(ResourceIdentity, serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - administrator_login = StringType(serialize_when_none=False) - byok_enforcement = StringType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - firewall_rules = ListType(ModelType(FirewallRule), serialize_when_none=False) - allow_azure_services_access = BooleanType(default=True, serialize_when_none=False) - fully_qualified_domain_name = StringType(serialize_when_none=False) - infrastructure_encryption = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - master_server_id = StringType(serialize_when_none=False) - minimal_tls_version = StringType(choices=('TLS1_0', 'TLS1_1', 'TLS1_2', 'TLSEnforcementDisabled'), serialize_when_none=False) - private_endpoint_connections = ListType(ModelType(ServerPrivateEndpointConnection), serialize_when_none=False) - public_network_access = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - replica_capacity = IntType(serialize_when_none=False) - replication_role = StringType(serialize_when_none=False) - ssl_enforcement = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_profile = ModelType(StorageProfile, serialize_when_none=False) - user_visible_state = StringType(choices=('Disabled', 'Dropping', 'Inaccessible', 'Ready'), serialize_when_none=False) - version = StringType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - type = 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", - } diff --git a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_account.yaml b/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_account.yaml deleted file mode 100644 index e90ea2c3..00000000 --- a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: MySQLServers -cloud_service_type: Server -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_region.yaml b/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_region.yaml deleted file mode 100644 index a0fd3377..00000000 --- a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: MySQLServers -cloud_service_type: Server -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_ code \ No newline at end of file diff --git a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_subscription.yaml b/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_subscription.yaml deleted file mode 100644 index c79735c3..00000000 --- a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: MySQLServers -cloud_service_type: Server -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_tier.yaml b/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_tier.yaml deleted file mode 100644 index 93933777..00000000 --- a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_count_by_tier.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: MySQLServers -cloud_service_type: Server -name: Count by Tier -query: - aggregate: - - group: - keys: - - name: name - key: data.sku.tier - fields: - - name: value - key: data.sku.tier - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_total_count.yaml b/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_total_count.yaml deleted file mode 100644 index e86e704e..00000000 --- a/src/spaceone/inventory/model/mysql_servers/widget/mysql_servers_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: MySQLServers -cloud_service_type: Server -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/nat_gateways/__init__.py b/src/spaceone/inventory/model/nat_gateways/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/nat_gateways/cloud_service.py b/src/spaceone/inventory/model/nat_gateways/cloud_service.py deleted file mode 100644 index b0c2b03d..00000000 --- a/src/spaceone/inventory/model/nat_gateways/cloud_service.py +++ /dev/null @@ -1,75 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.nat_gateways.data import NatGateway - -''' -NAT GATEWAY -''' -# TAB - Default -nat_gateway_info_meta = ItemDynamicLayout.set_fields('NAT Gateway', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Subnets', 'data.subnets_count'), - TextDyField.data_source('Public IP Addresses', 'data.public_ip_addresses_count'), - TextDyField.data_source('Public IP Prefixes', 'data.public_ip_prefixes_count'), - TextDyField.data_source('Idle Timeout (minutes)', 'data.idle_timeout_in_minutes'), -]) - -# TAB - Outbound IP -nat_gateway_outbound_ip_public_ip_addresses = SimpleTableDynamicLayout.set_fields('Public IP Addresses', 'data.public_ip_addresses', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Address', 'ip_address'), - TextDyField.data_source('DNS Name', 'dns_settings.domain_name_label') -]) - -nat_gateway_outbound_ip_public_ip_prefixes = SimpleTableDynamicLayout.set_fields('Public IP Prefixes', 'data.public_ip_prefixes', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Prefix', 'ip_prefix') -]) -nat_gateway_outbound_ip_info = ListDynamicLayout.set_layouts('Outbound IP', layouts=[nat_gateway_outbound_ip_public_ip_addresses, nat_gateway_outbound_ip_public_ip_prefixes]) - -nat_gateway_subnets = SimpleTableDynamicLayout.set_fields('Subnets', 'data.subnets', fields=[ - TextDyField.data_source('Subnet Name', 'name'), - TextDyField.data_source('Subnet Address ', 'address_prefix'), - TextDyField.data_source('Subnet Addresses', 'address_prefixes'), - TextDyField.data_source('Virtual Network', 'virtual_network'), - EnumDyField.data_source('Private Endpoint Network Policies', 'private_endpoint_network_policies', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - EnumDyField.data_source('Private Link Service Network Policies', 'private_link_service_network_policies', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }) -]) - -nat_gateway_meta = CloudServiceMeta.set_layouts( - [nat_gateway_info_meta, nat_gateway_outbound_ip_info, nat_gateway_subnets]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='NATGateways') - - -class NatGatewayResource(NetworkResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(NatGateway) - _metadata = ModelType(CloudServiceMeta, default=nat_gateway_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class NatGatewayResponse(CloudServiceResponse): - resource = PolyModelType(NatGatewayResource) diff --git a/src/spaceone/inventory/model/nat_gateways/cloud_service_type.py b/src/spaceone/inventory/model/nat_gateways/cloud_service_type.py deleted file mode 100644 index 7a11f290..00000000 --- a/src/spaceone/inventory/model/nat_gateways/cloud_service_type.py +++ /dev/null @@ -1,91 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -nat_gateways_count_by_account_conf = os.path.join(current_dir, 'widget/nat_gateways_count_by_account.yaml') -nat_gateways_count_by_region_conf = os.path.join(current_dir, 'widget/nat_gateways_count_by_region.yaml') -nat_gateways_count_by_subscription_conf = os.path.join(current_dir, 'widget/nat_gateways_count_by_subscription.yaml') -nat_gateways_total_count_conf = os.path.join(current_dir, 'widget/nat_gateways_total_count.yaml') - -cst_nat_gateways = CloudServiceTypeResource() -cst_nat_gateways.name = 'Instance' -cst_nat_gateways.group = 'NATGateways' -cst_nat_gateways.service_code = 'Microsoft.Network/natGateways' -cst_nat_gateways.labels = ['Networking'] -cst_nat_gateways.is_major = True -cst_nat_gateways.is_primary = True -cst_nat_gateways.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-nat.svg', -} - -cst_nat_gateways._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Subnets (count)', 'data.subnets_count'), - TextDyField.data_source('Public IP Addresses (count)', 'data.public_ip_prefixes_count'), - TextDyField.data_source('Public IP Prefixes (count)', 'data.public_ip_prefixes_count'), - # is_optional fields - Public IP Addresses - TextDyField.data_source('Public IP Name', 'data.public_ip_addresses.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Public IP Address', 'data.public_ip_addresses.ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Public DNS Name', 'data.public_ip_addresses.dns_settings.domain_name_label', options={ - 'is_optional': True - }), - # is_optional fields - Public IP Prefixes - TextDyField.data_source('Public IP Prefix Name', 'data.public_ip_prefixes.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Public IP Prefix', 'data.public_ip_prefixes.ip_prefix', options={ - 'is_optional': True - }), - # is_optional fields - Subnets - TextDyField.data_source('Subnet Name', 'data.subnets.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet Addresses', 'data.subnets.address_prefixes', options={ - 'is_optional': True - }), - TextDyField.data_source('Virtual Network', 'data.subnets.virtual_network', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Public IP Name', key='data.public_ip_addresses.name'), - SearchField.set(name='Public IP Address', key='data.public_ip_addresses.ip_address'), - SearchField.set(name='Public DNS Name', key='data.public_ip_addresses.dns_settings.domain_name_label'), - SearchField.set(name='Public IP Prefix Name', key='data.public_ip_prefixes.name'), - SearchField.set(name='Public IP Prefix', key='data.public_ip_prefixes.ip_prefix'), - SearchField.set(name='Subnet Name', key='data.subnets.name'), - SearchField.set(name='Subnet Addresses', key='data.subnets.address_prefixes'), - SearchField.set(name='Virtual Network', key='data.subnets.virtual_network') - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(nat_gateways_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(nat_gateways_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(nat_gateways_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(nat_gateways_total_count_conf)) - ] - -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_nat_gateways}), -] diff --git a/src/spaceone/inventory/model/nat_gateways/data.py b/src/spaceone/inventory/model/nat_gateways/data.py deleted file mode 100644 index 8cb55dcd..00000000 --- a/src/spaceone/inventory/model/nat_gateways/data.py +++ /dev/null @@ -1,1193 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -""" -START OF REF CLASSES -""" - - -class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(Model): - fqdns = ListType(StringType, serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - required_member_name = StringType(serialize_when_none=False) - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroupRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationRef( - Model -): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType( - ModelType(ApplicationSecurityGroupRef), serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - private_link_connection_properties = ModelType( - NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = StringType( - default="", serialize_when_none=False - ) # Change Public IP Address to id - subnet = StringType(default="", serialize_when_none=False) # Change Subnet to id - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -""" -END OF REF CLASSES -""" - - -class AddressSpace(Model): - address_count = IntType(serialize_when_none=False, default=0) - address_prefixes = ListType(StringType, default=["-"]) - - -class AutoApproval(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class ApplicationGatewayIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ConnectedDevice( - Model -): # Customized class, model for connected device lists attached to this virtual network - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - device = StringType(serialize_when_none=False) - - -class CustomDnsConfigPropertiesFormat(Model): - fqdn = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType, serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType( - choices=("Basic", "Standard"), serialize_when_none=False - ) - - -class DhcpOptions(Model): - dns_servers = ListType(StringType, default=["Azure provided DNS service"]) - - -class Delegation(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(default="-", serialize_when_none=False) - actions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service_name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FlowLogFormatType(Model): - json = StringType(serialize_when_none=False) - - -class FlowLogFormatParameters(Model): - type = ModelType(FlowLogFormatType, serialize_when_none=False) - version = IntType(serialize_when_none=False) - - -class InboundNatPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_port_range_end = IntType(serialize_when_none=False) - frontend_port_range_start = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class InboundNatRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_ip_configurations = ListType( - ModelType(NetworkInterfaceIPConfigurationRef), serialize_when_none=False - ) - target_virtual_machine = ListType(StringType, serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - port_mapping_display = StringType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class LoadBalancingRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_address_pool_display = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - disable_outbound_s_nat = BooleanType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - load_distribution = StringType( - choices=("Default", "SourceIP", "SourceIPProtocol"), serialize_when_none=False - ) - load_distribution_display = StringType(serialize_when_none=False) - probe = ModelType(SubResource, serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class OutboundRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allocated_outbound_ports = IntType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configurations = ListType( - ModelType(SubResource), serialize_when_none=False - ) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class PublicIPAddressDnsSettingsRef(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class IpTagRef(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class NatGatewaySkuRef(Model): - name = StringType(choices=("Standard", None), serialize_when_none=False) - - -class NatGatewayRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySkuRef, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPAddressSkuRef(Model): - name = StringType(choices=("Basic", "Standard"), serialize_when_none=False) - tier = StringType(choices=("Global", "Regional"), serialize_when_none=False) - - -class PublicIPAddressRef(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettingsRef, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = StringType( - serialize_when_none=False - ) # Change to IP Configuration id - ip_tags = ListType(ModelType(IpTagRef), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType( - choices=("Abort", "Commit", "Committed", "None", "Prepare"), - serialize_when_none=False, - ) - nat_gateway = ModelType(NatGatewayRef, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - public_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSkuRef, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class FrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(InboundNatPool), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(InboundNatRule), serialize_when_none=False) - load_balancing_rules = ListType( - ModelType(LoadBalancingRule), serialize_when_none=False - ) - outbound_rules = ListType(ModelType(OutboundRule), serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = ModelType(PublicIPAddressRef, serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class RetentionPolicyParameters(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class TrafficAnalyticsConfigurationProperties(Model): - enabled = BooleanType(serialize_when_none=False) - traffic_analytics_interval = IntType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - workspace_region = StringType(serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class TrafficAnalyticsProperties(Model): - network_watcher_flow_analytics_configuration = ModelType( - TrafficAnalyticsConfigurationProperties, serialize_when_none=False - ) - - -class FlowLog(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - enable = BooleanType(serialize_when_none=False) - flow_analytics_configuration = ModelType( - TrafficAnalyticsProperties, serialize_when_none=False - ) - format = ModelType(FlowLogFormatParameters, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - retention_policy = ModelType(RetentionPolicyParameters, serialize_when_none=False) - storage_id = StringType(serialize_when_none=False) - target_resource_guid = StringType(serialize_when_none=False) - target_resource_id = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfigurationProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = StringType( - serialize_when_none=False - ) # Change to PublicIPAddress ID - subnet = StringType(serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class ServiceAssociationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allow_delete = BooleanType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - locations = ListType(ModelType(ExtendedLocation), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class ServiceEndpointPolicy(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - service_endpoint_policy_definitions = ListType( - ModelType(ServiceEndpointPolicyDefinition), serialize_when_none=False - ) - subnets = ListType(StringType, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPropertiesFormat(Model): - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - - -class ResourceNavigationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class Route(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - next_hop_ip_address = StringType(serialize_when_none=False) - next_hop_type = StringType( - choices=( - "Internet", - "None", - "VirtualAppliance", - "VirtualNetworkGateway", - "VnetLocal", - ), - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - - -class RouteTable(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - disable_bgp_route_propagation = BooleanType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - routes = ListType(ModelType(Route), serialize_when_none=False) - subnets = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NatGatewaySku(Model): - name = StringType(choices=("Standard", None), serialize_when_none=False) - tier = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionState, serialize_when_none=False - ) - private_link_service_id = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - request_message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkServiceIpConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class Visibility(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class PrivateEndpointRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType( - ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False - ) - manual_private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - network_interfaces = ListType( - StringType(), serialize_when_none=False - ) # Change to network interfaces id - private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to subnet ID - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpointConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - link_identifier = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionState, serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class PrivateLinkService(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - alias = StringType(serialize_when_none=False) - auto_approval = ModelType(AutoApproval, serialize_when_none=False) - enable_proxy_protocol = BooleanType(serialize_when_none=False) - fqdns = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType( - ModelType(PrivateLinkServiceIpConfiguration), serialize_when_none=False - ) - loadBalancer_frontend_ip_configurations = ListType( - ModelType(FrontendIPConfiguration), serialize_when_none=False - ) - network_interfaces = ListType( - StringType, serialize_when_none=False - ) # Change to network interfaces' id - private_endpoint_connections = ListType( - ModelType(PrivateEndpointConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - visibility = ModelType(Visibility, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=("Basic", "Standard"), serialize_when_none=False) - tier = StringType(choices=("Global", "Regional"), serialize_when_none=False) - - -class ReferencedPublicIPAddress(Model): - id = StringType(serialize_when_none=False) - - -class PublicIPPrefix(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - custom_ip_prefix = ModelType(SubResource) - ip_prefix = StringType(serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - load_balancer_frontend_ip_configuration = ModelType(SubResource) - nat_gateway = (StringType(serialize_when_none=False),) # Change to NAT id - prefix_length = (IntType(serialize_when_none=False),) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - public_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - public_ip_addresses = ListType( - ModelType(ReferencedPublicIPAddress), serialize_when_none=False - ) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPPrefixSku(Model): - name = StringType(serialize_when_none=False) - tier = StringType(choices=("Global", "Regional"), serialize_when_none=False) - - -class PublicIPAddress(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType( - choices=("Abort", "Commit", "Committed", "None", "Prepare"), - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - public_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPPrefixSku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class ApplicationSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SecurityRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - access = StringType(choices=("Allow", "Deny"), serialize_when_none=False) - description = StringType(serialize_when_none=False) - destination_address_prefix = StringType(serialize_when_none=False) - destination_address_prefixes = ListType(StringType, serialize_when_none=False) - destination_application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - destination_port_range = StringType(serialize_when_none=False) - destination_port_ranges = ListType(StringType, serialize_when_none=False) - direction = StringType(choices=("Inbound", "Outbound"), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - protocol = StringType( - choices=("*", "Ah", "Esp", "Icmp", "Tcp", "Udp"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - source_address_prefix = StringType(serialize_when_none=False) - source_address_prefixes = ListType(StringType, serialize_when_none=False) - source_application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - source_port_range = StringType(serialize_when_none=False) - source_port_ranges = ListType(StringType, serialize_when_none=False) - - -class NetworkInterfaceDnsSettings(Model): - applied_dns_servers = ListType(StringType, serialize_when_none=False) - dns_servers = ListType(StringType, serialize_when_none=False) - internal_dns_name_label = StringType(serialize_when_none=False) - internal_domain_name_suffix = StringType(serialize_when_none=False) - internal_fqdn = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfiguration(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - private_link_connection_properties = ModelType( - NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -class NetworkInterfaceTapConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class NetworkSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(default="-", serialize_when_none=False) - default_security_rules = ListType( - ModelType(SecurityRule), serialize_when_none=False - ) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = StringType( - serialize_when_none=False - ) # Change to Network interfaces' Id - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) # Change to Subnet IDs - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterface(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - dns_settings = ModelType(NetworkInterfaceDnsSettings, serialize_when_none=False) - dscp_configuration = ModelType(SubResource, serialize_when_none=False) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - hosted_workloads = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType( - ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False - ) - mac_address = StringType(serialize_when_none=False) - migration_phase = StringType( - choices=("Abort", "Commit", "Committed", "None", "Prepare"), - serialize_when_none=False, - ) - nic_type = StringType(choices=("Elastic", "Standard"), serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroup, serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef, serialize_when_none=False) - private_link_service = ModelType(PrivateLinkService, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tap_configurations = ListType( - ModelType(NetworkInterfaceTapConfiguration), serialize_when_none=False - ) - virtual_machine = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpoint(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType( - ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False - ) - manual_private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - network_interfaces = ListType( - ModelType(NetworkInterface), serialize_when_none=False - ) - private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -###### Firewall Classes ###### -class AzureFirewallRCAction(Model): - type = StringType(choices=("Allow", "Deny"), serialize_when_none=False) - - -class AzureFirewallApplicationRuleProtocol(Model): - port = IntType(serialize_when_none=False) - protocol_type = StringType( - choices=("Http", "Https", "Mssql"), serialize_when_none=False - ) - - -class AzureFirewallApplicationRule(Model): - description = StringType(serialize_when_none=False) - fqdn_tags = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType( - ModelType(AzureFirewallApplicationRuleProtocol), serialize_when_none=False - ) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - target_fqdns = ListType(StringType, serialize_when_none=False) - - -class AzureFirewallApplicationRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallApplicationRule), serialize_when_none=False) - - -class AzureFirewallIPConfiguration(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = ModelType(SubResource, serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AzureFirewallPublicIPAddress(Model): - address = StringType(serialize_when_none=False) - - -class HubPublicIPAddresses(Model): - address = ListType( - ModelType(AzureFirewallPublicIPAddress), serialize_when_none=False - ) - count = IntType(serialize_when_none=False) - - -class HubIPAddresses(Model): - private_ip_address = StringType(serialize_when_none=False) - public_ips = ModelType(HubPublicIPAddresses, serialize_when_none=False) - - -class AzureFirewallIpGroups(Model): - change_number = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - - -class AzureFirewallNatRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNetworkRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - destination_fqdns = ListType(StringType, serialize_when_none=False) - destination_ip_groups = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNatRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = StringType(choices=("Dnat", "Snat"), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallNatRule), serialize_when_none=False) - - -class AzureFirewallNetworkRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallNetworkRule), serialize_when_none=False) - - -class AzureFirewallSku(Model): - name = StringType(choices=("AZFW_Hub", "AZFW_VNet"), serialize_when_none=False) - tier = StringType(choices=("Premium", "Standard"), serialize_when_none=False) - - -class AzureFirewall(Model): - etag = StringType() - id = StringType() - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - application_rule_collections = ListType( - ModelType(AzureFirewallApplicationRuleCollection), serialize_when_none=False - ) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - hub_ip_addresses = ModelType(HubIPAddresses, serialize_when_none=False) - ip_configurations = ListType( - ModelType(AzureFirewallIPConfiguration), serialize_when_none=False - ) - ip_groups = ListType(ModelType(AzureFirewallIpGroups), serialize_when_none=False) - management_ip_configuration = ModelType( - AzureFirewallIPConfiguration, serialize_when_none=False - ) - nat_rule_collections = ListType( - ModelType(AzureFirewallNatRuleCollection), serialize_when_none=False - ) - network_rule_collections = ListType( - ModelType(AzureFirewallNetworkRuleCollection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - sku = ModelType(AzureFirewallSku, serialize_when_none=False) - threat_intel_mode = StringType( - choices=("Alert", "Deny", "Off"), serialize_when_none=False - ) - virtual_hub = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class Subnet(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - virtual_network = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - address_prefixes = ListType(StringType, serialize_when_none=False) - application_gateway_ip_configurations = ModelType( - ApplicationGatewayIPConfiguration, serialize_when_none=False - ) - delegations = ListType(ModelType(Delegation), serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource), serialize_when_none=False) - ip_configuration_profiles = ListType( - ModelType(IPConfigurationProfile), serialize_when_none=False - ) - ip_configurations = ListType(ModelType(IPConfiguration), serialize_when_none=False) - azure_firewall = ListType(ModelType(AzureFirewall), serialize_when_none=False) - nat_gateway = ModelType(SubResource, serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroup, serialize_when_none=False) - private_endpoint_network_policies = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - private_endpoints = ListType(ModelType(PrivateEndpoint), serialize_when_none=False) - private_link_service_network_policies = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - purpose = StringType(serialize_when_none=False) - resource_navigation_links = ListType( - ModelType(ResourceNavigationLink, serialize_when_none=False) - ) - route_table = ModelType(RouteTable, serialize_when_none=False) - service_association_links = ListType( - ModelType(ServiceAssociationLink), serialize_when_none=False - ) - service_endpoint_policies = ListType( - ModelType(ServiceEndpointPolicy), serialize_when_none=False - ) - service_endpoints = ListType( - ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False - ) - type = StringType(serialize_when_none=False) - - -class VirtualNetworkBgpCommunities(Model): - regional_community = StringType(serialize_when_none=False) - virtual_network_community = StringType(serialize_when_none=False) - - -class VirtualNetworkPeering(Model): - id = StringType(serialize_when_none=False) - etag = StringType(serialize_when_none=False) - name = StringType() - allow_forwarded_traffic = BooleanType(serialize_when_none=False) - allow_gateway_transit = BooleanType(serialize_when_none=False) - allow_virtual_network_access = BooleanType(serialize_when_none=False) - do_not_verify_remote_gateways = BooleanType(serialize_when_none=False) - peering_state = StringType( - choices=("Connected", "Disconnected", "Initiated"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - remote_address_space = ModelType(AddressSpace, serialize_when_none=False) - remote_bgp_communities = ModelType( - VirtualNetworkBgpCommunities, serialize_when_none=False - ) - remote_virtual_network = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - use_remote_gateways = BooleanType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NatGateway(AzureCloudService): # Main class - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_addresses = ListType( - ModelType(PublicIPAddress), serialize_when_none=False - ) - public_ip_addresses_count = IntType(default=0) - public_ip_prefixes = ListType(ModelType(PublicIPPrefix), serialize_when_none=False) - public_ip_prefixes_count = IntType(default=0) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(Subnet), serialize_when_none=False) - subnets_count = IntType(default=0) - sku = ModelType(NatGatewaySku, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(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", - } diff --git a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_account.yaml b/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_account.yaml deleted file mode 100644 index 3fb9a4ec..00000000 --- a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: NATGateways -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_region.yaml b/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_region.yaml deleted file mode 100644 index 60fa33f7..00000000 --- a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: NATGateways -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_subscription.yaml b/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_subscription.yaml deleted file mode 100644 index 810a3c64..00000000 --- a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: NATGateways -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_total_count.yaml b/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_total_count.yaml deleted file mode 100644 index a41f2062..00000000 --- a/src/spaceone/inventory/model/nat_gateways/widget/nat_gateways_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: NATGateways -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: count - options: - default: 0 diff --git a/src/spaceone/inventory/model/network_security_groups/__init__.py b/src/spaceone/inventory/model/network_security_groups/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/network_security_groups/cloud_service.py b/src/spaceone/inventory/model/network_security_groups/cloud_service.py deleted file mode 100644 index 0248fb2a..00000000 --- a/src/spaceone/inventory/model/network_security_groups/cloud_service.py +++ /dev/null @@ -1,80 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.network_security_groups.data import NetworkSecurityGroup - -''' -NETWORK_SECURITY_GROUP -''' -# TAB - Default -network_security_group_info_meta = ItemDynamicLayout.set_fields('Network Security Group', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account') -]) - -# TAB - Inbound Security Rules -network_security_group_inbound_security_rules = TableDynamicLayout.set_fields('Inbound Security Rules', 'data.inbound_security_rules', fields=[ - TextDyField.data_source('Priority', 'priority'), - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Port', 'destination_port_range'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Source', 'source_address_prefix'), - TextDyField.data_source('Destination', 'destination_address_prefix'), - TextDyField.data_source('Action', 'access') -]) - -# TAB - Outbound Security Rules -network_security_group_outbound_security_rules = TableDynamicLayout.set_fields('Outbound Security Rules', 'data.outbound_security_rules', fields=[ - TextDyField.data_source('Priority', 'priority'), - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Port', 'destination_port_range'), - TextDyField.data_source('Protocol', 'protocol'), - TextDyField.data_source('Source', 'source_address_prefix'), - TextDyField.data_source('Destination', 'destination_address_prefix'), - TextDyField.data_source('Action', 'access') -]) - -# TAB - Network Interfaces -network_security_group_network_interfaces = TableDynamicLayout.set_fields('Network Interfaces', 'data.network_interfaces', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Public IP Address', 'public_ip_address'), - TextDyField.data_source('Private IP Address', 'private_ip_address'), - TextDyField.data_source('Virtual Machine', 'virtual_machine_display') -]) - -# TAB - Subnets -network_subnets = TableDynamicLayout.set_fields('Subnets', 'data.subnets', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Address Range', 'address_prefix'), - TextDyField.data_source('Virtual Network', 'virtual_network') -]) - -network_security_group_meta = CloudServiceMeta.set_layouts( - [network_security_group_info_meta, network_security_group_inbound_security_rules, network_subnets, - network_security_group_outbound_security_rules, network_security_group_network_interfaces]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='NetworkSecurityGroups') - - -class NetworkSecurityGroupResource(NetworkResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(NetworkSecurityGroup) - _metadata = ModelType(CloudServiceMeta, default=network_security_group_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 NetworkSecurityGroupResponse(CloudServiceResponse): - resource = PolyModelType(NetworkSecurityGroupResource) diff --git a/src/spaceone/inventory/model/network_security_groups/cloud_service_type.py b/src/spaceone/inventory/model/network_security_groups/cloud_service_type.py deleted file mode 100644 index 53aef9f1..00000000 --- a/src/spaceone/inventory/model/network_security_groups/cloud_service_type.py +++ /dev/null @@ -1,142 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -nsg_count_by_account_conf = os.path.join(current_dir, 'widget/nsg_count_by_account.yaml') -nsg_count_by_region_conf = os.path.join(current_dir, 'widget/nsg_count_by_region.yaml') -nsg_count_by_subscription_conf = os.path.join(current_dir, 'widget/nsg_count_by_subscription.yaml') -nsg_inbound_count_by_subscription_conf = os.path.join(current_dir, 'widget/nsg_inbound_count_by_subscription.yaml') -nsg_outbound_count_by_subscription_conf = os.path.join(current_dir, 'widget/nsg_outbound_count_by_subscription.yaml') -nsg_total_count_conf = os.path.join(current_dir, 'widget/nsg_total_count.yaml') - -cst_network_security_groups = CloudServiceTypeResource() -cst_network_security_groups.name = 'Instance' -cst_network_security_groups.group = 'NetworkSecurityGroups' -cst_network_security_groups.service_code = 'Microsoft.Network/networkSecurityGroups' -cst_network_security_groups.labels = ['Networking'] -cst_network_security_groups.is_major = True -cst_network_security_groups.is_primary = True -cst_network_security_groups.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-network-security-groups.svg', -} - -cst_network_security_groups._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Virtual Machines', 'data.virtual_machines_display'), - # is_optional fields - Inbound Security Rules - TextDyField.data_source('Inbound Rule Priority', 'data.inbound_security_rules.priority', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Name', 'data.inbound_security_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Port', 'data.inbound_security_rules.destination_port_range', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Protocol', 'data.inbound_security_rules.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Source', 'data.inbound_security_rules.source_address_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Destination', 'data.inbound_security_rules.destination_address_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Inbound Rule Action', 'data.inbound_security_rules.access', options={ - 'is_optional': True - }), - # is_optional fields - Outbound Security Rules - TextDyField.data_source('Outbound Rule Priority', 'data.outbound_security_rules.priority', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Name', 'data.outbound_security_rules.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Port', 'data.outbound_security_rules.destination_port_range', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Protocol', 'data.outbound_security_rules.protocol', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Source', 'data.outbound_security_rules.source_address_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Destination', 'data.outbound_security_rules.destination_address_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Outbound Rule Action', 'data.outbound_security_rules.access', options={ - 'is_optional': True - }), - # is_optional_field - Network Interfaces - TextDyField.data_source('Network Interface Name', 'data.network_interfaces.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Network Interface Public IP Address', 'data.network_interfaces.public_ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Network Interface Private IP Address', 'data.network_interfaces.private_ip_address', options={ - 'is_optional': True - }), - # is_optional field - Subnets - TextDyField.data_source('Subnet Name', 'data.subnets.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet Address Range', 'data.subnets.address_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Virtual Network', 'data.subnets.virtual_network', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Virtual Machines', key='data.virtual_machines_display'), - SearchField.set(name='Inbound Rule Priority', key='data.inbound_security_rules.priority', data_type='integer'), - SearchField.set(name='Inbound Rule Name', key='data.inbound_security_rules.name'), - SearchField.set(name='Inbound Rule Port', key='data.inbound_security_rules.destination_port_range'), - SearchField.set(name='Inbound Rule Protocol', key='data.inbound_security_rules.protocol'), - SearchField.set(name='Inbound Rule Source', key='data.inbound_security_rules.source_address_prefix'), - SearchField.set(name='Inbound Rule Destination', key='data.inbound_security_rules.destination_address_prefix'), - SearchField.set(name='Inbound Rule Action', key='data.inbound_security_rules.access'), - SearchField.set(name='Outbound Rule Priority', key='data.outbound_security_rules.priority', data_type='integer'), - SearchField.set(name='Outbound Rule Name', key='data.outbound_security_rules.name'), - SearchField.set(name='Outbound Rule Port', key='data.outbound_security_rules.destination_port_range'), - SearchField.set(name='Outbound Rule Protocol', key='data.outbound_security_rules.protocol'), - SearchField.set(name='Outbound Rule Source', key='data.outbound_security_rules.source_address_prefix'), - SearchField.set(name='Outbound Rule Destination', key='data.outbound_security_rules.destination_address_prefix'), - SearchField.set(name='Outbound Rule Action', key='data.outbound_security_rules.access'), - SearchField.set(name='Network Interface Name', key='data.network_interfaces.name'), - SearchField.set(name='Network Interface Public IP Address', key='data.network_interfaces.public_ip_address'), - SearchField.set(name='Network Interface Private IP Address', key='data.network_interfaces.private_ip_address'), - SearchField.set(name='Subnet Name', key='data.subnets.name'), - SearchField.set(name='Subnet Address Range', key='data.subnets.address_prefix'), - SearchField.set(name='Virtual Network', key='data.subnets.virtual_network'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(nsg_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(nsg_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(nsg_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(nsg_inbound_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(nsg_outbound_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(nsg_total_count_conf)) - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_network_security_groups}), -] diff --git a/src/spaceone/inventory/model/network_security_groups/data.py b/src/spaceone/inventory/model/network_security_groups/data.py deleted file mode 100644 index 792b1841..00000000 --- a/src/spaceone/inventory/model/network_security_groups/data.py +++ /dev/null @@ -1,1049 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SecurityRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - access = StringType(choices=("Allow", "Deny"), serialize_when_none=False) - description = StringType(serialize_when_none=False) - destination_address_prefix = StringType(serialize_when_none=False) - destination_address_prefixes = ListType(StringType, serialize_when_none=False) - destination_application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - destination_port_range = StringType(serialize_when_none=False) - destination_port_ranges = ListType(StringType, serialize_when_none=False) - direction = StringType(choices=("Inbound", "Outbound"), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - protocol = StringType( - choices=("*", "Ah", "Esp", "Icmp", "Tcp", "Udp"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - source_address_prefix = StringType(serialize_when_none=False) - source_address_prefixes = ListType(StringType, serialize_when_none=False) - source_application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - source_port_range = StringType(serialize_when_none=False) - source_port_ranges = ListType(StringType, serialize_when_none=False) - - -class TrafficAnalyticsConfigurationProperties(Model): - enabled = BooleanType(serialize_when_none=False) - traffic_analytics_interval = IntType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - workspace_region = StringType(serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class TrafficAnalyticsProperties(Model): - network_watcher_flow_analytics_configuration = ModelType( - TrafficAnalyticsConfigurationProperties, serialize_when_none=False - ) - - -class FlowLogFormatType(Model): - json = StringType(serialize_when_none=False) - - -class FlowLogFormatParameters(Model): - type = ModelType(FlowLogFormatType, serialize_when_none=False) - version = IntType(serialize_when_none=False) - - -class RetentionPolicyParameters(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class FlowLog(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - enable = BooleanType(serialize_when_none=False) - flow_analytics_configuration = ModelType( - TrafficAnalyticsProperties, serialize_when_none=False - ) - format = ModelType(FlowLogFormatParameters, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - retention_policy = ModelType(RetentionPolicyParameters, serialize_when_none=False) - storage_id = StringType(serialize_when_none=False) - target_resource_guid = StringType(serialize_when_none=False) - target_resource_id = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceDnsSettings(Model): - applied_dns_servers = ListType(StringType, serialize_when_none=False) - dns_servers = ListType(StringType, serialize_when_none=False) - internal_dns_name_label = StringType(serialize_when_none=False) - internal_domain_name_suffix = StringType(serialize_when_none=False) - internal_fqdn = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(Model): - fqdns = ListType(StringType, serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - required_member_name = StringType(serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=("Basic", "Standard"), serialize_when_none=False) - tier = StringType(choices=("Global", "Regional"), serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType( - choices=("Basic", "Standard"), serialize_when_none=False - ) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = StringType( - serialize_when_none=False - ) # Change to Public IP Address's ID - subnet = StringType(serialize_when_none=False) - - -class NatGatewaySku(Model): - name = StringType(choices=("Standard", None), serialize_when_none=False) - - -class NatGateway(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPAddress(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType( - choices=("Abort", "Commit", "Committed", "None", "Prepare"), - serialize_when_none=False, - ) - nat_gateway = ModelType(NatGateway, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - public_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class NetworkInterfaceIPConfiguration(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType( - ModelType(ApplicationSecurityGroup), serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - private_link_connection_properties = ModelType( - NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -class NetworkSecurityGroupRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(default="-", serialize_when_none=False) - default_security_rules = ListType( - ModelType(SecurityRule), serialize_when_none=False - ) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = StringType( - serialize_when_none=False - ) # Change to Network interfaces' Id - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) # Change to Subnet IDs - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionState, serialize_when_none=False - ) - private_link_service_id = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - request_message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class CustomDnsConfigPropertiesFormat(Model): - fqdn = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType, serialize_when_none=False) - - -class PrivateEndpointRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType( - ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False - ) - manual_private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - network_interfaces = ListType( - StringType(), serialize_when_none=False - ) # Change to network interfaces id - private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to subnet ID - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AutoApproval(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class PrivateLinkServiceIpConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class InboundNatPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_port_range_end = IntType(serialize_when_none=False) - frontend_port_range_start = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroupRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationRef( - Model -): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType( - ModelType(ApplicationSecurityGroupRef), serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - private_link_connection_properties = ModelType( - NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = StringType( - default="", serialize_when_none=False - ) # Change Public IP Address to id - subnet = StringType(default="", serialize_when_none=False) # Change Subnet to id - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -class InboundNatRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_ip_configurations = ListType( - ModelType(NetworkInterfaceIPConfigurationRef), serialize_when_none=False - ) - target_virtual_machine = ListType(StringType, serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - port_mapping_display = StringType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class LoadBalancingRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_address_pool_display = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - disable_outbound_s_nat = BooleanType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - load_distribution = StringType( - choices=("Default", "SourceIP", "SourceIPProtocol"), serialize_when_none=False - ) - load_distribution_display = StringType(serialize_when_none=False) - probe = ModelType(SubResource, serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class OutboundRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allocated_outbound_ports = IntType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configurations = ListType( - ModelType(SubResource), serialize_when_none=False - ) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=("All", "Tcp", "Udp"), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class FrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(InboundNatPool), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(InboundNatRule), serialize_when_none=False) - load_balancing_rules = ListType( - ModelType(LoadBalancingRule), serialize_when_none=False - ) - outbound_rules = ListType(ModelType(OutboundRule), serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), serialize_when_none=False - ) - private_ip_allocation_method = StringType( - choices=("Dynamic", "Static"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = StringType(serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PrivateEndpointConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - link_identifier = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionState, serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class Visibility(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class PrivateLinkService(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - alias = StringType(serialize_when_none=False) - auto_approval = ModelType(AutoApproval, serialize_when_none=False) - enable_proxy_protocol = BooleanType(serialize_when_none=False) - fqdns = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType( - ModelType(PrivateLinkServiceIpConfiguration), serialize_when_none=False - ) - loadBalancer_frontend_ip_configurations = ListType( - ModelType(FrontendIPConfiguration), serialize_when_none=False - ) - network_interfaces = ListType( - StringType, serialize_when_none=False - ) # Change to network interfaces' id - private_endpoint_connections = ListType( - ModelType(PrivateEndpointConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - visibility = ModelType(Visibility, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceTapConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class NetworkInterface(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - dns_settings = ModelType(NetworkInterfaceDnsSettings, serialize_when_none=False) - dscp_configuration = ModelType(SubResource, serialize_when_none=False) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - hosted_workloads = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType( - ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False - ) - private_ip_address = StringType(serialize_when_none=False) - public_ip_address = StringType(serialize_when_none=False) - mac_address = StringType(serialize_when_none=False) - migration_phase = StringType( - choices=("Abort", "Commit", "Committed", "None", "Prepare"), - serialize_when_none=False, - ) - nic_type = StringType(choices=("Elastic", "Standard"), serialize_when_none=False) - network_security_group = ModelType( - NetworkSecurityGroupRef, serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef, serialize_when_none=False) - private_link_service = ModelType(PrivateLinkService, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - tap_configurations = ListType( - ModelType(NetworkInterfaceTapConfiguration), serialize_when_none=False - ) - virtual_machine = ModelType(SubResource, serialize_when_none=False) - virtual_machine_display = StringType(default="-") - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -### Subnet Class ### -class ServiceEndpointPropertiesFormat(Model): - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - - -class ApplicationGatewayIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Delegation(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(default="-", serialize_when_none=False) - actions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service_name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfigurationProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class AzureFirewallRCAction(Model): - type = StringType(choices=("Allow", "Deny"), serialize_when_none=False) - - -class AzureFirewallApplicationRuleProtocol(Model): - port = IntType(serialize_when_none=False) - protocol_type = StringType( - choices=("Http", "Https", "Mssql"), serialize_when_none=False - ) - - -class AzureFirewallApplicationRule(Model): - description = StringType(serialize_when_none=False) - fqdn_tags = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType( - ModelType(AzureFirewallApplicationRuleProtocol), serialize_when_none=False - ) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - target_fqdns = ListType(StringType, serialize_when_none=False) - - -class AzureFirewallApplicationRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallApplicationRule), serialize_when_none=False) - - -class AzureFirewallPublicIPAddress(Model): - address = StringType(serialize_when_none=False) - - -class HubPublicIPAddresses(Model): - address = ListType( - ModelType(AzureFirewallPublicIPAddress), serialize_when_none=False - ) - count = IntType(serialize_when_none=False) - - -class HubIPAddresses(Model): - private_ip_address = StringType(serialize_when_none=False) - public_ips = ModelType(HubPublicIPAddresses, serialize_when_none=False) - - -class AzureFirewallIPConfiguration(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - public_ip_address = ModelType(SubResource, serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AzureFirewallIpGroups(Model): - change_number = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - - -class AzureFirewallNatRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNatRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = StringType(choices=("Dnat", "Snat"), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallNatRule), serialize_when_none=False) - - -class AzureFirewallNetworkRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - destination_fqdns = ListType(StringType, serialize_when_none=False) - destination_ip_groups = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNetworkRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - rules = ListType(ModelType(AzureFirewallNetworkRule), serialize_when_none=False) - - -class AzureFirewallSku(Model): - name = StringType(choices=("AZFW_Hub", "AZFW_VNet"), serialize_when_none=False) - tier = StringType(choices=("Premium", "Standard"), serialize_when_none=False) - - -class AzureFirewall(Model): - etag = StringType() - id = StringType() - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - application_rule_collections = ListType( - ModelType(AzureFirewallApplicationRuleCollection), serialize_when_none=False - ) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - hub_ip_addresses = ModelType(HubIPAddresses, serialize_when_none=False) - ip_configurations = ListType( - ModelType(AzureFirewallIPConfiguration), serialize_when_none=False - ) - ip_groups = ListType(ModelType(AzureFirewallIpGroups), serialize_when_none=False) - management_ip_configuration = ModelType( - AzureFirewallIPConfiguration, serialize_when_none=False - ) - nat_rule_collections = ListType( - ModelType(AzureFirewallNatRuleCollection), serialize_when_none=False - ) - network_rule_collections = ListType( - ModelType(AzureFirewallNetworkRuleCollection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - sku = ModelType(AzureFirewallSku, serialize_when_none=False) - threat_intel_mode = StringType( - choices=("Alert", "Deny", "Off"), serialize_when_none=False - ) - virtual_hub = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class ResourceNavigationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class Route(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - next_hop_ip_address = StringType(serialize_when_none=False) - next_hop_type = StringType( - choices=( - "Internet", - "None", - "VirtualAppliance", - "VirtualNetworkGateway", - "VnetLocal", - ), - serialize_when_none=False, - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - - -class RouteTable(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - disable_bgp_route_propagation = BooleanType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - routes = ListType(ModelType(Route), serialize_when_none=False) - subnets = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpoint(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType( - ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False - ) - manual_private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - network_interfaces = ListType( - ModelType(NetworkInterface), serialize_when_none=False - ) - private_link_service_connections = ListType( - ModelType(PrivateLinkServiceConnection), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - subnet = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceAssociationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allow_delete = BooleanType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - locations = ListType(ModelType(ExtendedLocation), serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class ServiceEndpointPolicy(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - service_endpoint_policy_definitions = ListType( - ModelType(ServiceEndpointPolicyDefinition), serialize_when_none=False - ) - subnets = ListType(StringType, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Subnet(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - virtual_network = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - address_prefixes = ListType(StringType, serialize_when_none=False) - application_gateway_ip_configurations = ListType( - ModelType(ApplicationGatewayIPConfiguration, serialize_when_none=False) - ) - delegations = ListType(ModelType(Delegation), serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource), serialize_when_none=False) - ip_configuration_profiles = ListType( - ModelType(IPConfigurationProfile), serialize_when_none=False - ) - ip_configurations = ListType(ModelType(IPConfiguration), serialize_when_none=False) - azure_firewall = ListType(ModelType(AzureFirewall), serialize_when_none=False) - nat_gateway = ModelType(SubResource, serialize_when_none=False) - network_security_group = ModelType( - NetworkSecurityGroupRef, serialize_when_none=False - ) - private_endpoint_network_policies = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - private_endpoints = ListType(ModelType(PrivateEndpoint), serialize_when_none=False) - private_link_service_network_policies = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - purpose = StringType(serialize_when_none=False) - resource_navigation_links = ListType( - ModelType(ResourceNavigationLink, serialize_when_none=False) - ) - route_table = ModelType(RouteTable, serialize_when_none=False) - service_association_links = ListType( - ModelType(ServiceAssociationLink), serialize_when_none=False - ) - service_endpoint_policies = ListType( - ModelType(ServiceEndpointPolicy), serialize_when_none=False - ) - service_endpoints = ListType( - ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False - ) - type = StringType(serialize_when_none=False) - - -class NetworkSecurityGroup(AzureCloudService): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(default="-", serialize_when_none=False) - default_security_rules = ListType( - ModelType(SecurityRule), serialize_when_none=False - ) - inbound_security_rules = ListType( - ModelType(SecurityRule), serialize_when_none=False - ) - outbound_security_rules = ListType( - ModelType(SecurityRule), serialize_when_none=False - ) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = ListType( - ModelType(NetworkInterface), serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Deleting", "Failed", "Succeeded", "Updating"), - serialize_when_none=False, - ) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(ModelType(Subnet), serialize_when_none=False) - virtual_machines_display = StringType(serialize_when_none=False) - type = 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", - } diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_account.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_account.yaml deleted file mode 100644 index 9c071834..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_region.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_region.yaml deleted file mode 100644 index a9f9d06c..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_subscription.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_subscription.yaml deleted file mode 100644 index 1e28d560..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_inbound_count_by_subscription.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_inbound_count_by_subscription.yaml deleted file mode 100644 index c12e6064..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_inbound_count_by_subscription.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Inbound Rule Count by Subscription -query: - aggregate: - - unwind: - path: data.inbound_security_rules - - group: - keys: - - name: name - key: account - fields: - - name: value - key: data.inbound_security_rules - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_outbound_count_by_subscription.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_outbound_count_by_subscription.yaml deleted file mode 100644 index 587ab324..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_outbound_count_by_subscription.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Outbound Rule Count by Subscription -query: - aggregate: - - unwind: - path: data.outbound_security_rules - - group: - keys: - - name: name - key: account - fields: - - name: value - key: data.outbound_security_rules - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/network_security_groups/widget/nsg_total_count.yaml b/src/spaceone/inventory/model/network_security_groups/widget/nsg_total_count.yaml deleted file mode 100644 index 9773f85d..00000000 --- a/src/spaceone/inventory/model/network_security_groups/widget/nsg_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: NetworkSecurityGroups -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/postgresql_servers/__init__.py b/src/spaceone/inventory/model/postgresql_servers/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/postgresql_servers/cloud_service.py b/src/spaceone/inventory/model/postgresql_servers/cloud_service.py deleted file mode 100644 index c578e544..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/cloud_service.py +++ /dev/null @@ -1,124 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.model.postgresql_servers.data import PostgreSQLServer -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, EnumDyField, \ - ListDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -''' -POSTGRESQL SERVERS -''' - -# TAB - Default -postgresql_servers_info_meta = ItemDynamicLayout.set_fields('PostgreSQL Servers', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Resource ID', 'data.id'), - EnumDyField.data_source('Status', 'data.user_visible_state', default_state={ - 'safe': ['Ready'], - 'warning': ['Disabled', 'Dropping', 'Inaccessible'] - }), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Server Name', 'data.fully_qualified_domain_name'), - TextDyField.data_source('Admin Username', 'data.administrator_login'), - TextDyField.data_source('PostgreSQL Version', 'data.version'), - TextDyField.data_source('Performance Configuration Tier', 'data.sku.tier'), - TextDyField.data_source('Performance Configuration Name', 'data.sku.name'), - TextDyField.data_source('Performance Configuration Capacity', 'data.sku.capacity'), - EnumDyField.data_source('SSL Enforce Status', 'data.ssl_enforcement', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }) -]) - -# TAB - Connection Security -postgresql_server_connection_security_default = ItemDynamicLayout.set_fields('Connection Security', fields=[ - EnumDyField.data_source('Public Network Access', 'data.public_network_access', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - EnumDyField.data_source('SSL Enforcement', 'data.ssl_enforcement', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - TextDyField.data_source('TLS Setting', 'data.minimal_tls_version'), - -]) - -postgresql_server_firewall_rules = SimpleTableDynamicLayout.set_fields('Firewall Rules', 'data.firewall_rules', fields=[ - TextDyField.data_source('Firewall Rule Name', 'name'), - TextDyField.data_source('Start IP', 'start_ip_address'), - TextDyField.data_source('End IP', 'end_ip_address') -]) - -# TAB - VNet Rules -postgresql_server_vnet_rules = SimpleTableDynamicLayout.set_fields('VNET Rules', 'data.virtual_network_rules', fields=[ - TextDyField.data_source('Rule Name', 'name'), - TextDyField.data_source('Virtual Network', 'virtual_network_name_display'), - TextDyField.data_source('Subnet', 'subnet_name'), - EnumDyField.data_source('Endpoint Status', 'state', default_state={ - 'safe': ['Ready', 'InProgress'], - 'warning': ['Deleting', 'Initializing', 'Unknown'] - }) -]) - -# 1 + 2 + 3) TAB - Connection Security Meta -postgresql_servers_connection_security = ListDynamicLayout.set_layouts('Connection Security', layouts=[ - postgresql_server_connection_security_default, - postgresql_server_firewall_rules, postgresql_server_vnet_rules]) - -# TAB - Replicas -postgresql_servers_replication = SimpleTableDynamicLayout.set_fields('Replicas', 'data.replicas', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Location', 'location'), - EnumDyField.data_source('Status', 'user_visible_state', default_state={ - 'safe': ['Ready'], - 'warning': ['Disabled', 'Dropping', 'Inaccessible'] - }), - TextDyField.data_source('Master Server Name', 'master_server_name') -]) - -# TAB - Server Admin -postgresql_servers_server_admin = SimpleTableDynamicLayout.set_fields('Active Directory Admin', 'data.server_administrators', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Login', 'login'), - TextDyField.data_source('SID', 'sid'), - TextDyField.data_source('Tenant ID', 'tenant_id') -]) - -# TAB - Pricing Tier -postgresql_servers_pricing_tier = ItemDynamicLayout.set_fields('Pricing Tier', fields=[ - TextDyField.data_source('Compute Generation', 'data.sku.name'), - TextDyField.data_source('vCore', 'data.sku.capacity'), - EnumDyField.data_source('Storage Auto Grow', 'data.storage_profile.storage_autogrow', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - TextDyField.data_source('Backup Retention Period (Days)', 'data.storage_profile.backup_retention_days') -]) - -postgresql_servers_meta = CloudServiceMeta.set_layouts( - [postgresql_servers_info_meta, postgresql_servers_connection_security, postgresql_servers_replication, - postgresql_servers_server_admin, postgresql_servers_pricing_tier]) - - -class DatabaseResource(CloudServiceResource): - cloud_service_group = StringType(default='PostgreSQLServers') - - -class PostgreSQLServerResource(DatabaseResource): - cloud_service_type = StringType(default='Server') - data = ModelType(PostgreSQLServer) - _metadata = ModelType(CloudServiceMeta, default=postgresql_servers_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 PostgreSQLServerResponse(CloudServiceResponse): - resource = PolyModelType(PostgreSQLServerResource) diff --git a/src/spaceone/inventory/model/postgresql_servers/cloud_service_type.py b/src/spaceone/inventory/model/postgresql_servers/cloud_service_type.py deleted file mode 100644 index f9dc2a08..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/cloud_service_type.py +++ /dev/null @@ -1,226 +0,0 @@ -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, - SizeField, -) -from spaceone.inventory.libs.schema.cloud_service_type import ( - CloudServiceTypeResource, - CloudServiceTypeResponse, - CloudServiceTypeMeta, -) -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -postgresql_count_by_account_conf = os.path.join( - current_dir, "widget/postgresql_count_by_account.yaml" -) -postgresql_count_by_region_conf = os.path.join( - current_dir, "widget/postgresql_count_by_region.yaml" -) -postgresql_count_by_subscription_conf = os.path.join( - current_dir, "widget/postgresql_count_by_subscription.yaml" -) -postgresql_count_by_tier_conf = os.path.join( - current_dir, "widget/postgresql_count_by_tier.yaml" -) -postgresql_total_count_conf = os.path.join( - current_dir, "widget/postgresql_total_count.yaml" -) - -cst_postgre_sql_servers = CloudServiceTypeResource() -cst_postgre_sql_servers.name = "Server" -cst_postgre_sql_servers.group = "PostgreSQLServers" -cst_postgre_sql_servers.service_code = "Microsoft.DBforPostgreSQL/servers" -cst_postgre_sql_servers.labels = ["Database"] -cst_postgre_sql_servers.is_primary = True -cst_postgre_sql_servers.is_major = True -cst_postgre_sql_servers.tags = { - "spaceone:icon": f"{ASSET_URL}/azure-sql-postgresql-server.svg", -} - -cst_postgre_sql_servers._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source("Type", "instance_type"), - EnumDyField.data_source( - "Status", - "data.user_visible_state", - default_state={ - "safe": ["Ready"], - "warning": ["Disabled", "Dropping", "Inaccessible"], - }, - ), - TextDyField.data_source( - "Resource Group", "data.resource_group", options={"is_optional": True} - ), - TextDyField.data_source( - "Location", "data.location", options={"is_optional": True} - ), - TextDyField.data_source( - "Subscription Name", "data.subscription_name", options={"is_optional": True} - ), - TextDyField.data_source( - "Subscription ID", "account", options={"is_optional": True} - ), - TextDyField.data_source( - "Server Name", - "data.fully_qualified_domain_name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Admin Username", "data.administrator_login", options={"is_optional": True} - ), - TextDyField.data_source( - "PostgreSQL Version", "data.version", options={"is_optional": True} - ), - TextDyField.data_source( - "Performance Configuration Tier", - "instance_type", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Performance Configuration Name", - "data.sku.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Performance Configuration Capacity", - "data.sku.capacity", - options={"is_optional": True}, - ), - TextDyField.data_source( - "SSL Enforce Status", "data.ssl_enforcement", options={"is_optional": True} - ), - TextDyField.data_source( - "Public Network Access", - "data.public_network_access", - options={"is_optional": True}, - ), - TextDyField.data_source( - "SSL Enforcement", "data.ssl_enforcement", options={"is_optional": True} - ), - TextDyField.data_source( - "TLS Setting", "data.minimal_tls_version", options={"is_optional": True} - ), - TextDyField.data_source( - "Firewall Rule Name", - "data.firewall_rules.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Start IP", - "data.firewall_rules.start_ip_address", - options={"is_optional": True}, - ), - TextDyField.data_source( - "End IP", - "data.firewall_rules.end_ip_address", - options={"is_optional": True}, - ), - # VNet Rules - TextDyField.data_source( - "Virtual Network Rule Name", - "data.virtual_network_rules.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Virtual Network", - "data.virtual_network_rules.virtual_network_name_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Subnet", - "data.virtual_network_rules.subnet_name", - options={"is_optional": True}, - ), - # Replicas - TextDyField.data_source( - "Replicas Name", "data.replicas.name", options={"is_optional": True} - ), - TextDyField.data_source( - "Replicas Location", "data.replicas.location", options={"is_optional": True} - ), - TextDyField.data_source( - "Replicas Master Server Name", - "data.replicas.master_server_name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Active Directory Name", - "data.server_administrators.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Login", "data.server_administrators.login", options={"is_optional": True} - ), - TextDyField.data_source( - "SID", "data.server_administrators.sid", options={"is_optional": True} - ), - TextDyField.data_source( - "Tenant ID", - "data.server_administrators.tenant_id", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Compute Generation", "data.sku.name", options={"is_optional": True} - ), - TextDyField.data_source( - "Compute Tier", "instance_type", options={"is_optional": True} - ), - TextDyField.data_source( - "vCore", "data.sku.capacity", options={"is_optional": True} - ), - TextDyField.data_source( - "Backup Retention Period (Days)", - "data.storage_profile.backup_retention_days", - options={"is_optional": True}, - ), - ], - search=[ - SearchField.set(name="Subscription ID", key="account"), - SearchField.set(name="Subscription Name", key="data.subscription_name"), - SearchField.set(name="Resource Group", key="data.resource_group"), - SearchField.set(name="Location", key="data.location"), - SearchField.set(name="Server Name", key="data.fully_qualified_domain_name"), - SearchField.set(name="Admin Username", key="data.administrator_login"), - SearchField.set(name="PostgreSQL Version", key="data.version"), - SearchField.set(name="Performance Configuration Tier", key="instance_type"), - SearchField.set(name="Performance Configuration Name", key="data.sku.name"), - SearchField.set( - name="Performance Configuration Capacity", - key="data.sku.capacity", - data_type="integer", - ), - SearchField.set(name="SSL Enforce Status", key="data.ssl_enforcement"), - SearchField.set(name="SSL Enforcement", key="data.ssl_enforcement"), - SearchField.set(name="Public Network Access", key="data.public_network_access"), - SearchField.set(name="TLS Setting", key="data.minimal_tls_version"), - SearchField.set(name="Firewall Rule Name", key="data.firewall_rules.name"), - SearchField.set( - name="Firewall Rule Start IP", key="data.firewall_rules.start_ip_address" - ), - SearchField.set( - name="Firewall Rule End IP", key="data.firewall_rules.end_ip_address" - ), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(postgresql_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(postgresql_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(postgresql_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(postgresql_count_by_tier_conf)), - CardWidget.set(**get_data_from_yaml(postgresql_total_count_conf)), - ], -) - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({"resource": cst_postgre_sql_servers}), -] diff --git a/src/spaceone/inventory/model/postgresql_servers/data.py b/src/spaceone/inventory/model/postgresql_servers/data.py deleted file mode 100644 index f3b89c69..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/data.py +++ /dev/null @@ -1,409 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, FloatType, DateTimeType -from spaceone.inventory.libs.schema.resource import AzureCloudService, AzureTags - - -class ResourceIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(choices=('SystemAssigned', ''), serialize_when_none=False) - - -class PrivateEndpointProperty(Model): - id = StringType() - - -class PrivateLinkServiceConnectionStateProperty(Model): - actions_required = StringType(choices=('None', ''), serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(choices=('Approved', 'Disconnected', 'Pending', 'Rejected'), serialize_when_none=False) - - -class PrivateEndpointConnectionProperties(Model): - private_endpoint = ModelType(PrivateEndpointProperty, serialize_when_none=False) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionStateProperty, - serialize_when_none=False) - provisioning_state = StringType(choices=('Approving', 'Dropping', 'Failed', 'Ready', 'Rejecting')) - - -class ServerPrivateEndpointConnection(Model): - id = StringType(serialize_when_none=False) - properties = ModelType(PrivateEndpointConnectionProperties) - - -class ServerAzureADAdministrator(Model): - id = StringType() - name = StringType(serialize_when_none=False) - administrator_type = StringType(choices=('ActiveDirectory', ''), serialize_when_none=False) - login = StringType(serialize_when_none=False) - sid = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - - -class AutomaticTuningServerOptions(Model): - actual_state = StringType(choices=('Off', 'On'), serialize_when_none=False) - desired_state = StringType(choices=('Default', 'Off', 'On'), serialize_when_none=False) - reason_code = IntType(serialize_when_none=False) - reason_desc = StringType(choices=('AutoConfigured', 'Default', 'Disabled'), serialize_when_none=False) - tuning_type = StringType(choices=('createIndex', 'dropIndex', 'forceLastGoodPlan'), serialize_when_none=False) - - -class ServerAutomaticTuning(Model): - name = StringType() - id = StringType() - actual_state = StringType(choices=('Auto', 'Custom', 'Unspecified'), serialize_when_none=False) - desired_state = StringType(choices=('Default', 'Off', 'On'), serialize_when_none=False) - options = ListType(ModelType(AutomaticTuningServerOptions, serialize_when_none=False)) - type = StringType(serialize_when_none=False) - - -class ServerBlobAuditingPolicy(Model): - name = StringType() - id = StringType() - audit_actions_and_groups = ListType(StringType, serialize_when_none=False) - is_azure_monitor_target_enabled = BooleanType(serialize_when_none=False) - is_storage_secondary_key_in_use = BooleanType(serialize_when_none=False) - queue_delay_ms = IntType(serialize_when_none=False) - retention_days = IntType(serialize_when_none=False) - state = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_account_access_key = StringType(serialize_when_none=False) - storage_account_subscription_id = StringType(serialize_when_none=False) - storage_endpoint = StringType(default='-') - type = StringType(serialize_when_none=False) - - -class PartnerInfo(Model): - id = StringType() - location = StringType() - replication_role = StringType(choices=('Primary', 'Secondary'), serialize_when_none=False) - - -class FailoverGroupReadOnlyEndpoint(Model): - failover_policy = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - - -class FailoverGroupReadWriteEndpoint(Model): - failover_policy = StringType(choices=('Automatic', 'Manual'), serialize_when_none=False) - failover_with_data_loss_grace_period_minutes = IntType(serialize_when_none=False) - - -class FailoverGroup(Model): - name = StringType(serialize_when_none=False) - id = StringType() - location = StringType() - databases = ListType(StringType, serialize_when_none=False) - partner_servers = ListType(ModelType(PartnerInfo), serialize_when_none=False) - primary_server = StringType(serialize_when_none=False) - secondary_server = StringType(serialize_when_none=False) - read_only_endpoint = ModelType(FailoverGroupReadOnlyEndpoint, serialize_when_none=False) - read_write_endpoint = ModelType(FailoverGroupReadWriteEndpoint, serialize_when_none=False) - replication_role = StringType(choices=('Primary', 'Secondary'), serialize_when_none=False) - replication_state = StringType(serialize_when_none=False) - failover_policy_display = StringType(serialize_when_none=False) - grace_period_display = StringType(serialize_when_none=False) - tags = ListType(ModelType(AzureTags)) - type = StringType(serialize_when_none=False) - - -class SyncGroupSchemaColumn(Model): - data_size = StringType(serialize_when_none=False) - data_type = StringType(serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchemaTable(Model): - columns = ListType(ModelType(SyncGroupSchemaColumn), serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchema(Model): - master_sync_member_name = StringType(serialize_when_none=False) - tables = ListType(ModelType(SyncGroupSchemaTable), serialize_when_none=False) - - -class SyncGroup(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - conflict_resolution_policy = StringType(choices=('HubWin', 'MemberWin'), serialize_when_none=False) - hub_database_password = StringType(serialize_when_none=False) - hub_database_user_name = StringType(serialize_when_none=False) - interval = IntType(serialize_when_none=False) - last_sync_time = DateTimeType(serialize_when_none=False) - schema = ModelType(SyncGroupSchema, serialize_when_none=False) - sync_database_id = StringType(serialize_when_none=False) - sync_state = StringType(choices=('Error', 'Good', 'NotReady', 'Progressing', 'Warning'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SyncAgent(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - expiry_time = StringType(serialize_when_none=False) - is_up_to_date = BooleanType(serialize_when_none=False) - last_alive_time = StringType(serialize_when_none=False) - state = StringType(choices=('NeverConnected', 'Offline', 'Online'), serialize_when_none=False) - sync_database_id = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class RetentionPolicy(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class LogSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - - -class MetricSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - time_grain = StringType(serialize_when_none=False) - - -class DiagnosticSettingsResource(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - event_hub_authorization_rule_id = StringType(serialize_when_none=False) - event_hub_name = StringType(serialize_when_none=False) - log_analytics_destination_type = StringType(serialize_when_none=False) - logs = ListType(ModelType(LogSettings), serialize_when_none=False) - metrics = ListType(ModelType(MetricSettings), serialize_when_none=False) - service_bus_rule_id = StringType(serialize_when_none=False) - storage_account_id = StringType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ReplicationLink(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - is_termination_allowed = BooleanType(serialize_when_none=False) - partner_database = StringType(serialize_when_none=False) - partner_location = StringType(serialize_when_none=False) - partner_role = StringType(choices=('Copy', 'NonReadableSecondary', 'Primary', 'Secondary', 'Source'), serialize_when_none=False) - partner_server = StringType(default='-') - percent_complete = IntType(serialize_when_none=False) - replication_mode = StringType(serialize_when_none=False) - replication_state = StringType(choices=('CATCH_UP', 'PENDING', 'SEEDING', 'SUSPENDED'), serialize_when_none=False) - role = StringType(choices=('Copy', 'NonReadableSecondary', 'Primary', 'Secondary', 'Source'), serialize_when_none=False) - start_time = DateTimeType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Sku(Model): - capacity = IntType(serialize_when_none=False) - family = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - size = StringType(serialize_when_none=False) - tier = StringType(serialize_when_none=False) - - -class Database(Model): - name = StringType(serialize_when_none=False) - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - managed_by = StringType(serialize_when_none=False) - server_name = StringType(serialize_when_none=False) - subscription_id = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - - administrator_login = StringType(default='-') - auto_pause_delay = IntType(serialize_when_none=False) - catalog_collation = StringType(choices=('DATABASE_DEFAULT', 'SQL_Latin1_General_CP1_CI_AS'), - serialize_when_none=False) - collation = StringType(serialize_when_none=False) - create_mode = StringType(choices=( - 'Copy', 'Default', 'OnlineSecondary', 'PointInTimeRestore', 'Recovery', 'Restore', 'RestoreExternalBackup', - 'RestoreExternalBackupSecondary', 'RestoreLongTermRetentionBackup', 'Secondary'), serialize_when_none=False) - creation_date = DateTimeType(serialize_when_none=False) - current_service_objective_name = StringType(serialize_when_none=False) - current_sku = ModelType(Sku, serialize_when_none=False) - database_id = StringType(serialize_when_none=False) - default_secondary_location = StringType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - elastic_pool_id = StringType(serialize_when_none=False) - failover_group_id = StringType(serialize_when_none=False) - high_availability_replica_count = IntType(serialize_when_none=False) - license_type = StringType(choices=('BasePrice', 'LicenseIncluded'), serialize_when_none=False) - long_term_retention_backup_resource_id = StringType(default='-') - maintenance_configuration_id = StringType(serialize_when_none=False) - max_log_size_bytes = IntType(serialize_when_none=False) - max_size_bytes = IntType(serialize_when_none=False) - max_size_gb = FloatType(serialize_when_none=False) - min_capacity = FloatType(serialize_when_none=False) - paused_date = DateTimeType(serialize_when_none=False) - read_scale = StringType(choices=('Disabled', 'Enabled'), default='Disabled') - recoverable_database_id = StringType(serialize_when_none=False) - recovery_services_recovery_point_id = StringType(serialize_when_none=False) - requested_service_objective_name = StringType(serialize_when_none=False) - restorable_dropped_database_id = StringType(serialize_when_none=False) - restore_point_in_time = StringType(serialize_when_none=False) - resumed_date = DateTimeType(serialize_when_none=False) - sample_name = StringType(choices=('AdventureWorksLT', 'WideWorldImportersFull', 'WideWorldImportersStd'), - serialize_when_none=False) - secondary_type = StringType(choices=('Geo', 'Named'), serialize_when_none=False) - source_database_deletion_date = StringType(serialize_when_none=False) - source_database_id = StringType(serialize_when_none=False) - status = StringType(choices=( - 'AutoClosed', 'Copying', 'Creating', 'Disabled', 'EmergencyMode', 'Inaccessible', 'Offline', - 'OfflineChangingDwPerformanceTiers', 'OfflineSecondary', 'Online', - 'OnlineChangingDwPerformanceTiers', 'Paused', 'Pausing', 'Recovering', 'RecoveryPending', 'Restoring', - 'Resuming', 'Scaling', 'Shutdown', 'Standby', 'Suspect'), serialize_when_none=False) - storage_account_type = StringType(choices=('GRS', 'LRS', 'ZRS'), serialize_when_none=False) - zone_redundant = BooleanType(serialize_when_none=False) - diagnostic_settings_resource = ListType(ModelType(DiagnosticSettingsResource), serialize_when_none=False) - replication_link = ListType(ModelType(ReplicationLink), serialize_when_none=False) - sync_group = ListType(ModelType(SyncGroup), serialize_when_none=False) - sync_agent = ListType(ModelType(SyncAgent), serialize_when_none=False) - sync_group_display = ListType(StringType, serialize_when_none=False) - sync_agent_display = ListType(StringType, serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - pricing_tier_display = StringType(default='-') - service_tier_display = StringType(default='-') - compute_tier = StringType(serialize_when_none=False) - tags = ListType(ModelType(AzureTags)) - type = StringType(serialize_when_none=False) - - -class ElasticPoolPerDatabaseSettings(Model): - max_capacity = FloatType(serialize_when_none=False) - min_capacity = FloatType(serialize_when_none=False) - - -class ElasticPool(Model): - name = StringType(serialize_when_none=False) - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - creation_date = DateTimeType(serialize_when_none=False) - license_type = StringType(choices=('BasePrice', 'LicenseIncluded'), default='BasePrice') - maintenance_configuration_id = StringType(serialize_when_none=False) - max_size_bytes = IntType(serialize_when_none=False) - max_size_gb = FloatType(serialize_when_none=False, default=0) - per_database_settings = ModelType(ElasticPoolPerDatabaseSettings, serialize_when_none=False) - state = StringType(choices=('Creating', 'Disabled', 'Ready'), serialize_when_none=False) - zone_redundant = BooleanType(serialize_when_none=False) - sku = ModelType(Sku) - per_db_settings_display = StringType(serialize_when_none=False) - pricing_tier_display = StringType(serialize_when_none=False) - databases = ListType(ModelType(Database)) - number_of_databases = IntType(serialize_when_none=False, default=0) - unit_display = StringType(serialize_when_none=False), - server_name_display = StringType(serialize_when_none=False) - resource_group_display = StringType(serialize_when_none=False) - tags = ModelType(AzureTags) - type = StringType(serialize_when_none=False) - - -class EncryptionProtector(Model): - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - name = StringType() - server_key_name = StringType(serialize_when_none=False) - server_key_type = StringType(choices=('AzureKeyVault', 'ServiceManaged'), default='ServiceManaged') - subregion = StringType(serialize_when_none=False) - thumbprint = StringType(serialize_when_none=False) - uri = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class RestorableDroppedDatabase(Model): - name = StringType(serialize_when_none=False) - id = StringType() - location = StringType() - creation_date = DateTimeType(serialize_when_none=False) - database_name = StringType(serialize_when_none=False) - deletion_date = DateTimeType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - edition = StringType(serialize_when_none=False) - elastic_pool_name = StringType(default='-') - max_size_bytes = StringType(serialize_when_none=False) - service_level_objective = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class VirtualNetworkRule(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - ignore_missing_vnet_service_endpoint = BooleanType(serialize_when_none=False) - state = StringType(choices=('Deleting', 'InProgress', 'Initializing', 'Ready', 'Unknown'), serialize_when_none=False) - virtual_network_subnet_id = StringType(serialize_when_none=False) - subnet_name = StringType(serialize_when_none=False) - virtual_network_name_display = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FirewallRule(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - end_ip_address = StringType(serialize_when_none=False) - start_ip_address = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class StorageProfile(Model): - backup_retention_days = IntType(serialize_when_none=False) - geo_redundant_backup = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_autogrow = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_mb = IntType(serialize_when_none=False) - - -class ReplicaServer(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - location = StringType(serialize_when_none=False) - user_visible_state = StringType(choices=('Disabled', 'Dropping', 'Inaccessible', 'Ready'), serialize_when_none=False) - master_server_name = StringType(serialize_when_none=False) - - -class ServerAdministratorResource(Model): - id = StringType() - name = StringType() - administrator_type = StringType(serialize_when_none=False) - login = StringType(serialize_when_none=False) - sid = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PostgreSQLServer(AzureCloudService): # Main Class - name = StringType() - id = StringType() - identity = ModelType(ResourceIdentity, serialize_when_none=False) - location = StringType() - administrator_login = StringType(serialize_when_none=False) - byok_enforcement = StringType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - firewall_rules = ListType(ModelType(FirewallRule), serialize_when_none=False) - fully_qualified_domain_name = StringType(serialize_when_none=False) - infrastructure_encryption = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - master_server_id = StringType(serialize_when_none=False) - minimal_tls_version = StringType(serialize_when_none=False) - private_endpoint_connections = ListType(ModelType(ServerPrivateEndpointConnection)) - public_network_access = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - replica_capacity = IntType(serialize_when_none=False) - replication_role = StringType(serialize_when_none=False) - replicas = ListType(ModelType(ReplicaServer), serialize_when_none=False) - server_administrators = ListType(ModelType(ServerAdministratorResource), serialize_when_none=False) - ssl_enforcement = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_profile = ModelType(StorageProfile, serialize_when_none=False) - user_visible_state = StringType(choices=('Disabled', 'Dropping', 'Inaccessible', 'Ready'), serialize_when_none=False) - version = StringType(serialize_when_none=False) - virtual_network_rules = ListType(ModelType(VirtualNetworkRule), serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - type = 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", - } diff --git a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_account.yaml b/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_account.yaml deleted file mode 100644 index 6ffda7de..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: PostgreSQLServers -cloud_service_type: Server -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_region.yaml b/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_region.yaml deleted file mode 100644 index 9d01fbf0..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: PostgreSQLServers -cloud_service_type: Server -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_subscription.yaml b/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_subscription.yaml deleted file mode 100644 index ed595b76..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: PostgreSQLServers -cloud_service_type: Server -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_tier.yaml b/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_tier.yaml deleted file mode 100644 index d5d3a630..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_count_by_tier.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: PostgreSQLServers -cloud_service_type: Server -name: Inbound Count by Tier -query: - aggregate: - - group: - keys: - - name: name - key: data.user_visible_state - fields: - - name: value - key: data.user_visible_state - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_total_count.yaml b/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_total_count.yaml deleted file mode 100644 index 7424eece..00000000 --- a/src/spaceone/inventory/model/postgresql_servers/widget/postgresql_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: PostgreSQLServers -cloud_service_type: Server -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/public_ip_addresses/__init__.py b/src/spaceone/inventory/model/public_ip_addresses/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/public_ip_addresses/cloud_service.py b/src/spaceone/inventory/model/public_ip_addresses/cloud_service.py deleted file mode 100644 index bd81bd30..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/cloud_service.py +++ /dev/null @@ -1,64 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, DateTimeType, FloatType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.public_ip_addresses.data import PublicIPAddress - -''' -PUBLIC_IP_ADDRESS -''' -# TAB - Default -public_ip_address_meta = ItemDynamicLayout.set_fields('Public IP Address', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('SKU', 'instance_type'), - TextDyField.data_source('Tier', 'data.sku.tier'), - TextDyField.data_source('IP Address', 'data.ip_address'), - TextDyField.data_source('DNS Name', 'data.dns_settings.fqdn'), - TextDyField.data_source('Associated To', 'data.associated_to') - # TextDyField.data_source('Routing Preference', ''), - -]) - -# TAB - Configuration -public_ip_address_configuration = ItemDynamicLayout.set_fields('Configuration', fields=[ - TextDyField.data_source('IP Address Assignment', 'data.public_ip_allocation_method'), - TextDyField.data_source('Idle Timeout(Minutes)', 'data.idle_timeout_in_minutes'), - TextDyField.data_source('DNS Name Label(Optional)', 'data.dns_settings.domain_name_label') -]) - -# TAB - Alias Record Sets TODO: Find Alias information API -public_ip_address_alias_record_sets = TableDynamicLayout.set_fields('Alias Record Sets', fields=[ - TextDyField.data_source('Subscription', ''), - TextDyField.data_source('DNS Zone', ''), - TextDyField.data_source('Name', ''), - TextDyField.data_source('Type', ''), - TextDyField.data_source('TTL', '') -]) - -public_addresses_meta = CloudServiceMeta.set_layouts([public_ip_address_meta, public_ip_address_configuration]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='PublicIPAddresses') - - -class PublicIPAddressResource(NetworkResource): - cloud_service_type = StringType(default='IPAddress') - data = ModelType(PublicIPAddress) - _metadata = ModelType(CloudServiceMeta, default=public_addresses_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 PublicIPAddressResponse(CloudServiceResponse): - resource = PolyModelType(PublicIPAddressResource) diff --git a/src/spaceone/inventory/model/public_ip_addresses/cloud_service_type.py b/src/spaceone/inventory/model/public_ip_addresses/cloud_service_type.py deleted file mode 100644 index 08cbd2d5..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/cloud_service_type.py +++ /dev/null @@ -1,90 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -public_ip_address_count_by_account_conf = os.path.join(current_dir, 'widget/public_ip_addresses_count_by_account.yaml') -public_ip_address_count_by_region_conf = os.path.join(current_dir, 'widget/public_ip_addresses_count_by_region.yaml') -public_ip_address_count_by_subscription_conf = os.path.join(current_dir, - 'widget/public_ip_addresses_count_by_subscription.yaml') -public_ip_address_total_count_conf = os.path.join(current_dir, 'widget/public_ip_addresses_total_count.yaml') - - -cst_public_ip_addresses = CloudServiceTypeResource() -cst_public_ip_addresses.name = 'IPAddress' -cst_public_ip_addresses.group = 'PublicIPAddresses' -cst_public_ip_addresses.service_code = 'Microsoft.Network/publicIPAddresses' -cst_public_ip_addresses.labels = ['Networking'] -cst_public_ip_addresses.is_major = True -cst_public_ip_addresses.is_primary = True -cst_public_ip_addresses.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-public-ip-address.svg', -} - -cst_public_ip_addresses._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Associated To', 'data.associated_to'), - - # is_optional fields - Default - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - TextDyField.data_source('SKU', 'instance_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Tier', 'data.sku.tier', options={ - 'is_optional': True - }), - TextDyField.data_source('IP Address', 'data.ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('DNS Name', 'data.dns_settings.fqdn', options={ - 'is_optional': True - }), - - # is_optional fields - Configuration - TextDyField.data_source('IP Address Assignment', 'data.public_ip_allocation_method', options={ - 'is_optional': True - }), - TextDyField.data_source('Idle Timeout(Minutes)', 'data.idle_timeout_in_minutes', options={ - 'is_optional': True - }), - TextDyField.data_source('DNS Name Label(Optional)', 'data.dns_settings.domain_name_label', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='SKU', key='instance_type'), - SearchField.set(name='Tier', key='data.sku.tier'), - SearchField.set(name='IP Address', key='data.ip_address'), - SearchField.set(name='DNS Name', key='data.dns_settings.fqdn'), - SearchField.set(name='IP Address Assignment', key='data.public_ip_allocation_method'), - SearchField.set(name='Idle Timeout(Minutes)', key='data.idle_timeout_in_minutes', data_type='integer'), - SearchField.set(name='DNS Name Label(Optional)', key='data.dns_settings.domain_name_label'), - SearchField.set(name='Associated To', key='data.associated_to') - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(public_ip_address_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(public_ip_address_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(public_ip_address_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(public_ip_address_total_count_conf)) - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_public_ip_addresses}), -] diff --git a/src/spaceone/inventory/model/public_ip_addresses/data.py b/src/spaceone/inventory/model/public_ip_addresses/data.py deleted file mode 100644 index 7dc89db3..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/data.py +++ /dev/null @@ -1,122 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, DateTimeType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Tags(Model): - key = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class SubResource(Model): - id = StringType() - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(default='-') - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class NetworkInterface(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - dscp_configuration = ModelType(SubResource, serialize_when_none=False) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nic_type = StringType(choices=('Elastic', 'Standard'), serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - virtual_machine = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = StringType(serialize_when_none=False) - network_interface = ModelType(NetworkInterface, serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class NatGatewaySku(Model): - name = StringType(choices=('Standard', None), serialize_when_none=False) - - -class NatGateway(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySku, serialize_when_none=False) - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - - -class PublicIPAddress(AzureCloudService): # Main Class - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - associated_to = StringType(serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nat_gateway = ModelType(NatGateway, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(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", - } diff --git a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_account.yaml b/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_account.yaml deleted file mode 100644 index e1b078fa..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: PublicIPAddresses -cloud_service_type: IPAddress -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_region.yaml b/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_region.yaml deleted file mode 100644 index 01d9e676..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: PublicIPAddresses -cloud_service_type: IPAddress -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_subscription.yaml b/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_subscription.yaml deleted file mode 100644 index 8674c7d6..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: PublicIPAddresses -cloud_service_type: IPAddress -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_total_count.yaml b/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_total_count.yaml deleted file mode 100644 index fef59547..00000000 --- a/src/spaceone/inventory/model/public_ip_addresses/widget/public_ip_addresses_total_count.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -cloud_service_group: PublicIPAddresses -cloud_service_type: IPAddress -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - key: region_code - operator: count diff --git a/src/spaceone/inventory/model/snapshots/__init__.py b/src/spaceone/inventory/model/snapshots/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/snapshots/cloud_service.py b/src/spaceone/inventory/model/snapshots/cloud_service.py deleted file mode 100644 index 5f6dfc3e..00000000 --- a/src/spaceone/inventory/model/snapshots/cloud_service.py +++ /dev/null @@ -1,53 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.model.snapshots.data import Snapshot -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, ListDyField, SizeField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -''' -SNAPSHOT -''' -# TAB - Default -snapshot_info_meta = ItemDynamicLayout.set_fields('Snapshots', fields=[ - - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Storage Type', 'instance_type'), - SizeField.data_source('Size', 'data.size'), - TextDyField.data_source('Source Disk', 'data.source_disk_name'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - EnumDyField.data_source('Snapshot state', 'data.disk_state', default_state={ - 'safe': ['ActiveSAS', 'ActiveUpload', 'Attached', 'Reserved'], - 'warning': ['ReadyToUpload'], - 'available': ['Unattached'] - }), - TextDyField.data_source('Snapshot Type', 'data.incremental_display'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Encryption Type', 'data.encryption.type_display'), - TextDyField.data_source('Network Access Policy', 'data.network_access_policy_display'), - DateTimeDyField.data_source('Created Time', 'launched_at') -]) - -snapshot_meta = CloudServiceMeta.set_layouts([snapshot_info_meta]) - - -class ComputeResource(CloudServiceResource): - cloud_service_group = StringType(default='Snapshots') - - -class SnapshotResource(ComputeResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(Snapshot) - _metadata = ModelType(CloudServiceMeta, default=snapshot_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 SnapshotResponse(CloudServiceResponse): - resource = PolyModelType(SnapshotResource) diff --git a/src/spaceone/inventory/model/snapshots/cloud_service_type.py b/src/spaceone/inventory/model/snapshots/cloud_service_type.py deleted file mode 100644 index ed5dac76..00000000 --- a/src/spaceone/inventory/model/snapshots/cloud_service_type.py +++ /dev/null @@ -1,79 +0,0 @@ -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, SizeField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -snapshots_count_by_account_conf = os.path.join(current_dir, 'widget/snapshots_count_by_account.yaml') -snapshots_count_by_region_conf = os.path.join(current_dir, 'widget/snapshots_count_by_region.yaml') -snapshots_count_by_resource_group_conf = os.path.join(current_dir, 'widget/snapshots_count_by_resource_group.yaml') -snapshots_count_by_subscription_conf = os.path.join(current_dir, 'widget/snapshots_count_by_subscription.yaml') -snapshots_total_count_conf = os.path.join(current_dir, 'widget/snapshots_total_count.yaml') -snapshots_total_size_conf = os.path.join(current_dir, 'widget/snapshots_total_size.yaml') - - -cst_snapshots = CloudServiceTypeResource() -cst_snapshots.name = 'Instance' -cst_snapshots.group = 'Snapshots' -cst_snapshots.service_code = 'Microsoft.Compute/snapshots' -cst_snapshots.labels = ['Compute', 'Storage'] -cst_snapshots.is_primary = True -cst_snapshots.is_major = True -cst_snapshots.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-disk-snapshot.svg', -} - -cst_snapshots._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Source disk', 'data.source_disk_name'), - TextDyField.data_source('Snapshot type', 'data.incremental_display'), - SizeField.data_source('Source disk size', 'data.disk_size_bytes'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - DateTimeDyField.data_source('Launched', 'data.time_created'), - - # is_optional fields - Default - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - TextDyField.data_source('Encryption Type', 'data.encryption.type_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Network Access Policy', 'data.network_access_policy_display', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Storage Account Type', key='instance_type'), - SearchField.set(name='Snapshot Type', key='data.incremental_display'), - SearchField.set(name='Disk Size (Bytes)', key='data.disk_size_bytes'), - SearchField.set(name='Disk Size (GB)', key='instance_size', data_type='float'), - SearchField.set(name='Encryption', key='data.encryption.type_display'), - SearchField.set(name='Network Access Policy', key='data.network_access_policy'), - SearchField.set(name='Provisioning State', key='data.provisioning_state'), - SearchField.set(name='Launched', key='data.time_created', data_type='datetime') - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(snapshots_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(snapshots_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(snapshots_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(snapshots_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(snapshots_total_count_conf)), - CardWidget.set(**get_data_from_yaml(snapshots_total_size_conf)) - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_snapshots}), -] diff --git a/src/spaceone/inventory/model/snapshots/data.py b/src/spaceone/inventory/model/snapshots/data.py deleted file mode 100644 index a8d352cc..00000000 --- a/src/spaceone/inventory/model/snapshots/data.py +++ /dev/null @@ -1,131 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - DateTimeType, - IntType, - BooleanType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Sku(Model): - name = StringType( - choices=("Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS"), - serialize_when_none=False, - ) - tier = StringType(choices=("Premium", "Standard"), serialize_when_none=False) - - -class ImageDiskReference(Model): - id = StringType(serialize_when_none=False) - Lun = IntType(serialize_when_none=False) - - -class CreationData(Model): - creation_option = StringType( - choices=("Attach", "Copy", "Empty", "FromImage", "Import", "Restore", "Upload"), - serialize_when_none=False, - ) - image_reference = ModelType(ImageDiskReference, serialize_when_none=False) - gallery_image_reference = ModelType(ImageDiskReference, serialize_when_none=False) - logical_sector_size = IntType(serialize_when_none=False) - source_resource_id = StringType() - source_uri = StringType(serialize_when_none=False) - source_unique_id = StringType(serialize_when_none=False) - storage_account_id = StringType(serialize_when_none=False) - upload_size_bytes = IntType(serialize_when_none=False) - - -class SourceVault(Model): - id = StringType(serialize_when_none=False) - - -class DiskEncryptionKey(Model): - source_vault = ModelType(SourceVault, serialize_when_none=False) - secret_url = StringType(serialize_when_none=False) - - -class KeyEncryptionKey(Model): - source_vault = ModelType(SourceVault) - key_url = StringType() - - -class EncryptionSettingsCollection(Model): - disk_encryption_key = ModelType(DiskEncryptionKey, serialize_when_none=False) - key_encryption_key = ModelType(KeyEncryptionKey, serialize_when_none=False) - - -class Encryption(Model): - disk_encryption_set_id = StringType(default="", serialize_when_none=False) - type = StringType( - choices=( - "EncryptionAtRestWithCustomerKey", - "EncryptionAtRestWithPlatformAndCustomerKeys", - "EncryptionAtRestWithPlatformKey", - ), - default="EncryptionAtRestWithPlatformKey", - serialize_when_none=False, - ) - type_display = StringType() - - -class ShareInfoElement(Model): - vm_uri = StringType(serialize_when_none=False) - - -class SupportedCapabilities(Model): - architecture = StringType(serialize_when_none=False) - - -class Snapshot(AzureCloudService): - id = StringType() - location = StringType() - managed_by = StringType(serialize_when_none=False) - name = StringType() - creation_data = ModelType(CreationData) - disk_access_id = StringType(serialize_when_none=False) - disk_iops_read_write = StringType(serialize_when_none=False) - disk_m_bps_read_write = StringType(serialize_when_none=False) - disk_size_bytes = IntType() - disk_size_gb = IntType() - disk_state = StringType( - choices=( - "ActiveSAS", - "ActiveUpload", - "Attached", - "ReadyToUpload", - "Reserved", - "Unattached", - ) - ) - encryption = ModelType(Encryption) - encryption_settings_collection = ModelType( - EncryptionSettingsCollection, serialize_when_none=False - ) - hyper_v_generation = StringType(serialize_when_none=False) - incremental = BooleanType() - incremental_display = StringType(default="Full", serialize_when_none=False) - network_access_policy = StringType( - choices=("AllowAll", "AllowPrivate", "DenyAll"), serialize_when_none=False - ) - network_access_policy_display = StringType(serialize_when_none=False) - os_type = StringType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Failed", "Succeeded"), serialize_when_none=False - ) - time_created = DateTimeType(serialize_when_none=False) - unique_id = StringType() - size = IntType() - sku = ModelType(Sku) - source_disk_name = StringType() - supported_capabilities = ModelType(SupportedCapabilities, serialize_when_none=False) - tier_display = StringType(default="") - type = 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", - } diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_account.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_account.yaml deleted file mode 100644 index d33c035d..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_region.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_region.yaml deleted file mode 100644 index ee19971c..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_resource_group.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_resource_group.yaml deleted file mode 100644 index 098504b4..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_resource_group.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Snapshots Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - key: data.resource_group - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_subscription.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_subscription.yaml deleted file mode 100644 index 908e36b1..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Snapshots Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_total_count.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_total_count.yaml deleted file mode 100644 index b7083bf2..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/snapshots/widget/snapshots_total_size.yaml b/src/spaceone/inventory/model/snapshots/widget/snapshots_total_size.yaml deleted file mode 100644 index a74e7139..00000000 --- a/src/spaceone/inventory/model/snapshots/widget/snapshots_total_size.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: Snapshots -cloud_service_type: Instance -name: Total Size -query: - aggregate: - - group: - fields: - - name: value - key: data.disk_size_gb - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 - source_unit: GB \ No newline at end of file diff --git a/src/spaceone/inventory/model/sql_databases/__init__.py b/src/spaceone/inventory/model/sql_databases/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/sql_databases/cloud_service.py b/src/spaceone/inventory/model/sql_databases/cloud_service.py deleted file mode 100644 index 497a94eb..00000000 --- a/src/spaceone/inventory/model/sql_databases/cloud_service.py +++ /dev/null @@ -1,142 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.model.sql_databases.data import * -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -''' -SQL DATABASES -''' - -# TAB - Default -# Resource Group, Location, Subscription, Subscription ID, SKU, Backend pool, Health probe, -# Load balancing rule, NAT Rules, Public IP Addresses, Load Balancing Type -sql_databases_info_meta = ItemDynamicLayout.set_fields('SQL Databases', fields=[ - TextDyField.data_source('Database Name', 'name'), - EnumDyField.data_source('Status', 'data.status', default_state={ - 'safe': ['Online', 'Creating', 'Copying', 'Creating', 'OnlineChangingDwPerformanceTiers', 'Restoring', - 'Resuming', 'Scaling', 'Standby'], - 'warning': ['AutoClosed', 'Inaccessible', 'Offline', 'OfflineChangingDwPerformanceTiers', 'OfflineSecondary', - 'Pausing', 'Recovering', 'RecoveryPending', 'Suspect'], - 'disable': ['Disabled', 'Paused', 'Shutdown'], - 'alert': ['EmergencyMode'] - }), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Server Name', 'data.server_name'), - TextDyField.data_source('Elastic Pool', 'data.elastic_pool_id'), - TextDyField.data_source('Pricing Tier', 'data.pricing_tier_display'), - DateTimeDyField.data_source('Earliest Restore Point', 'data.earliest_restore_date'), - TextDyField.data_source('Collation', 'data.collation'), - DateTimeDyField.data_source('Creation Date', 'launched_at'), - TextDyField.data_source('Server Admin Login', 'data.administrator_login'), - -]) - -# TAB - Configure -sql_databases_configure = ItemDynamicLayout.set_fields('Configure', fields=[ - TextDyField.data_source('Service Tier', 'data.service_tier_display'), - TextDyField.data_source('Compute Tier', 'data.compute_tier'), - TextDyField.data_source('Compute Hardware', 'data.sku.family'), - TextDyField.data_source('Licence Type', 'data.license_type'), - TextDyField.data_source('vCores', 'data.current_sku.capacity'), - TextDyField.data_source('Data max size', 'instance_size'), - TextDyField.data_source('Zone Redundant', 'data.zone_redundant'), - ListDyField.data_source('Sync Groups', 'data.sync_group_display'), - ListDyField.data_source('Sync Agents', 'data.sync_agent_display'), - TextDyField.data_source('Collation', 'data.collation'), - DateTimeDyField.data_source('Creation Date', 'data.creation_date') -]) - - -# TAB - Backups -# Database, Earliest PITR restore point (UTC), Available LTR backups -sql_databases_backups = TableDynamicLayout.set_fields('Backups', 'data', fields=[ - TextDyField.data_source('Database', 'name'), - TextDyField.data_source('Earliest PITR Restore Point (UTC)', 'earliest_restore_date'), - TextDyField.data_source('Available LTR backups', 'long_term_retention_backup_resource_id'), -]) - -# TAB - Replication -sql_databases_replication = TableDynamicLayout.set_fields('Replicas', 'data.replication_link', fields=[ - TextDyField.data_source('Name', 'partner_database'), - TextDyField.data_source('linkType', 'link_type'), - TextDyField.data_source('Region', 'partner_location'), - TextDyField.data_source('Replica state', 'replica_state'), -]) - -# TAB - Maintenance -sql_databases_maintenance = ItemDynamicLayout.set_fields('Maintenance', 'data', fields=[ - -]) - -# TAB - Sync to other databases - Sync database -sql_databases_sync_to_other_databases_sync_database = TableDynamicLayout.set_fields('Sync Group', 'data.sync_group', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Status', 'sync_state'), - TextDyField.data_source('Use private link', 'use_private_link_connection'), - TextDyField.data_source('Automatic Sync', 'automatic_sync'), - TextDyField.data_source('Conflict Resolution', 'conflict_resolution_policy'), - TextDyField.data_source('Interval', 'interval') - -]) -# TAB - Sync to other databases - Sync Agent -sql_databases_sync_to_other_databases_sync_agent = TableDynamicLayout.set_fields('Sync Agent', 'data.sync_agent', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Status', 'state'), - TextDyField.data_source('version', 'version') -]) - -# TAB - Sync to other databases -sql_databases_sync_to_other_databases_info = ListDynamicLayout.set_layouts('Sync to other databases', layouts=[ - sql_databases_sync_to_other_databases_sync_database, sql_databases_sync_to_other_databases_sync_agent -]) - -# TAB - Auditing -sql_servers_auditing = ItemDynamicLayout.set_fields('Auditing', 'data.database_auditing_settings', fields=[ - EnumDyField.data_source('Enable SQL Auditing', 'state', default_state={ - 'safe': ['Enabled'], - 'warning': ['Disabled'] - }), - TextDyField.data_source('Audit Log Destination', 'storage_endpoint'), - TextDyField.data_source('Storage Account ID', 'storage_account_subscription_id'), - TextDyField.data_source('Retention days', 'retention_days'), - TextDyField.data_source('Secondary Storage access key used', 'is_storage_secondary_key_in_use'), - TextDyField.data_source('Storage Authentication Type', 'storage_account_access_key') -]) - -# TAB - Diagnostic Settings -sql_databases_diagnostic_settings = SimpleTableDynamicLayout.set_fields('Diagnostic Settings', 'data.diagnostic_settings_resource', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Storage Account', 'storage_account_id'), - TextDyField.data_source('Event Hub', 'event_hub_name'), - TextDyField.data_source('Log Analytics Workspace', 'workspace_id'), -]) - -sql_databases_meta = CloudServiceMeta.set_layouts( - [sql_databases_info_meta, sql_databases_configure, sql_databases_diagnostic_settings, sql_databases_backups, - sql_databases_replication, sql_databases_sync_to_other_databases_info]) - - -class DatabaseResource(CloudServiceResource): - cloud_service_group = StringType(default='SQLDatabases') - - -class SQLDatabaseResource(DatabaseResource): - cloud_service_type = StringType(default='Database') - data = ModelType(SQLDatabase) - _metadata = ModelType(CloudServiceMeta, default=sql_databases_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class SQLDatabaseResponse(CloudServiceResponse): - resource = PolyModelType(SQLDatabaseResource) diff --git a/src/spaceone/inventory/model/sql_databases/cloud_service_type.py b/src/spaceone/inventory/model/sql_databases/cloud_service_type.py deleted file mode 100644 index 84893f2c..00000000 --- a/src/spaceone/inventory/model/sql_databases/cloud_service_type.py +++ /dev/null @@ -1,148 +0,0 @@ -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, SizeField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -sql_databases_count_by_account_conf = os.path.join(current_dir, 'widget/sql_databases_count_by_account.yaml') -sql_databases_count_by_region_conf = os.path.join(current_dir, 'widget/sql_databases_count_by_region.yaml') -sql_databases_count_by_subscription_conf = os.path.join(current_dir, 'widget/sql_databases_count_by_subscription.yaml') -sql_databases_total_count_conf = os.path.join(current_dir, 'widget/sql_databases_total_count.yaml') - -cst_sql_databases = CloudServiceTypeResource() -cst_sql_databases.name = 'Database' -cst_sql_databases.group = 'SQLDatabases' -cst_sql_databases.service_code = 'Microsoft.Sql/servers/databases' -cst_sql_databases.labels = ['Database'] -cst_sql_databases.is_major = True -cst_sql_databases.is_primary = True -cst_sql_databases.service_code = 'Microsoft.Sql/servers/databases' -cst_sql_databases.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-sql-databases.svg', -} - -cst_sql_databases._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source('Status', 'data.status', default_state={ - 'safe': ['Online', 'Creating', 'Copying', 'Creating', 'OnlineChangingDwPerformanceTiers', 'Restoring', - 'Resuming', 'Scaling', 'Standby'], - 'warning': ['AutoClosed', 'Inaccessible', 'Offline', 'OfflineChangingDwPerformanceTiers', - 'OfflineSecondary', - 'Pausing', 'Recovering', 'RecoveryPending', 'Suspect'], - 'disable': ['Disabled', 'Paused', 'Shutdown'], - 'alert': ['EmergencyMode'] - }), - TextDyField.data_source('Replication Partner Server', 'data.replication_link.partner_server'), - TextDyField.data_source('Server', 'data.server_name'), - TextDyField.data_source('Pricing Tier', 'data.pricing_tier_display'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - - # is_optional fields - Default - TextDyField.data_source('Elastic Pool', 'data.elastic_pool_id', options={ - 'is_optional': True - }), - DateTimeDyField.data_source('Earliest Restore Point', 'data.earliest_restore_date', options={ - 'is_optional': True - }), - TextDyField.data_source('Collation', 'data.collation', options={ - 'is_optional': True - }), - DateTimeDyField.data_source('Creation Date', 'launched_at', options={ - 'is_optional': True - }), - TextDyField.data_source('Server Admin Login', 'data.administrator_login', options={ - 'is_optional': True - }), - - # is_optional fields - Configure - TextDyField.data_source('Service Tier', 'data.service_tier_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Compute Tier', 'data.compute_tier', options={ - 'is_optional': True - }), - TextDyField.data_source('Compute Hardware', 'data.sku.family', options={ - 'is_optional': True - }), - TextDyField.data_source('Licence Type', 'data.license_type', options={ - 'is_optional': True - }), - TextDyField.data_source('vCores', 'data.current_sku.capacity', options={ - 'is_optional': True - }), - TextDyField.data_source('Data max size', 'instance_size', options={ - 'is_optional': True - }), - TextDyField.data_source('Zone Redundant', 'data.zone_redundant', options={ - 'is_optional': True - }), - ListDyField.data_source('Sync Groups', 'data.sync_group_display', options={ - 'is_optional': True - }), - ListDyField.data_source('Sync Agents', 'data.sync_agent_display', options={ - 'is_optional': True - }), - - # is_optional fields - Diagnostic Settings - TextDyField.data_source('Diagnostic Setting Name', 'data.diagnostic_settings_resource.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Diagnostic Setting Storage Account', 'data.diagnostic_settings_resource.storage_account_id', options={ - 'is_optional': True - }), - TextDyField.data_source('Event Hub', 'data.diagnostic_settings_resource.event_hub_name', options={ - 'is_optional': True - }), - TextDyField.data_source('Log Analytics Workspace', 'data.diagnostic_settings_resource.workspace_id', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Database ID', key='data.database_id'), - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Tier', key='instance_type'), - SearchField.set(name='Server Name', key='data.managed_by'), - SearchField.set(name='Status', key='data.status'), - SearchField.set(name='Replication Partner Server', key='data.replication_link.partner_server'), - SearchField.set(name='Pricing Tier', key='data.pricing_tier_display'), - SearchField.set(name='Elastic Pool', key='data.elastic_pool_id'), - SearchField.set(name='Earliest Restore Point', key='data.earliest_restore_date'), - SearchField.set(name='Collation', key='data.collation'), - SearchField.set(name='Server Admin Login', key='data.administrator_login'), - SearchField.set(name='Service Tier', key='data.service_tier_display'), - SearchField.set(name='Compute Tier', key='data.compute_tier'), - SearchField.set(name='Compute Hardware', key='data.sku.family'), - SearchField.set(name='Licence Type', key='data.license_type'), - SearchField.set(name='vCores', key='data.current_sku.capacity', data_type='integer'), - SearchField.set(name='Data max size', key='instance_size', data_type='integer'), - SearchField.set(name='Zone Redundant', key='data.zone_redundant'), - SearchField.set(name='Sync Groups', key='data.sync_group_display'), - SearchField.set(name='Sync Agents', key='data.sync_agent_display'), - SearchField.set(name='Diagnostic Setting Name', key='data.diagnostic_settings_resource.name'), - SearchField.set(name='Diagnostic Setting Storage Account', key='data.diagnostic_settings_resource.storage_account_id'), - SearchField.set(name='Event Hub', key='data.diagnostic_settings_resource.event_hub_name'), - SearchField.set(name='Log Analytics Workspace', key='data.diagnostic_settings_resource.workspace_id'), - SearchField.set(name='Creation Date', key='launched_at', data_type='datetime'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(sql_databases_total_count_conf)) - ] - -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_sql_databases}), -] diff --git a/src/spaceone/inventory/model/sql_databases/data.py b/src/spaceone/inventory/model/sql_databases/data.py deleted file mode 100644 index 1ccb999f..00000000 --- a/src/spaceone/inventory/model/sql_databases/data.py +++ /dev/null @@ -1,196 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, FloatType, DateTimeType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class Sku(Model): - capacity = IntType(serialize_when_none=False) - family = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - size = StringType(serialize_when_none=False) - tier = StringType(serialize_when_none=False) - - -class SyncGroupSchemaColumn(Model): - data_size = StringType(serialize_when_none=False) - data_type = StringType(serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchemaTable(Model): - columns = ListType(ModelType(SyncGroupSchemaColumn), serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchema(Model): - master_sync_member_name = StringType(serialize_when_none=False) - tables = ListType(ModelType(SyncGroupSchemaTable), serialize_when_none=False) - - -class SyncGroup(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - conflict_resolution_policy = StringType(choices=('HubWin', 'MemberWin'), serialize_when_none=False) - hub_database_password = StringType(serialize_when_none=False) - hub_database_user_name = StringType(serialize_when_none=False) - interval = IntType(serialize_when_none=False) - last_sync_time = DateTimeType(serialize_when_none=False) - schema = ModelType(SyncGroupSchema, serialize_when_none=False) - sync_database_id = StringType(serialize_when_none=False) - sync_state = StringType(choices=('Error', 'Good', 'NotReady', 'Progressing', 'Warning'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - user_private_link = BooleanType(serialize_when_none=False) - conflict_logging_retention_in_days = IntType(serialize_when_none=False) - use_private_link_connection = BooleanType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - automatic_sync = BooleanType(serialize_when_none=False) - - -class SyncAgent(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - expiry_time = DateTimeType(serialize_when_none=False) - is_up_to_date = BooleanType(serialize_when_none=False) - last_alive_time = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - state = StringType(choices=('NeverConnected', 'Offline', 'Online'), serialize_when_none=False) - sync_database_id = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class RetentionPolicy(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class LogSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - - -class MetricSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - time_grain = StringType(serialize_when_none=False) - - -class DiagnosticSettingsResource(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - event_hub_authorization_rule_id = StringType(serialize_when_none=False) - event_hub_name = StringType(serialize_when_none=False) - log_analytics_destination_type = StringType(serialize_when_none=False) - logs = ListType(ModelType(LogSettings), serialize_when_none=False) - metrics = ListType(ModelType(MetricSettings), serialize_when_none=False) - service_bus_rule_id = StringType(serialize_when_none=False) - storage_account_id = StringType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ReplicationLink(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - is_termination_allowed = BooleanType(serialize_when_none=False) - partner_database = StringType(serialize_when_none=False) - partner_location = StringType(serialize_when_none=False) - partner_role = StringType(choices=('Copy', 'NonReadableSecondary', 'Primary', 'Secondary', 'Source'), serialize_when_none=False) - partner_server = StringType(default='-') - percent_complete = IntType(serialize_when_none=False) - replication_mode = StringType(serialize_when_none=False) - replication_state = StringType(choices=('CATCH_UP', 'PENDING', 'SEEDING', 'SUSPENDED'), serialize_when_none=False) - role = StringType(choices=('Copy', 'NonReadableSecondary', 'Primary', 'Secondary', 'Source'), serialize_when_none=False) - start_time = DateTimeType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - link_type = StringType(choices=('GEO', 'NAMED'), serialize_when_none=False) - replica_state = StringType(serialized_name=False) - - -class DatabaseBlobAuditingPolicy(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - retention_days = IntType(serialize_when_none=False) - audit_actions_and_groups = ListType(StringType, serialize_when_none=False) - is_storage_secondary_key_in_use = BooleanType(serialize_when_none=False) - is_azure_monitor_target_enabled = BooleanType(serialize_when_none=False) - queue_delay_ms = IntType(serialize_when_none=False) - state = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - storage_endpoint = StringType(serialize_when_none=False) - storage_account_access_key = StringType(serialize_when_none=False) - storage_account_subscription_id = StringType(serialize_when_none=False) - - -class SQLDatabase(AzureCloudService): # Main Class - name = StringType(serialize_when_none=False) - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - managed_by = StringType(serialize_when_none=False) - server_name = StringType(serialize_when_none=False) - administrator_login = StringType(default='-') - auto_pause_delay = IntType(serialize_when_none=False) - catalog_collation = StringType(choices=('DATABASE_DEFAULT', 'SQL_Latin1_General_CP1_CI_AS'), - serialize_when_none=False) - collation = StringType(serialize_when_none=False) - create_mode = StringType(choices=( - 'Copy', 'Default', 'OnlineSecondary', 'PointInTimeRestore', 'Recovery', 'Restore', 'RestoreExternalBackup', - 'RestoreExternalBackupSecondary', 'RestoreLongTermRetentionBackup', 'Secondary'), serialize_when_none=False) - creation_date = DateTimeType(serialize_when_none=False) - current_service_objective_name = StringType(serialize_when_none=False) - current_sku = ModelType(Sku, serialize_when_none=False) - database_id = StringType(serialize_when_none=False) - default_secondary_location = StringType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - elastic_pool_id = StringType(serialize_when_none=False) - failover_group_id = StringType(serialize_when_none=False) - high_availability_replica_count = IntType(serialize_when_none=False) - license_type = StringType(choices=('BasePrice', 'LicenseIncluded'), serialize_when_none=False) - long_term_retention_backup_resource_id = StringType(default='-') - maintenance_configuration_id = StringType(serialize_when_none=False) - max_log_size_bytes = IntType(serialize_when_none=False) - max_size_bytes = IntType(serialize_when_none=False) - max_size_gb = FloatType(serialize_when_none=False) - min_capacity = FloatType(serialize_when_none=False) - paused_date = DateTimeType(serialize_when_none=False) - read_scale = StringType(choices=('Disabled', 'Enabled'), default='Disabled') - recoverable_database_id = StringType(serialize_when_none=False) - recovery_services_recovery_point_id = StringType(serialize_when_none=False) - requested_service_objective_name = StringType(serialize_when_none=False) - restorable_dropped_database_id = StringType(serialize_when_none=False) - restore_point_in_time = StringType(serialize_when_none=False) - resumed_date = DateTimeType(serialize_when_none=False) - sample_name = StringType(choices=('AdventureWorksLT', 'WideWorldImportersFull', 'WideWorldImportersStd'), - serialize_when_none=False) - secondary_type = StringType(choices=('Geo', 'Named'), serialize_when_none=False) - source_database_deletion_date = StringType(serialize_when_none=False) - source_database_id = StringType(serialize_when_none=False) - status = StringType(choices=( - 'AutoClosed', 'Copying', 'Creating', 'Disabled', 'EmergencyMode', 'Inaccessible', 'Offline', - 'OfflineChangingDwPerformanceTiers', 'OfflineSecondary', 'Online', - 'OnlineChangingDwPerformanceTiers', 'Paused', 'Pausing', 'Recovering', 'RecoveryPending', 'Restoring', - 'Resuming', 'Scaling', 'Shutdown', 'Standby', 'Suspect'), serialize_when_none=False) - storage_account_type = StringType(choices=('GRS', 'LRS', 'ZRS'), serialize_when_none=False) - zone_redundant = BooleanType(serialize_when_none=False) - diagnostic_settings_resource = ListType(ModelType(DiagnosticSettingsResource), serialize_when_none=False) - replication_link = ListType(ModelType(ReplicationLink), serialize_when_none=False) - sync_group = ListType(ModelType(SyncGroup), serialize_when_none=False) - sync_agent = ListType(ModelType(SyncAgent), serialize_when_none=False) - sync_group_display = ListType(StringType, serialize_when_none=False) - sync_agent_display = ListType(StringType, serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - pricing_tier_display = StringType(default='-') - service_tier_display = StringType(default='-') - compute_tier = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - database_auditing_settings = ModelType(DatabaseBlobAuditingPolicy, 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", - } diff --git a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_account.yaml b/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_account.yaml deleted file mode 100644 index a01706c9..00000000 --- a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: SQLDatabases -cloud_service_type: Database -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_region.yaml b/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_region.yaml deleted file mode 100644 index a829e27a..00000000 --- a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: SQLDatabases -cloud_service_type: Database -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_subscription.yaml b/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_subscription.yaml deleted file mode 100644 index 1704a372..00000000 --- a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: SQLDatabases -cloud_service_type: Database -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_total_count.yaml b/src/spaceone/inventory/model/sql_databases/widget/sql_databases_total_count.yaml deleted file mode 100644 index 6b1d042b..00000000 --- a/src/spaceone/inventory/model/sql_databases/widget/sql_databases_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: SQLDatabases -cloud_service_type: Database -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/sql_servers/__init__.py b/src/spaceone/inventory/model/sql_servers/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/sql_servers/cloud_service.py b/src/spaceone/inventory/model/sql_servers/cloud_service.py deleted file mode 100644 index 6d17ac8b..00000000 --- a/src/spaceone/inventory/model/sql_servers/cloud_service.py +++ /dev/null @@ -1,378 +0,0 @@ -from schematics.types import ( - ModelType, - StringType, - PolyModelType, - FloatType, - DateTimeType, -) - -from spaceone.inventory.model.sql_servers.data import SQLServer -from spaceone.inventory.libs.schema.metadata.dynamic_field import ( - TextDyField, - DateTimeDyField, - EnumDyField, - ListDyField, -) -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ( - ItemDynamicLayout, - TableDynamicLayout, - ListDynamicLayout, - SimpleTableDynamicLayout, -) -from spaceone.inventory.libs.schema.cloud_service import ( - CloudServiceResource, - CloudServiceResponse, - CloudServiceMeta, -) - -""" -SQL SERVERS - -""" - -# TAB - Default -# Resource Group, Status, Location, Subscription, Subscription ID, Server Admin, Firewalls, Active Directory admin, Server name -sql_servers_info_meta = ItemDynamicLayout.set_fields( - "SQL Servers", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Resource Group", "data.resource_group"), - TextDyField.data_source("Resource ID", "data.id"), - EnumDyField.data_source( - "Status", - "data.state", - default_state={"safe": ["Ready"], "warning": ["Disabled"]}, - ), - TextDyField.data_source("Location", "data.location"), - TextDyField.data_source("Subscription", "data.subscription_name"), - TextDyField.data_source("Subscription ID", "account"), - TextDyField.data_source("Server Admin", "data.administrator_login"), - TextDyField.data_source("Active Directory Admin", "data.azure_ad_admin_name"), - TextDyField.data_source("Server Name", "data.fully_qualified_domain_name"), - ], -) - -# TAB - Failover Groups -# Name, Primary Server, Secondary Server, Read/Write Failover Policy, Grace Period (minutes), Database count -sql_server_failover_group = TableDynamicLayout.set_fields( - "Failover Groups", - "data.failover_groups", - fields=[ - TextDyField.data_source("ID", "id"), - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Primary Server", "primary_server"), - TextDyField.data_source("Secondary Server", "secondary_server"), - TextDyField.data_source( - "Read/Write Failover Policy", "failover_policy_display" - ), - TextDyField.data_source("Grace Period (minutes)", "grace_period_display"), - # TextDyField.data_source('Database count', ''), - ], -) - -# TAB - Backups -# Database, Earliest PITR restore point (UTC), Available LTR backups -sql_server_backups = TableDynamicLayout.set_fields( - "Backups", - "data.databases", - fields=[ - TextDyField.data_source("Database", "name"), - TextDyField.data_source( - "Earliest PITR Restore Point (UTC)", "earliest_restore_date" - ), - TextDyField.data_source( - "Available LTR backups", "long_term_retention_backup_resource_id" - ), - ], -) - -# TAB - Active Directory Admin -# Active Directory Admin -sql_servers_active_directory_admin = ItemDynamicLayout.set_fields( - "Active Directory Admin", - fields=[ - TextDyField.data_source("Active Directory Admin", "data.azure_ad_admin_name") - ], -) - -# TAB - SQL Databases - Default -sql_servers_databases = TableDynamicLayout.set_fields( - "Databases", - "data.databases", - fields=[ - TextDyField.data_source("Database", "name"), - TextDyField.data_source("Resource ID", "id"), - EnumDyField.data_source( - "Status", - "status", - default_state={ - "safe": [ - "Online", - "Creating", - "Copying", - "Creating", - "OnlineChangingDwPerformanceTiers", - "Restoring", - "Resuming", - "Scaling", - "Standby", - ], - "warning": [ - "AutoClosed", - "Inaccessible", - "Offline", - "OfflineChangingDwPerformanceTiers", - "OfflineSecondary", - "Pausing", - "Recovering", - "RecoveryPending", - "Suspect", - ], - "disable": ["Disabled", "Paused", "Shutdown"], - "alert": ["EmergencyMode"], - }, - ), - TextDyField.data_source("Resource Group", "resource_group"), - TextDyField.data_source("Subscription ID", "subscription_id"), - TextDyField.data_source("Location", "location"), - TextDyField.data_source("Server Name", "server_name"), - TextDyField.data_source("Elastic Pool", ""), - # TextDyField.data_source('Connection Strings', ''), - TextDyField.data_source("Pricing Tier", "pricing_tier_display"), - TextDyField.data_source("Earliest Restore Point", "earliest_restore_date"), - ], -) - -# TAB - SQL Databases - Configure -sql_servers_databases_configure = TableDynamicLayout.set_fields( - "Databases Configure", - "data.databases", - fields=[ - TextDyField.data_source("Service Tier", "service_tier_display"), - TextDyField.data_source("Compute Tier", "compute_tier"), - TextDyField.data_source("Compute Hardware", "sku.family"), - TextDyField.data_source("License Type", "license_type"), - TextDyField.data_source("vCores", "sku.capacity"), - TextDyField.data_source("Data Max Size", "max_size_gb"), - TextDyField.data_source("Zone Redundant", "zone_redundant"), - ListDyField.data_source("Sync Groups", "sync_group_display"), - ListDyField.data_source("Sync Agents", "sync_agent_display"), - TextDyField.data_source("Collation", "collation"), - DateTimeDyField.data_source("Creation Date", "creation_date"), - # TextDyField.data_source('Server Admin Login', '') # Remove: DB is already under the specific server - # TextDyField.data_source('Active Directory Login', ''), # Remove: DB is already under the specific server - ], -) - -# TAB - SQL Databases - tags -sql_databases_info_tags = TableDynamicLayout.set_fields( - "Tags", - "data.tags", - fields=[ - TextDyField.data_source("Key", "key"), - TextDyField.data_source("Value", "value"), - ], -) - -# TAB - Dynamic Data Masking : "Masking rules: + Tab "Recommended fields to mask" # TODO: confirm!! -sql_servers_databases_info = ListDynamicLayout.set_layouts( - "SQL Databases", - layouts=[ - sql_servers_databases, - sql_servers_databases_configure, - sql_databases_info_tags, - ], -) - -# TAB - Elastic Pools -# Name, Pricing tier, Per DB settings, of DBs, Storage, unit, avg, peak, average utilization over past hour -sql_servers_elastic_pools = TableDynamicLayout.set_fields( - "Elastic Pools", - "data.elastic_pools", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Resource Group", "resource_group_display"), - TextDyField.data_source("Per DB Settings", "per_db_settings_display"), - TextDyField.data_source("Pricing Tier", "pricing_tier_display"), - TextDyField.data_source("# of DBs", "number_of_databases"), - TextDyField.data_source("Unit", "unit_display"), - EnumDyField.data_source( - "Status", - "state", - default_state={"safe": ["Ready", "Creating"], "warning": ["Disabled"]}, - ), - # TextDyField.data_source('Storage[%]', ''), - # TextDyField.data_source('Avg[%]', ''), - # TextDyField.data_source('Peak[%]', ''), - # TextDyField.data_source('Utilization Over Past Hour[%]', ''), - # TextDyField.data_source('Utilization Over Past Hour[%]', ''), - TextDyField.data_source("Server Name", "server_name_display"), - TextDyField.data_source("Resource Configuration", "pricing_tier_display"), - TextDyField.data_source("Maximum Storage Size", "max_size_gb"), - ListDyField.data_source("Tags", "tags"), - ], -) - -# TAB - Deleted Databases -sql_servers_deleted_databases = TableDynamicLayout.set_fields( - "Deleted Databases", - "data.deleted_databases", - fields=[ - TextDyField.data_source("Database", "database_name"), - DateTimeDyField.data_source("Deletion Time (UTC)", "deletion_date"), - DateTimeDyField.data_source("Creation Time (UTC)", "creation_date"), - TextDyField.data_source("Edition Time (UTC)", "edition"), - ], -) - -# TAB - Auditing -sql_servers_auditing = ItemDynamicLayout.set_fields( - "Auditing", - "data.server_auditing_settings", - fields=[ - EnumDyField.data_source( - "Enable SQL Auditing", - "state", - default_state={"safe": ["Enabled"], "warning": ["Disabled"]}, - ), - TextDyField.data_source("Audit Log Destination", "storage_endpoint"), - TextDyField.data_source( - "Storage Account ID", "storage_account_subscription_id" - ), - ], -) - -# TAB - Firewalls and Virtual Networks -sql_servers_network = ItemDynamicLayout.set_fields( - "Network", - fields=[ - EnumDyField.data_source( - "Public Network access", - "data.public_network_access", - default_state={"safe": ["Enabled"], "warning": ["Disabled"]}, - ), - TextDyField.data_source("Minimum TLS Version", "data.minimal_tls_version"), - TextDyField.data_source( - "Connection Policy", "data.server_auditing_settings.name" - ), - TextDyField.data_source( - "Allow Azure Services and Resources to Access this server", - "data.server_auditing_settings.is_azure_monitor_target_enabled", - ), - ], -) -sql_servers_firewall_rules = TableDynamicLayout.set_fields( - "Firewall Rules", - "data.firewall_rules", - fields=[ - TextDyField.data_source("Rule Name", "name"), - TextDyField.data_source("Start IP", "start_ip_address"), - TextDyField.data_source("End IP", "end_ip_address"), - ], -) - -sql_servers_virtual_network_rules = TableDynamicLayout.set_fields( - "Virtual Network Rules", - "data.virtual_network_rules", - fields=[ - TextDyField.data_source("Rule Name", "name"), - TextDyField.data_source("Virtual Network", "virtual_network_name_display"), - TextDyField.data_source("Subnet ID", "virtual_network_subnet_id"), - # TextDyField.data_source('Address Range', ''), - # TextDyField.data_source('Endpoint Status', ''), - TextDyField.data_source("Resource Group", "resource_group"), - TextDyField.data_source("Subscription", "subscription_id"), - EnumDyField.data_source( - "State", - "state", - default_state={ - "safe": ["Ready", "InProgress", "Initializing"], - "warning": ["Deleting", "Unknown"], - }, - ), - ], -) - -sql_servers_firewalls_and_vn = ListDynamicLayout.set_layouts( - "Firewalls and Network", - layouts=[ - sql_servers_network, - sql_servers_firewall_rules, - sql_servers_virtual_network_rules, - ], -) - -# TAB - Private Endpoint Connections -sql_servers_private_endpoint_connections = TableDynamicLayout.set_fields( - "Private Endpoint Connections", - "data.private_endpoint_connections", - fields=[ - TextDyField.data_source("Connection ID", "connection_id"), - TextDyField.data_source("State", "status"), - TextDyField.data_source("Private Endpoint Name", "private_endpoint_name"), - TextDyField.data_source("Request / Response Message", "description"), - ], -) - -# TAB - Transparent Data Encryption -sql_servers_transparent_data_encryption = TableDynamicLayout.set_fields( - "Transparent Data Encryption", - "data.encryption_protectors", - fields=[ - TextDyField.data_source("Transparent Data Encryption", "kind"), - TextDyField.data_source("Key", "server_key_name"), - TextDyField.data_source("Key Type", "server_key_type"), - TextDyField.data_source("Uri", "uri"), - ], -) - -# TAB - Automatic Tuning -sql_servers_automatic_tuning_options = TableDynamicLayout.set_fields( - "Tuning Options", - "data.server_automatic_tuning.options", - fields=[ - TextDyField.data_source("Tuning Type", "tuning_type"), - TextDyField.data_source("Desired State", "desired_state"), - TextDyField.data_source("Current State", "actual_state"), - ], -) - -# TAB - SQL Databases -sql_servers_meta = CloudServiceMeta.set_layouts( - [ - sql_servers_info_meta, - sql_server_failover_group, - sql_server_backups, - sql_servers_active_directory_admin, - sql_servers_databases_info, - sql_servers_elastic_pools, - sql_servers_deleted_databases, - sql_servers_auditing, - sql_servers_network, - sql_servers_transparent_data_encryption, - sql_servers_automatic_tuning_options, - sql_servers_firewalls_and_vn, - sql_servers_private_endpoint_connections, - ] -) - - -class DatabaseResource(CloudServiceResource): - cloud_service_group = StringType(default="SQLServers") - - -class SQLServerResource(DatabaseResource): - cloud_service_type = StringType(default="Server") - data = ModelType(SQLServer) - _metadata = ModelType( - CloudServiceMeta, default=sql_servers_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class SQLServerResponse(CloudServiceResponse): - resource = PolyModelType(SQLServerResource) diff --git a/src/spaceone/inventory/model/sql_servers/cloud_service_type.py b/src/spaceone/inventory/model/sql_servers/cloud_service_type.py deleted file mode 100644 index e195a090..00000000 --- a/src/spaceone/inventory/model/sql_servers/cloud_service_type.py +++ /dev/null @@ -1,477 +0,0 @@ -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, - SizeField, -) -from spaceone.inventory.libs.schema.cloud_service_type import ( - CloudServiceTypeResource, - CloudServiceTypeResponse, - CloudServiceTypeMeta, -) -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -sql_databases_count_by_server_conf = os.path.join( - current_dir, "widget/sql_databases_count_by_server.yaml" -) -sql_databases_count_by_subscription_conf = os.path.join( - current_dir, "widget/sql_databases_count_by_subscription.yaml" -) -sql_databases_count_by_tier_conf = os.path.join( - current_dir, "widget/sql_databases_count_by_tier.yaml" -) -sql_servers_count_by_account_conf = os.path.join( - current_dir, "widget/sql_servers_count_by_account.yaml" -) -sql_servers_count_by_region_conf = os.path.join( - current_dir, "widget/sql_servers_count_by_region.yaml" -) -sql_servers_count_by_subscription_conf = os.path.join( - current_dir, "widget/sql_servers_count_by_subscription.yaml" -) -sql_servers_failover_count_by_region_conf = os.path.join( - current_dir, "widget/sql_servers_failover_count_by_region.yaml" -) -sql_servers_failover_count_by_server_conf = os.path.join( - current_dir, "widget/sql_servers_failover_count_by_server.yaml" -) -sql_servers_total_count_conf = os.path.join( - current_dir, "widget/sql_servers_total_count.yaml" -) - -cst_sql_servers = CloudServiceTypeResource() -cst_sql_servers.name = "Server" -cst_sql_servers.group = "SQLServers" -cst_sql_servers.service_code = "Microsoft.Sql/servers" -cst_sql_servers.labels = ["Database"] -cst_sql_servers.is_primary = True -cst_sql_servers.is_major = True -cst_sql_servers.tags = { - "spaceone:icon": f"{ASSET_URL}/azure-sql-servers.svg", -} - -cst_sql_servers._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source( - "Status", - "data.state", - default_state={"safe": ["Ready"], "warning": ["Disabled"]}, - ), - TextDyField.data_source("Resource Group", "data.resource_group"), - TextDyField.data_source("Location", "data.location"), - TextDyField.data_source("Subscription Name", "data.subscription_name"), - # is_optional fields - Default - TextDyField.data_source( - "Subscription ID", "account", options={"is_optional": True} - ), - TextDyField.data_source( - "Server Admin", "data.administrator_login", options={"is_optional": True} - ), - TextDyField.data_source( - "Active Directory Admin", - "data.azure_ad_admin_name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Server Name", - "data.fully_qualified_domain_name", - options={"is_optional": True}, - ), - # is_optional fields - Failover Groups - TextDyField.data_source( - "Failover Group ID", - "data.failover_groups.id", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Failover Group Name", - "data.failover_groups.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Failover Groups Primary Server", - "data.failover_groups.primary_server", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Failover Groups Secondary Server", - "data.failover_groups.secondary_server", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Read/Write Failover Policy", - "data.failover_groups.failover_policy_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Grace Period (minutes)", - "data.failover_groups.grace_period_display", - options={"is_optional": True}, - ), - # is_optional fields - Backups - TextDyField.data_source( - "Backup Database", "data.databases.name", options={"is_optional": True} - ), - TextDyField.data_source( - "Backup Earliest PITR Restore Point (UTC)", - "data.databases.earliest_restore_date", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Backup Available LTR backups", - "data.databases.long_term_retention_backup_resource_id", - options={"is_optional": True}, - ), - # is_optional fields - Active Directory Admin - TextDyField.data_source( - "Active Directory Admin", - "data.azure_ad_admin_name", - options={"is_optional": True}, - ), - # is_optional fields - Elastic Pools - TextDyField.data_source( - "Elastic Pool Name", - "data.elastic_pools.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Elastic Pool Resource Group", - "data.elastic_pools.resource_group_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Per DB Settings", - "data.elastic_pools.per_db_settings_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Pricing Tier", - "data.elastic_pools.pricing_tier_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "# of DBs", - "data.elastic_pools.number_of_databases", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Elastic Pool Unit", - "data.elastic_pools.unit_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Elastic Pool Server Name", - "data.elastic_pools.server_name_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Elastic Pool Resource Configuration", - "data.elastic_pools.pricing_tier_display", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Elastic Pool Maximum Storage Size", - "data.elastic_pools.max_size_gb", - options={"is_optional": True}, - ), - # is_optional fields - Deleted Databases - TextDyField.data_source( - "Deleted Database", - "data.deleted_databases.database_name", - options={"is_optional": True}, - ), - DateTimeDyField.data_source( - "Deletion Time (UTC)", - "data.deleted_databases.deletion_date", - options={"is_optional": True}, - ), - DateTimeDyField.data_source( - "Deleted Databases Creation Time (UTC)", - "data.deleted_databases.creation_date", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Deleted Databases Edition Time (UTC)", - "data.deleted_databases.edition", - options={"is_optional": True}, - ), - # is_optional fields - Auditing - TextDyField.data_source( - "Audit Log Destination", - "data.server_auditing_settings.storage_endpoint", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Audit Storage Account ID", - "data.server_auditing_settings.storage_account_subscription_id", - options={"is_optional": True}, - ), - # is_optional fields - Firewalls and Vnets - TextDyField.data_source( - "Minimum TLS Version", - "data.minimal_tls_version", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Connection Policy", - "data.server_auditing_settings.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Allow Azure Services and Resources to Access this server", - "data.server_auditing_settings.is_azure_monitor_target_enabled", - options={"is_optional": True}, - ), - # is_optional fields - Firewall Rules - TextDyField.data_source( - "Firewall Rule Name", - "data.firewall_rules.name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Firewall Start IP", - "data.firewall_rules.start_ip_address", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Firewall End IP", - "data.firewall_rules.end_ip_address", - options={"is_optional": True}, - ), - # is_optional fields - Private Endpoint Connections - TextDyField.data_source( - "Private Endpoint Connection ID", - "data.private_endpoint_connections.connection_id", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Private Endpoint State", - "data.private_endpoint_connections.status", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Private Endpoint Name", - "data.private_endpoint_connections.private_endpoint_name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Request / Response Message", - "data.private_endpoint_connections.description", - options={"is_optional": True}, - ), - # is_optional fields - Transparent Data Encryption - TextDyField.data_source( - "Transparent Data Encryption", - "data.encryption_protectors.kind", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Encryption Key", - "data.encryption_protectors.server_key_name", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Encryption Key Type", - "data.encryption_protectors.server_key_type", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Encryption URI", - "data.encryption_protectors.uri", - options={"is_optional": True}, - ), - # is_optional fields - Automatic Tuning - TextDyField.data_source( - "Tuning Type", - "data.server_automatic_tuning.options.tuning_type", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Tuning Desired State", - "data.server_automatic_tuning.options.desired_state", - options={"is_optional": True}, - ), - TextDyField.data_source( - "Tuning Current State", - "data.server_automatic_tuning.options.actual_state", - options={"is_optional": True}, - ), - ], - search=[ - SearchField.set(name="Subscription ID", key="account"), - SearchField.set(name="Subscription Name", key="data.subscription_name"), - SearchField.set(name="Resource Group", key="data.resource_group"), - SearchField.set(name="Location", key="data.location"), - SearchField.set(name="Server Admin", key="data.administrator_login"), - SearchField.set(name="Active Directory Admin", key="data.azure_ad_admin_name"), - SearchField.set(name="Server Name", key="data.fully_qualified_domain_name"), - SearchField.set(name="Failover Group ID", key="data.failover_groups.id"), - SearchField.set(name="Failover Group Name", key="data.failover_groups.name"), - SearchField.set( - name="Failover Groups Primary Server", - key="data.failover_groups.primary_server", - ), - SearchField.set( - name="Failover Groups Secondary Server", - key="data.failover_groups.secondary_server", - ), - SearchField.set( - name="Read/Write Failover Policy", - key="data.failover_groups.failover_policy_display", - ), - SearchField.set( - name="Grace Period (minutes)", - key="data.failover_groups.grace_period_display", - data_type="integer", - ), - SearchField.set(name="Backup Database", key="data.databases.name"), - SearchField.set( - name="Backup Earliest PITR Restore Point (UTC)", - key="data.databases.earliest_restore_date", - data_type="datetime", - ), - SearchField.set( - name="Backup Available LTR backups", - key="data.databases.long_term_retention_backup_resource_id", - ), - SearchField.set(name="Active Directory Admin", key="data.azure_ad_admin_name"), - SearchField.set(name="Elastic Pool Name", key="data.elastic_pools.name"), - SearchField.set( - name="Elastic Pool Resource Group", - key="data.elastic_pools.resource_group_display", - ), - SearchField.set( - name="Per DB Settings", key="data.elastic_pools.per_db_settings_display" - ), - SearchField.set( - name="Pricing Tier", key="data.elastic_pools.pricing_tier_display" - ), - SearchField.set( - name="Number of DBs", - key="data.elastic_pools.number_of_databases", - data_type="integer", - ), - SearchField.set( - name="Elastic Pool Unit", key="data.elastic_pools.unit_display" - ), - SearchField.set( - name="Elastic Pool Server Name", - key="data.elastic_pools.server_name_display", - ), - SearchField.set( - name="Elastic Pool Resource Configuration", - key="data.elastic_pools.pricing_tier_display", - ), - SearchField.set( - name="Elastic Pool Maximum Storage Size", - key="data.elastic_pools.max_size_gb", - ), - SearchField.set( - name="Deleted Database", key="data.deleted_databases.database_name" - ), - SearchField.set( - name="Deletion Time (UTC)", - key="data.deleted_databases.deletion_date", - data_type="datetime", - ), - SearchField.set( - name="Deleted Databases Creation Time (UTC)", - key="data.deleted_databases.creation_date", - data_type="datetime", - ), - SearchField.set( - name="Deleted Databases Edition Time (UTC)", - key="data.deleted_databases.edition", - data_type="datetime", - ), - SearchField.set( - name="Audit Log Destination", - key="data.server_auditing_settings.storage_endpoint", - ), - SearchField.set( - name="Audit Storage Account ID", - key="data.server_auditing_settings.storage_account_subscription_id", - ), - SearchField.set(name="Minimum TLS Version", key="data.minimal_tls_version"), - SearchField.set( - name="Connection Policy", key="data.server_auditing_settings.name" - ), - SearchField.set( - name="Allow Azure Services and Resources to Access this server", - key="data.server_auditing_settings.is_azure_monitor_target_enabled", - ), - SearchField.set(name="Firewall Rule Name", key="data.firewall_rules.name"), - SearchField.set( - name="Firewall Start IP", key="data.firewall_rules.start_ip_address" - ), - SearchField.set( - name="Firewall End IP", key="data.firewall_rules.end_ip_address" - ), - SearchField.set( - name="Private Endpoint Connection ID", - key="data.private_endpoint_connections.connection_id", - ), - SearchField.set( - name="Private Endpoint State", - key="data.private_endpoint_connections.status", - ), - SearchField.set( - name="Private Endpoint Name", - key="data.private_endpoint_connections.private_endpoint_name", - ), - SearchField.set( - name="Request / Response Message", - key="data.private_endpoint_connections.description", - ), - SearchField.set( - name="Transparent Data Encryption", key="data.encryption_protectors.kind" - ), - SearchField.set( - name="Encryption Key", key="data.encryption_protectors.server_key_name" - ), - SearchField.set( - name="Encryption Key Type", key="data.encryption_protectors.server_key_type" - ), - SearchField.set(name="Encryption URI", key="data.encryption_protectors.uri"), - SearchField.set( - name="Tuning Type", key="data.server_automatic_tuning.options.tuning_type" - ), - SearchField.set( - name="Tuning Desired State", - key="data.server_automatic_tuning.options.desired_state", - ), - SearchField.set( - name="Tuning Current State", - key="data.server_automatic_tuning.options.actual_state", - ), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(sql_servers_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(sql_servers_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(sql_servers_count_by_subscription_conf)), - ChartWidget.set( - **get_data_from_yaml(sql_servers_failover_count_by_region_conf) - ), - ChartWidget.set( - **get_data_from_yaml(sql_servers_failover_count_by_server_conf) - ), - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_server_conf)), - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(sql_databases_count_by_tier_conf)), - CardWidget.set(**get_data_from_yaml(sql_servers_total_count_conf)), - ], -) - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({"resource": cst_sql_servers}), -] diff --git a/src/spaceone/inventory/model/sql_servers/data.py b/src/spaceone/inventory/model/sql_servers/data.py deleted file mode 100644 index c674077a..00000000 --- a/src/spaceone/inventory/model/sql_servers/data.py +++ /dev/null @@ -1,517 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - IntType, - BooleanType, - FloatType, - DateTimeType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService, AzureTags - - -class ResourceIdentity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(choices=("None", "SystemAssigned", "UserAssigned")) - - -class PrivateEndpointProperty(Model): - id = StringType() - - -class PrivateLinkServiceConnectionStateProperty(Model): - actions_required = StringType(choices=("None", ""), serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType( - choices=("Approved", "Disconnected", "Pending", "Rejected"), - serialize_when_none=False, - ) - - -class PrivateEndpointConnectionProperties(Model): - private_endpoint = ModelType(PrivateEndpointProperty, serialize_when_none=False) - private_link_service_connection_state = ModelType( - PrivateLinkServiceConnectionStateProperty, serialize_when_none=False - ) - provisioning_state = StringType( - choices=("Approving", "Dropping", "Failed", "Ready", "Rejecting") - ) - - -class ServerPrivateEndpointConnection(Model): - id = StringType(serialize_when_none=False) - connection_id = StringType(serialize_when_none=False) - private_endpoint_name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - properties = ModelType(PrivateEndpointConnectionProperties) - - -class ServerAzureADAdministrator(Model): - id = StringType() - name = StringType(serialize_when_none=False) - administrator_type = StringType( - choices=("ActiveDirectory", ""), serialize_when_none=False - ) - login = StringType(serialize_when_none=False) - sid = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - - -class AutomaticTuningServerOptions(Model): - actual_state = StringType(choices=("Off", "On"), serialize_when_none=False) - desired_state = StringType( - choices=("Default", "Off", "On"), serialize_when_none=False - ) - reason_code = IntType(serialize_when_none=False) - reason_desc = StringType( - choices=("AutoConfigured", "Default", "Disabled"), serialize_when_none=False - ) - tuning_type = StringType( - choices=("createIndex", "dropIndex", "forceLastGoodPlan"), - serialize_when_none=False, - ) - - -class ServerAutomaticTuning(Model): - name = StringType() - id = StringType() - actual_state = StringType( - choices=("Auto", "Custom", "Unspecified"), serialize_when_none=False - ) - desired_state = StringType( - choices=("Default", "Off", "On"), serialize_when_none=False - ) - options = ListType( - ModelType(AutomaticTuningServerOptions, serialize_when_none=False) - ) - type = StringType(serialize_when_none=False) - - -class ServerBlobAuditingPolicy(Model): - name = StringType() - id = StringType() - audit_actions_and_groups = ListType(StringType, serialize_when_none=False) - is_azure_monitor_target_enabled = BooleanType(serialize_when_none=False) - is_storage_secondary_key_in_use = BooleanType(serialize_when_none=False) - queue_delay_ms = IntType(serialize_when_none=False) - retention_days = IntType(serialize_when_none=False) - state = StringType(choices=("Disabled", "Enabled"), serialize_when_none=False) - storage_account_access_key = StringType(serialize_when_none=False) - storage_account_subscription_id = StringType(serialize_when_none=False) - storage_endpoint = StringType(default="-") - type = StringType(serialize_when_none=False) - - -class PartnerInfo(Model): - id = StringType() - location = StringType() - replication_role = StringType( - choices=("Primary", "Secondary"), serialize_when_none=False - ) - - -class FailoverGroupReadOnlyEndpoint(Model): - failover_policy = StringType( - choices=("Disabled", "Enabled"), serialize_when_none=False - ) - - -class FailoverGroupReadWriteEndpoint(Model): - failover_policy = StringType( - choices=("Automatic", "Manual"), serialize_when_none=False - ) - failover_with_data_loss_grace_period_minutes = IntType(serialize_when_none=False) - - -class FailoverGroup(Model): - name = StringType(serialize_when_none=False) - id = StringType() - location = StringType() - databases = ListType(StringType, serialize_when_none=False) - partner_servers = ListType(ModelType(PartnerInfo), serialize_when_none=False) - primary_server = StringType(serialize_when_none=False) - secondary_server = StringType(serialize_when_none=False) - read_only_endpoint = ModelType( - FailoverGroupReadOnlyEndpoint, serialize_when_none=False - ) - read_write_endpoint = ModelType( - FailoverGroupReadWriteEndpoint, serialize_when_none=False - ) - replication_role = StringType( - choices=("Primary", "Secondary"), serialize_when_none=False - ) - replication_state = StringType(serialize_when_none=False) - failover_policy_display = StringType(serialize_when_none=False) - grace_period_display = StringType(serialize_when_none=False) - tags = ListType(ModelType(AzureTags)) - type = StringType(serialize_when_none=False) - - -class SyncGroupSchemaColumn(Model): - data_size = StringType(serialize_when_none=False) - data_type = StringType(serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchemaTable(Model): - columns = ListType(ModelType(SyncGroupSchemaColumn), serialize_when_none=False) - quoted_name = StringType(serialize_when_none=False) - - -class SyncGroupSchema(Model): - master_sync_member_name = StringType(serialize_when_none=False) - tables = ListType(ModelType(SyncGroupSchemaTable), serialize_when_none=False) - - -class SyncGroup(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - conflict_resolution_policy = StringType( - choices=("HubWin", "MemberWin"), serialize_when_none=False - ) - hub_database_password = StringType(serialize_when_none=False) - hub_database_user_name = StringType(serialize_when_none=False) - interval = IntType(serialize_when_none=False) - last_sync_time = DateTimeType(serialize_when_none=False) - schema = ModelType(SyncGroupSchema, serialize_when_none=False) - sync_database_id = StringType(serialize_when_none=False) - sync_state = StringType( - choices=("Error", "Good", "NotReady", "Progressing", "Warning"), - serialize_when_none=False, - ) - type = StringType(serialize_when_none=False) - - -class SyncAgent(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - expiry_time = DateTimeType(serialize_when_none=False) - is_up_to_date = BooleanType(serialize_when_none=False) - last_alive_time = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - state = StringType( - choices=("NeverConnected", "Offline", "Online"), serialize_when_none=False - ) - sync_database_id = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class RetentionPolicy(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class LogSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - - -class MetricSettings(Model): - category = StringType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - retention_policy = ModelType(RetentionPolicy) - time_grain = StringType(serialize_when_none=False) - - -class DiagnosticSettingsResource(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - event_hub_authorization_rule_id = StringType(serialize_when_none=False) - event_hub_name = StringType(serialize_when_none=False) - log_analytics_destination_type = StringType(serialize_when_none=False) - logs = ListType(ModelType(LogSettings), serialize_when_none=False) - metrics = ListType(ModelType(MetricSettings), serialize_when_none=False) - service_bus_rule_id = StringType(serialize_when_none=False) - storage_account_id = StringType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ReplicationLink(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - is_termination_allowed = BooleanType(serialize_when_none=False) - partner_database = StringType(serialize_when_none=False) - partner_location = StringType(serialize_when_none=False) - partner_role = StringType( - choices=("Copy", "NonReadableSecondary", "Primary", "Secondary", "Source"), - serialize_when_none=False, - ) - partner_server = StringType(default="-") - percent_complete = IntType(serialize_when_none=False) - replication_mode = StringType(serialize_when_none=False) - replication_state = StringType( - choices=("CATCH_UP", "PENDING", "SEEDING", "SUSPENDED"), - serialize_when_none=False, - ) - role = StringType( - choices=("Copy", "NonReadableSecondary", "Primary", "Secondary", "Source"), - serialize_when_none=False, - ) - start_time = DateTimeType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Sku(Model): - capacity = IntType(serialize_when_none=False) - family = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - size = StringType(serialize_when_none=False) - tier = StringType(serialize_when_none=False) - - -class Database(Model): - name = StringType(serialize_when_none=False) - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - managed_by = StringType(serialize_when_none=False) - server_name = StringType(serialize_when_none=False) - subscription_id = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - - administrator_login = StringType(default="-") - auto_pause_delay = IntType(serialize_when_none=False) - catalog_collation = StringType( - choices=("DATABASE_DEFAULT", "SQL_Latin1_General_CP1_CI_AS"), - serialize_when_none=False, - ) - collation = StringType(serialize_when_none=False) - create_mode = StringType( - choices=( - "Copy", - "Default", - "OnlineSecondary", - "PointInTimeRestore", - "Recovery", - "Restore", - "RestoreExternalBackup", - "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", - "Secondary", - ), - serialize_when_none=False, - ) - creation_date = DateTimeType(serialize_when_none=False) - current_service_objective_name = StringType(serialize_when_none=False) - current_sku = ModelType(Sku, serialize_when_none=False) - database_id = StringType(serialize_when_none=False) - default_secondary_location = StringType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - elastic_pool_id = StringType(serialize_when_none=False) - failover_group_id = StringType(serialize_when_none=False) - high_availability_replica_count = IntType(serialize_when_none=False) - license_type = StringType( - choices=("BasePrice", "LicenseIncluded"), serialize_when_none=False - ) - long_term_retention_backup_resource_id = StringType(default="-") - maintenance_configuration_id = StringType(serialize_when_none=False) - max_log_size_bytes = IntType(serialize_when_none=False) - max_size_bytes = IntType(serialize_when_none=False) - max_size_gb = FloatType(serialize_when_none=False) - min_capacity = FloatType(serialize_when_none=False) - paused_date = DateTimeType(serialize_when_none=False) - read_scale = StringType(choices=("Disabled", "Enabled"), default="Disabled") - recoverable_database_id = StringType(serialize_when_none=False) - recovery_services_recovery_point_id = StringType(serialize_when_none=False) - requested_service_objective_name = StringType(serialize_when_none=False) - restorable_dropped_database_id = StringType(serialize_when_none=False) - restore_point_in_time = StringType(serialize_when_none=False) - resumed_date = DateTimeType(serialize_when_none=False) - sample_name = StringType( - choices=("AdventureWorksLT", "WideWorldImportersFull", "WideWorldImportersStd"), - serialize_when_none=False, - ) - secondary_type = StringType(choices=("Geo", "Named"), serialize_when_none=False) - source_database_deletion_date = StringType(serialize_when_none=False) - source_database_id = StringType(serialize_when_none=False) - status = StringType( - choices=( - "AutoClosed", - "Copying", - "Creating", - "Disabled", - "EmergencyMode", - "Inaccessible", - "Offline", - "OfflineChangingDwPerformanceTiers", - "OfflineSecondary", - "Online", - "OnlineChangingDwPerformanceTiers", - "Paused", - "Pausing", - "Recovering", - "RecoveryPending", - "Restoring", - "Resuming", - "Scaling", - "Shutdown", - "Standby", - "Suspect", - ), - serialize_when_none=False, - ) - storage_account_type = StringType( - choices=("GRS", "LRS", "ZRS"), serialize_when_none=False - ) - zone_redundant = BooleanType(serialize_when_none=False) - diagnostic_settings_resource = ListType( - ModelType(DiagnosticSettingsResource), serialize_when_none=False - ) - replication_link = ListType(ModelType(ReplicationLink), serialize_when_none=False) - sync_group = ListType(ModelType(SyncGroup), serialize_when_none=False) - sync_agent = ListType(ModelType(SyncAgent), serialize_when_none=False) - sync_group_display = ListType(StringType, serialize_when_none=False) - sync_agent_display = ListType(StringType, serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - pricing_tier_display = StringType(default="-") - service_tier_display = StringType(default="-") - compute_tier = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ElasticPoolPerDatabaseSettings(Model): - max_capacity = FloatType(serialize_when_none=False) - min_capacity = FloatType(serialize_when_none=False) - - -class ElasticPool(Model): - name = StringType(serialize_when_none=False) - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - creation_date = DateTimeType(serialize_when_none=False) - license_type = StringType( - choices=("BasePrice", "LicenseIncluded"), default="BasePrice" - ) - maintenance_configuration_id = StringType(serialize_when_none=False) - max_size_bytes = IntType(serialize_when_none=False) - max_size_gb = FloatType(serialize_when_none=False, default=0) - per_database_settings = ModelType( - ElasticPoolPerDatabaseSettings, serialize_when_none=False - ) - state = StringType( - choices=("Creating", "Disabled", "Ready"), serialize_when_none=False - ) - zone_redundant = BooleanType(serialize_when_none=False) - sku = ModelType(Sku) - per_db_settings_display = StringType(serialize_when_none=False) - pricing_tier_display = StringType(serialize_when_none=False) - databases = ListType(ModelType(Database)) - number_of_databases = IntType(serialize_when_none=False, default=0) - unit_display = (StringType(serialize_when_none=False),) - server_name_display = StringType(serialize_when_none=False) - resource_group_display = StringType(serialize_when_none=False) - tags = ModelType(AzureTags) - type = StringType(serialize_when_none=False) - - -class EncryptionProtector(Model): - id = StringType() - kind = StringType(serialize_when_none=False) - location = StringType() - name = StringType() - server_key_name = StringType(serialize_when_none=False) - server_key_type = StringType( - choices=("AzureKeyVault", "ServiceManaged"), default="ServiceManaged" - ) - subregion = StringType(serialize_when_none=False) - thumbprint = StringType(serialize_when_none=False) - uri = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class RestorableDroppedDatabase(Model): - name = StringType(serialize_when_none=False) - id = StringType() - location = StringType() - creation_date = DateTimeType(serialize_when_none=False) - database_name = StringType(serialize_when_none=False) - deletion_date = DateTimeType(serialize_when_none=False) - earliest_restore_date = DateTimeType(serialize_when_none=False) - edition = StringType(serialize_when_none=False) - elastic_pool_name = StringType(default="-") - max_size_bytes = StringType(serialize_when_none=False) - service_level_objective = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class VirtualNetworkRule(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - subscription_id = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - ignore_missing_vnet_service_endpoint = BooleanType(serialize_when_none=False) - state = StringType( - choices=("Deleting", "InProgress", "Initializing", "Ready", "Unknown"), - serialize_when_none=False, - ) - virtual_network_subnet_id = StringType(serialize_when_none=False) - virtual_network_name_display = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FirewallRule(Model): - id = StringType(serialize_when_none=False) - kind = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - end_ip_address = StringType(serialize_when_none=False) - start_ip_address = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SQLServer(AzureCloudService): - name = StringType() - id = StringType() - identity = ModelType(ResourceIdentity, serialize_when_none=False) - kind = StringType(serialize_when_none=False) - location = StringType() - type = StringType() - administrator_login = StringType(serialize_when_none=False) - azure_ad_admin_name = StringType(default="Not configured") - administrator_login_password = StringType(serialize_when_none=False) - encryption_protectors = ListType( - ModelType(EncryptionProtector), serialize_when_none=False - ) - fully_qualified_domain_name = StringType(serialize_when_none=False) - minimal_tls_version = StringType( - choices=("1.0", "1.1", "1.2"), serialize_when_none=False - ) - private_endpoint_connections = ListType(ModelType(ServerPrivateEndpointConnection)) - public_network_access = StringType(choices=("Disabled", "Enabled")) - state = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - administrators = ModelType(ServerAzureADAdministrator, serialize_when_none=False) - azure_ad_administrators = ListType( - ModelType(ServerAzureADAdministrator, serialize_when_none=False) - ) - server_automatic_tuning = ModelType( - ServerAutomaticTuning, serialize_when_none=False - ) - server_automatic_tuning_display = BooleanType(serialize_when_none=False) - server_auditing_settings = ModelType( - ServerBlobAuditingPolicy, serialize_when_none=False - ) - failover_groups = ListType(ModelType(FailoverGroup), serialize_when_none=False) - databases = ListType(ModelType(Database), serialize_when_none=False) - elastic_pools = ListType(ModelType(ElasticPool), serialize_when_none=False) - deleted_databases = ListType( - ModelType(RestorableDroppedDatabase), serialize_when_none=False - ) - virtual_network_rules = ListType( - ModelType(VirtualNetworkRule), serialize_when_none=False - ) - firewall_rules = ListType(ModelType(FirewallRule), 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", - } diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_server.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_server.yaml deleted file mode 100644 index 01d49f3c..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_server.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Databases Count by Server -query: - aggregate: - - unwind: - path: data.databases - - group: - keys: - - name: name - key: data.databases.server_name - fields: - - name: value - key: data.databases.server_name - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_subscription.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_subscription.yaml deleted file mode 100644 index 33fe4e3b..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Databases Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_tier.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_tier.yaml deleted file mode 100644 index 62af3d2b..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_databases_count_by_tier.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Databases Count by Server -query: - aggregate: - - unwind: - path: data.databases - - group: - keys: - - name: name - key: data.databases.server_name - fields: - - name: value - key: data.databases.server_name - operator: text -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_account.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_account.yaml deleted file mode 100644 index f3e32e66..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_region.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_region.yaml deleted file mode 100644 index 62e79cdc..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_subscription.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_subscription.yaml deleted file mode 100644 index a682ffa0..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_count_by_subscription.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_region.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_region.yaml deleted file mode 100644 index f12cb1c2..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_region.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Failover Count by Region -query: - aggregate: - - unwind: - path: data.failover_groups - - group: - keys: - - name: name - key: data.failover_groups.location - fields: - - name: value - key: data.failover_groups.location - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_server.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_server.yaml deleted file mode 100644 index f12cb1c2..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_failover_count_by_server.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Failover Count by Region -query: - aggregate: - - unwind: - path: data.failover_groups - - group: - keys: - - name: name - key: data.failover_groups.location - fields: - - name: value - key: data.failover_groups.location - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_total_count.yaml b/src/spaceone/inventory/model/sql_servers/widget/sql_servers_total_count.yaml deleted file mode 100644 index bd9c6503..00000000 --- a/src/spaceone/inventory/model/sql_servers/widget/sql_servers_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: SQLServers -cloud_service_type: Server -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/storage_accounts/__init__.py b/src/spaceone/inventory/model/storage_accounts/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/storage_accounts/cloud_service.py b/src/spaceone/inventory/model/storage_accounts/cloud_service.py deleted file mode 100644 index 30f9d29d..00000000 --- a/src/spaceone/inventory/model/storage_accounts/cloud_service.py +++ /dev/null @@ -1,98 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.storage_accounts.data import StorageAccount - -''' -STORAGE_ACCOUNT -''' -# TAB - Default -storage_account_info_meta = ItemDynamicLayout.set_fields('Storage Account', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('State of Primary', 'data.status_of_primary'), - TextDyField.data_source('Performance Tier', 'instance_type'), - TextDyField.data_source('Access Tier', 'data.access_tier'), - TextDyField.data_source('Replication', 'data.sku.name'), - TextDyField.data_source('Account Kind', 'data.kind'), - TextDyField.data_source('Provisioning State', 'data.provisioning_state'), - DateTimeDyField.data_source('Creation Time', 'data.creation_time'), - TextDyField.data_source('Container count', 'data.container_count_display'), - TextDyField.data_source('Blob count', 'data.blob_count_display'), - SizeField.data_source('Blob total size', 'data.blob_size_display') -]) - -# TAB - Networking -storage_group_networking = ItemDynamicLayout.set_fields('Networking', fields=[ - TextDyField.data_source('Is Public', 'data.network_rule_set.is_public_access_allowed'), - TextDyField.data_source('Virtual Network', 'data.network_rule_set.virtual_networks'), - ListDyField.data_source('Firewall Address Range', 'data.network_rule_set.firewall_address_range'), - ListDyField.data_source('Resource Instances', 'data.network_rule_set.resource_access_rules_display'), - TextDyField.data_source('Exceptions', 'data.network_rule_set.bypass'), - TextDyField.data_source('Routing Preference', 'data.routing_preference_display'), - TextDyField.data_source('Publish Microsoft Endpoints', 'data.routing_preference.publish_microsoft_endpoints'), - TextDyField.data_source('Publish Internet Endpoints', 'data.routing_preference.publish_internet_endpoints') -]) - -# TAB - Endpoints -storage_account_primary_endpoints = ItemDynamicLayout.set_fields('Primary Endpoints', fields=[ - TextDyField.data_source('Blob', 'data.primary_endpoints.blob'), - TextDyField.data_source('Queue', 'data.primary_endpoints.queue'), - TextDyField.data_source('Table', 'data.primary_endpoints.table'), - TextDyField.data_source('File', 'data.primary_endpoints.file'), - TextDyField.data_source('Web', 'data.primary_endpoints.web'), - TextDyField.data_source('DFS', 'data.primary_endpoints.dfs'), - TextDyField.data_source('Microsoft Endpoints', 'data.routing_preference.publish_microsoft_endpoints'), - TextDyField.data_source('Internet Endpoints', 'data.routing_preference.publish_internet_endpoints') -]) - -# TAB - Encryption -storage_account_encryption = ItemDynamicLayout.set_fields('Encryption', 'data.encryption', fields=[ - TextDyField.data_source('Key Source', 'key_source'), - TextDyField.data_source('Key Vault URI', 'key_vault_properties.key_vault_uri') -]) - - -# TAB - Geo-Replication -storage_account_geo_replication = TableDynamicLayout.set_fields('Geo-Replication', fields=[ - TextDyField.data_source('Primary Location', 'data.primary_location'), - EnumDyField.data_source('Status of Primary', 'data.status_of_primary', default_state={ - 'safe': ['available'], - 'warning': ['unavailable'] - }), - TextDyField.data_source('Secondary Location', 'data.secondary_location'), - EnumDyField.data_source('Status of Secondary', 'data.status_of_secondary', default_state={ - 'safe': ['available'], - 'warning': ['unavailable'] - }) -]) - -storage_account_meta = CloudServiceMeta.set_layouts( - [storage_account_info_meta, storage_group_networking, storage_account_primary_endpoints, storage_account_encryption, - storage_account_geo_replication]) - - -class StorageResource(CloudServiceResource): - cloud_service_group = StringType(default='StorageAccounts') - - -class StorageAccountResource(StorageResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(StorageAccount) - _metadata = ModelType(CloudServiceMeta, default=storage_account_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 StorageAccountResponse(CloudServiceResponse): - resource = PolyModelType(StorageAccountResource) diff --git a/src/spaceone/inventory/model/storage_accounts/cloud_service_type.py b/src/spaceone/inventory/model/storage_accounts/cloud_service_type.py deleted file mode 100644 index 2b56f574..00000000 --- a/src/spaceone/inventory/model/storage_accounts/cloud_service_type.py +++ /dev/null @@ -1,188 +0,0 @@ -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, \ - SizeField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -storage_accounts_blob_count_by_account_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_count_by_account.yaml') -storage_accounts_blob_count_by_region_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_count_by_region.yaml') -storage_accounts_blob_count_by_resource_group_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_count_by_resource_group.yaml') -storage_accounts_blob_size_by_account_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_size_by_account.yaml') -storage_accounts_blob_size_by_region_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_size_by_region.yaml') -storage_accounts_blob_size_by_resource_group_conf = os.path.join(current_dir, 'widget/storage_accounts_blob_size_by_resource_group.yaml') -storage_accounts_count_by_account_conf = os.path.join(current_dir, 'widget/storage_accounts_count_by_account.yaml') -storage_accounts_count_by_region_conf = os.path.join(current_dir, 'widget/storage_accounts_count_by_region.yaml') -storage_accounts_count_by_resource_group_conf = os.path.join(current_dir, 'widget/storage_accounts_count_by_resource_group.yaml') -storage_accounts_total_blob_count_conf = os.path.join(current_dir, 'widget/storage_accounts_total_blob_count.yaml') -storage_accounts_total_blob_size_conf = os.path.join(current_dir, 'widget/storage_accounts_total_blob_size.yaml') -storage_accounts_total_count_conf = os.path.join(current_dir, 'widget/storage_accounts_total_count.yaml') - -cst_storage_accounts = CloudServiceTypeResource() -cst_storage_accounts.name = 'Instance' -cst_storage_accounts.group = 'StorageAccounts' -cst_storage_accounts.service_code = 'Microsoft.Storage/storageAccounts' -cst_storage_accounts.labels = ['Storage'] -cst_storage_accounts.is_major = True -cst_storage_accounts.is_primary = True -cst_storage_accounts.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-service-accounts.svg', -} -cst_storage_accounts._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Container count', 'data.container_count_display'), - TextDyField.data_source('Blob count', 'data.blob_count_display'), - SizeField.data_source('Blob total size', 'data.blob_size_display'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('SKU', 'data.sku.name'), - TextDyField.data_source('Type', 'data.type'), - TextDyField.data_source('State of Primary', 'data.status_of_primary', options={ - 'is_optional': True - }), - TextDyField.data_source('Performance Tier', 'instance_type', options={ - 'is_optional': True - }), - TextDyField.data_source('Access Tier', 'data.access_tier', options={ - 'is_optional': True - }), - TextDyField.data_source('Replication', 'data.sku.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Kind of Account', 'data.kind', options={ - 'is_optional': True - }), - TextDyField.data_source('Provisioning State', 'data.provisioning_state', options={ - 'is_optional': True - }), - TextDyField.data_source('Is Public', 'data.allow_blob_public_access', options={ - 'is_optional': True - }), - TextDyField.data_source('Virtual Network', 'data.network_acls.virtual_networks', options={ - 'is_optional': True - }), - ListDyField.data_source('Firewall Address Range', 'data.network_acls.firewall_address_range', options={ - 'is_optional': True - }), - ListDyField.data_source('Resource Instances', 'data.network_acls.resource_access_rules_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Exceptions', 'data.network_acls.bypass', options={ - 'is_optional': True - }), - TextDyField.data_source('Routing Preference', 'data.routing_preference_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Publish Microsoft Endpoints', 'data.routing_preference.publish_microsoft_endpoints', options={ - 'is_optional': True - }), - TextDyField.data_source('Publish Internet Endpoints', 'data.routing_preference.publish_internet_endpoints', options={ - 'is_optional': True - }), - TextDyField.data_source('Blob', 'data.primary_endpoints.blob', options={ - 'is_optional': True - }), - TextDyField.data_source('Queue', 'data.primary_endpoints.queue', options={ - 'is_optional': True - }), - TextDyField.data_source('Table', 'data.primary_endpoints.table', options={ - 'is_optional': True - }), - TextDyField.data_source('File', 'data.primary_endpoints.file', options={ - 'is_optional': True - }), - TextDyField.data_source('Web', 'data.primary_endpoints.web', options={ - 'is_optional': True - }), - TextDyField.data_source('DFS', 'data.primary_endpoints.dfs', options={ - 'is_optional': True - }), - TextDyField.data_source('Microsoft Endpoints', 'data.routing_preference.publish_microsoft_endpoints', options={ - 'is_optional': True - }), - TextDyField.data_source('Internet Endpoints', 'data.routing_preference.publish_internet_endpoints', options={ - 'is_optional': True - }), - TextDyField.data_source('Container Name', 'data.container_item.name', options={ - 'is_optional': True - }), - DateTimeDyField.data_source('Container Last Modified', 'data.container_item.last_modified_time', options={ - 'is_optional': True - }), - TextDyField.data_source('Container Public Access Level', 'data.container_item.public_access', options={ - 'is_optional': True - }), - TextDyField.data_source('Container Lease State', 'data.container_item.lease_state', options={ - 'is_optional': True - }), - TextDyField.data_source('Primary Location', 'data.primary_location', options={ - 'is_optional': True - }), - TextDyField.data_source('Secondary Location', 'data.secondary_location', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Container count', key='data.container_count_display', data_type='integer'), - SearchField.set(name='Blob count', key='data.blob_count_display', data_type='integer'), - SearchField.set(name='Blob total size(Bytes)', key='data.blob_size_display', data_type='integer'), - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='SKU', key='data.sku.name'), - SearchField.set(name='Type', key='data.type'), - SearchField.set(name='State of Primary', key='data.status_of_primary'), - SearchField.set(name='Performance Tier', key='instance_type'), - SearchField.set(name='Access Tier', key='data.access_tier'), - SearchField.set(name='Replication', key='data.sku.name'), - SearchField.set(name='Kind of Account', key='data.kind'), - SearchField.set(name='Provisioning State', key='data.provisioning_state'), - SearchField.set(name='Is Public', key='data.allow_blob_public_access', data_type='boolean'), - SearchField.set(name='Virtual Network', key='data.network_acls.virtual_networks'), - SearchField.set(name='Firewall Address Range', key='data.network_acls.firewall_address_range'), - SearchField.set(name='Resource Instances', key='data.network_acls.resource_access_rules_display'), - SearchField.set(name='Exceptions', key='data.network_acls.bypass'), - SearchField.set(name='Routing Preference', key='data.routing_preference_display'), - SearchField.set(name='Publish Microsoft Endpoints', key='data.routing_preference.publish_microsoft_endpoints'), - SearchField.set(name='Publish Internet Endpoints', key='data.routing_preference.publish_internet_endpoints'), - SearchField.set(name='Blob', key='data.primary_endpoints.blob'), - SearchField.set(name='Queue', key='data.primary_endpoints.queue'), - SearchField.set(name='Table', key='data.primary_endpoints.table'), - SearchField.set(name='File', key='data.primary_endpoints.file'), - SearchField.set(name='Web', key='data.primary_endpoints.web'), - SearchField.set(name='DFS', key='data.primary_endpoints.dfs'), - SearchField.set(name='Microsoft Endpoints', key='data.routing_preference.publish_microsoft_endpoints'), - SearchField.set(name='Internet Endpoints', key='data.routing_preference.publish_internet_endpoints'), - SearchField.set(name='Container Name', key='data.container_item.name'), - SearchField.set(name='Container Last Modified', key='data.container_item.last_modified_time', data_type='datetime'), - SearchField.set(name='Container Public Access Level', key='data.container_item.public_access'), - SearchField.set(name='Container Lease State', key='data.container_item.lease_state'), - SearchField.set(name='Primary Location', key='data.primary_location'), - SearchField.set(name='Secondary Location', key='data.secondary_location'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(storage_accounts_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_size_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_size_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(storage_accounts_blob_size_by_account_conf)), - CardWidget.set(**get_data_from_yaml(storage_accounts_total_count_conf)), - CardWidget.set(**get_data_from_yaml(storage_accounts_total_blob_count_conf)), - CardWidget.set(**get_data_from_yaml(storage_accounts_total_blob_size_conf)), - ] -) - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_storage_accounts}), -] diff --git a/src/spaceone/inventory/model/storage_accounts/data.py b/src/spaceone/inventory/model/storage_accounts/data.py deleted file mode 100644 index 960cb5a0..00000000 --- a/src/spaceone/inventory/model/storage_accounts/data.py +++ /dev/null @@ -1,300 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, DateTimeType, DictType, FloatType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -class SubResource(Model): - id = StringType() - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateEndpointRef(Model): - id = StringType(serialize_when_none=False) - ''' - etag = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) - manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), - serialize_when_none=False) - network_interfaces = ListType(StringType(), serialize_when_none=False) # Change to network interfaces id - private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to subnet ID - tags = ModelType(Tags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - ''' - - -class PrivateEndpointConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - link_identifier = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class UserAssignedIdentity(Model): - client_id = StringType(serialize_when_none=False) - principal_id = StringType(serialize_when_none=False) - - -class Identity(Model): - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType(choices=('None', 'SystemAssigned', 'SystemAssigned,UserAssigned', 'UserAssigned'), serialize_when_none=False) - user_assigned_identities = DictType(StringType, ModelType(UserAssignedIdentity), serialize_when_none=False) - - -class ActiveDirectoryProperties(Model): - azure_storage_s_id = StringType(serialize_when_none=False) - domain_guid = StringType(serialize_when_none=False) - domain_name = StringType(serialize_when_none=False) - domain_s_id = StringType(serialize_when_none=False) - forest_name = StringType(serialize_when_none=False) - net_bios_domain_name = StringType(serialize_when_none=False) - - -class AzureFilesIdentityBasedAuthentication(Model): - active_directory_properties = ModelType(ActiveDirectoryProperties, serialize_when_none=False) - default_share_permission = StringType(choices=('None', 'StorageFileDataSmbShareContributor', 'StorageFileDataSmbShareElevatedContributor', 'StorageFileDataSmbShareOwner', 'StorageFileDataSmbShareReader'), serialize_when_none=False) - directory_service_options = StringType(choices=('AADDS', 'AD', 'None'), serialize_when_none=False) - - -class BlobRestoreRange(Model): - end_range = StringType(serialize_when_none=False) - start_range = StringType(serialize_when_none=False) - - -class BlobRestoreParameters(Model): - blob_ranges = ListType(ModelType(BlobRestoreRange), serialize_when_none=False) - time_to_restore = StringType(serialize_when_none=False) - - -class BlobRestoreStatus(Model): - failure_reason = StringType(serialize_when_none=False) - parameters = ModelType(BlobRestoreParameters, serialize_when_none=False) - restore_id = StringType(serialize_when_none=False) - status = StringType(choices=('Complete', 'Failed', 'InProgress'), serialize_when_none=False) - - -class CustomDomain(Model): - name = StringType(serialize_when_none=False) - use_sub_domain_name = BooleanType(serialize_when_none=False) - - -class EncryptionIdentity(Model): - user_assigned_identity = StringType(serialize_when_none=False) - - -class KeyVaultProperties(Model): - current_versioned_key_identifier = StringType(serialize_when_none=False) - key_name = StringType(serialize_when_none=False) - key_vault_uri = StringType(serialize_when_none=False) - key_version = StringType(serialize_when_none=False) - last_key_rotation_timestamp = DateTimeType(serialize_when_none=False) - - -class EncryptionService(Model): - enabled = BooleanType(serialize_when_none=False) - key_type = StringType(choices=('Account', 'Service'), serialize_when_none=False) - last_enabled_time = DateTimeType(serialize_when_none=False) - - -class EncryptionServices(Model): - blob = ModelType(EncryptionService, serialize_when_none=False) - file = ModelType(EncryptionService, serialize_when_none=False) - queue = ModelType(EncryptionService, serialize_when_none=False) - table = ModelType(EncryptionService, serialize_when_none=False) - - -class Encryption(Model): - identity = ModelType(EncryptionIdentity, serialize_when_none=False) - key_source = StringType(choices=('Microsoft.Keyvault', 'Microsoft.Storage')) - key_vault_properties = ModelType(KeyVaultProperties, serialize_when_none=False) - require_infrastructure_encryption = BooleanType(serialize_when_none=False) - services = ModelType(EncryptionServices, serialize_when_none=False) - - -class GeoReplicationStats(Model): - can_failover = BooleanType(serialize_when_none=False) - last_sync_time = StringType(serialize_when_none=False) - status = StringType(choices=('Bootstrap', 'Live', 'Unavailable'), serialize_when_none=False) - - -class KeyCreationTime(Model): - key1 = DateTimeType(serialize_when_none=False) - key2 = DateTimeType(serialize_when_none=False) - - -class KeyPolicy(Model): - key_expiration_period_in_days = IntType(serialize_when_none=False) - - -class IPRule(Model): - action = StringType(serialize_when_none=False) - value = StringType(serialize_when_none=False) - - -class ResourceAccessRule(Model): - resource_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - - -class VirtualNetworkRule(Model): - action = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - state = StringType(choices=('Deprovisioning', 'Failed', 'NetworkSourceDeleted', 'Provisioning', 'Succeeded'), serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -class NetworkRuleSet(Model): - bypass = StringType(choices=('AzureServices', 'Logging', 'Metrics', 'None'), serialize_when_none=False) - default_action = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - is_public_access_allowed = BooleanType(serialize_when_none=False) - firewall_address_range = ListType(StringType, serialize_when_none=False) - ip_rules = ListType(ModelType(IPRule), serialize_when_none=False) - resource_access_rules = ListType(ModelType(ResourceAccessRule), serialize_when_none=False) - resource_access_rules_display = ListType(StringType, serialize_when_none=False) - virtual_network_rules = ListType(ModelType(VirtualNetworkRule), serialize_when_none=False) - virtual_networks = ListType(StringType, serialize_when_none=False) - - -class StorageAccountInternetEndpoints(Model): - blob = StringType(serialize_when_none=False) - dfs = StringType(serialize_when_none=False) - file = StringType(serialize_when_none=False) - web = StringType(serialize_when_none=False) - - -class StorageAccountMicrosoftEndpoints(Model): - blob = StringType(serialize_when_none=False) - dfs = StringType(serialize_when_none=False) - file = StringType(serialize_when_none=False) - web = StringType(serialize_when_none=False) - queue = StringType(serialize_when_none=False) - table = StringType(serialize_when_none=False) - - -class Endpoints(Model): - blob = StringType(serialize_when_none=False) - dfs = StringType(serialize_when_none=False) - file = StringType(serialize_when_none=False) - internet_endpoints = ModelType(StorageAccountInternetEndpoints, serialize_when_none=False) - microsoft_endpoints = ModelType(StorageAccountMicrosoftEndpoints, serialize_when_none=False) - queue = StringType(serialize_when_none=False) - table = StringType(serialize_when_none=False) - web = StringType(serialize_when_none=False) - - -class RoutingPreference(Model): - publish_internet_endpoints = BooleanType(serialize_when_none=False) - publish_microsoft_endpoints = BooleanType(serialize_when_none=False) - routing_choice = StringType(choices=('InternetRouting', 'MicrosoftRouting'), serialize_when_none=False) - - -class SasPolicy(Model): - expiration_action = StringType(serialize_when_none=False) - sas_expiration_period = StringType(serialize_when_none=False) - - -class Sku(Model): - name = StringType(choices=('Premium_LRS', 'Premium_ZRS', 'Standard_GRS', 'Standard_GZRS', 'Standard_LRS', - 'Standard_RAGRS', 'Standard_RAGZRS', 'Standard_ZRS'), serialize_when_none=False) - tier = StringType(choices=('Premium', 'Standard'), serialize_when_none=False) - - -class ContainerItem(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - etag = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - deleted = BooleanType(serialize_when_none=False) - deleted_time = DateTimeType(serialize_when_none=False) - remaining_retention_days = IntType(serialize_when_none=False) - public_access = StringType(serialize_when_none=False) - last_modified_time = DateTimeType(serialize_when_none=False) - lease_state = StringType(serialize_when_none=False) - lease_status = StringType(choices=['LOCKED', 'UNLOCKED']) - lease_duration = StringType(choices=['FIXED', 'INFINITE']) - # metadata = DictType(StringType) - default_encryption_scope = StringType(serialize_when_none=False) - - -class StorageAccount(AzureCloudService): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - container_item = ListType(ModelType(ContainerItem), serialize_when_none=False) - identity = ModelType(Identity, serialize_when_none=False) - is_public = StringType(serialize_when_none=False) - access_tier = StringType(choices=('Cool', 'Hot'), serialize_when_none=False) - allow_blob_public_access = BooleanType(serialize_when_none=False) - allow_cross_tenant_replication = BooleanType(serialize_when_none=False) - allow_shared_key_access = BooleanType(serialize_when_none=False) - azure_files_identity_based_authentication = ModelType(AzureFilesIdentityBasedAuthentication, - serialize_when_none=False) - blob_range_status = ModelType(BlobRestoreStatus, serialize_when_none=False) - creation_time = DateTimeType(serialize_when_none=False) - custom_domain = ModelType(CustomDomain, serialize_when_none=False) - encryption = ModelType(Encryption, serialize_when_none=False) - failover_in_progress = BooleanType(serialize_when_none=False) - geo_replication_stats = ModelType(GeoReplicationStats, serialize_when_none=False) - is_hns_enabled = BooleanType(serialize_when_none=False) - is_nfs_v3_enabled = BooleanType(serialize_when_none=False) - key_creation_time = ModelType(KeyCreationTime, serialize_when_none=False) - key_policy = ModelType(KeyPolicy, serialize_when_none=False) - large_file_shares_state = StringType(choices=('Enabled', 'Disabled'), serialize_when_none=False) - last_geo_failover_time = StringType(serialize_when_none=False) - minimum_tls_version = StringType(choices=('TLS1_0', 'TLS1_1', 'TLS1_2'), serialize_when_none=False) - network_rule_set = ModelType(NetworkRuleSet, serialize_when_none=False) - primary_endpoints = ModelType(Endpoints, serialize_when_none=False) - primary_location = StringType(serialize_when_none=False) - private_endpoint_connections = ListType(ModelType(PrivateEndpointConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Creating', 'ResolvingDNS', 'Succeeded'), serialize_when_none=False) - routing_preference = ModelType(RoutingPreference, serialize_when_none=False) - routing_preference_display = StringType(default='Microsoft network routing') - sas_policy = ModelType(SasPolicy, serialize_when_none=False) - secondary_endpoints = ModelType(Endpoints, serialize_when_none=False) - secondary_location = StringType(default='-') - status_of_primary = StringType(choices=('available', 'unavailable'), serialize_when_none=False) - status_of_secondary = StringType(choices=('available', 'unavailable'), serialize_when_none=False) - supports_https_traffic_only = BooleanType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - type = StringType(serialize_when_none=False) - blob_size_display = FloatType(default=0.0) - blob_count_display = IntType(default=0) - container_count_display = IntType(default=0) - - def reference(self): - return { - "resource_id": self.id, - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", - } diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_account.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_account.yaml deleted file mode 100644 index 67875926..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_account.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: data.blob_count_display - operator: sum - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_region.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_region.yaml deleted file mode 100644 index 048f68e4..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_region.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Count By Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - key: data.blob_count_display - operator: sum - filter: - - key: account - value: true - operator: exists -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code - diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_resource_group.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_resource_group.yaml deleted file mode 100644 index 6c4ddade..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_count_by_resource_group.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - key: data.blob_count_display - operator: sum -options: - chart_type: DONUT \ No newline at end of file diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_account.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_account.yaml deleted file mode 100644 index 97ad9997..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_account.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Size By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: data.blob_size_display - operator: sum - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT - value_options: - key: value - type: size diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_region.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_region.yaml deleted file mode 100644 index f8e28d1d..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_region.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Size by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - key: data.blob_size_display - operator: sum -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: "inventory.Region" - reference_key: region_code - value_options: - key: value - type: size \ No newline at end of file diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_resource_group.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_resource_group.yaml deleted file mode 100644 index a59c0051..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_blob_size_by_resource_group.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Blob Size by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - key: data.blob_size_display - operator: sum -options: - chart_type: DONUT - value_options: - key: value - type: size diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_account.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_account.yaml deleted file mode 100644 index f4d064a1..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_region.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_region.yaml deleted file mode 100644 index f71045f6..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_resource_group.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_resource_group.yaml deleted file mode 100644 index c1b47c2f..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_count_by_resource_group.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - operator: count -options: - chart_type: DONUT \ No newline at end of file diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_count.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_count.yaml deleted file mode 100644 index 30715273..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Total Blob Count -query: - aggregate: - - group: - fields: - - name: value - key: data.blob_count_display - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_size.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_size.yaml deleted file mode 100644 index ea267919..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_blob_size.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Total Blob Size -query: - aggregate: - - group: - fields: - - name: value - key: data.blob_size_display - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 diff --git a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_count.yaml b/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_count.yaml deleted file mode 100644 index f990bf8c..00000000 --- a/src/spaceone/inventory/model/storage_accounts/widget/storage_accounts_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: StorageAccounts -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/virtual_machines/__init__.py b/src/spaceone/inventory/model/virtual_machines/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/virtual_machines/cloud_service.py b/src/spaceone/inventory/model/virtual_machines/cloud_service.py deleted file mode 100644 index d37ea67e..00000000 --- a/src/spaceone/inventory/model/virtual_machines/cloud_service.py +++ /dev/null @@ -1,290 +0,0 @@ -from schematics.types import ( - ModelType, - StringType, - PolyModelType, - FloatType, - DateTimeType, - DictType, - ListType, -) -from spaceone.inventory.libs.schema.metadata.dynamic_field import ( - TextDyField, - DateTimeDyField, - EnumDyField, - SizeField, - ListDyField, -) -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ( - ItemDynamicLayout, - TableDynamicLayout, - ListDynamicLayout, -) -from spaceone.inventory.libs.schema.cloud_service import ( - CloudServiceResource, - CloudServiceResponse, - CloudServiceMeta, - Tags, -) -from spaceone.inventory.model.virtual_machines.data import VirtualMachine - -""" -Virtual Machine -""" - -# TAB Default -# Instance -virtual_machine = ItemDynamicLayout.set_fields( - "Virtual Machine", - fields=[ - TextDyField.data_source("Resource ID", "data.compute.instance_id"), - TextDyField.data_source("VM ID", "data.compute.tags.vm_id"), - EnumDyField.data_source( - "VM State", - "data.compute.instance_state", - default_state={ - "safe": ["RUNNING"], - "warning": ["STARTING", "DEALLOCATING", "STOPPING", "DEALLOCATING"], - "disable": ["DEALLOCATED"], - "alert": ["STOPPED"], - }, - ), - TextDyField.data_source("Instance Type", "data.compute.instance_type"), - TextDyField.data_source("Image", "data.compute.image"), - EnumDyField.data_source( - "Azure Priority", - "data.azure.priority", - default_badge={ - "indigo.500": ["Regular"], - "coral.600": ["Low"], - "peacock.600": ["Spot"], - }, - ), - TextDyField.data_source("Region", "region_code"), - TextDyField.data_source("Availability Zone", "data.compute.az"), - TextDyField.data_source("Key Pair", "data.compute.keypair"), - EnumDyField.data_source( - "Ultra SSD Enabled", - "data.azure.ultra_ssd_enabled", - default_badge={ - "indigo.500": ["true"], - "coral.600": ["false"], - }, - ), - EnumDyField.data_source( - "Write Accelerator Enabled", - "data.azure.write_accelerator_enabled", - default_badge={"indigo.500": ["true"], "coral.600": ["false"]}, - ), - EnumDyField.data_source( - "Boot Diagnostics", - "data.azure.boot_diagnostics", - default_badge={"indigo.500": ["true"], "coral.600": ["false"]}, - ), - ListDyField.data_source( - "Public IP", - "data.nics", - options={"sub_key": "public_ip_address", "delimiter": "
"}, - ), - ListDyField.data_source( - "Security Groups", - "data.compute.security_groups", - options={"sub_key": "display", "delimiter": "
"}, - ), - DateTimeDyField.data_source("Launched At", "data.compute.launched_at"), - ], -) - -vnet = ItemDynamicLayout.set_fields( - "Virtual Network", - fields=[ - TextDyField.data_source("VNet ID", "data.vnet.vnet_id"), - TextDyField.data_source("VNet Name", "data.vnet.vnet_name"), - TextDyField.data_source("Subnet ID", "data.subnet.subnet_id"), - TextDyField.data_source("Subnet Name", "data.subnet.subnet_name"), - ], -) - -vm_os = ItemDynamicLayout.set_fields( - "Operating System", - fields=[ - TextDyField.data_source( - "OS Type", - "data.os.os_type", - options={"translation_id": "PAGE_SCHEMA.OS_TYPE"}, - ), - TextDyField.data_source( - "OS Distribution", - "data.os.os_distro", - options={ - "translation_id": "PAGE_SCHEMA.OS_DISTRO", - }, - ), - TextDyField.data_source( - "OS Architecture", - "data.os.os_arch", - options={ - "translation_id": "PAGE_SCHEMA.OS_ARCH", - }, - ), - TextDyField.data_source( - "OS Version Details", - "data.os.details", - options={ - "translation_id": "PAGE_SCHEMA.OS_DETAILS", - }, - ), - TextDyField.data_source( - "OS License", - "data.os.os_license", - options={ - "translation_id": "PAGE_SCHEMA.OS_LICENSE", - }, - ), - ], -) - -vm_hw = ItemDynamicLayout.set_fields( - "Hardware", - fields=[ - TextDyField.data_source( - "Core", - "data.hardware.core", - options={ - "translation_id": "PAGE_SCHEMA.CPU_CORE", - }, - ), - TextDyField.data_source( - "Memory", - "data.hardware.memory", - options={ - "translation_id": "PAGE_SCHEMA.MEMORY", - }, - ), - ], -) - -azure_vm = ListDynamicLayout.set_layouts( - "Azure VM", layouts=[virtual_machine, vm_os, vm_hw, vnet] -) - -# Tab Disk -disk = TableDynamicLayout.set_fields( - "Disk", - root_path="data.disks", - fields=[ - TextDyField.data_source("Index", "device_index"), - TextDyField.data_source("Name", "tags.disk_name"), - SizeField.data_source("Size", "size"), - TextDyField.data_source("Disk ID", "tags.disk_id"), - TextDyField.data_source("Storage Account Type", "tags.storage_Account_type"), - TextDyField.data_source("IOPS", "tags.iops"), - TextDyField.data_source("Throughput (mbps)", "tags.throughput_mbps"), - TextDyField.data_source("Encryption Set", "tags.disk_encryption_set"), - TextDyField.data_source("Caching", "tags.caching"), - ], -) - -# Tab - NIC -nic = TableDynamicLayout.set_fields( - "NIC", - root_path="data.nics", - fields=[ - TextDyField.data_source("Index", "device_index"), - TextDyField.data_source("Name", "tags.name"), - ListDyField.data_source( - "IP Addresses", "ip_addresses", options={"delimiter": "
"} - ), - TextDyField.data_source("Public IP", "public_ip_address"), - TextDyField.data_source("MAC Address", "mac_address"), - TextDyField.data_source("CIDR", "cidr"), - TextDyField.data_source("etag", "tags.etag"), - EnumDyField.data_source( - "Enable Accelerated Networking", - "tags.enable_accelerated_networking", - default_badge={"indigo.500": ["true"], "coral.600": ["false"]}, - ), - EnumDyField.data_source( - "Enable IP Forwarding", - "tags.enable_ip_forwarding", - default_badge={"indigo.500": ["true"], "coral.600": ["false"]}, - ), - ], -) - -# Tab - Security Group -security_group = TableDynamicLayout.set_fields( - "Network Security Groups", - root_path="data.security_group", - fields=[ - EnumDyField.data_source( - "Direction", - "direction", - default_badge={"indigo.500": ["inbound"], "coral.600": ["outbound"]}, - ), - TextDyField.data_source("Name", "security_group_name"), - EnumDyField.data_source( - "Protocol", "protocol", default_outline_badge=["ALL", "TCP", "UDP", "ICMP"] - ), - TextDyField.data_source("Port Range", "port"), - TextDyField.data_source("Remote", "remote"), - TextDyField.data_source("Priority", "priority"), - EnumDyField.data_source( - "Action", - "action", - default_badge={"indigo.500": ["allow"], "coral.600": ["deny"]}, - ), - TextDyField.data_source("Description", "description"), - ], -) - -# Tab - Load Balancer -lb = TableDynamicLayout.set_fields( - "Load Balancer", - root_path="data.load_balancer", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Endpoint", "endpoint"), - EnumDyField.data_source( - "Type", - "type", - default_badge={"indigo.500": ["network"], "coral.600": ["application"]}, - ), - ListDyField.data_source("Protocol", "protocol", options={"delimiter": "
"}), - ListDyField.data_source("Port", "port", options={"delimiter": "
"}), - EnumDyField.data_source( - "Scheme", - "scheme", - default_badge={ - "indigo.500": ["internet-facing"], - "coral.600": ["internal"], - }, - ), - ], -) - -virtual_machine_meta = CloudServiceMeta.set_layouts( - [azure_vm, disk, nic, security_group, lb] -) - - -class ComputeResource(CloudServiceResource): - cloud_service_group = StringType(default="VirtualMachines") - - -class VirtualMachineResource(ComputeResource): - cloud_service_type = StringType(default="Instance") - data = ModelType(VirtualMachine) - _metadata = ModelType( - CloudServiceMeta, default=virtual_machine_meta, serialized_name="metadata" - ) - name = StringType() - account = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType()) - server_type = StringType(default="VM") - instance_type = StringType(serialize_when_none=False) - instance_size = FloatType(serialize_when_none=False) - launched_at = DateTimeType(serialize_when_none=False) - - -class VirtualMachineResponse(CloudServiceResponse): - resource = PolyModelType(VirtualMachineResource) diff --git a/src/spaceone/inventory/model/virtual_machines/cloud_service_type.py b/src/spaceone/inventory/model/virtual_machines/cloud_service_type.py deleted file mode 100644 index 892858ef..00000000 --- a/src/spaceone/inventory/model/virtual_machines/cloud_service_type.py +++ /dev/null @@ -1,269 +0,0 @@ -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, SizeField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -virtual_machine_total_count_conf = os.path.join(current_dir, 'widget/virtual_machine_total_running_count.yaml') -virtual_machine_total_disk_size_conf = os.path.join(current_dir, 'widget/virtual_machine_total_disk_size.yaml') -virtual_machine_total_memory_size_conf = os.path.join(current_dir, 'widget/virtual_machine_total_memory_size.yaml') -virtual_machine_total_vcpu_count_conf = os.path.join(current_dir, 'widget/virtual_machine_total_vcpu_count.yaml') -virtual_machine_count_by_account_conf = os.path.join(current_dir, 'widget/virtual_machine_count_by_account.yaml') -virtual_machine_count_by_instance_type_conf = os.path.join(current_dir, - 'widget/virtual_machine_count_by_instance_type.yaml') -virtual_machine_count_by_region_conf = os.path.join(current_dir, 'widget/virtual_machine_count_by_region.yaml') - -cst_virtual_machine = CloudServiceTypeResource() -cst_virtual_machine.name = 'Instance' -cst_virtual_machine.group = 'VirtualMachines' -cst_virtual_machine.labels = ['Compute', 'Server'] -cst_virtual_machine.is_major = True -cst_virtual_machine.is_primary = True -cst_virtual_machine.service_code = 'Microsoft.Compute/virtualMachines' -cst_virtual_machine.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-vm.svg', -} - - -cst_virtual_machine._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source('Instance State', 'data.compute.instance_state', default_state={ - 'safe': ['RUNNING'], - 'warning': ['PENDING', 'REBOOTING', 'SHUTTING-DOWN', 'STOPPING', 'STARTING', - 'PROVISIONING', 'STAGING', 'DEALLOCATING', 'REPAIRING'], - 'alert': ['STOPPED', 'DEALLOCATED', 'SUSPENDED'], - 'disable': ['TERMINATED']} - ), - TextDyField.data_source('Cloud Service ID', 'cloud_service_id', options={ - 'is_optional': True - }), - TextDyField.data_source('Instance Type', 'data.compute.instance_type'), - TextDyField.data_source('Core', 'data.hardware.core'), - TextDyField.data_source('Memory', 'data.hardware.memory'), - TextDyField.data_source('Instance ID', 'data.compute.instance_id', options={ - 'is_optional': True - }), - TextDyField.data_source('Key Pair', 'data.compute.keypair', options={ - 'is_optional': True - }), - TextDyField.data_source('Image', 'data.compute.image', options={ - 'is_optional': True - }), - - TextDyField.data_source('Availability Zone', 'data.compute.az'), - TextDyField.data_source('OS Type', 'data.os.os_type', options={ - 'is_optional': True - }), - TextDyField.data_source('OS', 'data.os.os_distro'), - TextDyField.data_source('OS Architecture', 'data.os.os_arch', options={ - 'is_optional': True - }), - TextDyField.data_source('Primary IP', 'data.primary_ip_address'), - ListDyField.data_source('Public DNS', 'data.nics', options={ - 'sub_key': 'tags.public_dns', - 'is_optional': True - }), - ListDyField.data_source('Public IP', 'data.nics', options={ - 'sub_key': 'public_ip_address', - 'is_optional': True - }), - TextDyField.data_source('All IP', 'ip_addresses', options={ - 'is_optional': True - }), - TextDyField.data_source('MAC Address', 'data.nics.mac_address', options={ - 'is_optional': True - }), - TextDyField.data_source('CIDR', 'data.vnet.cidr', options={ - 'is_optional': True - }), - TextDyField.data_source('VNet ID', 'data.vnet.vnet_id', options={ - 'is_optional': True - }), - TextDyField.data_source('VNet Name', 'data.vnet.vnet_name', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet ID', 'data.subnet.subnet_id', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet Name', 'data.subnet.subnet_name', options={ - 'is_optional': True - }), - TextDyField.data_source('Load Balancer Name', 'data.load_balancer.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Load Balancer DNS', 'data.load_balancer.endpoint', options={ - 'is_optional': True - }), - TextDyField.data_source('Ultra SSD Enabled', 'data.azure.ultra_ssd_enabled', options={ - 'is_optional': True - }), - TextDyField.data_source('Write Accelerator Enabled', 'data.azure.write_accelerator_enabled', options={ - 'is_optional': True - }), - TextDyField.data_source('Boot Diagnostics', 'data.azure.boot_diagnostics', options={ - 'is_optional': True - }), - TextDyField.data_source('Priority', 'data.azure.priority', options={ - 'is_optional': True - }), - TextDyField.data_source('Auto Scaling Group', 'data.auto_scaling_group.name', options={ - 'is_optional': True - }), - TextDyField.data_source('CPU Utilization', 'data.monitoring.cpu.utilization.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('Memory Usage', 'data.monitoring.memory.usage.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('Disk Read IOPS', 'data.monitoring.disk.read_iops.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('Disk Write IOPS', 'data.monitoring.disk.write_iops.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - SizeField.data_source('Disk Read Throughput', 'data.monitoring.disk.read_throughput.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - SizeField.data_source('Disk Write Throughput', 'data.monitoring.disk.write_throughput.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('Network Received PPS', 'data.monitoring.network.received_pps.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('Network Send PPS', 'data.monitoring.network.sent_pps.avg', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - SizeField.data_source('Network Received Throughput', 'data.monitoring.network.received_throughput.avg', - options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - SizeField.data_source('Network Sent Throughput', 'data.monitoring.network.sent_throughput.avg', - options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Average)' - }), - TextDyField.data_source('CPU Utilization', 'data.monitoring.cpu.utilization.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Memory Usage', 'data.monitoring.memory.usage.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Disk Read IOPS', 'data.monitoring.disk.read_iops.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Disk Write IOPS', 'data.monitoring.disk.write_iops.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - SizeField.data_source('Disk Read Throughput', 'data.monitoring.disk.read_throughput.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - SizeField.data_source('Disk Write Throughput', 'data.monitoring.disk.write_throughput.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Network Received PPS', 'data.monitoring.network.received_pps.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Network Send PPS', 'data.monitoring.network.sent_pps.max', options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - SizeField.data_source('Network Received Throughput', 'data.monitoring.network.received_throughput.max', - options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - SizeField.data_source('Network Sent Throughput', 'data.monitoring.network.sent_throughput.max', - options={ - 'default': 0, - 'is_optional': True, - 'field_description': '(Daily Max)' - }), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Launched', 'launched_at', options={'is_optional': True}), - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group.resource_group_name'), - SearchField.set(name='IP Address', key='ip_addresses'), - SearchField.set(name='Instance ID', key='data.compute.instance_id'), - SearchField.set(name='Instance State', key='data.compute.instance_state'), - SearchField.set(name='Instance Type', key='data.compute.instance_type'), - SearchField.set(name='Key Pair', key='data.compute.keypair'), - SearchField.set(name='Image', key='data.compute.image'), - SearchField.set(name='Availability Zone', key='data.compute.az'), - SearchField.set(name='OS Type', key='data.os.os_type'), - SearchField.set(name='OS Architecture', key='data.os.os_arch'), - SearchField.set(name='MAC Address', key='data.nics.mac_address'), - SearchField.set(name='Public IP Address', key='data.nics.public_ip_address'), - SearchField.set(name='Public DNS', key='data.nics.tags.public_dns'), - SearchField.set(name='VNet ID', key='data.vnet.vnet_id'), - SearchField.set(name='VNet Name', key='data.vnet.vnet_name'), - SearchField.set(name='Subnet ID', key='data.subnet.subnet_id'), - SearchField.set(name='Subnet Name', key='data.subnet.subnet_name'), - SearchField.set(name='ELB Name', key='data.load_balancer.name'), - SearchField.set(name='ELB DNS', key='data.load_balancer.endpoint'), - SearchField.set(name='Auto Scaling Group', key='data.auto_scaling_group.name'), - SearchField.set(name='Core', key='data.hardware.core', data_type='integer'), - SearchField.set(name='Memory', key='data.hardware.memory', data_type='float'), - SearchField.set(name='Management State', key='state'), - SearchField.set(name='Cloud Service Group', key='cloud_service_group'), - SearchField.set(name='Cloud Service Type', key='cloud_service_type'), - SearchField.set(name='Service Account', key='collection_info.service_accounts', - reference='identity.ServiceAccount'), - SearchField.set(name='Launched', key='data.launched_at'), - ], - widget=[ - CardWidget.set(**get_data_from_yaml(virtual_machine_total_count_conf)), - CardWidget.set(**get_data_from_yaml(virtual_machine_total_vcpu_count_conf)), - CardWidget.set(**get_data_from_yaml(virtual_machine_total_memory_size_conf)), - CardWidget.set(**get_data_from_yaml(virtual_machine_total_disk_size_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_machine_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_machine_count_by_instance_type_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_machine_count_by_account_conf)), - ] -) -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_virtual_machine}), -] diff --git a/src/spaceone/inventory/model/virtual_machines/data.py b/src/spaceone/inventory/model/virtual_machines/data.py deleted file mode 100644 index 8e9d88d7..00000000 --- a/src/spaceone/inventory/model/virtual_machines/data.py +++ /dev/null @@ -1,209 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - FloatType, - DateTimeType, - BooleanType, - IntType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService, AzureTags -from spaceone.inventory.libs.schema.region import RegionResource - -from pydantic import BaseModel - - -# Activity Log -class ActivityLog(Model): - resource_uri = StringType() - - -# Azure -class Azure(Model): - ultra_ssd_enabled = BooleanType(default=False) - write_accelerator_enabled = BooleanType(default=False) - boot_diagnostics = BooleanType(default=True) - priority = StringType(choices=("Regular", "Low", "Spot"), default="Regular") - tags = ListType(ModelType(AzureTags)) - - -# Compute -class SecurityGroups(Model): - display = StringType() - id = StringType() - name = StringType() - - -class ComputeTags(Model): - vm_id = StringType() - - -class Compute(Model): - keypair = StringType() - az = StringType() - instance_state = StringType( - choices=( - "STARTING", - "RUNNING", - "STOPPING", - "STOPPED", - "DEALLOCATING", - "DEALLOCATED", - ) - ) - instance_type = StringType() - launched_at = DateTimeType() - instance_id = StringType(default="") - instance_name = StringType(default="") - security_groups = ListType(ModelType(SecurityGroups)) - image = StringType() - account = StringType(default="") - tags = ModelType(ComputeTags, default={}) - - -# Disk -class DiskTags(Model): - disk_name = StringType() - caching = StringType(choices=("None", "ReadOnly", "ReadWrite")) - storage_account_type = StringType( - choices=("Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS") - ) - disk_encryption_set = StringType(choices=("PMK", "CMK"), default="PMK") - iops = IntType() - throughput_mbps = IntType() - disk_id = StringType() - - -class Disk(Model): - device_index = IntType() - device = StringType(default="") - disk_type = StringType(choices=("os_disk", "data_disk")) - size = FloatType() - tags = ModelType(DiskTags, default={}) - - -# Hardware -class Hardware(Model): - core = IntType(default=0) - memory = FloatType(default=0.0) - - -# Load Balancer -class LoadBalancerTags(Model): - lb_id = StringType() - - -class LoadBalancer(Model): - type = StringType(choices=("application", "network")) - endpoint = StringType() - port = ListType(IntType()) - name = StringType() - protocol = ListType(StringType()) - scheme = StringType(choices=("internet-facing", "internal")) - tags = ModelType(LoadBalancerTags, default={}) - - -# Nic -class NICTags(Model): - name = StringType() - etag = StringType() - enable_accelerated_networking = BooleanType(default=False) - enable_ip_forwarding = BooleanType(default=False) - - -class NIC(Model): - device_index = IntType() - device = StringType(default="") - nic_type = StringType(default="") - ip_addresses = ListType(StringType(), default=[]) - cidr = StringType() - mac_address = StringType(default="") - public_ip_address = StringType() - tags = ModelType(NICTags, default={}) - - -# OS -class OS(Model): - os_distro = StringType() - os_arch = StringType(default="x86_64") - details = StringType() - os_type = StringType(choices=("LINUX", "WINDOWS")) - - -# Resource Group -class ResourceGroup(Model): - resource_group_name = StringType() - resource_group_id = StringType() - - -# Security Group -class SecurityGroup(Model): - protocol = StringType() - remote = StringType() - remote_cidr = StringType(serialize_when_none=False) - remote_id = StringType(serialize_when_none=False) - security_group_name = StringType() - security_group_id = StringType() - description = StringType(default="") - direction = StringType(choices=("inbound", "outbound")) - port_range_min = IntType(serialize_when_none=False) - port_range_max = IntType(serialize_when_none=False) - port = StringType(serialize_when_none=False) - priority = IntType(serialize_when_none=False) - action = StringType(choices=("allow", "deny")) - - -# Subnet -class Subnet(Model): - subnet_name = StringType() - subnet_id = StringType() - cidr = StringType() - - -# Subscription -class Subscription(Model): - subscription_id = StringType() - subscription_name = StringType() - tenant_id = StringType() - tenant_name = StringType(serialize_when_none=False) - domain = StringType(serialize_when_none=False) - - -# VMSS -class VMSS(Model): - scale_set_name = StringType() - capacity = IntType() - admin_username = StringType() - unique_id = StringType() - - -# VNet -class VNet(Model): - vnet_id = StringType() - vnet_name = StringType() - cidr = StringType() - - -class VirtualMachine(AzureCloudService): # Main Class - os = ModelType(OS) - azure = ModelType(Azure) - hardware = ModelType(Hardware) - security_group = ListType(ModelType(SecurityGroup)) - compute = ModelType(Compute) - load_balancer = ListType(ModelType(LoadBalancer)) - vnet = ModelType(VNet) - subnet = ModelType(Subnet) - vmss = ModelType(VMSS, serialize_when_none=False) - activity_log = ModelType(ActivityLog, serialize_when_none=False) - primary_ip_address = StringType(default="") - disks = ListType(ModelType(Disk)) - nics = ListType(ModelType(NIC)) - subscription = ModelType(Subscription) - resource_group = 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", - } diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_account.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_account.yaml deleted file mode 100644 index f7972deb..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_instance_type.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_instance_type.yaml deleted file mode 100644 index 04a0f7ac..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_instance_type.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Count By Instance Type -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: TREEMAP - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_region.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_region.yaml deleted file mode 100644 index a85bfcd3..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_disk_size.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_disk_size.yaml deleted file mode 100644 index 9481ddcb..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_disk_size.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Total Disk Size -query: - aggregate: - - unwind: - path: data.disks - - group: - fields: - - name: value - key: data.disks.size - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 - source_unit: Byte diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_memory_size.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_memory_size.yaml deleted file mode 100644 index 347b008d..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_memory_size.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Total Memory Size -query: - aggregate: - - group: - fields: - - name: value - key: data.hardware.memory - operator: sum -options: - value_options: - key: value - type: size - options: - default: 0 - source_unit: GB diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_running_count.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_running_count.yaml deleted file mode 100644 index 3ba08653..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_running_count.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Total Running Count -query: - aggregate: - - count: - name: value - filter: - - key: data.compute.instance_state - value: RUNNING - operator: eq -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_vcpu_count.yaml b/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_vcpu_count.yaml deleted file mode 100644 index 19a92513..00000000 --- a/src/spaceone/inventory/model/virtual_machines/widget/virtual_machine_total_vcpu_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: VirtualMachines -cloud_service_type: Instance -name: Total vCPU Count -query: - aggregate: - - group: - fields: - - name: value - key: data.hardware.core - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/virtual_networks/__init__.py b/src/spaceone/inventory/model/virtual_networks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/virtual_networks/cloud_service.py b/src/spaceone/inventory/model/virtual_networks/cloud_service.py deleted file mode 100644 index 6038d89a..00000000 --- a/src/spaceone/inventory/model/virtual_networks/cloud_service.py +++ /dev/null @@ -1,119 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, DateTimeType, FloatType - -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, \ - ListDyField, SizeField, StateItemDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout, SimpleTableDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta -from spaceone.inventory.model.virtual_networks.data import VirtualNetwork - -''' -VIRTUAL_NETWORK -''' -# TAB - Default -virtual_network_info_meta = ItemDynamicLayout.set_fields('Virtual Network', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - ListDyField.data_source('DNS servers', 'data.dhcp_options.dns_servers'), - EnumDyField.data_source('DDoS Protection Standard', 'data.enable_ddos_protection', default_state={ - 'safe': ['True'], - 'warning': ['False'] - }), - TextDyField.data_source('Resource GUID', 'data.resource_guid'), - ListDyField.data_source('Address Space', 'data.address_space.address_prefixes') -]) - - -''' -# TAB - Address Space - -# Address space, Address range, Address count -virtual_network_address_space = ItemDynamicLayout.set_fields('Address Space', 'data.address_space', fields=[ - ListDyField.data_source('Address Space', 'address_prefixes'), - TextDyField.data_source('Address Range', ''), - TextDyField.data_source('Address Count', '') -]) -''' - -# TAB - Connected Devices -virtual_network_connected_devices = SimpleTableDynamicLayout.set_fields('Connected Devices', 'data.connected_devices', fields=[ - TextDyField.data_source('Device', 'device'), - TextDyField.data_source('Type', 'type'), - # TextDyField.data_source('IP Address', ''), - TextDyField.data_source('Subnet', 'name') # TODO : 210713 -]) - -# TAB - Subnets -# Name, IPv4, IPv6, Available Ips, Delegated To, Security Group -virtual_network_subnets = SimpleTableDynamicLayout.set_fields('Subnets', 'data.subnets', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Address Prefix', 'address_prefix'), - ListDyField.data_source('IP Address Prefixes', 'address_prefixes'), - TextDyField.data_source('Delegated To', 'delegations.name'), - TextDyField.data_source('Security Group', 'network_security_group.name') -]) - - -# TAB - Firewall -# Name, IP Address, Subnet -virtual_network_firewall = SimpleTableDynamicLayout.set_fields('Firewall', 'data.azure_firewall', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('IP Address', 'ip_configurations.private_ip_address'), - TextDyField.data_source('Subnet', 'subnet') -]) - -# TAB - Peerings -# Name, Peering Status, Peer, Gateway Transit -virtual_network_peerings = SimpleTableDynamicLayout.set_fields('Peerings', 'data.virtual_network_peerings', fields=[ - TextDyField.data_source('Name', 'name'), - EnumDyField.data_source('Peering Status', 'peering_state', default_state={ - 'safe': ['Connected'], - 'warning': ['Disconnected', 'Initiated'] - }), - TextDyField.data_source('Peer', 'remote_virtual_network.id'), - TextDyField.data_source('Gateway Transit', 'allow_gateway_transit') -]) - -virtual_network_service_endpoints = SimpleTableDynamicLayout.set_fields('Service Endpoints', 'data.service_endpoints', fields=[ - TextDyField.data_source('Service', 'service'), - TextDyField.data_source('Subnet', 'subnet'), - EnumDyField.data_source('Status', 'provisioning_state', default_state={ - 'safe': ['Succeeded'], - 'warning': ['Failed', 'Deleting', 'Updating'] - }), - TextDyField.data_source('Locations', 'locations') -]) - -# TAB - Private Endpoints -virtual_network_private_endpoints = SimpleTableDynamicLayout.set_fields('Private Endpoints', 'data.private_endpoints', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Subnet', 'subnet'), - TextDyField.data_source('Resource Group', 'resource_group') -]) - -virtual_network_meta = CloudServiceMeta.set_layouts( - [virtual_network_info_meta, virtual_network_connected_devices, - virtual_network_subnets, virtual_network_firewall, virtual_network_peerings, virtual_network_service_endpoints, - virtual_network_private_endpoints]) - - -class NetworkResource(CloudServiceResource): - cloud_service_group = StringType(default='VirtualNetworks') - - -class VirtualNetworkResource(NetworkResource): - cloud_service_type = StringType(default='Instance') - data = ModelType(VirtualNetwork) - _metadata = ModelType(CloudServiceMeta, default=virtual_network_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class VirtualNetworkResponse(CloudServiceResponse): - resource = PolyModelType(VirtualNetworkResource) diff --git a/src/spaceone/inventory/model/virtual_networks/cloud_service_type.py b/src/spaceone/inventory/model/virtual_networks/cloud_service_type.py deleted file mode 100644 index e49c6f6d..00000000 --- a/src/spaceone/inventory/model/virtual_networks/cloud_service_type.py +++ /dev/null @@ -1,144 +0,0 @@ -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, ListDyField -from spaceone.inventory.libs.schema.cloud_service_type import CloudServiceTypeResource, CloudServiceTypeResponse, \ - CloudServiceTypeMeta -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -virtual_networks_count_by_account_conf = os.path.join(current_dir, 'widget/virtual_networks_count_by_account.yaml') -virtual_networks_count_by_region_conf = os.path.join(current_dir, 'widget/virtual_networks_count_by_region.yaml') -virtual_networks_count_by_subscription_conf = os.path.join(current_dir, 'widget/virtual_networks_count_by_subscription.yaml') -virtual_networks_subnet_count_by_region_conf = os.path.join(current_dir, 'widget/virtual_networks_subnet_count_by_region.yaml') -virtual_networks_subnet_count_by_subscription_conf = os.path.join(current_dir, 'widget/virtual_networks_subnet_count_by_subscription.yaml') -virtual_networks_total_count_conf = os.path.join(current_dir, 'widget/virtual_networks_total_count.yaml') - -cst_virtual_network = CloudServiceTypeResource() -cst_virtual_network.name = 'Instance' -cst_virtual_network.group = 'VirtualNetworks' -cst_virtual_network.service_code = 'Microsoft.Network/virtualNetworks' -cst_virtual_network.labels = ['Networking'] -cst_virtual_network.is_major = True -cst_virtual_network.is_primary = True -cst_virtual_network.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-virtual-networks.svg', -} - -cst_virtual_network._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - - # is_optional fields - Default - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - ListDyField.data_source('DNS servers', 'data.dhcp_options.dns_servers', options={ - 'is_optional': True - }), - TextDyField.data_source('Resource GUID', 'data.resource_guid', options={ - 'is_optional': True - }), - ListDyField.data_source('Address Space', 'data.address_space.address_prefixes', options={ - 'is_optional': True - }), - - # is_optional fields - Connected Devices - TextDyField.data_source('Connected Device', 'data.connected_devices.device', options={ - 'is_optional': True - }), - TextDyField.data_source('Connected Device Type', 'data.connected_devices.type', options={ - 'is_optional': True - }), - TextDyField.data_source('Connected Subnet', 'data.connected_devices.name', options={ - 'is_optional': True - }), - - # is_optional fields -Subnets - TextDyField.data_source('Subnet Name', 'data.subnets.name', options={ - 'is_optional': True - }), - ListDyField.data_source('Subnet IP Prefixes', 'data.subnets.address_prefixes', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet Delegated To', 'data.subnets.delegations.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Subnet Network Security Group', 'data.subnets.network_security_group.name', options={ - 'is_optional': True - }), - - # is optional fields - Firewall - TextDyField.data_source('Firewall Name', 'data.azure_firewall.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall IP Address', 'data.azure_firewall.ip_configurations.private_ip_address', options={ - 'is_optional': True - }), - TextDyField.data_source('Firewall Subnet', 'data.azure_firewall.subnet', options={ - 'is_optional': True - }), - - # is_optional fields - Peerings - TextDyField.data_source('Peering Name', 'data.virtual_network_peerings.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Peer', 'data.virtual_network_peerings.remote_virtual_network.id', options={ - 'is_optional': True - }), - TextDyField.data_source('Peer Gateway Transit', 'data.virtual_network_peerings.allow_gateway_transit', options={ - 'is_optional': True - }), - - # is optional fields - Service Endpoints - TextDyField.data_source('Service Endpoint', 'data.service_endpoints.service', options={ - 'is_optional': True - }), - TextDyField.data_source('Service Endpoint Subnet', 'data.service_endpoints.subnet', options={ - 'is_optional': True - }), - TextDyField.data_source('Service Endpoint Locations', 'data.service_endpoints.locations', options={ - 'is_optional': True - }), - - # is optional fields - Private Endpoints - TextDyField.data_source('Private Endpoint', 'data.private_endpoints.name', options={ - 'is_optional': True - }), - TextDyField.data_source('Private Endpoint Subnet', 'data.private_endpoints.subnet', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='DNS servers', key='data.dhcp_options.dns_servers'), - SearchField.set(name='Resource GUID', key='data.resource_guid'), - SearchField.set(name='Address Space', key='data.address_space.address_prefixes'), - SearchField.set(name='Connected Device', key='data.connected_devices.device'), - SearchField.set(name='Connected Device Type', key='data.connected_devices.type'), - SearchField.set(name='Connected Subnet', key='data.connected_devices.name'), - SearchField.set(name='Subnet Name', key='data.subnets.name'), - SearchField.set(name='Subnet IP Prefixes', key='data.subnets.address_prefixes'), - SearchField.set(name='Subnet Delegated To', key='data.subnets.delegations.name'), - SearchField.set(name='Subnet Network Security Group', key='data.subnets.network_security_group.name'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(virtual_networks_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_networks_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_networks_count_by_subscription_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_networks_subnet_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(virtual_networks_subnet_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(virtual_networks_total_count_conf)), - ] -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_virtual_network}), -] diff --git a/src/spaceone/inventory/model/virtual_networks/data.py b/src/spaceone/inventory/model/virtual_networks/data.py deleted file mode 100644 index 27926fca..00000000 --- a/src/spaceone/inventory/model/virtual_networks/data.py +++ /dev/null @@ -1,888 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType -from spaceone.inventory.libs.schema.resource import AzureCloudService, AzureTags - - -class SubResource(Model): - id = StringType() - - -''' -START OF REF CLASSES -''' - - -class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(Model): - fqdns = ListType(StringType, serialize_when_none=False) - group_id = StringType(serialize_when_none=False) - required_member_name = StringType(serialize_when_none=False) - - -class ExtendedLocation(Model): - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ApplicationSecurityGroupRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfigurationRef(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType(ModelType(ApplicationSecurityGroupRef), serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - private_link_connection_properties = ModelType(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = StringType(default='', serialize_when_none=False) # Change Public IP Address to id - subnet = StringType(default='', serialize_when_none=False) # Change Subnet to id - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -''' -END OF REF CLASSES -''' - - -class AddressSpace(Model): - address_count = IntType(serialize_when_none=False, default=0) - address_prefixes = ListType(StringType, default=['-']) - - -class AutoApproval(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class ApplicationGatewayIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ConnectedDevice(Model): # Customized class, model for connected device lists attached to this virtual network - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - device = StringType(serialize_when_none=False) - - -class CustomDnsConfigPropertiesFormat(Model): - fqdn = StringType(serialize_when_none=False) - ip_addresses = ListType(StringType, serialize_when_none=False) - - -class DdosSettings(Model): - ddos_custom_policy = ModelType(SubResource, serialize_when_none=False) - protected_ip = BooleanType(serialize_when_none=False) - protection_coverage = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - - -class DhcpOptions(Model): - dns_servers = ListType(StringType, default=['Azure provided DNS service']) - - -class Delegation(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(default='-', serialize_when_none=False) - actions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service_name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class FlowLogFormatType(Model): - json = StringType(serialize_when_none=False) - - -class FlowLogFormatParameters(Model): - type = ModelType(FlowLogFormatType, serialize_when_none=False) - version = IntType(serialize_when_none=False) - - -class InboundNatPool(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_port_range_end = IntType(serialize_when_none=False) - frontend_port_range_start = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class InboundNatRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_ip_configurations = ListType(ModelType(NetworkInterfaceIPConfigurationRef), serialize_when_none=False) - target_virtual_machine = ListType(StringType, serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - port_mapping_display = StringType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class LoadBalancingRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - backend_address_pool_display = StringType(serialize_when_none=False) - backend_port = IntType(serialize_when_none=False) - disable_outbound_s_nat = BooleanType(serialize_when_none=False) - enable_floating_ip = BooleanType(serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configuration = ModelType(SubResource, serialize_when_none=False) - frontend_ip_configuration_display = StringType(serialize_when_none=False) - frontend_port = IntType(serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - load_distribution = StringType(choices=('Default', 'SourceIP', 'SourceIPProtocol'), serialize_when_none=False) - load_distribution_display = StringType(serialize_when_none=False) - probe = ModelType(SubResource, serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class OutboundRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allocated_outbound_ports = IntType(serialize_when_none=False) - backend_address_pool = ModelType(SubResource, serialize_when_none=False) - enable_tcp_reset = BooleanType(serialize_when_none=False) - frontend_ip_configurations = ListType(ModelType(SubResource), serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - protocol = StringType(choices=('All', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PublicIPAddressDnsSettingsRef(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class IpTagRef(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class NatGatewaySkuRef(Model): - name = StringType(choices=('Standard', None), serialize_when_none=False) - - -class NatGatewayRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySkuRef, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PublicIPAddressSkuRef(Model): - name = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - - -class PublicIPAddressRef(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettingsRef, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = StringType(serialize_when_none=False) # Change to IP Configuration id - ip_tags = ListType(ModelType(IpTagRef), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nat_gateway = ModelType(NatGatewayRef, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSkuRef, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class FrontendIPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - inbound_nat_pools = ListType(ModelType(InboundNatPool), serialize_when_none=False) - inbound_nat_rules = ListType(ModelType(InboundNatRule), serialize_when_none=False) - load_balancing_rules = ListType(ModelType(LoadBalancingRule), serialize_when_none=False) - outbound_rules = ListType(ModelType(OutboundRule), serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddressRef, serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class RetentionPolicyParameters(Model): - days = IntType(serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - - -class TrafficAnalyticsConfigurationProperties(Model): - enabled = BooleanType(serialize_when_none=False) - traffic_analytics_interval = IntType(serialize_when_none=False) - workspace_id = StringType(serialize_when_none=False) - workspace_region = StringType(serialize_when_none=False) - workspace_resource_id = StringType(serialize_when_none=False) - - -class TrafficAnalyticsProperties(Model): - network_watcher_flow_analytics_configuration = ModelType(TrafficAnalyticsConfigurationProperties, - serialize_when_none=False) - - -class FlowLog(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - enable = BooleanType(serialize_when_none=False) - flow_analytics_configuration = ModelType(TrafficAnalyticsProperties, serialize_when_none=False) - format = ModelType(FlowLogFormatParameters, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - retention_policy = ModelType(RetentionPolicyParameters, serialize_when_none=False) - storage_id = StringType(serialize_when_none=False) - target_resource_guid = StringType(serialize_when_none=False) - target_resource_id = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class IPConfigurationProfile(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class IPConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = StringType(serialize_when_none=False) # Change to PublicIPAddress ID - subnet = StringType(serialize_when_none=False) - - -class IpTag(Model): - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class ServiceAssociationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - allow_delete = BooleanType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - locations = ListType(ModelType(ExtendedLocation), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPolicyDefinition(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - service_resources = ListType(StringType) - - -class ServiceEndpointPolicy(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - service_endpoint_policy_definitions = ListType(ModelType(ServiceEndpointPolicyDefinition), - serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class ServiceEndpointPropertiesFormat(Model): - locations = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - service = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - - -class ResourceNavigationLink(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - link = StringType(serialize_when_none=False) - linked_resource_type = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class Route(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - next_hop_ip_address = StringType(serialize_when_none=False) - next_hop_type = StringType(choices=('Internet', 'None', 'VirtualAppliance', 'VirtualNetworkGateway', 'VnetLocal'), - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - - -class RouteTable(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - disable_bgp_route_propagation = BooleanType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - routes = ListType(ModelType(Route), serialize_when_none=False) - subnets = ListType(StringType, default=[], serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NatGatewaySku(Model): - name = StringType(choices=('Standard', None), serialize_when_none=False) - - -class NatGateway(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_addresses = ListType(ModelType(SubResource), serialize_when_none=False) - public_ip_prefixes = ListType(ModelType(SubResource), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - subnets = ListType(ModelType(SubResource), serialize_when_none=False) - sku = ModelType(NatGatewaySku, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class PrivateLinkServiceConnectionState(Model): - actions_required = StringType(serialize_when_none=False) - description = StringType(serialize_when_none=False) - status = StringType(serialize_when_none=False) - - -class PrivateLinkServiceConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState, serialize_when_none=False) - private_link_service_id = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - request_message = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkServiceIpConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - type = StringType(serialize_when_none=False) - - -class Visibility(Model): - subscriptions = ListType(StringType, serialize_when_none=False) - - -class PrivateEndpointRef(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) - manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), - serialize_when_none=False) - network_interfaces = ListType(StringType(), serialize_when_none=False) # Change to network interfaces id - private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to subnet ID - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpointConnection(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - link_identifier = StringType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateLinkService(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - alias = StringType(serialize_when_none=False) - auto_approval = ModelType(AutoApproval, serialize_when_none=False) - enable_proxy_protocol = BooleanType(serialize_when_none=False) - fqdns = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType(ModelType(PrivateLinkServiceIpConfiguration), serialize_when_none=False) - loadBalancer_frontend_ip_configurations = ListType(ModelType(FrontendIPConfiguration), serialize_when_none=False) - network_interfaces = ListType(StringType, serialize_when_none=False) # Change to network interfaces' id - private_endpoint_connections = ListType(ModelType(PrivateEndpointConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - visibility = ModelType(Visibility, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PublicIPAddressDnsSettings(Model): - domain_name_label = StringType(serialize_when_none=False) - fqdn = StringType(serialize_when_none=False) - reverse_fqdn = StringType(serialize_when_none=False) - - -class PublicIPAddressSku(Model): - name = StringType(choices=('Basic', 'Standard'), serialize_when_none=False) - tier = StringType(choices=('Global', 'Regional'), serialize_when_none=False) - - -class PublicIPAddress(Model): - etag = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - ddos_settings = ModelType(DdosSettings, serialize_when_none=False) - dns_settings = ModelType(PublicIPAddressDnsSettings, serialize_when_none=False) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_address = StringType(serialize_when_none=False) - ip_configuration = ModelType(IPConfiguration, serialize_when_none=False) - ip_tags = ListType(ModelType(IpTag), serialize_when_none=False) - # linked_public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nat_gateway = ModelType(NatGateway, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - public_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - sku = ModelType(PublicIPAddressSku, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class ApplicationSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class SecurityRule(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - access = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - description = StringType(serialize_when_none=False) - destination_address_prefix = StringType(serialize_when_none=False) - destination_address_prefixes = ListType(StringType, serialize_when_none=False) - destination_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - destination_port_range = StringType(serialize_when_none=False) - destination_port_ranges = ListType(StringType, serialize_when_none=False) - direction = StringType(choices=('Inbound', 'Outbound'), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - protocol = StringType(choices=('*', 'Ah', 'Esp', 'Icmp', 'Tcp', 'Udp'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - source_address_prefix = StringType(serialize_when_none=False) - source_address_prefixes = ListType(StringType, serialize_when_none=False) - source_application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - source_port_range = StringType(serialize_when_none=False) - source_port_ranges = ListType(StringType, serialize_when_none=False) - - -class NetworkInterfaceDnsSettings(Model): - applied_dns_servers = ListType(StringType, serialize_when_none=False) - dns_servers = ListType(StringType, serialize_when_none=False) - internal_dns_name_label = StringType(serialize_when_none=False) - internal_domain_name_suffix = StringType(serialize_when_none=False) - internal_fqdn = StringType(serialize_when_none=False) - - -class NetworkInterfaceIPConfiguration(Model): # ip configuration in a network interface - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_security_groups = ListType(ModelType(ApplicationSecurityGroup), serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - private_ip_address_version = StringType(choices=('IPv4', 'IPv6'), serialize_when_none=False) - private_ip_allocation_method = StringType(choices=('Dynamic', 'Static'), serialize_when_none=False) - private_link_connection_properties = ModelType(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties, - serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(PublicIPAddress, serialize_when_none=False) - subnet = StringType(serialize_when_none=False) # Change to Subnet ID - virtual_network_taps = ListType(ModelType(SubResource), serialize_when_none=False) - - -class NetworkInterfaceTapConfiguration(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkSecurityGroup(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - default_security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - flow_logs = ListType(ModelType(FlowLog), serialize_when_none=False) - network_interfaces = StringType(serialize_when_none=False) # Change to Network interfaces' Id - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - security_rules = ListType(ModelType(SecurityRule), serialize_when_none=False) - subnets = ListType(StringType, serialize_when_none=False) # Change to Subnet IDs - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class NetworkInterface(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - dns_settings = ModelType(NetworkInterfaceDnsSettings, serialize_when_none=False) - dscp_configuration = ModelType(SubResource, serialize_when_none=False) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - hosted_workloads = ListType(StringType, serialize_when_none=False) - ip_configurations = ListType(ModelType(NetworkInterfaceIPConfiguration), serialize_when_none=False) - mac_address = StringType(serialize_when_none=False) - migration_phase = StringType(choices=('Abort', 'Commit', 'Committed', 'None', 'Prepare'), serialize_when_none=False) - nic_type = StringType(choices=('Elastic', 'Standard'), serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroup, serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - private_endpoint = ModelType(PrivateEndpointRef, serialize_when_none=False) - private_link_service = ModelType(PrivateLinkService, serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - tap_configurations = ListType(ModelType(NetworkInterfaceTapConfiguration), serialize_when_none=False) - virtual_machine = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class PrivateEndpoint(Model): - etag = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - location = ModelType(ExtendedLocation, serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - name = StringType(serialize_when_none=False) - custom_dns_configs = ListType(ModelType(CustomDnsConfigPropertiesFormat), serialize_when_none=False) - manual_private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), - serialize_when_none=False) - network_interfaces = ListType(ModelType(NetworkInterface), serialize_when_none=False) - private_link_service_connections = ListType(ModelType(PrivateLinkServiceConnection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - resource_group = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -###### Firewall Classes ###### -class AzureFirewallRCAction(Model): - type = StringType(choices=('Allow', 'Deny'), serialize_when_none=False) - - -class AzureFirewallApplicationRuleProtocol(Model): - port = IntType(serialize_when_none=False) - protocol_type = StringType(choices=('Http', 'Https', 'Mssql'), serialize_when_none=False) - - -class AzureFirewallApplicationRule(Model): - description = StringType(serialize_when_none=False) - fqdn_tags = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(ModelType(AzureFirewallApplicationRuleProtocol), serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - target_fqdns = ListType(StringType, serialize_when_none=False) - - -class AzureFirewallApplicationRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallApplicationRule), serialize_when_none=False) - - -class AzureFirewallIPConfiguration(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - private_ip_address = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - public_ip_address = ModelType(SubResource, serialize_when_none=False) - subnet = ModelType(SubResource, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AzureFirewallPublicIPAddress(Model): - address = StringType(serialize_when_none=False) - - -class HubPublicIPAddresses(Model): - address = ListType(ModelType(AzureFirewallPublicIPAddress), serialize_when_none=False) - count = IntType(serialize_when_none=False) - - -class HubIPAddresses(Model): - private_ip_address = StringType(serialize_when_none=False) - public_ips = ModelType(HubPublicIPAddresses, serialize_when_none=False) - - -class AzureFirewallIpGroups(Model): - change_number = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - - -class AzureFirewallNatRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNetworkRule(Model): - description = StringType(serialize_when_none=False) - destination_addresses = ListType(StringType, serialize_when_none=False) - destination_ports = ListType(StringType, serialize_when_none=False) - destination_fqdns = ListType(StringType, serialize_when_none=False) - destination_ip_groups = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - protocols = ListType(StringType, serialize_when_none=False) - source_addresses = ListType(StringType, serialize_when_none=False) - source_ip_groups = ListType(StringType, serialize_when_none=False) - translated_address = StringType(serialize_when_none=False) - translated_fqdn = StringType(serialize_when_none=False) - translated_port = StringType(serialize_when_none=False) - - -class AzureFirewallNatRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = StringType(choices=('Dnat', 'Snat'), serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallNatRule), serialize_when_none=False) - - -class AzureFirewallNetworkRuleCollection(Model): - etag = StringType() - id = StringType() - name = StringType(serialize_when_none=False) - action = ModelType(AzureFirewallRCAction, serialize_when_none=False) - priority = IntType(serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - rules = ListType(ModelType(AzureFirewallNetworkRule), serialize_when_none=False) - - -class AzureFirewallSku(Model): - name = StringType(choices=('AZFW_Hub', 'AZFW_VNet'), serialize_when_none=False) - tier = StringType(choices=('Premium', 'Standard'), serialize_when_none=False) - - -class AzureFirewall(Model): - etag = StringType() - id = StringType() - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - subnet = StringType(serialize_when_none=False) - application_rule_collections = ListType(ModelType(AzureFirewallApplicationRuleCollection), - serialize_when_none=False) - firewall_policy = ModelType(SubResource, serialize_when_none=False) - hub_ip_addresses = ModelType(HubIPAddresses, serialize_when_none=False) - ip_configurations = ListType(ModelType(AzureFirewallIPConfiguration), serialize_when_none=False) - ip_groups = ListType(ModelType(AzureFirewallIpGroups), serialize_when_none=False) - management_ip_configuration = ModelType(AzureFirewallIPConfiguration, serialize_when_none=False) - nat_rule_collections = ListType(ModelType(AzureFirewallNatRuleCollection), serialize_when_none=False) - network_rule_collections = ListType(ModelType(AzureFirewallNetworkRuleCollection), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - sku = ModelType(AzureFirewallSku, serialize_when_none=False) - threat_intel_mode = StringType(choices=('Alert', 'Deny', 'Off'), serialize_when_none=False) - virtual_hub = ModelType(SubResource, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class Subnet(Model): - etag = StringType(serialize_when_none=False) - id = StringType() - name = StringType(serialize_when_none=False) - address_prefix = StringType(serialize_when_none=False) - address_prefixes = ListType(StringType, serialize_when_none=False) - application_gateway_ip_configurations = ListType(ModelType(ApplicationGatewayIPConfiguration, serialize_when_none=False)) - delegations = ListType(ModelType(Delegation), serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource), serialize_when_none=False) - ip_configuration_profiles = ListType(ModelType(IPConfigurationProfile), serialize_when_none=False) - ip_configurations = ListType(ModelType(IPConfiguration), serialize_when_none=False) - azure_firewall = ListType(ModelType(AzureFirewall), serialize_when_none=False) - nat_gateway = ModelType(SubResource, serialize_when_none=False) - network_security_group = ModelType(NetworkSecurityGroup, serialize_when_none=False) - private_endpoint_network_policies = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - private_endpoints = ListType(ModelType(PrivateEndpoint), serialize_when_none=False) - private_link_service_network_policies = StringType(choices=('Disabled', 'Enabled'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - purpose = StringType(serialize_when_none=False) - resource_navigation_links = ListType(ModelType(ResourceNavigationLink, serialize_when_none=False)) - route_table = ModelType(RouteTable, serialize_when_none=False) - service_association_links = ListType(ModelType(ServiceAssociationLink), serialize_when_none=False) - service_endpoint_policies = ListType(ModelType(ServiceEndpointPolicy), serialize_when_none=False) - service_endpoints = ListType(ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class VirtualNetworkBgpCommunities(Model): - regional_community = StringType(serialize_when_none=False) - virtual_network_community = StringType(serialize_when_none=False) - - -class VirtualNetworkPeering(Model): - id = StringType(serialize_when_none=False) - etag = StringType(serialize_when_none=False) - name = StringType() - allow_forwarded_traffic = BooleanType(serialize_when_none=False) - allow_gateway_transit = BooleanType(serialize_when_none=False) - allow_virtual_network_access = BooleanType(serialize_when_none=False) - do_not_verify_remote_gateways = BooleanType(serialize_when_none=False) - peering_state = StringType(choices=('Connected', 'Disconnected', 'Initiated'), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - remote_address_space = ModelType(AddressSpace, serialize_when_none=False) - remote_bgp_communities = ModelType(VirtualNetworkBgpCommunities, serialize_when_none=False) - remote_virtual_network = ModelType(SubResource, serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - use_remote_gateways = BooleanType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class VirtualNetwork(AzureCloudService): # Main Class - id = StringType(serialize_when_none=False) - etag = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(default='-', serialize_when_none=False) - extended_location = ModelType(ExtendedLocation, serialize_when_none=False) - address_space = ModelType(AddressSpace, serialize_when_none=False) - bgp_communities = ModelType(VirtualNetworkBgpCommunities, serialize_when_none=False) - ddos_protection_plan = ModelType(SubResource, serialize_when_none=False) - dhcp_options = ModelType(DhcpOptions, serialize_when_none=False) - enable_ddos_protection = BooleanType(default=False, serialize_when_none=False) - enable_vm_protection = BooleanType(serialize_when_none=False) - ip_allocations = ListType(ModelType(SubResource), serialize_when_none=False) - provisioning_state = StringType(choices=('Deleting', 'Failed', 'Succeeded', 'Updating'), serialize_when_none=False) - resource_guid = StringType(serialize_when_none=False) - service_endpoints = ListType(ModelType(ServiceEndpointPropertiesFormat), serialize_when_none=False) - private_endpoints = ListType(ModelType(PrivateEndpoint), serialize_when_none=False) - connected_devices = ListType(ModelType(ConnectedDevice), serialize_when_none=False) - subnets = ListType(ModelType(Subnet), serialize_when_none=False) - virtual_network_peerings = ListType(ModelType(VirtualNetworkPeering), serialize_when_none=False) - azure_firewall = ListType(ModelType(AzureFirewall), serialize_when_none=False) - type = 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", - } diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_account.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_account.yaml deleted file mode 100644 index fd31940a..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_account.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Count By Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count - filter: - - key: account - value: true - operator: exists -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_region.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_region.yaml deleted file mode 100644 index 72c46b55..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_subscription.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_subscription.yaml deleted file mode 100644 index 7d08c5a3..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_count_by_subscription.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_region.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_region.yaml deleted file mode 100644 index 1a2973c4..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_region.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Subnet Count by Region -query: - aggregate: - - unwind: - path: data.subnets - - group: - keys: - - name: name - key: region_code - fields: - - name: value - key: region_code - operator: count -options: - chart_type: COLUMN diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_subscription.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_subscription.yaml deleted file mode 100644 index 98df63d4..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_subnet_count_by_subscription.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Subnet Count by Subscription -query: - aggregate: - - unwind: - path: data.subnets - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_total_count.yaml b/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_total_count.yaml deleted file mode 100644 index d02f8e6f..00000000 --- a/src/spaceone/inventory/model/virtual_networks/widget/virtual_networks_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: VirtualNetworks -cloud_service_type: Instance -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/vm_scale_sets/__init__.py b/src/spaceone/inventory/model/vm_scale_sets/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/vm_scale_sets/cloud_service.py b/src/spaceone/inventory/model/vm_scale_sets/cloud_service.py deleted file mode 100644 index d44ed302..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/cloud_service.py +++ /dev/null @@ -1,296 +0,0 @@ -from schematics.types import ( - ModelType, - StringType, - PolyModelType, - FloatType, - DateTimeType, -) - -from spaceone.inventory.model.vm_scale_sets.data import VirtualMachineScaleSet -from spaceone.inventory.libs.schema.metadata.dynamic_field import ( - TextDyField, - DateTimeDyField, - EnumDyField, - ListDyField, - SizeField, - StateItemDyField, -) -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ( - ItemDynamicLayout, - TableDynamicLayout, - ListDynamicLayout, - SimpleTableDynamicLayout, -) -from spaceone.inventory.libs.schema.cloud_service import ( - CloudServiceResource, - CloudServiceResponse, - CloudServiceMeta, -) - -""" -VM_SCALE_SET -""" -# TAB - Default -# Instance termination notification(Configuration Tab), over provisioning, proximity placement group, Termination Notification -# application health monitoring(Health and repair Tab), Upgrade Policy(Upgrade Policy Tab), -vm_scale_set_info_meta = ItemDynamicLayout.set_fields( - "VmScaleSets", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Resource ID", "data.id"), - TextDyField.data_source("Resource Group", "data.resource_group"), - TextDyField.data_source("Location", "data.location"), - TextDyField.data_source("Subscription", "data.subscription_name"), - TextDyField.data_source("Subscription ID", "account"), - TextDyField.data_source("Instances", "data.instance_count"), - TextDyField.data_source( - "Operating System", - "data.virtual_machine_profile.os_profile.operating_system", - ), - TextDyField.data_source("Size", "instance_type"), - TextDyField.data_source( - "Virtual network/subnet", - "data.virtual_machine_profile.network_profile.primary_vnet", - ), - TextDyField.data_source("Host group", "data.host_group.id"), - TextDyField.data_source( - "Ephemeral OS Disk", - "data.virtual_machine_profile.storage_profile.os_disk.diff_disk_settings.option.local", - ), - TextDyField.data_source( - "Azure Spot Eviction Policy", "data.virtual_machine_profile.eviction_policy" - ), - TextDyField.data_source( - "Azure Spot Max Price", - "data.virtual_machine_profile.billing_profile.max_price", - ), - TextDyField.data_source( - "Termination Notification", "data.terminate_notification_display" - ), - TextDyField.data_source("OverProvisioning", "data.overprovision"), - TextDyField.data_source( - "Proximity Placement Group", "data.proximity_placement_group_display" - ), - TextDyField.data_source( - "Automatic Repairs", "data.automatic_repairs_policy.enabled" - ), - TextDyField.data_source("Upgrade Policy", "data.upgrade_policy.mode"), - TextDyField.data_source("Fault Domains", "data.platform_fault_domain_count"), - ], -) - -# TAB - Instances -# name, computer name, location, status, provisioning state, fault domain, -# protection policy, and latest model -vm_scale_set_instance = TableDynamicLayout.set_fields( - "Instances", - "data.vm_instances", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Computer Name", "os_profile.computer_name"), - TextDyField.data_source("Location", "location"), - EnumDyField.data_source( - "Status", - "vm_instance_status_profile.statuses.code", - default_state={ - "safe": ["PowerState/running", "PowerState/starting"], - "warning": [ - "PowerState/deallocated", - "PowerState/deallocating", - "PowerState/stopped", - "PowerState/stopping", - "PowerState/unknown", - ], - }, - ), - TextDyField.data_source("Provisioning State", "provisioning_state"), - TextDyField.data_source( - "Protection From Scale-in", "protection_policy.protect_from_scale_in" - ), - TextDyField.data_source( - "Protection From Scale-set Actions", - "protection_policy.protect_from_scale_set_actions", - ), - TextDyField.data_source("Latest Model", "latest_model_applied"), - TextDyField.data_source("Virtual Network", "primary_vnet"), - ], -) - -# TAB - Networking -# IP Configuration, Network interface, Virtual Network, Accelerated Networking, -# Inbound /Outbound port rules(x) , Load balancing(x) -vm_scale_set_info_networking = ItemDynamicLayout.set_fields( - "Networking", - "data.virtual_machine_profile.network_profile", - fields=[ - TextDyField.data_source("Virtual Network", "primary_vnet"), - ], -) - -vm_scale_set_info_network_configuration = SimpleTableDynamicLayout.set_fields( - "Network Configuration", - "data.virtual_machine_profile.network_profile.network_interface_configurations", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source( - "Network interface", "enable_accelerated_networking_display" - ), - TextDyField.data_source( - "Accelerated Networking", "enable_accelerated_networking_display" - ), - TextDyField.data_source("Primary", "primary"), - ], -) - -vm_scale_set_info_ip_configurations = SimpleTableDynamicLayout.set_fields( - "IP Configurations", - "data.virtual_machine_profile.network_profile.network_interface_configurations.ip_configurations", - fields=[ - TextDyField.data_source( - "Public Ip Address Configuration", "public_ip_address_configuration" - ), - TextDyField.data_source( - "Private IP Address Version", "private_ip_address_version" - ), - ], -) - -vm_scale_set_info_network = ListDynamicLayout.set_layouts( - "Networking", - layouts=[ - vm_scale_set_info_networking, - vm_scale_set_info_network_configuration, - vm_scale_set_info_ip_configurations, - ], -) - -# TAB - Scaling -# Instance Count, Scale-in policy -vm_scale_set_scaling_info = ItemDynamicLayout.set_fields( - "Scaling", - fields=[ - TextDyField.data_source("Instance Count", "data.instance_count"), - ListDyField.data_source( - "Scale-in Policy", - "data.scale_in_policy.rules", - options={"delimiter": "
"}, - ), - ], -) - -vm_scale_set_scaling_rules = SimpleTableDynamicLayout.set_fields( - "Autoscale Settings", - "data.virtual_machine_scale_set_power_state", - fields=[ - TextDyField.data_source("Name", "name"), - ListDyField.data_source( - "Profiles", "profiles_display", options={"delimiter": "
"} - ), - TextDyField.data_source("Default", "profiles.capacity.default"), - TextDyField.data_source("Max", "profiles.capacity.maximum"), - TextDyField.data_source("Min", "profiles.capacity.minimum"), - ], -) -vm_scale_set_info_scaling = ListDynamicLayout.set_layouts( - "Scaling", layouts=[vm_scale_set_scaling_info, vm_scale_set_scaling_rules] -) - -# TAB - Disks OS Disks and Data Disks -# Image reference, Storage Type, Size, MAX iops, max throughput, encryption, host caching -# : LUN, Storage Type, Size, MAx iops, max throughput, encryption, host caching -os_disk = ItemDynamicLayout.set_fields( - "OS Disk", - "data.virtual_machine_profile.storage_profile", - fields=[ - TextDyField.data_source("Image Reference", "image_reference_display"), - TextDyField.data_source( - "Storage Account Type", "os_disk.managed_disk.storage_account_type" - ), - SizeField.data_source( - "Size", "os_disk.disk_size_gb", options={"source_unit": "GB"} - ), - TextDyField.data_source("Host Caching", "os_disk.caching"), - ], -) -data_disks = SimpleTableDynamicLayout.set_fields( - "Data Disks", - "data.virtual_machine_profile.storage_profile.data_disks", - fields=[ - TextDyField.data_source("Name", "name"), - TextDyField.data_source("Storage Type", "managed_disk.storage_type"), - SizeField.data_source("Size", "disk_size_gb", options={"source_unit": "GB"}), - TextDyField.data_source("Max IOPS", "disk_iops_read_write"), - TextDyField.data_source("MAX Throughput(MBps)", "disk_m_bps_read_write"), - TextDyField.data_source("Encryption", "disk_encryption_set.id"), - TextDyField.data_source("Host Caching", "caching"), - TextDyField.data_source("LUN", "lun"), - ], -) -vm_scale_set_info_disk = ListDynamicLayout.set_layouts( - "Disks", layouts=[os_disk, data_disks] -) - -# TAB - Operating System -# Operating system, image reference, computer name prefix, administrator username, -# password authentication, vm agent, enable automatic OS upgrades, custom data and cloud init - -vm_scale_set_info_os_profile = ItemDynamicLayout.set_fields( - "Operating System", - fields=[ - TextDyField.data_source( - "Computer Name Prefix", - "data.virtual_machine_profile.os_profile.computer_name_prefix", - ), - TextDyField.data_source( - "Administrator Username", - "data.virtual_machine_profile.os_profile.admin_username", - ), - TextDyField.data_source( - "Operating System", - "data.virtual_machine_profile.os_profile.operating_system", - ), - TextDyField.data_source( - "VM Agent", - "data.virtual_machine_profile.os_profile.linux_configuration.provision_vm_agent", - ), - TextDyField.data_source( - "Automatic OS Upgrades", - "data.upgrade_policy.automatic_os_upgrade_policy.enable_automatic_os_upgrade", - ), - TextDyField.data_source( - "Custom Data", "data.virtual_machine_profile.os_profile.custom_data" - ), - ], -) - -vm_scale_set_meta = CloudServiceMeta.set_layouts( - [ - vm_scale_set_info_meta, - vm_scale_set_instance, - vm_scale_set_info_network, - vm_scale_set_info_scaling, - vm_scale_set_info_disk, - vm_scale_set_info_os_profile, - ] -) - - -class ComputeResource(CloudServiceResource): - cloud_service_group = StringType(default="VMScaleSets") - - -class VmScaleSetResource(ComputeResource): - cloud_service_type = StringType(default="ScaleSet") - data = ModelType(VirtualMachineScaleSet) - _metadata = ModelType( - CloudServiceMeta, default=vm_scale_set_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) - launched_at = DateTimeType(serialize_when_none=False) - - -class VmScaleSetResponse(CloudServiceResponse): - resource = PolyModelType(VmScaleSetResource) diff --git a/src/spaceone/inventory/model/vm_scale_sets/cloud_service_type.py b/src/spaceone/inventory/model/vm_scale_sets/cloud_service_type.py deleted file mode 100644 index 6fada7b2..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/cloud_service_type.py +++ /dev/null @@ -1,106 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -vm_scale_sets_count_by_region_conf = os.path.join(current_dir, 'widget/vm_scale_sets_count_by_region.yaml') -vm_scale_sets_count_by_subscription_conf = os.path.join(current_dir, 'widget/vm_scale_sets_count_by_subscription.yaml') -vm_scale_sets_total_instance_count_conf = os.path.join(current_dir, 'widget/vm_scale_sets_total_instance_count.yaml') - -cst_vm_scale_sets = CloudServiceTypeResource() -cst_vm_scale_sets.name = 'ScaleSet' -cst_vm_scale_sets.group = 'VMScaleSets' -cst_vm_scale_sets.service_code = 'Microsoft.Compute/virtualMachineScaleSets' -cst_vm_scale_sets.labels = ['Compute'] -cst_vm_scale_sets.is_major = True -cst_vm_scale_sets.is_primary = True -cst_vm_scale_sets.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-vm-scale-set.svg', -} - -cst_vm_scale_sets._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - TextDyField.data_source('Instance Count', 'data.instance_count'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Default', 'data.virtual_machine_scale_set_power_state.profiles.capacity.default'), - TextDyField.data_source('Max', 'data.virtual_machine_scale_set_power_state.profiles.capacity.maximum'), - TextDyField.data_source('Min', 'data.virtual_machine_scale_set_power_state.profiles.capacity.minimum'), - TextDyField.data_source('Azure Spot Eviction Policy', 'data.virtual_machine_profile.eviction_policy'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - - # is_optional fields - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - TextDyField.data_source('Virtual network/subnet', 'data.virtual_machine_profile.network_profile.primary_vnet', options={ - 'is_optional': True - }), - TextDyField.data_source('Host group', 'data.host_group.id', options={ - 'is_optional': True - }), - TextDyField.data_source('Ephemeral OS Disk', - 'data.virtual_machine_profile.storage_profile.os_disk.diff_disk_settings.option.local', options={ - 'is_optional': True - }), - TextDyField.data_source('Azure Spot Eviction Policy', 'data.virtual_machine_profile.eviction_policy', options={ - 'is_optional': True - }), - TextDyField.data_source('Azure Spot Max Price', 'data.virtual_machine_profile.billing_profile.max_price', options={ - 'is_optional': True - }), - TextDyField.data_source('Termination Notification', - 'data.virtual_machine_profile.terminate_notification_display', options={ - 'is_optional': True - }), - TextDyField.data_source('OverProvisioning', 'data.overprovision', options={ - 'is_optional': True - }), - TextDyField.data_source('Proximity Placement Group', 'data.proximity_placement_group_display', options={ - 'is_optional': True - }), - TextDyField.data_source('Automatic Repairs', 'data.automatic_repairs_policy.enabled', options={ - 'is_optional': True - }), - TextDyField.data_source('Upgrade Policy', 'data.upgrade_policy.mode', options={ - 'is_optional': True - }), - TextDyField.data_source('Fault Domains (count)', 'data.platform_fault_domain_count', options={ - 'is_optional': True - }) - ], - search=[ - SearchField.set(name='Subscription ID', key='account'), - SearchField.set(name='Subscription Name', key='data.subscription_name'), - SearchField.set(name='Resource Group', key='data.resource_group'), - SearchField.set(name='Location', key='data.location'), - SearchField.set(name='Default', key='data.virtual_machine_scale_set_power_state.profiles.capacity.default'), - SearchField.set(name='Max', key='data.virtual_machine_scale_set_power_state.profiles.capacity.maximum'), - SearchField.set(name='Min', key='data.virtual_machine_scale_set_power_state.profiles.capacity.minimum'), - SearchField.set(name='Azure Spot Eviction Policy', key='data.virtual_machine_profile.eviction_policy'), - SearchField.set(name='Azure Spot Max Price', key='data.virtual_machine_profile.billing_profile.max_price'), - SearchField.set(name='Termination Notification', key='data.virtual_machine_profile.terminate_notification_display'), - SearchField.set(name='OverProvisioning', key='data.overprovision', data_type='boolean'), - SearchField.set(name='Proximity Placement Group', key='data.proximity_placement_group_display'), - SearchField.set(name='Automatic Repairs', key='data.automatic_repairs_policy.enabled', data_type='boolean'), - SearchField.set(name='Upgrade Policy', key='data.upgrade_policy.mode'), - SearchField.set(name='Fault Domains (count)', key='data.platform_fault_domain_count', data_type='integer'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(vm_scale_sets_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(vm_scale_sets_count_by_subscription_conf)), - CardWidget.set(**get_data_from_yaml(vm_scale_sets_total_instance_count_conf)) - ] - -) - - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_vm_scale_sets}), -] diff --git a/src/spaceone/inventory/model/vm_scale_sets/data.py b/src/spaceone/inventory/model/vm_scale_sets/data.py deleted file mode 100644 index 1b2aecff..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/data.py +++ /dev/null @@ -1,877 +0,0 @@ -from schematics import Model -from schematics.types import ( - ModelType, - ListType, - StringType, - IntType, - BooleanType, - DateTimeType, - TimedeltaType, - FloatType, -) -from spaceone.inventory.libs.schema.resource import AzureCloudService, AzureTags - - -class AdditionalCapabilities(Model): # belongs to VmScaleSet - ultra_ssd_enabled = BooleanType(serialize_when_none=False) - - -class AutomaticOSUpgradePolicy(Model): # belongs to VmScaleSet >> UpgradePolicy - disable_automatic_rollback = BooleanType(default=False, serialize_when_none=False) - enable_automatic_os_upgrade = BooleanType(default=False) - - -class AutomaticRepairsPolicy(Model): # belongs to VmScaleSet - enabled = BooleanType(default=False) - grace_period = StringType(serialize_when_none=False) - - -class EmailNotification(Model): - custom_emails = ListType(StringType, serialize_when_none=False) - send_to_subscription_administrator = BooleanType(serialize_when_none=False) - send_to_subscription_co_administrators = BooleanType(serialize_when_none=False) - - -class OperationType(Model): - scale = StringType(serialize_when_none=False) - - -class WebhookNotification(Model): - properties = StringType(serialize_when_none=False) - - -class AutoscaleNotification(Model): - email = ModelType(EmailNotification, serialize_when_none=False) - operation = ModelType(OperationType, serialize_when_none=False) - webhooks = ListType(ModelType(WebhookNotification), serialize_when_none=False) - - -class ScaleRuleMetricDimension(Model): - dimension_name = StringType(serialize_when_none=False) - operator = StringType(choices=("Equals", "NotEquals"), serialize_when_none=False) - values = ListType(StringType, serialize_when_none=False) - - -class MetricTrigger(Model): - dimensions = ListType( - ModelType(ScaleRuleMetricDimension), serialize_when_none=False - ) - metric_name = StringType(serialize_when_none=False) - metric_namespace = StringType(serialize_when_none=False) - metric_resource_uri = StringType(serialize_when_none=False) - operator = StringType( - choices=( - "Equals", - "GreaterThan", - "GreaterThanOrEqual", - "LessThan", - "LessThanOrEqual", - "NotEquals", - ), - serialize_when_none=False, - ) - statistic = StringType( - choices=("Average", "Max", "Min", "Sum"), serialize_when_none=False - ) - threshold = IntType(serialize_when_none=False) - time_aggregation = StringType( - choices=("Average", "Count", "Last", "Maximum", "Minimum", "Total"), - serialize_when_none=False, - ) - time_grain = TimedeltaType(serialize_when_none=False) - time_window = TimedeltaType(serialize_when_none=False) - - -class ScaleCapacity(Model): - default = StringType(serialize_when_none=False) - maximum = StringType(serialize_when_none=False) - minimum = StringType(serialize_when_none=False) - - -class TimeWindow(Model): - end = StringType(serialize_when_none=False) - start = StringType(serialize_when_none=False) - time_zone = StringType(serialize_when_none=False) - - -class RecurrentSchedule(Model): - days = ListType(StringType, serialize_when_none=False) - hours = ListType(IntType, serialize_when_none=False) - minutes = ListType(IntType, serialize_when_none=False) - time_zone = StringType(serialize_when_none=False) - - -class Recurrence(Model): - frequency = StringType( - choices=("Day", "Hour", "Minute", "Month", "None", "Second", "Week", "Year"), - serialize_when_none=False, - ) - schedule = ModelType(RecurrentSchedule) - - -class ScaleAction(Model): - direction = StringType( - choices=("Decrease", "Increase", "None"), serialize_when_none=False - ) - type = StringType( - choices=("ChangeCount", "ExactCount", "PercentChangeCount"), - serialize_when_none=False, - ) - value = StringType(serialize_when_none=False) - cooldown = TimedeltaType(serialize_when_none=False) - - -class ScaleRule(Model): - metric_trigger = ModelType(MetricTrigger, serialize_when_none=False) - scale_action = ModelType(ScaleAction, serialize_when_none=False) - - -class AutoscaleProfile(Model): - capacity = ModelType(ScaleCapacity, serialize_when_none=False) - fixed_date = ModelType(TimeWindow, serialize_when_none=False) - name = StringType(serialize_when_none=False) - recurrence = ModelType(Recurrence, serialize_when_none=False) - rules = ListType(ModelType(ScaleRule), serialize_when_none=False) - - -class AutoscaleSettingResource(Model): # belongs to VmScaleSet - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - enabled = BooleanType(default=True) - notifications = ListType( - ModelType(AutoscaleNotification), serialize_when_none=False - ) - profiles = ListType(ModelType(AutoscaleProfile), serialize_when_none=False) - profiles_display = ListType(StringType, serialize_when_none=False) - target_resource_uri = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - - -class AutoscaleSettingResourceCollection(Model): - next_link = StringType(serialize_when_none=False) - value = ListType(ModelType(AutoscaleSettingResource), serialize_when_none=False) - - -class ApiEntityReference( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - id = StringType(serialize_when_none=False) - - -class BillingProfile(Model): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - max_price = FloatType(serialize_when_none=False) - - -class BootDiagnostics(Model): - # belongs to the VmScaleSet >> VirtualMachineScaleSetVMProfile >> DiagnosticsProfile - enabled = BooleanType(serialize_when_none=False) - storage_uri = StringType(serialize_when_none=False) - - -class DiffDiskOptions(Model): # belongs to VmScaleSet >> DiffDiskSettings - local = StringType(serialize_when_none=False) - - -class DiffDiskSettings(Model): - option = StringType(serialize_when_none=False) - placement = StringType( - choices=("CacheDisk", "ResourceDisk"), serialize_when_none=False - ) - - -class DiagnosticsProfile( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - boot_diagnostics = ModelType(BootDiagnostics, serialize_when_none=False) - - -class ImageReference(Model): - exact_version = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - offer = StringType(serialize_when_none=False) - publisher = StringType(serialize_when_none=False) - sku = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - - -class SshPublicKey( - Model -): # belongs to VmScaleSet >> LinuxConfiguration >> SshConfiguration - key_data = StringType(serialize_when_none=False) - path = StringType(serialize_when_none=False) - - -class SshConfiguration(Model): # belongs to VmScaleSet >> LinuxConfiguration - public_keys = ListType(ModelType(SshPublicKey), serialize_when_none=False) - - -class LinuxConfiguration( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetOSProfile - disable_password_authentication = BooleanType(serialize_when_none=False) - provision_vm_agent = BooleanType(serialize_when_none=False, default=True) - ssh = ModelType(SshConfiguration, serialize_when_none=False) - - -class Plan(Model): # belongs to VmScaleSet - name = StringType(serialize_when_none=False) - product = StringType(serialize_when_none=False) - promotion_code = StringType(serialize_when_none=False) - publisher = StringType(serialize_when_none=False) - - -class RollingUpgradePolicy(Model): # belongs to VmScaleSet >> UpgradePolicy - max_batch_instance_percent = IntType(default=20, serialize_when_none=False) - max_unhealthy_instance_percent = IntType(default=20, serialize_when_none=False) - max_unhealthy_upgraded_instance_percent = IntType( - default=20, serialize_when_none=False - ) - pause_time_between_batches = StringType(default="PT0S", serialize_when_none=False) - - -class ScaleInPolicy(Model): # belongs to VmScaleSet - rules = ListType(StringType, serialize_when_none=False) - - -class TerminateNotificationProfile( - Model -): # belongs to VmScaleSet >> ScheduledEventsProfile - enable = BooleanType(serialize_when_none=False) - not_before_timeout = StringType(default="PT5M", serialize_when_none=False) - - -class ScheduledEventsProfile(Model): # belongs to VmScaleSet - terminate_notification_profile = ModelType( - TerminateNotificationProfile, serialize_when_none=False - ) - - -class SecurityProfile(Model): # belongs to VmScaleSet - encryption_at_host = BooleanType(default=False, serialize_when_none=False) - - -class Settings(Model): - protocol = StringType(serialize_when_none=False) - port = IntType(serialize_when_none=False) - requestPath = StringType(serialize_when_none=False) - - -class Sku(Model): # belongs to VmScaleSet - capacity = IntType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - tier = StringType( - choices=("Standard", "Basic", "", None), - default="Standard", - serialize_when_none=False, - ) - - -class SubResource(Model): # belongs to VmScaleSet - id = StringType(serialize_when_none=False) - - -class InGuestPatchMode(Model): # belongs to VmScaleSet >> PatchSettings - in_guest_patch_mode = StringType( - choices=("AutomaticByOS", "Manual", "AutomaticByPlatform", "", None), - serialize_when_none=False, - ) - - -class PatchSettings(Model): # belongs to VmScaleSet - # patch_mode = ModelType(InGuestPatchMode, serialize_when_none=False) - patch_mode = StringType( - choices=("AutomaticByOS", "Manual", "AutomaticByPlatform"), - serialize_when_none=False, - ) - - -class AdditionalUnattendedContent(Model): # belongs to VmScaleSet - component_name = StringType( - choices=("Microsoft-Windows-Shell-Setup", ""), serialize_when_none=False - ) - content = StringType(serialize_when_none=False) - pass_name = StringType(choices=("OobeSystem", "", None), serialize_when_none=False) - setting_name = StringType( - choices=("AutoLogon", "FirstLogonCommands", "", None), serialize_when_none=False - ) - - -class WinRMListener(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> WindowsConfiguration >> WinRMConfiguration - certificate_url = StringType(serialize_when_none=False) - protocol_types = StringType(choices=("http", "https"), serialize_when_none=False) - - -class WinRMConfiguration(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> WindowsConfiguration - listeners = ListType(ModelType(WinRMListener), serialize_when_none=False) - - -class WindowsConfiguration(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - additional_unattended_content = ListType( - ModelType(AdditionalUnattendedContent), serialize_when_none=False - ) - enable_automatic_updates = BooleanType(serialize_when_none=False) - patch_settings = ModelType(PatchSettings, serialize_when_none=False) - provision_vm_agent = BooleanType(serialize_when_none=False) - time_zone = StringType(serialize_when_none=False) - win_rm = ModelType(WinRMConfiguration, serialize_when_none=False) - - -class UpgradePolicy(Model): # belongs to VmScaleSet - automatic_os_upgrade_policy = ModelType( - AutomaticOSUpgradePolicy, serialize_when_none=False - ) - mode = StringType( - choices=("Manual", "Automatic", "Rolling", None, ""), serialize_when_none=False - ) - rolling_upgrade_policy = ModelType(RollingUpgradePolicy, serialize_when_none=False) - - -class VirtualMachineScaleSetIdentity(Model): # belongs to VmScaleSet - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - type = StringType( - choices=( - "None", - "SystemAssigned", - " SystemAssigned,UserAssigned", - "UserAssigned", - "", - None, - ), - serialize_when_none=False, - ) - - -class VirtualMachineScaleSetExtension(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetExtensionProfile - id = StringType() - name = StringType() - auto_upgrade_minor_version = BooleanType(serialize_when_none=False) - enable_automatic_upgrade = BooleanType(serialize_when_none=False) - force_update_tag = StringType(serialize_when_none=False) - protected_settings = StringType(serialize_when_none=False) - provisioned_after_extensions = ListType(StringType, serialize_when_none=False) - provisioning_state = StringType(serialize_when_none=False) - publisher = StringType(serialize_when_none=False) - settings = ModelType(Settings, serialize_when_none=False) - type = StringType(serialize_when_none=False) - type_handler_version = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetExtensionProfile(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - extensions = ListType( - ModelType(VirtualMachineScaleSetExtension), serialize_when_none=False - ) - extensions_time_budget = StringType(serialize_when_none=False) # ISO 8601 format - - -class VirtualMachineScaleSetNetworkConfigurationDNSSettings(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetNetworkProfile - # >> VirtualMachineScaleSetNetworkConfiguration - dns_servers = ListType(StringType, serialize_when_none=False) - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetNetworkProfile >> - # VirtualMachineScaleSetNetworkConfiguration >> VirtualMachineScaleSetIPConfiguration >> - # VirtualMachineScaleSetPublicIPAddressConfiguration - domain_name_label = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetIpTag(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetNetworkProfile >> - # VirtualMachineScaleSetNetworkConfiguration >> VirtualMachineScaleSetIPConfiguration >> - # VirtualMachineScaleSetPublicIPAddressConfiguration - ip_tag_type = StringType(serialize_when_none=False) - tag = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - # >> VirtualMachineScaleSetNetworkProfile >> VirtualMachineScaleSetNetworkConfiguration - # >> VirtualMachineScaleSetIPConfiguration - name = StringType() - dns_settings = ModelType( - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - serialize_when_none=False, - ) - idle_timeout_in_minutes = IntType(serialize_when_none=False) - ip_tags = ListType( - ModelType(VirtualMachineScaleSetIpTag), serialize_when_none=False - ) - public_ip_address_version = StringType( - choices=("IPv4", "IPv6"), default="IPv4", serialize_when_none=False - ) - public_ip_prefix = ModelType(SubResource, serialize_when_none=False) - - -class VirtualMachineScaleSetIPConfiguration(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - # >> VirtualMachineScaleSetNetworkProfile >> VirtualMachineScaleSetNetworkConfiguration - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - application_gateway_backend_address_pools = ListType( - ModelType(SubResource), serialize_when_none=False - ) - application_security_groups = ListType( - ModelType(SubResource), serialize_when_none=False - ) - load_balancer_backend_address_pools = ListType( - ModelType(SubResource), serialize_when_none=False - ) - load_balancer_inbound_nat_pools = ListType( - ModelType(SubResource), serialize_when_none=False - ) - primary = BooleanType(serialize_when_none=False) - private_ip_address_version = StringType( - choices=("IPv4", "IPv6"), default="IPv4", serialize_when_none=False - ) - public_ip_address_configuration = ModelType( - VirtualMachineScaleSetPublicIPAddressConfiguration, serialize_when_none=False - ) - subnet = ModelType(ApiEntityReference, serialize_when_none=False) - - -class VirtualMachineScaleSetNetworkConfiguration(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetNetworkProfile - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - dns_settings = ModelType( - VirtualMachineScaleSetNetworkConfigurationDNSSettings, serialize_when_none=False - ) - enable_accelerated_networking = BooleanType(serialize_when_none=False) - enable_ip_forwarding = BooleanType(serialize_when_none=False) - ip_configurations = ListType( - ModelType(VirtualMachineScaleSetIPConfiguration), serialize_when_none=False - ) - network_security_group = ModelType(SubResource, serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - - -class VaultCertificate(Model): - # belongs to VmScaleSet >> >> VirtualMachineScaleSetVMProfile >> VaultSecretGroup - certificate_store = StringType(serialize_when_none=False) - certificate_uri = StringType(serialize_when_none=False) - - -class VaultSecretGroup( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - source_vault = ModelType(SubResource, serialize_when_none=False) - vault_certificates = ListType( - ModelType(VaultCertificate), serialize_when_none=False - ) - - -class VirtualMachineScaleSetNetworkProfile( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - health_probe = ModelType(ApiEntityReference, serialize_when_none=False) - network_interface_configurations = ListType( - ModelType(VirtualMachineScaleSetNetworkConfiguration), serialize_when_none=False - ) - primary_vnet = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetOSProfile( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - admin_username = StringType(serialize_when_none=False) - admin_password = StringType(serialize_when_none=False) - computer_name_prefix = StringType(serialize_when_none=False) - custom_data = StringType(serialize_when_none=False, default="") - linux_configuration = ModelType(LinuxConfiguration, serialize_when_none=False) - secrets = ListType(ModelType(VaultSecretGroup), serialize_when_none=False) - windows_configuration = ModelType(WindowsConfiguration, serialize_when_none=False) - operating_system = StringType(serialize_when_none=False) - - -class DiskEncryptionSetParameters(Model): - id = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetManagedDiskParameters(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - # >> VirtualMachineScaleSetStorageProfile >> VirtualMachineScaleSetDataDisk - disk_encryption_set = ModelType( - DiskEncryptionSetParameters, serialize_when_none=False - ) - storage_account_type = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetDataDisk(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetStorageProfile - name = StringType(serialize_when_none=False) - caching = StringType( - choices=("None", "ReadOnly", "ReadWrite", "", None), serialize_when_none=False - ) - create_option = StringType( - choices=("Attach", "Empty", "FromImage", None, ""), - default="Empty", - serialize_when_none=False, - ) - disk_iops_read_write = IntType(serialize_when_none=False) - disk_m_bps_read_write = IntType(serialize_when_none=False) - disk_size_gb = IntType(serialize_when_none=False) - lun = IntType(serialize_when_none=False) - managed_disk = ModelType( - VirtualMachineScaleSetManagedDiskParameters, serialize_when_none=False - ) - write_accelerator_enabled = BooleanType(serialize_when_none=False) - - -class VirtualHardDisk(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetStorageProfile - # >> VirtualMachineScaleSetOSDisk - uri = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetOSDisk(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile >> VirtualMachineScaleSetStorageProfile - name = StringType() - caching = StringType( - choices=("None", "ReadOnly", "ReadWrite"), - default="None", - serialize_when_none=False, - ) - create_option = StringType( - choices=("Attach", "Empty", "FromImage"), - default="Empty", - serialize_when_none=False, - ) - diff_disk_settings = ModelType( - DiffDiskSettings, default=None, serialize_when_none=False - ) - disk_size_gb = IntType(serialize_when_none=False) - image = ModelType(VirtualHardDisk, serialize_when_none=False) - managed_disk = ModelType( - VirtualMachineScaleSetManagedDiskParameters, serialize_when_none=False - ) - os_type = StringType(choices=("Linux", "Windows"), serialize_when_none=False) - vhd_containers = ListType(StringType, serialize_when_none=False) - write_accelerator_enabled = BooleanType(serialize_when_none=False) - - -class VirtualMachineScaleSetStorageProfile( - Model -): # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - data_disks = ListType( - ModelType(VirtualMachineScaleSetDataDisk), serialize_when_none=False - ) - image_reference = ModelType(ImageReference, serialize_when_none=False) - os_disk = ModelType(VirtualMachineScaleSetOSDisk, serialize_when_none=False) - image_reference_display = StringType(serialize_when_none=False) - - -class VirtualMachineScaleSetVMProfile(Model): # belongs to VmScaleSet - billing_profile = ModelType(BillingProfile, serialize_when_none=False) - diagnostics_profile = ModelType(DiagnosticsProfile, serialize_when_none=False) - eviction_policy = StringType( - choices=("Deallocate", "Delete", "None"), default="None" - ) - extension_profile = ModelType( - VirtualMachineScaleSetExtensionProfile, serialize_when_none=False - ) - license_type = StringType( - choices=("Windows_Client", "Windows_Server", "RHEL_BYOS", "SLES_BYOS", None), - serialize_when_none=False, - ) - network_profile = ModelType( - VirtualMachineScaleSetNetworkProfile, serialize_when_none=False - ) - os_profile = ModelType(VirtualMachineScaleSetOSProfile, serialize_when_none=False) - priority = StringType( - choices=("Low", "Regular", "Spot", "", None), serialize_when_none=False - ) - scheduled_events_profile = ModelType( - ScheduledEventsProfile, serialize_when_none=False - ) - security_profile = ModelType(SecurityProfile, serialize_when_none=False) - storage_profile = ModelType( - VirtualMachineScaleSetStorageProfile, serialize_when_none=False - ) - terminate_notification_display = StringType(serialize_when_none=False) - - -# vm instances class -class InstanceViewStatus(Model): - code = StringType(serialize_when_none=False) - display_status = StringType(serialize_when_none=False) - level = StringType(choices=("Error", "Info", "Warning"), serialize_when_none=False) - message = StringType(serialize_when_none=False) - time = DateTimeType(serialize_when_none=False) - - -class VirtualMachineExtensionInstanceView(Model): - name = StringType(serialize_when_none=False) - statuses = ListType(ModelType(InstanceViewStatus)) - substatuses = ListType(ModelType(InstanceViewStatus)) - type = StringType(serialize_when_none=False) - type_handler_version = StringType(serialize_when_none=False) - display_status = StringType(serialize_when_none=False) - - -class VirtualMachineExtension(Model): - id = StringType(serialize_when_none=False) - location = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - auto_upgrade_minor_version = BooleanType(serialize_when_none=False) - enable_automatic_upgrade = BooleanType(serialize_when_none=False) - force_update_tag = StringType(serialize_when_none=False) - instance_view = ModelType(VirtualMachineExtensionInstanceView) - protected_settings = StringType(serialize_when_none=False) - provisioning_state = StringType(serialize_when_none=False) - publisher = StringType(serialize_when_none=False) - settings = ModelType(Settings, serialize_when_none=False) - type = StringType(serialize_when_none=False) - type_handler_version = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - - -class KeyVaultSecretReference(Model): - secret_url = StringType(serialize_when_none=False) - source_vault = ModelType(SubResource, serialize_when_none=False) - - -class KeyVaultKeyReference(Model): - key_url = StringType(serialize_when_none=False) - source_vault = ModelType(SubResource, serialize_when_none=False) - - -class DiskEncryptionSettings(Model): - disk_encryption_key = ModelType(KeyVaultSecretReference, serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - key_encryption_key = ModelType(KeyVaultKeyReference, serialize_when_none=False) - - -class ManagedDiskParameters(Model): - # belongs to VmScaleSet >> VirtualMachineScaleSetVMProfile - # >> VirtualMachineScaleSetStorageProfile >> VirtualMachineScaleSetDataDisk - disk_encryption_set = ModelType( - DiskEncryptionSetParameters, serialize_when_none=False - ) - storage_account_type = StringType(serialize_when_none=False) - storage_type = StringType(serialize_when_none=False) - id = StringType(serialize_when_none=False) - - -class OSDisk(Model): - name = StringType(serialize_when_none=False) - caching = StringType( - choices=("None", "ReadOnly", "ReadWrite"), - default="None", - serialize_when_none=False, - ) - create_option = StringType( - choices=("Attach", "Empty", "FromImage"), - default="Empty", - serialize_when_none=False, - ) - diff_disk_settings = ModelType(DiffDiskSettings, serialize_when_none=False) - disk_size_gb = IntType(serialize_when_none=False) - encryption_settings = ModelType(DiskEncryptionSettings, serialize_when_none=False) - image = ModelType(VirtualHardDisk, serialize_when_none=False) - managed_disk = ModelType(ManagedDiskParameters, serialize_when_none=False) - os_type = StringType(choices=("Linux", "Windows"), serialize_when_none=False) - vhd = ModelType(VirtualHardDisk, serialize_when_none=False) - write_accelerator_enabled = BooleanType(serialize_when_none=False) - - -class DataDisk(Model): - caching = StringType( - choices=("None", "ReadOnly", "ReadWrite", None), serialize_when_none=False - ) - name = StringType(serialize_when_none=False) - create_option = StringType( - choices=("Attach", "Empty", "FromImage", None), - default="Empty", - serialize_when_none=False, - ) - disk_iops_read_write = IntType(serialize_when_none=False) - disk_m_bps_read_write = IntType(serialize_when_none=False) - disk_size_gb = IntType(serialize_when_none=False) - lun = IntType(serialize_when_none=False) - managed_disk = ModelType(ManagedDiskParameters, serialize_when_none=False) - write_accelerator_enabled = BooleanType(serialize_when_none=False) - image = ModelType(VirtualHardDisk, serialize_when_none=False) - to_be_detached = BooleanType(serialize_when_none=False) - vhd = ModelType(VirtualHardDisk, serialize_when_none=False) - - -class StorageProfile(Model): - data_disks = ListType(ModelType(DataDisk), serialize_when_none=False) - image_reference = ModelType(ImageReference, serialize_when_none=False) - os_disk = ModelType(OSDisk, serialize_when_none=False) - - -class VirtualMachineScaleSetVMProtectionPolicy(Model): - protect_from_scale_in = BooleanType(default=False) - protect_from_scale_set_actions = BooleanType(default=False) - - -class OSProfile(Model): # belongs to VirtualMachineScaleSetVM - admin_username = StringType(serialize_when_none=False) - admin_password = StringType(serialize_when_none=False) - allow_extension_operations = BooleanType(serialize_when_none=False) - computer_name = StringType(serialize_when_none=False) - custom_data = StringType(serialize_when_none=False) - linux_configuration = ModelType(LinuxConfiguration, serialize_when_none=False) - windows_configuration = ModelType(WindowsConfiguration, serialize_when_none=False) - require_guest_provision_signal = BooleanType(serialize_when_none=False) - secrets = ListType(ModelType(VaultSecretGroup), serialize_when_none=False) - - -class HardwareProfile(Model): # belongs to VMScaleSet >> vm instances - vm_size = StringType(serialize_when_none=False) - - -class NetworkInterfaceReference(Model): - id = StringType(serialize_when_none=False) - primary = BooleanType(serialize_when_none=False) - - -class NetworkProfile(Model): # belongs to VirtualMachineScaleSetVM - network_interfaces = ListType( - ModelType(NetworkInterfaceReference), serialize_when_none=False - ) - - -class VirtualMachineScaleSetVMNetworkProfileConfiguration(Model): - network_interface_configurations = ListType( - ModelType(VirtualMachineScaleSetNetworkConfiguration), serialize_when_none=False - ) - - -class VirtualMachineAgentInstanceView(Model): - statuses = ListType(ModelType(InstanceViewStatus), serialize_when_none=False) - vm_agent_version = StringType(serialize_when_none=False) - display_status = StringType(serialize_when_none=False) # # - - -class VirtualMachineExtensionVMInstanceView(Model): - assigned_host = StringType(serialize_when_none=False) - # boot_diagnostics = ModelType(BootDiagnosticsInstanceView, serialize_when_none=False) - extensions = ListType( - ModelType(VirtualMachineExtensionInstanceView), serialize_when_none=False - ) - placement_group_id = StringType(serialize_when_none=False) - statuses = ListType(ModelType(InstanceViewStatus), serialize_when_none=False) - display_status = StringType(serialize_when_none=False) - vm_agent = ModelType(VirtualMachineAgentInstanceView, serialize_when_none=False) - - -class VirtualMachineScaleSetVM(Model): # data model for actual instances - id = StringType() - instance_id = StringType() - location = StringType() - name = StringType() - plan = ModelType(Plan, serialize_when_none=False) - additional_capabilities = ModelType( - AdditionalCapabilities, serialize_when_none=False - ) - available_set = ModelType(SubResource, serialize_when_none=False) - diagnostics_profile = ModelType(DiagnosticsProfile, serialize_when_none=False) - hardware_profile = ModelType(HardwareProfile, serialize_when_none=False) - latest_model_applied = BooleanType(default=True, serialize_when_none=False) - licence_type = StringType(serialize_when_none=False) - model_definition_applied = StringType(serialize_when_none=False) - network_profile = ModelType(NetworkProfile, serialize_when_none=False) - network_profile_configuration = ModelType( - VirtualMachineScaleSetVMNetworkProfileConfiguration, serialize_when_none=False - ) - primary_vnet = StringType(serialize_when_none=False) - os_profile = ModelType(OSProfile, serialize_when_none=False) - protection_policy = ModelType( - VirtualMachineScaleSetVMProtectionPolicy, serialize_when_none=False - ) - provisioning_state = StringType(serialize_when_none=False) - vm_instance_status_display = StringType(serialize_when_none=False) - security_profile = ModelType(SecurityProfile, serialize_when_none=False) - storage_profile = ModelType(StorageProfile, serialize_when_none=False) - vm_id = StringType(serialize_when_none=False) - vm_instance_status_profile = ModelType( - VirtualMachineExtensionVMInstanceView, serialize_when_none=False - ) - resources = ListType(ModelType(VirtualMachineExtension), serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - - -class VirtualMachineScaleSetPowerState(Model): - # id = StringType() - # vm_instances = ListType(ModelType(VirtualMachineScaleSetVM), serialize_when_none=False) - # instance_count = IntType() - # mode = StringType(choices=('Custom', 'Manual'), serialize_when_none=False) - location = StringType() - profiles = ListType(ModelType(AutoscaleProfile), serialize_when_none=False) - enabled = BooleanType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - notifications = ListType( - ModelType(AutoscaleNotification), serialize_when_none=False - ) - target_resource_uri = StringType(serialize_when_none=False) - tags = ModelType(AzureTags, serialize_when_none=False) - - -class VirtualMachineScaleSet(AzureCloudService): - id = StringType(serialize_when_none=False) - autoscale_setting_resource_collection = ModelType( - AutoscaleSettingResourceCollection, serialize_when_none=False - ) - location = StringType(serialize_when_none=False) - identity = ModelType(VirtualMachineScaleSetIdentity, serialize_when_none=False) - instance_count = IntType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - plan = ModelType(Plan, serialize_when_none=False) - additional_capabilities = ModelType( - AdditionalCapabilities, serialize_when_none=False - ) - automatic_repairs_policy = ModelType( - AutomaticRepairsPolicy, serialize_when_none=False - ) - do_not_run_extensions_on_overprovisioned_v_ms = BooleanType( - serialize_when_none=False - ) - host_group = ModelType(SubResource, serialize_when_none=False) - overprovision = BooleanType(default=True, serialize_when_none=False) - platform_fault_domain_count = IntType(serialize_when_none=False) - provisioning_state = StringType( - choices=("Failed", "Succeeded"), serialize_when_none=False - ) - proximity_placement_group = ModelType(SubResource, serialize_when_none=False) - proximity_placement_group_display = StringType( - serialize_when_none=False, default="None" - ) - scale_in_policy = ModelType(ScaleInPolicy, serialize_when_none=False) - single_placement_group = BooleanType(serialize_when_none=False) - unique_id = StringType(serialize_when_none=False) - upgrade_policy = ModelType(UpgradePolicy, serialize_when_none=False) - virtual_machine_profile = ModelType( - VirtualMachineScaleSetVMProfile, serialize_when_none=False - ) - terminate_notification_display = StringType(serialize_when_none=False) - virtual_machine_scale_set_power_state = ListType( - ModelType(VirtualMachineScaleSetPowerState) - ) - zone_balance = BooleanType(serialize_when_none=False) - sku = ModelType(Sku, serialize_when_none=False) - type = StringType(serialize_when_none=False) - zones = ListType(StringType, serialize_when_none=False) - vm_instances = ListType( - ModelType(VirtualMachineScaleSetVM), 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", - } diff --git a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_region.yaml b/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_region.yaml deleted file mode 100644 index f18ea2a8..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: VMScaleSets -cloud_service_type: ScaleSet -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code diff --git a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_subscription.yaml b/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_subscription.yaml deleted file mode 100644 index f79e4b2d..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_count_by_subscription.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: VMScaleSets -cloud_service_type: ScaleSet -name: Count by Subscription -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_total_instance_count.yaml b/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_total_instance_count.yaml deleted file mode 100644 index 4d782595..00000000 --- a/src/spaceone/inventory/model/vm_scale_sets/widget/vm_scale_sets_total_instance_count.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -cloud_service_group: VMScaleSets -cloud_service_type: ScaleSet -name: Total Instance Count -query: - aggregate: - - group: - fields: - - name: value - key: data.instance_count - operator: sum diff --git a/src/spaceone/inventory/model/web_pubsub_service/__init__.py b/src/spaceone/inventory/model/web_pubsub_service/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/spaceone/inventory/model/web_pubsub_service/cloud_service.py b/src/spaceone/inventory/model/web_pubsub_service/cloud_service.py deleted file mode 100644 index 6810fac6..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/cloud_service.py +++ /dev/null @@ -1,202 +0,0 @@ -from schematics.types import ModelType, StringType, PolyModelType, FloatType, DateTimeType -from spaceone.inventory.model.web_pubsub_service.data import WebPubSubService, WebPubSubHub -from spaceone.inventory.libs.schema.metadata.dynamic_field import TextDyField, DateTimeDyField, EnumDyField, ListDyField -from spaceone.inventory.libs.schema.metadata.dynamic_layout import ItemDynamicLayout, TableDynamicLayout, \ - ListDynamicLayout -from spaceone.inventory.libs.schema.cloud_service import CloudServiceResource, CloudServiceResponse, CloudServiceMeta - -''' -Web PubSub Service -''' - -# TAB - Web PubSub Service -web_pubsub_svc_info_meta = ItemDynamicLayout.set_fields('Web PubSub Service', fields=[ - TextDyField.data_source('Name', 'name'), - EnumDyField.data_source('Service State', 'data.provisioning_state', default_state={ - 'safe': ['Running', 'Succeeded'], - 'warning': ['Creating', 'Updating', 'Deleting', 'Moving', 'Updating'], - 'alert': ['Failed', 'Canceled'], - 'disable': ['Unknown']}), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Region', 'data.location'), - TextDyField.data_source('Hub count', 'data.web_pubsub_hub_count_display'), - TextDyField.data_source('SKU', 'data.sku.tier'), - TextDyField.data_source('Unit', 'data.sku.capacity'), - TextDyField.data_source('Version', 'data.version'), - TextDyField.data_source('Host name', 'data.host_name'), - TextDyField.data_source('Host name prefix', 'data.host_name_prefix'), - TextDyField.data_source('Public IP', 'data.external_ip'), - TextDyField.data_source('Public access', 'data.public_network_access'), - TextDyField.data_source('Public port', 'data.public_port'), - TextDyField.data_source('Server port', 'data.server_port'), - TextDyField.data_source('Disable add auth', 'data.disable_aad_auth'), - TextDyField.data_source('Disable local auth', 'data.disable_local_auth'), - TextDyField.data_source('TLS', 'data.tls.client_cert_enabled'), -]) - -# TAB - Keys -web_pubsub_svc_keys_info = ItemDynamicLayout.set_fields('Keys', fields=[ - TextDyField.data_source('Host name', 'data.host_name'), - TextDyField.data_source('Access Key', 'data.disable_local_auth'), - TextDyField.data_source('Primary Key', 'data.web_pubsub_key.primary_key'), - TextDyField.data_source('Primary Connection string', 'data.web_pubsub_key.primary_connection_string'), - TextDyField.data_source('Secondary Key', 'data.web_pubsub_key.secondary_key'), - TextDyField.data_source('Secondary Connection string', 'data.web_pubsub_key.secondary_connection_string'), -]) - -# TAB - Hub -web_pubsub_svc_hubs_info = TableDynamicLayout.set_fields('Hubs', root_path='data.web_pubsub_hubs', fields=[ - TextDyField.data_source('Hub name', 'name'), - EnumDyField.data_source('Anonymous Connect', 'properties.anonymous_connect_policy', default_badge={ - 'indigo.500': ['allow'], 'coral.600': ['deny'] - }), - ListDyField.data_source('Event Handlers', 'properties.event_handlers.url_template', options={'delimiter': '
'}) -]) - -# TAB - Public access -web_pubsub_svc_public_access_info = ItemDynamicLayout.set_fields('Public access', fields=[ - EnumDyField.data_source('Public network access', 'data.public_network_access', default_badge={ - 'indigo.500': ['Enabled'], 'coral.600': ['Disabled'] - }) -]) - -# TAB - Private access -private_endpoint_connections_private_access = TableDynamicLayout.set_fields('Private endpoint connections', root_path='data.private_endpoint_connections', fields=[ - TextDyField.data_source('Connection name', 'name'), - EnumDyField.data_source('Connection state', 'private_link_service_connection_state.status', default_state={ - 'safe': ['Approved'], - 'warning': ['Pending'], - 'alert': ['Disconnected', 'Rejected'], - 'disable': []}), - TextDyField.data_source('Private Endpoint', 'private_endpoint.private_endpoint_name_display'), - TextDyField.data_source('Description', 'private_link_service_connection_state.status'), - ListDyField.data_source('Group ids', 'group_ids', options={'delimiter': '
'}), - TextDyField.data_source('Provisioning state', 'provisioning_state') -]) -shared_private_endpoints_private_access = TableDynamicLayout.set_fields('Shared private endpoints', root_path='data.shared_private_link_resources', fields=[ - TextDyField.data_source('Name', 'name'), - TextDyField.data_source('Private link resource ID', 'private_link_resource_id'), - TextDyField.data_source('Group ID', 'group_id'), - EnumDyField.data_source('Connection state', 'status', default_state={ - 'safe': ['Approved'], - 'warning': ['Pending'], - 'alert': ['Disconnected', 'Rejected'], - 'disable': []}), - TextDyField.data_source('Description', 'request_message'), - TextDyField.data_source('Provisioning state', 'provisioning_state') -]) - -web_pubsub_svc_private_access_info = ListDynamicLayout.set_layouts('Private access', layouts=[ - private_endpoint_connections_private_access, shared_private_endpoints_private_access]) - -# TAB - Access control rules -default_action_access_control_rules = ItemDynamicLayout.set_fields('Default action', fields=[ - EnumDyField.data_source('Default action', 'data.network_ac_ls.default_action', default_badge={ - 'indigo.500': ['Allow'], 'coral.600': ['Deny']}) -]) - -public_network_access_control_rules = ItemDynamicLayout.set_fields('Public network', fields=[ - ListDyField.data_source('Allow', 'data.network_ac_ls.public_network.allow', options={'delimiter': ','}) -]) - -private_endpoint_connections_access_control_rules = TableDynamicLayout.set_fields('Private endpoint connections', - root_path='data.network_ac_ls.private_endpoints' ,fields=[ - TextDyField.data_source('Connection name', 'name'), - ListDyField.data_source('Allow', 'allow', options={'delimiter': ', '}) - ]) - -web_pubsub_svc_access_control_rules_info = ListDynamicLayout.set_layouts(' Access control rules', layouts=[ - default_action_access_control_rules, public_network_access_control_rules, - private_endpoint_connections_access_control_rules -]) - -# TAB - System data -web_pub_sub_svc_system_data_info = ItemDynamicLayout.set_fields('System data', root_path='data.system_data', fields=[ - DateTimeDyField.data_source('Created at', 'created_at'), - TextDyField.data_source('Created by', 'created_by'), - TextDyField.data_source('Created by type', 'created_by_type'), - DateTimeDyField.data_source('Last modified at', 'last_modified_at'), - TextDyField.data_source('Last modified by', 'last_modified_by'), - TextDyField.data_source('Last modified by type', 'last_modified_by_type'), -]) - -# TAB - Custom domain is not yet supported - -web_pubsub_service_meta = CloudServiceMeta.set_layouts( - [web_pubsub_svc_info_meta, web_pubsub_svc_keys_info, web_pubsub_svc_hubs_info, web_pubsub_svc_public_access_info, - web_pubsub_svc_private_access_info, web_pubsub_svc_access_control_rules_info, web_pub_sub_svc_system_data_info]) - - -class ApplicationIntegrationResource(CloudServiceResource): - cloud_service_group = StringType(default='WebPubSubService') - - -class WebPubSubServiceResource(ApplicationIntegrationResource): - cloud_service_type = StringType(default='Service') - data = ModelType(WebPubSubService) - _metadata = ModelType(CloudServiceMeta, default=web_pubsub_service_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(WebPubSubServiceResource) - - -''' -Web PubSub Hub -''' - -# TAB - Web PubSub Hub -web_pubsub_hub_info_meta = ItemDynamicLayout.set_fields('Web PubSub Hub', fields=[ - TextDyField.data_source('Hub name', 'name'), - TextDyField.data_source('Resource ID', 'data.id'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Subscription', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Region', 'data.location'), - EnumDyField.data_source('Anonymous Connect', 'data.properties.anonymous_connect_policy', default_badge={ - 'indigo.500': ['allow'], 'coral.600': ['deny'] - }), - TextDyField.data_source('EventHandler count', 'data.web_pubsub_hub_evnet_handler_count_display') -]) - -# TAB - Event Handlers -web_pubsub_hub_event_handlers_info = TableDynamicLayout.set_fields('Event Handlers', root_path='data.properties.event_handlers', fields=[ - TextDyField.data_source('Url template', 'url_template'), - TextDyField.data_source('User events', 'user_event_pattern'), - ListDyField.data_source('System events', 'system_events', options={'delimiter': ', '}), - TextDyField.data_source('Authentication', 'auth.type') -]) - -# TAB - System data -web_pubsub_hub_system_data_info = ItemDynamicLayout.set_fields('System data', root_path='data.system_data', fields=[ - DateTimeDyField.data_source('Created at', 'created_at'), - TextDyField.data_source('Created by', 'created_by'), - TextDyField.data_source('Created by type', 'created_by_type'), - DateTimeDyField.data_source('Last modified at', 'last_modified_at'), - TextDyField.data_source('Last modified by', 'last_modified_by'), - TextDyField.data_source('Last modified by type', 'last_modified_by_type'), -]) - -web_pubsub_hub_meta = CloudServiceMeta.set_layouts( - [web_pubsub_hub_info_meta, web_pubsub_hub_event_handlers_info, web_pubsub_hub_system_data_info]) - - -class WebPubSubHubResource(ApplicationIntegrationResource): - cloud_service_type = StringType(default='Hub') - data = ModelType(WebPubSubHub) - _metadata = ModelType(CloudServiceMeta, default=web_pubsub_hub_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 WebPubSubHubResponse(CloudServiceResponse): - resource = PolyModelType(WebPubSubHubResource) diff --git a/src/spaceone/inventory/model/web_pubsub_service/cloud_service_type.py b/src/spaceone/inventory/model/web_pubsub_service/cloud_service_type.py deleted file mode 100644 index bd1d4502..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/cloud_service_type.py +++ /dev/null @@ -1,151 +0,0 @@ -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 -from spaceone.inventory.conf.cloud_service_conf import ASSET_URL - -current_dir = os.path.abspath(os.path.dirname(__file__)) - -''' -Service -''' - -web_pubsub_svc_count_by_region_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_count_by_region.yaml') -web_pubsub_svc_count_by_resource_group_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_count_by_resource_group.yaml') -web_pubsub_svc_count_by_account_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_count_by_account.yaml') -web_pubsub_svc_total_count_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_total_count.yaml') -web_pubsub_svc_total_unit_count_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_total_unit_count.yaml') -web_pubsub_svc_unit_count_by_tier_conf = os.path.join(current_dir, 'widget/web_pubsub_svc_unit_count_by_tier.yaml') - -cst_web_pubsub_svc = CloudServiceTypeResource() -cst_web_pubsub_svc.name = 'Service' -cst_web_pubsub_svc.group = 'WebPubSubService' -cst_web_pubsub_svc.service_code = 'Microsoft.SignalRService/WebPubSub' -cst_web_pubsub_svc.labels = ['Application Integration'] -cst_web_pubsub_svc.is_major = True -cst_web_pubsub_svc.is_primary = True -cst_web_pubsub_svc.tags = { - 'spaceone:icon': f'{ASSET_URL}/azure-web-pubsub-service.svg', -} - -cst_web_pubsub_svc._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source('Service State', 'data.provisioning_state', default_state={ - 'safe': ['Running', 'Succeeded'], - 'warning': ['Creating', 'Updating', 'Deleting', 'Moving', 'Updating'], - 'alert': ['Failed', 'Canceled'], - 'disable': ['Unknown']}), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account', options={ - 'is_optional': True - }), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - TextDyField.data_source('Hub count', 'data.web_pubsub_hub_count_display'), - TextDyField.data_source('SKU', 'data.sku.tier'), - TextDyField.data_source('Unit', 'data.sku.capacity'), - TextDyField.data_source('Version', 'data.version', options={ - 'is_optional': True - }), - TextDyField.data_source('Host name', 'data.host_name'), - TextDyField.data_source('Host name prefix', 'data.host_name_prefix', options={ - 'is_optional': True - }), - TextDyField.data_source('Public IP', 'data.external_ip'), - TextDyField.data_source('Public access', 'data.public_network_access'), - TextDyField.data_source('Public port', 'data.public_port', options={ - 'is_optional': True - }), - TextDyField.data_source('Server port', 'data.server_port', options={ - 'is_optional': True - }), - TextDyField.data_source('TLS', 'data.tls.client_cert_enabled', options={ - 'is_optional': True - }), - - ], - search=[ - SearchField.set('Service State', key='data.provisioning_state'), - SearchField.set('Subscription Name', key='data.subscription_name'), - SearchField.set('Subscription ID', key='account'), - SearchField.set('Resource Group', key='data.resource_group'), - SearchField.set('Location', key='data.location'), - SearchField.set('Hub count', key='data.web_pubsub_hub_count_display', data_type='integer'), - SearchField.set('SKU', key='data.sku.tier'), - SearchField.set('Unit', key='data.sku.capacity', data_type='integer'), - SearchField.set('Version', key='data.version', data_type='float'), - SearchField.set('Host name', key='data.host_name'), - SearchField.set('Host name prefix', key='data.host_name_prefix'), - SearchField.set('Public IP', key='data.external_ip'), - SearchField.set('Public access', key='data.public_network_access'), - SearchField.set('Public port', key='data.public_port'), - SearchField.set('Server port', key='data.server_port'), - SearchField.set('TLS', key='data.tls.client_cert_enabled'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(web_pubsub_svc_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(web_pubsub_svc_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(web_pubsub_svc_count_by_region_conf)), - ChartWidget.set(**get_data_from_yaml(web_pubsub_svc_unit_count_by_tier_conf)), - CardWidget.set(**get_data_from_yaml(web_pubsub_svc_total_count_conf)), - CardWidget.set(**get_data_from_yaml(web_pubsub_svc_total_unit_count_conf)), - ] -) - -''' -Hub -''' -web_pubsub_hub_count_by_region_conf = os.path.join(current_dir, 'widget/web_pubsub_hub_count_by_region.yaml') -web_pubsub_hub_count_by_resource_group_conf = os.path.join(current_dir, 'widget/web_pubsub_hub_count_by_resource_group.yaml') -web_pubsub_hub_count_by_account_conf = os.path.join(current_dir, 'widget/web_pubsub_hub_count_by_account.yaml') -web_pubsub_hub_event_handler_total_count_conf = os.path.join(current_dir, 'widget/web_pubsub_hub_event_handler_total_count.yaml') -web_pubsub_hub_total_count_conf = os.path.join(current_dir, 'widget/web_pubsub_hub_total_count.yaml') - -cst_web_pubsub_hub = CloudServiceTypeResource() -cst_web_pubsub_hub.name = 'Hub' -cst_web_pubsub_hub.group = 'WebPubSubService' -cst_web_pubsub_hub.service_code = 'Microsoft.SignalRService/WebPubSub/hubs' -cst_web_pubsub_hub.labels = ['Application Integration'] -cst_web_pubsub_hub.is_major = False -cst_web_pubsub_hub.is_primary = False -cst_web_pubsub_hub.tags = { - 'spaceone:icon': 'https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure/azure-web-pubsub-service.svg', -} - -cst_web_pubsub_hub._metadata = CloudServiceTypeMeta.set_meta( - fields=[ - EnumDyField.data_source('Anonymous Connect', 'data.properties.anonymous_connect_policy', default_badge={ - 'indigo.500': ['allow'], 'coral.600': ['deny']}), - TextDyField.data_source('Event Handlers count', 'data.web_pubsub_hub_evnet_handler_count_display'), - TextDyField.data_source('Web SubSub Service', 'data.web_pubsub_svc_name'), - TextDyField.data_source('Subscription Name', 'data.subscription_name'), - TextDyField.data_source('Subscription ID', 'account'), - TextDyField.data_source('Resource Group', 'data.resource_group'), - TextDyField.data_source('Location', 'data.location'), - ], - search=[ - SearchField.set('Anonymous Connect', key='data.properties.anonymous_connect_policy'), - SearchField.set('Event Handlers count', key='data.web_pubsub_hub_evnet_handler_count_display', data_type='integer'), - SearchField.set('Web SubSub Service', 'data.web_pubsub_svc_name'), - SearchField.set('Subscription Name', key='data.subscription_name'), - SearchField.set('Subscription ID', key='account'), - SearchField.set('Resource Group', key='data.resource_group'), - SearchField.set('Location', key='data.location'), - ], - widget=[ - ChartWidget.set(**get_data_from_yaml(web_pubsub_hub_count_by_account_conf)), - ChartWidget.set(**get_data_from_yaml(web_pubsub_hub_count_by_resource_group_conf)), - ChartWidget.set(**get_data_from_yaml(web_pubsub_hub_count_by_region_conf)), - CardWidget.set(**get_data_from_yaml(web_pubsub_hub_total_count_conf)), - CardWidget.set(**get_data_from_yaml(web_pubsub_hub_event_handler_total_count_conf)) - ] -) - -CLOUD_SERVICE_TYPES = [ - CloudServiceTypeResponse({'resource': cst_web_pubsub_svc}), - CloudServiceTypeResponse({'resource': cst_web_pubsub_hub}), -] diff --git a/src/spaceone/inventory/model/web_pubsub_service/data.py b/src/spaceone/inventory/model/web_pubsub_service/data.py deleted file mode 100644 index 7b733298..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/data.py +++ /dev/null @@ -1,222 +0,0 @@ -from schematics import Model -from schematics.types import ModelType, ListType, StringType, IntType, BooleanType, DateTimeType -from spaceone.inventory.libs.schema.resource import AzureCloudService - - -# SkuResource -class SkuResource(Model): - name = StringType(serialize_when_none=False) - tier = StringType(serialize_when_none=False) - size = StringType(serialize_when_none=False) - family = StringType(serialize_when_none=False) - capacity = IntType(serialize_when_none=False) - - -# ManagedIdentity - -# ManagedIdentity - UserAssignedIdentityProperty -class UserAssignedIdentityProperty(Model): - principal_id = StringType(serialize_when_none=False) - client_id = StringType(serialize_when_none=False) - - -class ManagedIdentity(Model): - type = StringType(serialize_when_none=False) - user_assigned_identities = ModelType(UserAssignedIdentityProperty) - principal_id = StringType(serialize_when_none=False) - tenant_id = StringType(serialize_when_none=False) - - -# SystemData -class SystemData(Model): - created_by = StringType(serialize_when_none=False) - created_by_type = StringType(serialize_when_none=False) - created_at = DateTimeType(serialize_when_none=False) - last_modified_by = StringType(serialize_when_none=False) - last_modified_by_type = StringType(serialize_when_none=False) - last_modified_at = DateTimeType(serialize_when_none=False) - - -# PrivateEndpointConnection - -# PrivateEndpointConnection - PrivateEndpoint -class PrivateEndpoint(Model): - id = StringType(serialize_when_none=False) - private_endpoint_name_display = StringType(serialize_when_none=False) - - -# PrivateEndpointConnection - PrivateLinkServiceConnectionState -class PrivateLinkServiceConnectionState(Model): - status = StringType(choices=('Approved', 'Disconnected', 'Pending', 'Rejected')) - description = StringType(serialize_when_none=False) - actions_required = StringType(serialize_when_none=False) - - -class PrivateEndpointConnection(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - system_data = ModelType(SystemData, serialize_when_none=False) - provisioning_state = StringType(choices=('Canceled', 'Creating', 'Deleting', 'Failed', 'Moving', 'Running', - 'Succeeded', 'Unknown', 'Updating')) - private_endpoint = ModelType(PrivateEndpoint) - group_ids = ListType(StringType, serialize_when_none=False) - private_link_service_connection_state = ModelType(PrivateLinkServiceConnectionState) - - -# SharedPrivateLinkResource -class SharedPrivateLinkResource(Model): - id = StringType(serialize_when_none=False) - name = StringType(serialize_when_none=False) - type = StringType(serialize_when_none=False) - system_data = ModelType(SystemData) - group_id = StringType(serialize_when_none=False) - private_link_resource_id = StringType(serialize_when_none=False) - provisioning_state = StringType(choices=('Canceled', 'Creating', 'Deleting', 'Failed', 'Moving', 'Running', - 'Succeeded', 'Unknown', 'Updating')) - request_message = StringType(serialize_when_none=False) - status = StringType(choices=('Approved', 'Disconnected', 'Pending', 'Rejected')) - - -# WebPubSubTlsSettings -class WebPubSubTlsSettings(Model): - client_cert_enabled = BooleanType(default=True) - - -# LiveTraceConfiguration - -# LiveTraceConfiguration - LiveTraceCategory -class LiveTraceCategory(Model): - name = StringType(serialize_when_none=False) - enabled = StringType(serialize_when_none=False) - - -class LiveTraceConfiguration(Model): - enabled = StringType(serialize_when_none=False) - categories = ListType(ModelType(LiveTraceCategory), serialize_when_none=False) - - -# ResourceLogConfiguration - -# ResourceLogConfiguration - ResourceLogCategory -class ResourceLogCategory(Model): - name = StringType(serialize_when_none=False) - enabled = StringType(serialize_when_none=False) - - -class ResourceLogConfiguration(Model): - categories = ListType(ModelType(ResourceLogCategory), serialize_when_none=False) - - -# WebPubSubNetworkACLs - -# WebPubSubNetworkACLs - NetworkACL -class NetworkACL(Model): - allow = ListType(StringType, serialize_when_none=False) - deny = ListType(StringType, serialize_when_none=False) - - -# WebPubSubNetworkACLs - PrivateEndpointACL -class PrivateEndpointACL(Model): - allow = ListType(StringType, serialize_when_none=False) - deny = ListType(StringType, serialize_when_none=False) - name = StringType(serialize_when_none=False) - - -class WebPubSubNetworkACLs(Model): - default_action = StringType(serialize_when_none=False) - public_network = ModelType(NetworkACL) - private_endpoints = ListType(ModelType(PrivateEndpointACL), serialize_when_none=False) - - -# WebPubSubHub - -# WebPubSubHub- WebPubSubNetworkACLs- UpstreamAuthSettings - ManagedIdentitySettings -class ManagedIdentitySettings(Model): - resource = StringType(serialize_when_none=False) - - -# WebPubSubHub- WebPubSubNetworkACLs- UpstreamAuthSettings -class UpstreamAuthSettings(Model): - type = StringType(serialize_when_none=False) - managed_identity = ModelType(ManagedIdentitySettings) - - -# WebPubSubHub - WebPubSubHubProperties - EventHandler -class EventHandler(Model): - url_template = StringType(serialize_when_none=False) - user_event_pattern = StringType(serialize_when_none=False) - system_events = ListType(StringType, serialize_when_none=False) - auth = ModelType(UpstreamAuthSettings) - - -# WebPubSubHub - WebPubSubHubProperties -class WebPubSubHubProperties(Model): - event_handlers = ListType(ModelType(EventHandler)) - anonymous_connect_policy = StringType(default='deny', choices=('allow', 'deny')) - - -class WebPubSubHub(AzureCloudService): - id = StringType() - name = StringType() - location = StringType() - type = StringType(serialize_when_none=False) - system_data = ModelType(SystemData) - properties = ModelType(WebPubSubHubProperties) - web_pubsub_svc_name = StringType(serialize_when_none=False) - web_pubsub_hub_evnet_handler_count_display = IntType(default=0) - - def reference(self): - return { - "resource_id": self.id, - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", - } - - -# CustomDomain -class CustomDomain(Model): - pass - - -# WebPubSubKeys -class WebPubSubKey(Model): - primary_key = StringType(serialize_when_none=False) - primary_connection_string = StringType(serialize_when_none=False) - secondary_key = StringType(serialize_when_none=False) - secondary_connection_string = StringType(serialize_when_none=False) - - -class WebPubSubService(AzureCloudService): # Main Class - id = StringType() - name = StringType() - location = StringType() - sku = ModelType(SkuResource, serialize_when_none=False) - identity = ModelType(ManagedIdentity, serialize_when_none=False) - system_data = ModelType(SystemData, serialize_when_none=False) - provisioning_state = StringType(choices=('Canceled', 'Creating', 'Deleting', 'Failed', 'Moving', 'Running', - 'Succeeded', 'Unknown', 'Updating')) - external_ip = StringType(serialize_when_none=False) - host_name = StringType(serialize_when_none=False) - public_port = StringType(serialize_when_none=False) - server_port = StringType(serialize_when_none=False) - version = StringType(serialize_when_none=False) - private_endpoint_connections = ListType(ModelType(PrivateEndpointConnection)) - shared_private_link_resources = ListType(ModelType(SharedPrivateLinkResource)) - tls = ModelType(WebPubSubTlsSettings) - host_name_prefix = StringType(serialize_when_none=False) - live_trace_configuration = ModelType(LiveTraceConfiguration) - resource_log_configuration = ModelType(ResourceLogConfiguration) - network_ac_ls = ModelType(WebPubSubNetworkACLs) - public_network_access = StringType(default='Enabled') - disable_local_auth = BooleanType(default=False) - disable_aad_auth = BooleanType(default=False) - web_pubsub_hubs = ListType(ModelType(WebPubSubHub)) - web_pubsub_hub_count_display = IntType(default=0) - custom_domains = ListType(ModelType(CustomDomain)) # not yet supported - web_pubsub_key = ModelType(WebPubSubKey) - - def reference(self): - return { - "resource_id": self.id, - "external_link": f"https://portal.azure.com/#@.onmicrosoft.com/resource{self.id}/overview", - } diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_account.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_account.yaml deleted file mode 100644 index 4b0f9cea..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_account.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Hub -name: Count by Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_region.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_region.yaml deleted file mode 100644 index 236115ad..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Hub -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_resource_group.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_resource_group.yaml deleted file mode 100644 index e48ae666..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_count_by_resource_group.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Hub -name: Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - operator: count -options: - chart_type: DONUT \ No newline at end of file diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_event_handler_total_count.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_event_handler_total_count.yaml deleted file mode 100644 index cf93d4fb..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_event_handler_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Hub -name: Total EventHandler Count -query: - aggregate: - - group: - fields: - - name: value - key: data.web_pubsub_hub_evnet_handler_count_display - operator: sum -options: - value_options: - key: value - options: - default: 0 \ No newline at end of file diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_total_count.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_total_count.yaml deleted file mode 100644 index 0ca0abc4..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_hub_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Hub -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_account.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_account.yaml deleted file mode 100644 index d63b1c64..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_account.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Count by Account -query: - aggregate: - - group: - keys: - - name: name - key: account - fields: - - name: value - key: account - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_region.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_region.yaml deleted file mode 100644 index 13e03a59..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_region.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Count by Region -query: - aggregate: - - group: - keys: - - name: name - key: region_code - fields: - - name: value - operator: count -options: - chart_type: COLUMN - name_options: - key: name - reference: - resource_type: inventory.Region - reference_key: region_code \ No newline at end of file diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_resource_group.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_resource_group.yaml deleted file mode 100644 index e506ff16..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_count_by_resource_group.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Count by Resource Group -query: - aggregate: - - group: - keys: - - name: name - key: data.resource_group - fields: - - name: value - operator: count -options: - chart_type: DONUT \ No newline at end of file diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_count.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_count.yaml deleted file mode 100644 index 48223b36..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Total Count -query: - aggregate: - - group: - fields: - - name: value - operator: count -options: - value_options: - key: value - type: text - options: - default: 0 diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_unit_count.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_unit_count.yaml deleted file mode 100644 index 955255cb..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_total_unit_count.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Total Unit Count -query: - aggregate: - - group: - fields: - - name: value - key: data.sku.capacity - operator: sum -options: - value_options: - key: value - options: - default: 0 diff --git a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_unit_count_by_tier.yaml b/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_unit_count_by_tier.yaml deleted file mode 100644 index 1d13b078..00000000 --- a/src/spaceone/inventory/model/web_pubsub_service/widget/web_pubsub_svc_unit_count_by_tier.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -cloud_service_group: WebPubSubService -cloud_service_type: Service -name: Unit Count by Tier -query: - aggregate: - - group: - keys: - - name: name - key: data.sku.tier - fields: - - name: value - key: data.sku.tier - operator: count -options: - chart_type: DONUT diff --git a/src/spaceone/inventory/service/__init__.py b/src/spaceone/inventory/service/__init__.py deleted file mode 100644 index 5880d009..00000000 --- a/src/spaceone/inventory/service/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from spaceone.inventory.service.collector_service import CollectorService -from spaceone.inventory.service.job_service import JobService diff --git a/src/spaceone/inventory/service/collector_service.py b/src/spaceone/inventory/service/collector_service.py deleted file mode 100644 index 24bd263a..00000000 --- a/src/spaceone/inventory/service/collector_service.py +++ /dev/null @@ -1,181 +0,0 @@ -import concurrent.futures -import logging -import time -import os - -from spaceone.inventory.libs.manager import AzureManager -from spaceone.inventory.manager.subscriptions.subscription_manager import ( - SubscriptionsManager, -) -from spaceone.core import utils -from spaceone.core.service import * -from spaceone.inventory.conf.cloud_service_conf import * - -_LOGGER = logging.getLogger(__name__) - -_CURRENT_DIR = os.path.dirname(__file__) -_BEFORE_CURRENT_DIR, _ = _CURRENT_DIR.rsplit("/", 1) -_METRIC_DIR = os.path.join(_BEFORE_CURRENT_DIR, "metrics/") - - -@authentication_handler -class CollectorService(BaseService): - resource = "Collector" - - def __init__(self, metadata): - super().__init__(metadata) - - @check_required(["options"]) - def init(self, params): - """init plugin by options""" - capability = { - "filter_format": FILTER_FORMAT, - "supported_resource_type": SUPPORTED_RESOURCE_TYPE, - "supported_features": SUPPORTED_FEATURES, - "supported_schedules": SUPPORTED_SCHEDULES, - } - return {"metadata": capability} - - @transaction - @check_required(["options", "secret_data"]) - def verify(self, params): - """ - Args: - params: - - options - - secret_data - """ - options = params["options"] - secret_data = params.get("secret_data", {}) - if secret_data != {}: - azure_manager = AzureManager() - active = azure_manager.verify({}, secret_data=secret_data) - - return {} - - @transaction - @check_required(["options", "secret_data", "filter"]) - def collect(self, params: dict): - """ - Args: - params: - - options - - schema - - secret_data - - filter - - task_options - """ - - start_time = time.time() - options = params.get("options", {}) - task_options = params.get("task_options", {}) - params.update({"subscription_info": self.get_subscription_info(params)}) - - _LOGGER.debug("[ EXECUTOR START: Azure Cloud Service ]") - target_execute_managers = self._get_target_execute_manger(options, task_options) - - # Thread per cloud services - with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_WORKER) as executor: - future_executors = [] - - for execute_manager in target_execute_managers: - _LOGGER.info(f"@@@ {execute_manager} @@@") - _manager = self.locator.get_manager(execute_manager) - future_executors.append( - executor.submit(_manager.collect_resources, params) - ) - - for future in concurrent.futures.as_completed(future_executors): - for result in future.result(): - yield result.to_primitive() - - """ - for manager in self.execute_managers: - _LOGGER.debug(f'@@@ {manager} @@@') - _manager = self.locator.get_manager(manager) - - for resource in _manager.collect_resources(params): - yield resource.to_primitive() - """ - - if cloud_service_types := params.get("options", {}).get("cloud_service_types"): - for service in cloud_service_types: - for response in self.collect_metrics(service): - yield response - else: - for service in CLOUD_SERVICE_GROUP_MAP.keys(): - for response in self.collect_metrics(service): - yield response - _LOGGER.debug(f"TOTAL TIME : {time.time() - start_time} Seconds") - - def get_subscription_info(self, params): - subscription_manager: SubscriptionsManager = self.locator.get_manager( - "SubscriptionsManager" - ) - return subscription_manager.get_subscription_info(params) - - def list_location_info(self, params): - subscription_manager: SubscriptionsManager = self.locator.get_manager( - "SubscriptionsManager" - ) - return subscription_manager.list_location_info(params) - - def _get_target_execute_manger(self, options: dict, task_options: dict) -> list: - if "cloud_service_types" in options: - execute_managers = self._match_execute_manager( - options["cloud_service_types"] - ) - elif "cloud_service_types" in task_options: - execute_managers = self._match_execute_manager( - task_options["cloud_service_types"] - ) - else: - execute_managers = list(CLOUD_SERVICE_GROUP_MAP.values()) - - return execute_managers - - @staticmethod - def _match_execute_manager(cloud_service_groups): - return [ - CLOUD_SERVICE_GROUP_MAP[_cloud_service_group] - for _cloud_service_group in cloud_service_groups - if _cloud_service_group in CLOUD_SERVICE_GROUP_MAP - ] - - def collect_metrics(self, service: str) -> list: - if not os.path.exists(os.path.join(_METRIC_DIR, service)): - os.mkdir(os.path.join(_METRIC_DIR, service)) - for dirname in os.listdir(os.path.join(_METRIC_DIR, service)): - for filename in os.listdir(os.path.join(_METRIC_DIR, service, dirname)): - if filename.endswith(".yaml"): - file_path = os.path.join(_METRIC_DIR, service, dirname, filename) - info = utils.load_yaml_from_file(file_path) - if filename == "namespace.yaml": - yield self.make_namespace_or_metric_response( - namespace=info, - resource_type="inventory.Namespace", - ) - else: - yield self.make_namespace_or_metric_response( - metric=info, - resource_type="inventory.Metric", - ) - - @staticmethod - def make_namespace_or_metric_response( - metric=None, - namespace=None, - resource_type: str = "inventory.Metric", - ) -> dict: - response = { - "state": "SUCCESS", - "resource_type": resource_type, - "match_rules": {}, - } - - if resource_type == "inventory.Metric" and metric is not None: - response["resource"] = metric - elif resource_type == "inventory.Namespace" and namespace is not None: - response["resource"] = namespace - - return response diff --git a/src/spaceone/inventory/service/job_service.py b/src/spaceone/inventory/service/job_service.py deleted file mode 100644 index f367b532..00000000 --- a/src/spaceone/inventory/service/job_service.py +++ /dev/null @@ -1,49 +0,0 @@ -import logging - -from spaceone.core.service import * -from spaceone.inventory.model.job_model import Tasks -from spaceone.inventory.conf.cloud_service_conf import * - -_LOGGER = logging.getLogger(__name__) - - -@authentication_handler -class JobService(BaseService): - resource = "Job" - - def __init__(self, metadata): - super().__init__(metadata) - - @transaction - @check_required(["options", "secret_data"]) - def get_tasks(self, params: dict): - """ - Args: - params: - - options - - schema - - secret_data - - task_filter - """ - - options = params.get("options", {}) - secret_data = params.get("secret_data", {}) - - tasks = [] - - cloud_service_types = options.get( - "cloud_service_types", CLOUD_SERVICE_GROUP_MAP.keys() - ) - - for cloud_service_type in cloud_service_types: - tasks.append( - { - "task_options": { - "cloud_service_types": [cloud_service_type], - } - } - ) - tasks = Tasks({"tasks": tasks}) - tasks.validate() - - return tasks.to_primitive() diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/test/api/config.yml b/test/api/config.yml deleted file mode 100644 index 9cc5091b..00000000 --- a/test/api/config.yml +++ /dev/null @@ -1,7 +0,0 @@ -GLOBAL: - SERVICE: inventory - ENDPOINTS: - inventory: - plugin: localhost:50051 - #plugin: dev-docker.pyengine.net:50062 - diff --git a/test/api/scenario.json b/test/api/scenario.json deleted file mode 100644 index 0967ef42..00000000 --- a/test/api/scenario.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/test/api/test_cloud_service_api.py b/test/api/test_cloud_service_api.py deleted file mode 100644 index e9436b9f..00000000 --- a/test/api/test_cloud_service_api.py +++ /dev/null @@ -1,73 +0,0 @@ -import os -import unittest -import json - -from spaceone.core.unittest.result import print_data -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core import utils -from spaceone.core.transaction import Transaction -from spaceone.tester import TestCase, print_json - - -class TestCollector(TestCase): - @classmethod - def setUpClass(cls): - azure_cred = os.environ.get("AZURE_CRED") - test_config = utils.load_yaml_from_file(azure_cred) - - cls.schema = "azure_client_secret" - cls.azure_credentials = test_config.get("AZURE_CREDENTIALS", {}) - super().setUpClass() - - def test_init(self): - v_info = self.inventory.Collector.init({"options": {}}) - print_json(v_info) - - def test_verify(self): - options = {} - v_info = self.inventory.Collector.verify( - {"options": options, "secret_data": self.azure_credentials} - ) - print_json(v_info) - - def test_get_tasks(self): - options = { - "cloud_service_types": ["KeyVaults"], - # 'custom_asset_url': 'https://xxxxx.cloudforet.dev.icon/azure' - } - # options = {} - v_info = self.inventory.Job.get_tasks( - { - "options": options, - "secret_data": self.azure_credentials, - } - ) - print_json(v_info) - - def test_collect(self): - options = { - # "cloud_service_types": ["KeyVaults"], - # 'custom_asset_url': 'https://xxxxx.cloudforet.dev.icon/azure' - } - - # options = {} - task_options = { - # "cloud_service_types": ["StorageAccounts"], - } - filter = {} - resource_stream = self.inventory.Collector.collect( - { - "options": options, - "secret_data": self.azure_credentials, - "task_options": task_options, - "filter": filter, - } - ) - - for res in resource_stream: - print_json(res) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) diff --git a/test/connector/__init__.py b/test/connector/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/test/connector/test_disk_connector.py b/test/connector/test_disk_connector.py deleted file mode 100644 index 3d4cbd2f..00000000 --- a/test/connector/test_disk_connector.py +++ /dev/null @@ -1,47 +0,0 @@ -import unittest -import os -from datetime import datetime, timedelta -from unittest.mock import patch - -from spaceone.core.unittest.result import print_data -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core import utils -from spaceone.core.transaction import Transaction -from spaceone.inventory.connector.disk import DiskConnector - - -class TestDiskConnector(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = { - 'secret_data': test_config.get('AZURE_CREDENTIALS', {}) - } - - cls.azure_connector = DiskConnector(transaction=Transaction(), config={}, - secret_data=test_config.get('AZURE_CREDENTIALS', {})) - #cls.azure_connector = DiskConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials['secret_data']) - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_list_disks(self): - #self.azure_connector.set_connect(self.azure_credentials) - disks = self.azure_connector.list_disks() - - for disk in disks: - print('=====') - print(disk) - print('=====') - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) diff --git a/test/connector/test_load_balancer_connector.py b/test/connector/test_load_balancer_connector.py deleted file mode 100644 index 53727d12..00000000 --- a/test/connector/test_load_balancer_connector.py +++ /dev/null @@ -1,47 +0,0 @@ -import unittest -import os -from datetime import datetime, timedelta -from unittest.mock import patch - -from spaceone.core.unittest.result import print_data -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core import utils -from spaceone.core.transaction import Transaction -from spaceone.inventory.connector.loadbalncer import LoadBalancerConnector - - -class TestLoadBalancerConnector(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = { - 'secret_data': test_config.get('AZURE_CREDENTIALS', {}) - } - - cls.azure_connector = LoadBalancerConnector(transaction=Transaction(), config={}, - secret_data=test_config.get('AZURE_CREDENTIALS', {})) - #cls.azure_connector = DiskConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials['secret_data']) - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_list_load_balancers(self): - # self.azure_connector.set_connect(self.azure_credentials) - load_balancers = self.azure_connector.list_load_balancers() - - for load_balancer in load_balancers: - print('=====') - print(load_balancer) - print('=====') - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) diff --git a/test/connector/test_snapshot_connector.py b/test/connector/test_snapshot_connector.py deleted file mode 100644 index a1092439..00000000 --- a/test/connector/test_snapshot_connector.py +++ /dev/null @@ -1,47 +0,0 @@ -import unittest -import os -from datetime import datetime, timedelta -from unittest.mock import patch - -from spaceone.core.unittest.result import print_data -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core import utils -from spaceone.core.transaction import Transaction -from spaceone.inventory.connector.snapshot import SnapshotConnector - - -class TestSnapshotConnector(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = { - 'secret_data': test_config.get('AZURE_CREDENTIALS', {}) - } - - cls.azure_connector = SnapshotConnector(transaction=Transaction(), config={}, - secret_data=test_config.get('AZURE_CREDENTIALS', {})) - # cls.azure_connector = DiskConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials['secret_data']) - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_list_snapshots(self): - # self.azure_connector.set_connect(self.azure_credentials) - snapshots = self.azure_connector.list_snapshots() - - for snapshot in snapshots: - print('=====') - print(snapshot) - print('=====') - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) diff --git a/test/manager/__init__.py b/test/manager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/test/manager/test_application_gateway_manager.py b/test/manager/test_application_gateway_manager.py deleted file mode 100644 index deed7e00..00000000 --- a/test/manager/test_application_gateway_manager.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.application_gateway import ApplicationGatewayConnector -from spaceone.inventory.manager.application_gateways.instance_manager import ApplicationGatewayManager - - -class TestApplicationGatewayManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.application_gateway_connector = ApplicationGatewayConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.application_gateway_manager = ApplicationGatewayManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - application_gateways = self.application_gateway_manager.collect_cloud_service(params) - - for applicaiton_gateway in application_gateways: - print(applicaiton_gateway.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_cosmos_db_manager.py b/test/manager/test_cosmos_db_manager.py deleted file mode 100644 index e790a0d9..00000000 --- a/test/manager/test_cosmos_db_manager.py +++ /dev/null @@ -1,49 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.cosmos_db import CosmosDBConnector -from spaceone.inventory.manager.cosmos_db.instance_manager import CosmosDBManager - - -class TestCosmosDBManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.cosmos_db_connector = CosmosDBConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.cosmos_db_manager = CosmosDBManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - subscription_info = { - 'subscription_id': '3ec64e1e-1ce8-4f2c-82a0-a7f6db0899ca', - 'subscription_name': 'Azure subscription 1', - 'tenant_id': '35f43e22-0c0b-4ff3-90aa-b2c04ef1054c' - } - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}, 'subscription_info': subscription_info} - - cosmos_dbs = self.cosmos_db_manager.collect_cloud_service(params) - - for cosmos_db in cosmos_dbs: - print(cosmos_db.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_disk_manager.py b/test/manager/test_disk_manager.py deleted file mode 100644 index 8856ecb0..00000000 --- a/test/manager/test_disk_manager.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.disk import DiskConnector -from spaceone.inventory.manager.disks.disk_manager import DiskManager - - -class TestDiskManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.disk_connector = DiskConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - - cls.disk_manager = DiskManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - disks = self.disk_manager.collect_cloud_service(params) - - for disk in disks: - print(disk.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_key_vault_manager.py b/test/manager/test_key_vault_manager.py deleted file mode 100644 index bf3facf7..00000000 --- a/test/manager/test_key_vault_manager.py +++ /dev/null @@ -1,50 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.key_vault import KeyVaultConnector -from spaceone.inventory.manager.key_vaults.instance_manager import KeyVaultManager - - -class TestKeyVaultManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.key_vault_connector = KeyVaultConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.key_vault_manager = KeyVaultManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - subscription_info = { - 'subscription_id': '3ec64e1e-1ce8-4f2c-82a0-a7f6db0899ca', - 'subscription_name': 'Azure subscription 1', - 'tenant_id': '35f43e22-0c0b-4ff3-90aa-b2c04ef1054c' - } - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}, 'subscription_info': subscription_info} - - key_vaults = self.key_vault_manager.collect_cloud_service(params) - - for key_vault in key_vaults: - print(key_vault.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_load_balancer_manager.py b/test/manager/test_load_balancer_manager.py deleted file mode 100644 index de647c6b..00000000 --- a/test/manager/test_load_balancer_manager.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.loadbalncer import LoadBalancerConnector -from spaceone.inventory.manager.load_balancers.instance_manager import LoadBalancerManager - - -class TestLoadBalancerManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.load_balancer_connector = LoadBalancerConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - - cls.load_balancer_manager = LoadBalancerManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - load_balancers = self.load_balancer_manager.collect_cloud_service(params) - - for load_balancer in load_balancers: - print(load_balancer.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_mysql_server_manager.py b/test/manager/test_mysql_server_manager.py deleted file mode 100644 index 6f4adecc..00000000 --- a/test/manager/test_mysql_server_manager.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.mysql_server import MySQLServerConnector -from spaceone.inventory.manager.mysql_servers.server_manager import MySQLServerManager - - -class TestMySQLServerManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - cls.subscription_info = test_config.get('SUBSCRIPTION_INFO', {}) - - cls.mysql_servers_connector = MySQLServerConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.mysql_servers_manager = MySQLServerManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - subscription_info = self.subscription_info - params = {'options': {}, 'secret_data': secret_data, 'filter': {}, 'subscription_info': subscription_info} - - mysql_servers = self.mysql_servers_manager.collect_cloud_service(params) - - for mysql_server in mysql_servers: - print(mysql_server.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_nat_gateway_manager.py b/test/manager/test_nat_gateway_manager.py deleted file mode 100644 index af244bab..00000000 --- a/test/manager/test_nat_gateway_manager.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.nat_gateway import NATGatewayConnector -from spaceone.inventory.manager.nat_gateways.instance_manager import NATGatewayManager - - -class TestVirtualNetworkManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.nat_gateway_connector = NATGatewayConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.nat_gateway_manager = NATGatewayManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - nat_gateways = self.nat_gateway_manager.collect_cloud_service(params) - - for nat_gateway in nat_gateways: - print(nat_gateway.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_network_security_group_manager.py b/test/manager/test_network_security_group_manager.py deleted file mode 100644 index 9a67399a..00000000 --- a/test/manager/test_network_security_group_manager.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.network_security_group import NetworkSecurityGroupConnector -from spaceone.inventory.manager.network_security_groups.instance_manager import NetworkSecurityGroupManager - - -class TestNetworkSecurityGroupManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.network_security_group_connector = NetworkSecurityGroupConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.network_security_group_manager = NetworkSecurityGroupManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - network_security_groups = self.network_security_group_manager.collect_cloud_service(params) - - for network_security_group in network_security_groups: - print(network_security_group.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_postgresql_server_manager.py b/test/manager/test_postgresql_server_manager.py deleted file mode 100644 index 34014d17..00000000 --- a/test/manager/test_postgresql_server_manager.py +++ /dev/null @@ -1,49 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.postgresql_server import PostgreSQLServerConnector -from spaceone.inventory.manager.postgresql_servers.server_manager import PostgreSQLServerManager - - -class TestPostgreSQLServerManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.postgresql_server_connector = PostgreSQLServerConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.postgresql_server_manager = PostgreSQLServerManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - subscription_info = { - 'subscription_id': '3ec64e1e-1ce8-4f2c-82a0-a7f6db0899ca', - 'subscription_name': 'Azure subscription 1', - 'tenant_id': '35f43e22-0c0b-4ff3-90aa-b2c04ef1054c' - } - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}, 'subscription_info': subscription_info} - - postgre_sql_servers = self.postgresql_server_manager.collect_cloud_service(params) - - for postgre_sql_server in postgre_sql_servers: - print(postgre_sql_server.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_public_ip_address_manager.py b/test/manager/test_public_ip_address_manager.py deleted file mode 100644 index 31472288..00000000 --- a/test/manager/test_public_ip_address_manager.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.public_ip_address import PublicIPAddressConnector -from spaceone.inventory.manager.public_ip_addresses.ip_address_manager import PublicIPAddressManager - - -class TestPublicIPAddressManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.public_ip_address_connector = PublicIPAddressConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.public_ip_address_manager = PublicIPAddressManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - public_ip_addresses = self.public_ip_address_manager.collect_cloud_service(params) - - for public_ip_address in public_ip_addresses: - print(public_ip_address.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_snapshot_manager.py b/test/manager/test_snapshot_manager.py deleted file mode 100644 index 45d84895..00000000 --- a/test/manager/test_snapshot_manager.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.snapshot import SnapshotConnector -from spaceone.inventory.manager.snapshots.instance_manager import SnapshotManager - - -class TestSnapshotManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.snapshot_connector = SnapshotConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - - cls.snapshot_manager = SnapshotManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - snapshots = self.snapshot_manager.collect_cloud_service(params) - - for snapshot in snapshots: - print(snapshot.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_sql_server_manaer.py b/test/manager/test_sql_server_manaer.py deleted file mode 100644 index 6d330643..00000000 --- a/test/manager/test_sql_server_manaer.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.sql import SqlConnector -from spaceone.inventory.manager.sql_databases.database_manager import SqlServerManager - - -class TestSqlServerManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.sql_server_connector = SqlConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - - cls.sql_server_manager = SqlServerManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - sql_servers = self.sql_server_manager.collect_cloud_service(params) - - for sql_server in sql_servers: - print(sql_server.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_storage_account_manager.py b/test/manager/test_storage_account_manager.py deleted file mode 100644 index 31b2e42c..00000000 --- a/test/manager/test_storage_account_manager.py +++ /dev/null @@ -1,48 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.storage_account import StorageAccountConnector -from spaceone.inventory.manager.storage_accounts.instance_manager import StorageAccountManager - - -class TestVirtualNetworkManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.storage_account_connector = StorageAccountConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.storage_account_manager = StorageAccountManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - subscription_info = { - 'subscription_id': '3ec64e1e-1ce8-4f2c-82a0-a7f6db0899ca', - 'subscription_name': 'Azure subscription 1', - 'tenant_id': '35f43e22-0c0b-4ff3-90aa-b2c04ef1054c' - } - params = {'options': {}, 'secret_data': secret_data, 'subscription_info': subscription_info, 'filter': {}} - - application_gateways = self.storage_account_manager.collect_cloud_service(params) - - for application_gateway in application_gateways: - print(application_gateway.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_virtualnetwork_manager.py b/test/manager/test_virtualnetwork_manager.py deleted file mode 100644 index fe003ebf..00000000 --- a/test/manager/test_virtualnetwork_manager.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.virtual_network import VirtualNetworkConnector -from spaceone.inventory.manager.virtual_networks.instance_manager import VirtualNetworkManager - - -class TestVirtualNetworkManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.vnet_connector = VirtualNetworkConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - cls.vnet_manager = VirtualNetworkManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - virtual_networks = self.vnet_manager.collect_cloud_service(params) - - for virtual_network in virtual_networks: - print(virtual_network.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file diff --git a/test/manager/test_vmss_manager.py b/test/manager/test_vmss_manager.py deleted file mode 100644 index ec480cf5..00000000 --- a/test/manager/test_vmss_manager.py +++ /dev/null @@ -1,45 +0,0 @@ -import unittest -import os -from spaceone.core.unittest.runner import RichTestRunner -from spaceone.core import config -from spaceone.core.transaction import Transaction -from spaceone.core import utils -from spaceone.inventory.connector.vmscaleset import VmScaleSetConnector -from spaceone.inventory.manager.vm_scale_sets.scale_set_manager import VmScaleSetManager - - -class TestVMScaleSetManager(unittest.TestCase): - - @classmethod - def setUpClass(cls): - config.init_conf(package='spaceone.inventory') - - config_path = os.environ.get('TEST_CONFIG') - test_config = utils.load_yaml_from_file(config_path) - - cls.schema = 'azure_client_secret' - cls.azure_credentials = test_config.get('AZURE_CREDENTIALS', {}) - - cls.vmss_connector = VmScaleSetConnector(transaction=Transaction(), config={}, secret_data=cls.azure_credentials) - - cls.vmss_manager = VmScaleSetManager(Transaction()) - - super().setUpClass() - - @classmethod - def tearDownClass(cls) -> None: - super().tearDownClass() - - def test_collect_cloud_service(self, *args): - secret_data = self.azure_credentials - - params = {'options': {}, 'secret_data': secret_data, 'filter': {}} - - vm_scale_sets = self.vmss_manager.collect_cloud_service(params) - - for vm_scale_set in vm_scale_sets: - print(vm_scale_set.to_primitive()) - - -if __name__ == "__main__": - unittest.main(testRunner=RichTestRunner) \ No newline at end of file