self._user_endpoint = 'admin/v1/users'
self._host = os.getenv('OSM_SERVER', "localhost")
self._so_port = 9999
- self._base_path = 'https://{0}:{1}/osm'.format(self._host, self._so_port)
+ self._base_path = 'https://{0}:{1}/osm'.format(
+ self._host, self._so_port)
def auth(self, args):
result = {'error': True, 'data': ''}
token_url = "{0}/{1}".format(self._base_path, self._token_endpoint)
- headers = {"Content-Type": "application/yaml", "accept": "application/json"}
+ headers = {"Content-Type": "application/yaml",
+ "accept": "application/json"}
try:
- r = requests.post(token_url, json=args, verify=False, headers=headers)
+ r = requests.post(token_url, json=args,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
def switch_project(self, args):
result = {'error': True, 'data': ''}
token_url = "{0}/{1}".format(self._base_path, self._token_endpoint)
- headers = {"Content-Type": "application/yaml", "accept": "application/json"}
+ headers = {"Content-Type": "application/yaml",
+ "accept": "application/json"}
try:
- r = requests.post(token_url, json=args, verify=False, headers=headers)
+ r = requests.post(token_url, json=args,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/roles".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/roles".format(self._base_path)
try:
- r = requests.post(_url, json=role_data, verify=False, headers=headers)
+ r = requests.post(_url, json=role_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/roles/{1}".format(self._base_path, role_id)
try:
- r = requests.patch(_url, json=role_data, verify=False, headers=headers)
+ r = requests.patch(_url, json=role_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
else:
result['data'] = Util.json_loads_byteified(r.text)
return result
-
+
def role_delete(self, token, id, force=None):
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
query_path = ''
if force:
query_path = '?FORCE=true'
- _url = "{0}/admin/v1/roles/{1}{2}".format(self._base_path, id, query_path)
+ _url = "{0}/admin/v1/roles/{1}{2}".format(
+ self._base_path, id, query_path)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
-
+
_url = "{0}/admin/v1/roles/{1}".format(self._base_path, id)
try:
r = requests.get(_url, params=None, verify=False, headers=headers)
_url = "{0}/admin/v1/users".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/users".format(self._base_path)
try:
- r = requests.post(_url, json=user_data, verify=False, headers=headers)
+ r = requests.post(_url, json=user_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/users/{1}".format(self._base_path, id)
try:
- r = requests.patch(_url, json=user_data, verify=False, headers=headers)
+ r = requests.patch(_url, json=user_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/users/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/users/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result['data'] = Util.json_loads_byteified(r.text)
return result
+ def get_domains(self, token):
+ result = {'error': False, 'data': ''}
+ headers = {"accept": "application/json", 'Authorization': 'Bearer {}'.format(token['id'])}
+
+ _url = "{0}/admin/v1/domains".format(self._base_path)
+ try:
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
+ except Exception as e:
+ log.exception(e)
+ result['data'] = str(e)
+ return result
+ if r.status_code in (200, 201, 202, 204):
+ result['error'] = False
+
+ result['data'] = Util.json_loads_byteified(r.text)
+ return result
+
def get_projects(self, token, uuids):
result = {'error': False, 'data': ''}
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
-
+
projects = []
try:
for uuid in uuids:
- _url = "{0}/admin/v1/projects/{1}".format(self._base_path, uuid)
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ _url = "{0}/admin/v1/projects/{1}".format(
+ self._base_path, uuid)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
if r.status_code not in (200, 201, 202, 204):
raise Exception()
projects.append(Util.json_loads_byteified(r.text))
_url = "{0}/admin/v1/projects".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/projects/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/projects".format(self._base_path)
try:
- r = requests.post(_url, json=project_data, verify=False, headers=headers)
+ r = requests.post(_url, json=project_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/projects/{1}".format(self._base_path, id)
try:
- r = requests.patch(_url, json=project_data, verify=False, headers=headers)
+ r = requests.patch(_url, json=project_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/projects/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nst/v1/netslice_templates/{1}".format(self._base_path,id)
+ _url = "{0}/nst/v1/netslice_templates/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "text/plain",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nst/v1/netslice_templates/{1}/nst".format(self._base_path,id)
+ _url = "{0}/nst/v1/netslice_templates/{1}/nst".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
return result
if r.status_code in (200, 201, 202, 204):
result['error'] = False
- result['data'] = Util.json2yaml(yaml.load(str(r.text)))
+ result['data'] = Util.json2yaml(yaml.load(str(r.text)))
return result
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
-
+
_url = "{0}/nst/v1/netslice_templates".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
query_path = ''
if filter:
query_path = '?_admin.type='+filter
- _url = "{0}/nsd/v1/ns_descriptors_content{1}".format(self._base_path, query_path)
+ _url = "{0}/nsd/v1/ns_descriptors_content{1}".format(
+ self._base_path, query_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
query_path = ''
if filter:
query_path = '?_admin.type='+filter
- _url = "{0}/vnfpkgm/v1/vnf_packages_content{1}".format(self._base_path, query_path)
+ _url = "{0}/vnfpkgm/v1/vnf_packages_content{1}".format(
+ self._base_path, query_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/nsilcm/v1/netslice_instances".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result['data'] = Util.json_loads_byteified(r.text)
return result
-
+
def ns_list(self, token):
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/nslcm/v1/ns_instances_content".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/nslcm/v1/vnfrs".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/pdu/v1/pdu_descriptors".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nst/v1/netslice_templates/{1}?FORCE=True".format(self._base_path, id)
+ _url = "{0}/nst/v1/netslice_templates/{1}?FORCE=True".format(
+ self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
return result
if r.status_code in (200, 201, 202, 204):
result['error'] = False
-
+
return result
def nsd_delete(self, token, id):
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsd/v1/ns_descriptors_content/{1}".format(self._base_path, id)
+ _url = "{0}/nsd/v1/ns_descriptors_content/{1}".format(
+ self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/vnfpkgm/v1/vnf_packages_content/{1}".format(self._base_path, id)
+ _url = "{0}/vnfpkgm/v1/vnf_packages_content/{1}".format(
+ self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
headers["Content-Type"] = "application/gzip"
else:
headers["Content-Type"] = "application/yaml"
- r = requests.post(_url, data=template, verify=False, headers=headers)
+ r = requests.post(_url, data=template,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
with open('/tmp/' + package.name, 'wb+') as destination:
for chunk in package.chunks():
destination.write(chunk)
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + package.name, 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + package.name, 'rb'))
_url = "{0}/nsd/v1/ns_descriptors_content/".format(self._base_path)
try:
- r = requests.post(_url, data=open('/tmp/' + package.name, 'rb'), verify=False, headers=headers)
+ r = requests.post(_url, data=open(
+ '/tmp/' + package.name, 'rb'), verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
with open('/tmp/' + package.name, 'wb+') as destination:
for chunk in package.chunks():
destination.write(chunk)
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + package.name, 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + package.name, 'rb'))
_url = "{0}/vnfpkgm/v1/vnf_packages_content".format(self._base_path)
try:
- r = requests.post(_url, data=open('/tmp/' + package.name, 'rb'), verify=False, headers=headers)
+ r = requests.post(_url, data=open(
+ '/tmp/' + package.name, 'rb'), verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
try:
self._create_base_pkg('nsd', pkg_name)
headers['Content-Filename'] = pkg_name + '.tar.gz'
- r = requests.post(_url, data=open('/tmp/' + pkg_name + '.tar.gz', 'rb'), verify=False, headers=headers)
+ r = requests.post(_url, data=open(
+ '/tmp/' + pkg_name + '.tar.gz', 'rb'), verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
try:
self._create_base_pkg('vnfd', pkg_name)
- r = requests.post(_url, data=open('/tmp/' + pkg_name + '.tar.gz', 'rb'), verify=False, headers=headers)
+ r = requests.post(_url, data=open(
+ '/tmp/' + pkg_name + '.tar.gz', 'rb'), verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
tar_pkg = self.get_nsd_pkg(token, id)
tarf = tarfile.open(fileobj=tar_pkg)
tarf = self._descriptor_clone(tarf, 'nsd')
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'))
_url = "{0}/nsd/v1/ns_descriptors_content/".format(self._base_path)
tarf = tarfile.open(fileobj=tar_pkg)
tarf = self._descriptor_clone(tarf, 'vnfd')
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'))
_url = "{0}/vnfpkgm/v1/vnf_packages_content".format(self._base_path)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nst/v1/netslice_templates/{1}/nst_content".format(self._base_path,id)
+ _url = "{0}/nst/v1/netslice_templates/{1}/nst_content".format(
+ self._base_path, id)
try:
- r = requests.put(_url, data=template, verify=False, headers=headers)
+ r = requests.put(_url, data=template,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
tarf = tarfile.open(fileobj=tar_pkg)
tarf = self._descriptor_update(tarf, data)
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'))
- _url = "{0}/nsd/v1/ns_descriptors/{1}/nsd_content".format(self._base_path, id)
+ _url = "{0}/nsd/v1/ns_descriptors/{1}/nsd_content".format(
+ self._base_path, id)
try:
r = requests.put(_url, data=open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'), verify=False,
tarf = tarfile.open(fileobj=tar_pkg)
tarf = self._descriptor_update(tarf, data)
- headers['Content-File-MD5'] = self.md5(open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'))
+ headers['Content-File-MD5'] = self.md5(
+ open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'))
- _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/package_content".format(self._base_path, id)
+ _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/package_content".format(
+ self._base_path, id)
try:
r = requests.put(_url, data=open('/tmp/' + tarf.getnames()[0] + ".tar.gz", 'rb'), verify=False,
headers = {"accept": "application/zip",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsd/v1/ns_descriptors/{1}/nsd_content".format(self._base_path, id)
+ _url = "{0}/nsd/v1/ns_descriptors/{1}/nsd_content".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"accept": "application/zip",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/package_content".format(self._base_path, id)
+ _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/package_content".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
def _descriptor_update(self, tarf, data):
# extract the package on a tmp directory
- tarf.extractall('/tmp')
+ tarf.extractall('/tmp')
regex = re.compile(r"^[^/]+(/[^/]+\.(yaml|yml))$", re.U)
for name in tarf.getnames():
if regex.match(name):
yaml.safe_dump(data, outfile, default_flow_style=False)
break
- tarf_temp = tarfile.open('/tmp/' + tarf.getnames()[0] + ".tar.gz", "w:gz")
+ tarf_temp = tarfile.open(
+ '/tmp/' + tarf.getnames()[0] + ".tar.gz", "w:gz")
for tarinfo in tarf:
- tarf_temp.add('/tmp/' + tarinfo.name, tarinfo.name, recursive=False)
+ tarf_temp.add('/tmp/' + tarinfo.name,
+ tarinfo.name, recursive=False)
tarf_temp.close()
return tarf
yaml_file.write(yaml.dump(descriptor, default_flow_style=False))
tarf_temp = tarfile.open('/tmp/' + pkg_name + '.tar.gz', "w:gz")
- tarf_temp.add('/tmp/'+pkg_name+'/' + pkg_name + '.yaml', pkg_name + '/' + pkg_name + '.yaml', recursive=False)
+ tarf_temp.add('/tmp/'+pkg_name+'/' + pkg_name + '.yaml',
+ pkg_name + '/' + pkg_name + '.yaml', recursive=False)
tarf_temp.close()
def _descriptor_clone(self, tarf, descriptor_type):
vnfd['short-name'] = 'clone_' + vnfd['short-name']
with open('/tmp/' + name, 'w') as yaml_file:
- yaml_file.write(yaml.dump(yaml_object, default_flow_style=False))
+ yaml_file.write(
+ yaml.dump(yaml_object, default_flow_style=False))
break
- tarf_temp = tarfile.open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", "w:gz")
+ tarf_temp = tarfile.open(
+ '/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", "w:gz")
for tarinfo in tarf:
- tarf_temp.add('/tmp/' + tarinfo.name, tarinfo.name, recursive=False)
+ tarf_temp.add('/tmp/' + tarinfo.name,
+ tarinfo.name, recursive=False)
tarf_temp.close()
return tarf
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/nsd/v1/ns_descriptors/{1}/nsd".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {'Content-Type': 'application/yaml',
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/vnfd".format(self._base_path, id)
+ _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/vnfd".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {'Content-Type': 'application/yaml', 'accept': 'text/plain',
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsd/v1/ns_descriptors/{1}/artifacts".format(self._base_path, id)
+ _url = "{0}/nsd/v1/ns_descriptors/{1}/artifacts".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {'Content-Type': 'application/yaml', 'accept': 'text/plain',
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/artifacts".format(self._base_path, id)
+ _url = "{0}/vnfpkgm/v1/vnf_packages/{1}/artifacts".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
headers = {"Content-Type": "application/yaml", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsilcm/v1/netslice_instances_content".format(self._base_path)
+ _url = "{0}/nsilcm/v1/netslice_instances_content".format(
+ self._base_path)
try:
- r = requests.post(_url, json=nsi_data, verify=False, headers=headers)
+ r = requests.post(_url, json=nsi_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/nslcm/v1/ns_instances_content".format(self._base_path)
try:
- r = requests.post(_url, json=ns_data, verify=False, headers=headers)
+ r = requests.post(_url, json=ns_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/pdu/v1/pdu_descriptors".format(self._base_path)
try:
- r = requests.post(_url, json=pdu_data, verify=False, headers=headers)
+ r = requests.post(_url, json=pdu_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nslcm/v1/ns_lcm_op_occs/?nsInstanceId={1}".format(self._base_path, id)
+ _url = "{0}/nslcm/v1/ns_lcm_op_occs/?nsInstanceId={1}".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsilcm/v1/nsi_lcm_op_occs/?netsliceInstanceId={1}".format(self._base_path, id)
+ _url = "{0}/nsilcm/v1/nsi_lcm_op_occs/?netsliceInstanceId={1}".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/nslcm/v1/ns_lcm_op_occs/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nslcm/v1/ns_instances/{1}/action".format(self._base_path, id)
+ _url = "{0}/nslcm/v1/ns_instances/{1}/action".format(
+ self._base_path, id)
try:
- r = requests.post(_url, json=action_payload, verify=False, headers=headers)
+ r = requests.post(_url, json=action_payload,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
query_path = ''
if force:
query_path = '?FORCE=true'
- _url = "{0}/nsilcm/v1/netslice_instances_content/{1}{2}".format(self._base_path, id, query_path)
+ _url = "{0}/nsilcm/v1/netslice_instances_content/{1}{2}".format(
+ self._base_path, id, query_path)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
query_path = ''
if force:
query_path = '?FORCE=true'
- _url = "{0}/nslcm/v1/ns_instances_content/{1}{2}".format(self._base_path, id, query_path)
+ _url = "{0}/nslcm/v1/ns_instances_content/{1}{2}".format(
+ self._base_path, id, query_path)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/pdu/v1/pdu_descriptors/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nsilcm/v1/netslice_instances/{1}".format(self._base_path, id)
+ _url = "{0}/nsilcm/v1/netslice_instances/{1}".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result = {'error': True, 'data': ''}
headers = {"Content-Type": "application/json", "accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
- _url = "{0}/nslcm/v1/ns_instances_content/{1}".format(self._base_path, id)
+ _url = "{0}/nslcm/v1/ns_instances_content/{1}".format(
+ self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/nslcm/v1/vnfrs/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/pdu/v1/pdu_descriptors/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/test/message/alarm_request".format(self._base_path)
try:
- r = requests.post(_url, json=alarm_payload, verify=False, headers=headers)
+ r = requests.post(_url, json=alarm_payload,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/test/message/metric_request".format(self._base_path)
try:
- r = requests.post(_url, json=metric_payload, verify=False, headers=headers)
+ r = requests.post(_url, json=metric_payload,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/wim_accounts".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/vims".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/wim_accounts/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/vims/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/wim_accounts/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/vims/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/wim_accounts".format(self._base_path)
try:
- r = requests.post(_url, json=wim_data, verify=False, headers=headers)
+ r = requests.post(_url, json=wim_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/vims".format(self._base_path)
try:
- r = requests.post(_url, json=vim_data, verify=False, headers=headers)
+ r = requests.post(_url, json=vim_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/sdns".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/sdns/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/sdns/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/sdns".format(self._base_path)
try:
- r = requests.post(_url, json=sdn_data, verify=False, headers=headers)
+ r = requests.post(_url, json=sdn_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/k8sclusters/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
result['error'] = False
result['data'] = Util.json_loads_byteified(r.text)
return result
-
+
def k8sc_list(self, token):
result = {'error': True, 'data': ''}
headers = {"accept": "application/json",
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/k8sclusters".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8sclusters".format(self._base_path)
try:
- r = requests.post(_url, json=cluster_data, verify=False, headers=headers)
+ r = requests.post(_url, json=cluster_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8sclusters/{1}".format(self._base_path, id)
try:
- r = requests.patch(_url, json=cluster_data, verify=False, headers=headers)
+ r = requests.patch(_url, json=cluster_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8sclusters/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/k8srepos/{1}".format(self._base_path, id)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
'Authorization': 'Bearer {}'.format(token['id'])}
_url = "{0}/admin/v1/k8srepos".format(self._base_path)
try:
- r = requests.get(_url, params=None, verify=False, stream=True, headers=headers)
+ r = requests.get(_url, params=None, verify=False,
+ stream=True, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8srepos".format(self._base_path)
try:
- r = requests.post(_url, json=cluster_data, verify=False, headers=headers)
+ r = requests.post(_url, json=cluster_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8srepos/{1}".format(self._base_path, id)
try:
- r = requests.patch(_url, json=cluster_data, verify=False, headers=headers)
+ r = requests.patch(_url, json=cluster_data,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)
_url = "{0}/admin/v1/k8srepos/{1}".format(self._base_path, id)
try:
- r = requests.delete(_url, params=None, verify=False, headers=headers)
+ r = requests.delete(_url, params=None,
+ verify=False, headers=headers)
except Exception as e:
log.exception(e)
result['data'] = str(e)