-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from ImMin5/master
Add metric data query for all services
- Loading branch information
Showing
126 changed files
with
9,223 additions
and
4,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ local-conf.yml | |
.venv/ | ||
.venv.nosync/ | ||
.DS_Store | ||
!src/spaceone/inventory/metrics/Disks/disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
MAX_WORKER = 20 | ||
SUPPORTED_FEATURES = ['garbage_collection'] | ||
SUPPORTED_SCHEDULES = ['hours'] | ||
SUPPORTED_RESOURCE_TYPE = ['inventory.CloudService', 'inventory.CloudServiceType', 'inventory.Region'] | ||
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' | ||
ASSET_URL = "https://spaceone-custom-assets.s3.ap-northeast-2.amazonaws.com/console-assets/icons/cloud-services/azure" | ||
|
||
CLOUD_SERVICE_GROUP_MAP = { | ||
'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', | ||
'VirtualMachines': 'VirtualMachinesManager', | ||
'VirtualNetworks': 'VirtualNetworksManager', | ||
'VMScaleSets': 'VmScaleSetsManager', | ||
'WebPubSubService': 'WebPubSubServiceManager', | ||
"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", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,50 @@ | ||
import logging | ||
|
||
import azure.core.exceptions | ||
|
||
from spaceone.inventory.libs.connector import AzureConnector | ||
from spaceone.inventory.error.custom import * | ||
from azure.keyvault.secrets import SecretClient | ||
from azure.keyvault.certificates import CertificateClient | ||
from azure.identity import DefaultAzureCredential | ||
|
||
__all__ = ['KeyVaultsConnector'] | ||
__all__ = ["KeyVaultsConnector"] | ||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class KeyVaultsConnector(AzureConnector): | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
|
||
self.set_connect(kwargs.get('secret_data')) | ||
self.key_vault_secret_client = None | ||
self.key_vault_certificate_client = None | ||
self.set_connect(kwargs.get("secret_data")) | ||
# self.key_vault_secret_client = None | ||
# self.key_vault_certificate_client = None | ||
|
||
def init_key_vault_secret_client(self, subscription_id, vault_uri): | ||
credential = DefaultAzureCredential() | ||
key_vault_secret_client = SecretClient(credential=credential, subscription_id=subscription_id, vault_url=vault_uri) | ||
key_vault_secret_client = SecretClient( | ||
credential=credential, subscription_id=subscription_id, vault_url=vault_uri | ||
) | ||
return key_vault_secret_client | ||
|
||
def init_key_vault_certificate_client(self, subscription_id, vault_uri): | ||
credential = DefaultAzureCredential() | ||
key_vault_certificate_client = CertificateClient(credential=credential, subscription_id=subscription_id, vault_url=vault_uri) | ||
key_vault_certificate_client = CertificateClient( | ||
credential=credential, subscription_id=subscription_id, vault_url=vault_uri | ||
) | ||
return key_vault_certificate_client | ||
|
||
def list_all_key_vaults(self): | ||
return self.key_vault_client.vaults.list_by_subscription() | ||
|
||
def get_key_vaults(self): | ||
return self.key_vault_client.vaults.get() | ||
|
||
def list_keys(self, resource_group_name, vault_name): | ||
return self.key_vault_client.keys.list(resource_group_name=resource_group_name, vault_name=vault_name) | ||
return self.key_vault_client.keys.list( | ||
resource_group_name=resource_group_name, vault_name=vault_name | ||
) | ||
|
||
def list_secrets(self): | ||
return self.key_vault_secret_client.list_properties_of_secrets() | ||
# return self.key_vault_secrets_client.list_properties_of_secrets() | ||
return self.key_vault_client.secrets.list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from spaceone.inventory.connector.resources.connector import ResourcesConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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() |
11 changes: 5 additions & 6 deletions
11
src/spaceone/inventory/connector/storage_accounts/connector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import logging | ||
|
||
from spaceone.inventory.libs.connector import AzureConnector | ||
from spaceone.inventory.error.custom import * | ||
|
||
__all__ = ['StorageAccountsConnector'] | ||
__all__ = ["StorageAccountsConnector"] | ||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class StorageAccountsConnector(AzureConnector): | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.set_connect(kwargs.get('secret_data')) | ||
self.set_connect(kwargs.get("secret_data")) | ||
|
||
def list_storage_accounts(self): | ||
return self.storage_client.storage_accounts.list() | ||
|
||
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) | ||
|
||
return self.storage_client.blob_containers.list( | ||
resource_group_name=rg_name, account_name=account_name | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from spaceone.inventory.info.collector_info import * | ||
from spaceone.inventory.info.job_info import * | ||
from spaceone.inventory.info.common_info import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
__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)), | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.