X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=lib%2Fosm%2Fosmclient%2Fclientv2.py;fp=lib%2Fosm%2Fosmclient%2Fclientv2.py;h=f82bf4d29a43a7cdc3618f2f83ded6e938eeb6a6;hb=cf3a1f01c2b7ef2e76f8090fc995b74e95835306;hp=191385e4d6125eedfdc16cecf897dd506d2fdc64;hpb=19d7de46e124710409ef0218a58bed5d2c671086;p=osm%2FLW-UI.git diff --git a/lib/osm/osmclient/clientv2.py b/lib/osm/osmclient/clientv2.py index 191385e..f82bf4d 100644 --- a/lib/osm/osmclient/clientv2.py +++ b/lib/osm/osmclient/clientv2.py @@ -343,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", @@ -908,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", @@ -962,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", @@ -998,6 +1051,26 @@ class Client(object): 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", @@ -1035,6 +1108,23 @@ class Client(object): 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",