WIM handler
[osm/LW-UI.git] / lib / osm / osmclient / clientv2.py
index feb710c..0914fb3 100644 (file)
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 #
-
+import errno
 import requests
 import logging
-import json
 import tarfile
 import yaml
-import pyaml
 import StringIO
 from lib.util import Util
 import hashlib
 import os
+from requests.packages.urllib3.exceptions import InsecureRequestWarning
+
+requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.INFO)
 log = logging.getLogger('helper.py')
+logging.getLogger("urllib3").setLevel(logging.INFO)
 
 
 class Client(object):
@@ -35,7 +37,7 @@ class Client(object):
         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': ''}
@@ -102,12 +104,29 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.created:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def user_update(self, token, id, user_data):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/json", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/admin/v1/users/{1}".format(self._base_path, id)
+        try:
+            r = requests.patch(_url, json=user_data, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.no_content:
+            result['error'] = False
+        else:
+            result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def user_delete(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
@@ -190,7 +209,6 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.created:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
@@ -210,7 +228,6 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.no_content:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
@@ -234,12 +251,46 @@ class Client(object):
             result['data'] = Util.json_loads_byteified(r.text)
         return result
 
-    def nsd_list(self, token):
+    def nst_details(self, token, id):
         result = {'error': True, 'data': ''}
-        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+        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)
+        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 == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
 
-        _url = "{0}/nsd/v1/ns_descriptors_content".format(self._base_path)
+        return result
+
+    def nst_content(self, token, id):
+        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)
+        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 == requests.codes.ok:
+            result['error'] = False
+        result['data']  = Util.json2yaml(yaml.load(str(r.text)))
+
+        return result
+
+    def nst_list(self, token):
+        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)
         except Exception as e:
@@ -252,12 +303,34 @@ class Client(object):
 
         return result
 
-    def vnfd_list(self, token):
+    def nsd_list(self, token, filter=None):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
                    'Authorization': 'Bearer {}'.format(token['id'])}
+        query_path = ''
+        if filter:
+            query_path = '?_admin.type='+filter
+        _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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
 
-        _url = "{0}/vnfpkgm/v1/vnf_packages_content".format(self._base_path)
+        return result
+
+    def vnfd_list(self, token, filter=None):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+        query_path = ''
+        if filter:
+            query_path = '?_admin.type='+filter
+        _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)
         except Exception as e:
@@ -270,6 +343,23 @@ class Client(object):
 
         return result
 
+    def nsi_list(self, token):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   '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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        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",
@@ -304,6 +394,40 @@ class Client(object):
 
         return result
 
+    def pdu_list(self, token):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   '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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+
+        return result
+
+    def nst_delete(self, token, id):
+        result = {'error': True, 'data': ''}
+        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)
+        try:
+            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 == requests.codes.no_content:
+            result['error'] = False
+        
+        return result
+
     def nsd_delete(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
@@ -311,7 +435,7 @@ class Client(object):
 
         _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)
@@ -339,17 +463,38 @@ class Client(object):
             result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def nst_onboard(self, token, template):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/gzip", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+        _url = "{0}/nst/v1/netslice_templates_content".format(self._base_path)
+        try:
+            fileName, fileExtension = os.path.splitext(template.name)
+            if fileExtension == '.gz':
+                headers["Content-Type"] = "application/gzip"
+            else:
+                headers["Content-Type"] = "application/yaml"
+            r = requests.post(_url, data=template, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def nsd_onboard(self, token, package):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/gzip", "accept": "application/json",
                    'Authorization': 'Bearer {}'.format(token['id'])}
-        with open('/tmp/'+package.name, 'wb+') as destination:
+        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)
@@ -363,13 +508,13 @@ class Client(object):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/gzip", "accept": "application/json",
                    'Authorization': 'Bearer {}'.format(token['id'])}
-        with open('/tmp/'+package.name, 'wb+') as destination:
+        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)
@@ -379,6 +524,119 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def nsd_create_pkg_base(self, token, pkg_name):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/gzip", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/nsd/v1/ns_descriptors_content/".format(self._base_path)
+
+        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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['data'] = r.json()
+            result['error'] = False
+        if r.status_code == requests.codes.conflict:
+            result['data'] = "Invalid ID."
+        return result
+
+    def vnfd_create_pkg_base(self, token, pkg_name):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/gzip", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/vnfpkgm/v1/vnf_packages_content".format(self._base_path)
+
+        try:
+            self._create_base_pkg('vnfd', pkg_name)
+            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)
+            return result
+        if r.status_code == requests.codes.created:
+            result['data'] = r.json()
+            result['error'] = False
+        if r.status_code == requests.codes.conflict:
+            result['data'] = "Invalid ID."
+        return result
+
+    def nsd_clone(self, token, id):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/gzip", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        # get the package onboarded
+        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'))
+
+        _url = "{0}/nsd/v1/ns_descriptors_content/".format(self._base_path)
+
+        try:
+            r = requests.post(_url, data=open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'), verify=False,
+                              headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        if r.status_code == requests.codes.conflict:
+            result['data'] = "Invalid ID."
+
+        return result
+
+    def vnfd_clone(self, token, id):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/gzip", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        # get the package onboarded
+        tar_pkg = self.get_vnfd_pkg(token, id)
+        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'))
+
+        _url = "{0}/vnfpkgm/v1/vnf_packages_content".format(self._base_path)
+
+        try:
+            r = requests.post(_url, data=open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", 'rb'), verify=False,
+                              headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        if r.status_code == requests.codes.conflict:
+            result['data'] = "Invalid ID."
+
+        return result
+
+    def nst_content_update(self, token, id, template):
+        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)
+        try:
+            r = requests.put(_url, data=template, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.no_content:
+            result['error'] = False
+        return result
+
     def nsd_update(self, token, id, data):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/gzip", "accept": "application/json",
@@ -402,6 +660,11 @@ class Client(object):
             return result
         if r.status_code == requests.codes.no_content:
             result['error'] = False
+        else:
+            try:
+                result['data'] = r.json()
+            except Exception as e:
+                result['data'] = {}
 
         return result
 
@@ -428,12 +691,17 @@ class Client(object):
             return result
         if r.status_code == requests.codes.no_content:
             result['error'] = False
+        else:
+            try:
+                result['data'] = r.json()
+            except Exception as e:
+                result['data'] = {}
 
         return result
 
     def get_nsd_pkg(self, token, id):
         result = {'error': True, 'data': ''}
-        headers = { "accept": "application/zip",
+        headers = {"accept": "application/zip",
                    'Authorization': 'Bearer {}'.format(token['id'])}
 
         _url = "{0}/nsd/v1/ns_descriptors/{1}/nsd_content".format(self._base_path, id)
@@ -456,7 +724,6 @@ class Client(object):
         _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)
-            print r.status_code
         except Exception as e:
             log.exception(e)
             result['data'] = str(e)
@@ -468,7 +735,6 @@ class Client(object):
         return result
 
     def _descriptor_update(self, tarf, data):
-        print tarf.getnames()
         # extract the package on a tmp directory
         tarf.extractall('/tmp')
 
@@ -479,14 +745,97 @@ class Client(object):
                 break
 
         tarf_temp = tarfile.open('/tmp/' + tarf.getnames()[0] + ".tar.gz", "w:gz")
-        # tarf_temp = tarfile.open("pippo.tar.gz", "w:gz")
-        print tarf_temp.getnames()
-        # tarf_temp.add('/tmp/'+tarf.getnames()[0])
+
+        for tarinfo in tarf:
+            tarf_temp.add('/tmp/' + tarinfo.name, tarinfo.name, recursive=False)
+        tarf_temp.close()
+        return tarf
+
+    def _create_base_pkg(self, descriptor_type, pkg_name):
+        filename = '/tmp/'+pkg_name+'/' + pkg_name + '.yaml'
+        if descriptor_type == 'nsd':
+            descriptor = {
+                "nsd:nsd-catalog": {
+                    "nsd": [
+                        {
+                            "short-name": str(pkg_name),
+                            "vendor": "OSM Composer",
+                            "description": str(pkg_name) + " descriptor",
+                            "vld": [],
+                            "constituent-vnfd": [],
+                            "version": "1.0",
+                            "id": str(pkg_name),
+                            "name": str(pkg_name)
+                        }
+                    ]
+                }
+            }
+
+        elif descriptor_type == 'vnfd':
+            descriptor = {
+                "vnfd:vnfd-catalog": {
+                    "vnfd": [
+                        {
+                            "short-name": str(pkg_name),
+                            "vdu": [],
+                            "description": "",
+                            "mgmt-interface": {
+                                "cp": ""
+                            },
+                            "id": str(pkg_name),
+                            "version": "1.0",
+                            "internal-vld": [],
+                            "connection-point": [],
+                            "name": str(pkg_name)
+                        }
+                    ]
+                }
+            }
+
+        if not os.path.exists(os.path.dirname(filename)):
+            try:
+                os.makedirs(os.path.dirname(filename))
+            except OSError as exc:  # Guard against race condition
+                if exc.errno != errno.EEXIST:
+                    raise
+
+        with open('/tmp/' + pkg_name + '/' + pkg_name + '.yaml', 'w') as yaml_file:
+            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.close()
+
+    def _descriptor_clone(self, tarf, descriptor_type):
+        # extract the package on a tmp directory
+        tarf.extractall('/tmp')
+
+        for name in tarf.getnames():
+            if name.endswith(".yaml") or name.endswith(".yml"):
+                with open('/tmp/' + name, 'r') as outfile:
+                    yaml_object = yaml.load(outfile)
+
+                    if descriptor_type == 'nsd':
+                        nsd_list = yaml_object['nsd:nsd-catalog']['nsd']
+                        for nsd in nsd_list:
+                            nsd['id'] = 'clone_' + nsd['id']
+                            nsd['name'] = 'clone_' + nsd['name']
+                            nsd['short-name'] = 'clone_' + nsd['short-name']
+                    elif descriptor_type == 'vnfd':
+                        vnfd_list = yaml_object['vnfd:vnfd-catalog']['vnfd']
+                        for vnfd in vnfd_list:
+                            vnfd['id'] = 'clone_' + vnfd['id']
+                            vnfd['name'] = 'clone_' + vnfd['name']
+                            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))
+                break
+
+        tarf_temp = tarfile.open('/tmp/' + tarf.getnames()[0] + "_clone.tar.gz", "w:gz")
+
         for tarinfo in tarf:
-            # if tarinfo.name.startswith(tarf.getnames()[0]):
-            #    new_name = tarinfo.name[len(tarf.getnames()[0]):]
             tarf_temp.add('/tmp/' + tarinfo.name, tarinfo.name, recursive=False)
-        print tarf_temp.getnames()
         tarf_temp.close()
         return tarf
 
@@ -576,6 +925,24 @@ class Client(object):
 
         return result
 
+    def nsi_create(self, token, nsi_data):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/nsilcm/v1/netslice_instances_content".format(self._base_path)
+
+        try:
+            r = requests.post(_url, json=nsi_data, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def ns_create(self, token, ns_data):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
@@ -594,6 +961,24 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def pdu_create(self, token, pdu_data):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/pdu/v1/pdu_descriptors".format(self._base_path)
+
+        try:
+            r = requests.post(_url, json=pdu_data, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def ns_op_list(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/json", "accept": "application/json",
@@ -612,6 +997,24 @@ class Client(object):
 
         return result
 
+    def nsi_op_list(self, token, id):
+        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/?nsInstanceId={1}".format(self._base_path, id)
+
+        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 == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+
+        return result
+
     def ns_op(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/json", "accept": "application/json",
@@ -643,12 +1046,31 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.created:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def nsi_delete(self, token, id, force=None):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+        query_path = ''
+        if force:
+            query_path = '?FORCE=true'
+        _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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r:
+            result['error'] = False
+        if r.status_code != requests.codes.no_content:
+            result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def ns_delete(self, token, id, force=None):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
@@ -669,6 +1091,40 @@ class Client(object):
             result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def pdu_delete(self, token, id):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   '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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r:
+            result['error'] = False
+        if r.status_code != requests.codes.no_content:
+            result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
+    def nsi_get(self, token, id):
+        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)
+
+        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 == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def ns_get(self, token, id):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/json", "accept": "application/json",
@@ -703,6 +1159,23 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def pdu_get(self, token, id):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/json", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+        _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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def ns_alarm_create(self, token, id, alarm_payload):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/json",
@@ -714,10 +1187,9 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.ok:
             result['error'] = False
-        #result['data'] = Util.json_loads_byteified(r.text)
+        # result['data'] = Util.json_loads_byteified(r.text)
         result['data'] = r.text
         return result
 
@@ -732,13 +1204,29 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.ok:
             result['error'] = False
-        #result['data'] = Util.json_loads_byteified(r.text)
+        # result['data'] = Util.json_loads_byteified(r.text)
         result['data'] = r.text
         return result
 
+    def wim_list(self, token):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/yaml", "accept": "application/json",
+                   '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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+
+        return result
+
     def vim_list(self, token):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/yaml", "accept": "application/json",
@@ -756,9 +1244,26 @@ class Client(object):
 
         return result
 
+    def wim_delete(self, token, id):
+        result = {'error': True, 'data': ''}
+        headers = {"accept": "application/json",
+                   '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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.accepted:
+            result['error'] = False
+        else:
+            result['data'] = r.text
+        return result
+
     def vim_delete(self, token, id):
         result = {'error': True, 'data': ''}
-        headers = { "accept": "application/json",
+        headers = {"accept": "application/json",
                    'Authorization': 'Bearer {}'.format(token['id'])}
         _url = "{0}/admin/v1/vims/{1}".format(self._base_path, id)
         try:
@@ -767,13 +1272,30 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.accepted:
             result['error'] = False
         else:
             result['data'] = r.text
         return result
 
+    def wim_get(self, token, id):
+
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/json", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+        _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)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.ok:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def vim_get(self, token, id):
 
         result = {'error': True, 'data': ''}
@@ -792,6 +1314,24 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
+    def wim_create(self, token, wim_data):
+        result = {'error': True, 'data': ''}
+        headers = {"Content-Type": "application/json", "accept": "application/json",
+                   'Authorization': 'Bearer {}'.format(token['id'])}
+
+        _url = "{0}/admin/v1/wim_accounts".format(self._base_path)
+
+        try:
+            r = requests.post(_url, json=wim_data, verify=False, headers=headers)
+        except Exception as e:
+            log.exception(e)
+            result['data'] = str(e)
+            return result
+        if r.status_code == requests.codes.created:
+            result['error'] = False
+        result['data'] = Util.json_loads_byteified(r.text)
+        return result
+
     def vim_create(self, token, vim_data):
 
         result = {'error': True, 'data': ''}
@@ -806,7 +1346,6 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.created:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
@@ -839,7 +1378,6 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.accepted:
             result['error'] = False
         else:
@@ -863,7 +1401,6 @@ class Client(object):
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
-
     def sdn_create(self, token, sdn_data):
         result = {'error': True, 'data': ''}
         headers = {"Content-Type": "application/json", "accept": "application/json",
@@ -877,13 +1414,11 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        print r.status_code
         if r.status_code == requests.codes.created:
             result['error'] = False
         result['data'] = Util.json_loads_byteified(r.text)
         return result
 
-
     @staticmethod
     def md5(f):
         hash_md5 = hashlib.md5()