import logging
import os
+from genericparser.pub.config.config import SDC_BASE_URL, SDC_USER, SDC_PASSWD
from genericparser.pub.exceptions import GenericparserException
-from genericparser.pub.utils import restcall
from genericparser.pub.utils import fileutil
-from genericparser.pub.config.config import SDC_BASE_URL, SDC_USER, SDC_PASSWD
+from genericparser.pub.utils import restcall
logger = logging.getLogger(__name__)
"invariantUUID": "63eaec39-ffbe-411c-a838-448f2c73f7eb",
"name": "underlayvpn",
"version": "2.0",
- "toscaModelURL": "/sdc/v1/genericparser/resources/c94490a0-f7ef-48be-b3f8-8d8662a37236/toscaModel",
+ "toscaModelURL": "/sdc/v1/catalog/resources/c94490a0-f7ef-48be-b3f8-8d8662a37236/toscaModel",
"category": "Volte",
"subCategory": "VolteVF",
"resourceType": "VF",
def get_artifacts(asset_type):
- resource = "/sdc/v1/genericparser/{assetType}"
+ resource = "/sdc/v1/catalog/{assetType}"
resource = resource.format(assetType=asset_type)
ret = call_sdc(resource, "GET")
if ret[0] != 0:
if artifact["uuid"] == csar_id:
if asset_type == ASSETTYPE_SERVICES and \
artifact.get("distributionStatus", None) != DISTRIBUTED:
- raise GenericparserException("The artifact (%s,%s) is not distributed from sdc." % (asset_type, csar_id))
+ raise GenericparserException(
+ "The artifact (%s,%s) is not distributed from sdc." % (asset_type, csar_id))
else:
return artifact
raise GenericparserException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id))
+def get_asset(asset_type, uuid):
+ resource = "/sdc/v1/catalog/{assetType}/{uuid}/metadata".format(assetType=asset_type, uuid=uuid)
+ ret = call_sdc(resource, "GET")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise GenericparserException("Failed to get asset(%s, %s) from sdc." % (asset_type, uuid))
+ asset = json.JSONDecoder().decode(ret[1])
+ if asset.get("distributionStatus", None) != DISTRIBUTED:
+ raise GenericparserException("The asset (%s,%s) is not distributed from sdc." % (asset_type, uuid))
+ else:
+ return asset
+
+
def delete_artifact(asset_type, asset_id, artifact_id):
- resource = "/sdc/v1/genericparser/{assetType}/{uuid}/artifacts/{artifactUUID}"
+ resource = "/sdc/v1/catalog/{assetType}/{uuid}/artifacts/{artifactUUID}"
resource = resource.format(assetType=asset_type, uuid=asset_id, artifactUUID=artifact_id)
ret = call_sdc(resource, "DELETE")
if ret[0] != 0: