logger = logging.getLogger(__name__)
-ASSETTYPE_RESOURCES = "resources"
+ASSETTYPE_RESOURCES = "resources"
ASSETTYPE_SERVICES = "services"
+
def call_sdc(resource, method, content=''):
additional_headers = {
'X-ECOMP-InstanceID': 'VFC',
}
- return restcall.call_req(base_url=SDC_BASE_URL,
- user=SDC_USER,
- passwd=SDC_PASSWD,
- auth_type=restcall.rest_no_auth,
- resource=resource,
- method=method,
- content=content,
- additional_headers=additional_headers)
+ return restcall.call_req(base_url=SDC_BASE_URL,
+ user=SDC_USER,
+ passwd=SDC_PASSWD,
+ auth_type=restcall.rest_no_auth,
+ resource=resource,
+ method=method,
+ content=content,
+ additional_headers=additional_headers)
+
"""
sample of return value
}
]
"""
+
+
def get_artifacts(asset_type):
resource = "/sdc/v1/catalog/{assetType}"
resource = resource.format(assetType=asset_type)
raise NSLCMException("Failed to query artifacts(%s) from sdc." % asset_type)
return json.JSONDecoder().decode(ret[1])
+
def get_artifact(asset_type, csar_id):
artifacts = get_artifacts(asset_type)
for artifact in artifacts:
return artifact
raise NSLCMException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id))
+
def delete_artifact(asset_type, asset_id, artifact_id):
resource = "/sdc/v1/catalog/{assetType}/{uuid}/artifacts/{artifactUUID}"
resource = resource.format(assetType=asset_type, uuid=asset_id, artifactUUID=artifact_id)
raise NSLCMException("Failed to delete artifacts(%s) from sdc." % artifact_id)
return json.JSONDecoder().decode(ret[1])
+
def download_artifacts(download_url, local_path, file_name):
additional_headers = {
'X-ECOMP-InstanceID': 'VFC',
'accept': 'application/octet-stream'
}
- ret = restcall.call_req(base_url=SDC_BASE_URL,
- user=SDC_USER,
- passwd=SDC_PASSWD,
- auth_type=rest_no_auth,
- resource=download_url,
- method="GET",
- additional_headers=additional_headers)
+ ret = restcall.call_req(base_url=SDC_BASE_URL,
+ user=SDC_USER,
+ passwd=SDC_PASSWD,
+ auth_type=restcall.rest_no_auth,
+ resource=download_url,
+ method="GET",
+ additional_headers=additional_headers)
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Failed to download %s from sdc." % download_url)
local_file.write(ret[1])
local_file.close()
return local_file_name
-
-
-
-
-
-
-
-
-
-
-