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 fileutil
-from genericparser.pub.utils import restcall
+from catalog.pub.config.config import SDC_BASE_URL, SDC_USER, SDC_PASSWD
+from catalog.pub.exceptions import CatalogException
+from catalog.pub.utils import fileutil
+from catalog.pub.utils import restcall
logger = logging.getLogger(__name__)
def call_sdc(resource, method, content=''):
additional_headers = {
- 'X-ECOMP-InstanceID': 'Modeling',
+ 'X-ECOMP-InstanceID': 'VFC',
}
return restcall.call_req(base_url=SDC_BASE_URL,
user=SDC_USER,
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 query artifacts(%s) from sdc." % asset_type)
+ raise CatalogException("Failed to query artifacts(%s) from sdc." % asset_type)
return json.JSONDecoder().decode(ret[1])
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 CatalogException("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))
+ raise CatalogException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id))
def get_asset(asset_type, 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))
+ raise CatalogException("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))
+ raise CatalogException("The asset (%s,%s) is not distributed from sdc." % (asset_type, uuid))
else:
return asset
ret = call_sdc(resource, "DELETE")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
- raise GenericparserException("Failed to delete artifacts(%s) from sdc." % artifact_id)
+ raise CatalogException("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': 'Modeling',
+ 'X-ECOMP-InstanceID': 'VFC',
'accept': 'application/octet-stream'
}
ret = restcall.call_req(base_url=SDC_BASE_URL,
additional_headers=additional_headers)
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
- raise GenericparserException("Failed to download %s from sdc." % download_url)
+ raise CatalogException("Failed to download %s from sdc." % download_url)
fileutil.make_dirs(local_path)
local_file_name = os.path.join(local_path, file_name)
local_file = open(local_file_name, 'wb')