from osmclient.common.exceptions import NotFound
import yaml
import json
+import logging
class Nsi(object):
def __init__(self, http=None, client=None):
self._http = http
self._client = client
+ self._logger = logging.getLogger('osmclient')
self._apiName = '/nsilcm'
self._apiVersion = '/v1'
self._apiResource = '/netslice_instances_content'
# NSI '--wait' option
def _wait(self, id, deleteFlag=False):
+ self._logger.debug("")
self._client.get_token()
# Endpoint to get operation status
apiUrlStatus = '{}{}{}'.format(self._apiName, self._apiVersion, '/nsi_lcm_op_occs')
def list(self, filter=None):
"""Returns a list of NSI
"""
+ self._logger.debug("")
self._client.get_token()
filter_string = ''
if filter:
def get(self, name):
"""Returns an NSI based on name or id
"""
+ self._logger.debug("")
self._client.get_token()
if utils.validate_uuid4(name):
for nsi in self.list():
raise NotFound("nsi {} not found".format(name))
def get_individual(self, name):
+ self._logger.debug("")
nsi_id = name
self._client.get_token()
if not utils.validate_uuid4(name):
raise NotFound("nsi {} not found".format(name))
def delete(self, name, force=False, wait=False):
+ self._logger.debug("")
nsi = self.get(name)
querystring = ''
if force:
ssh_keys=None, description='default description',
admin_status='ENABLED', wait=False):
+ self._logger.debug("")
self._client.get_token()
nst = self._client.nst.get(nst_name)
vim_account_id = {}
def get_vim_account_id(vim_account):
+ self._logger.debug("")
if vim_account_id.get(vim_account):
return vim_account_id[vim_account]
not additional_param_subnet.get("additionalParamsForVnf"):
raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain "
"'additionalParamsForNs' and/or 'additionalParamsForVnf'")
+ if "timeout_nsi_deploy" in nsi_config:
+ nsi["timeout_nsi_deploy"] = nsi_config.pop("timeout_nsi_deploy")
# print(yaml.safe_dump(nsi))
try:
message="failed to create nsi: {} nst: {}\nerror:\n{}".format(
nsi_name,
nst_name,
- exc.message)
+ str(exc))
raise ClientException(message)
def list_op(self, name, filter=None):
"""Returns the list of operations of a NSI
"""
+ self._logger.debug("")
nsi = self.get(name)
try:
self._apiResource = '/nsi_lcm_op_occs'
except ClientException as exc:
message="failed to get operation list of NSI {}:\nerror:\n{}".format(
name,
- exc.message)
+ str(exc))
raise ClientException(message)
def get_op(self, operationId):
"""Returns the status of an operation
"""
+ self._logger.debug("")
self._client.get_token()
try:
self._apiResource = '/nsi_lcm_op_occs'
except ClientException as exc:
message="failed to get status of operation {}:\nerror:\n{}".format(
operationId,
- exc.message)
+ str(exc))
raise ClientException(message)
def exec_op(self, name, op_name, op_data=None):
"""Executes an operation on a NSI
"""
+ self._logger.debug("")
nsi = self.get(name)
try:
self._apiResource = '/netslice_instances'
except ClientException as exc:
message="failed to exec operation {}:\nerror:\n{}".format(
name,
- exc.message)
+ str(exc))
raise ClientException(message)