diff --git a/src/spaceone/inventory/plugin/collector/lib/metadata.py b/src/spaceone/inventory/plugin/collector/lib/metadata.py index ebf314d..5ff93f7 100644 --- a/src/spaceone/inventory/plugin/collector/lib/metadata.py +++ b/src/spaceone/inventory/plugin/collector/lib/metadata.py @@ -29,9 +29,12 @@ def convert_cloud_service_meta( } -def convert_cloud_service_type_meta(metadata_path: str) -> dict: - yaml_path = _get_yaml_path(metadata_path) - old_metadata = load_yaml_from_file(yaml_path) +def convert_cloud_service_type_meta(metadata_path: str, metadata: dict = None) -> dict: + if not metadata: + yaml_path = _get_yaml_path(metadata_path) + old_metadata = load_yaml_from_file(yaml_path) + else: + old_metadata = metadata return MetadataGenerator(old_metadata).generate_metadata() diff --git a/src/spaceone/inventory/plugin/collector/lib/utils.py b/src/spaceone/inventory/plugin/collector/lib/utils.py index 8fcd285..e952e15 100644 --- a/src/spaceone/inventory/plugin/collector/lib/utils.py +++ b/src/spaceone/inventory/plugin/collector/lib/utils.py @@ -22,13 +22,17 @@ def make_cloud_service_type( name, group, provider, - metadata_path, + metadata_path=None, + metadata=None, is_primary=False, is_major=False, service_code=None, tags=None, labels=None, ) -> dict: + if not metadata and metadata_path is None: + raise ERROR_REQUIRED_PARAMETER(key="metadata or metadata_path") + if tags is None: tags = {} if labels is None: @@ -38,7 +42,9 @@ def make_cloud_service_type( name=name, group=group, provider=provider, - json_metadata=utils.dump_json(convert_cloud_service_type_meta(metadata_path)), + json_metadata=utils.dump_json( + convert_cloud_service_type_meta(metadata_path, metadata) + ), is_primary=is_primary, is_major=is_major, service_code=service_code,