X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=lib%2Fosm%2Fosmclient%2Fclient.py;h=e9248ec1f5b56a3a65f70d9c16ff2bb18c9c0e3a;hb=refs%2Fchanges%2F84%2F6284%2F1;hp=a65808f2b1c6c9b0551e28ab9e5184b136bc29b2;hpb=a03da5e2aab552daa3e7ced70b3e90466c7c8b82;p=osm%2FLW-UI.git diff --git a/lib/osm/osmclient/client.py b/lib/osm/osmclient/client.py index a65808f..e9248ec 100644 --- a/lib/osm/osmclient/client.py +++ b/lib/osm/osmclient/client.py @@ -77,7 +77,6 @@ class Client(object): json=vim_data) return None - def sdn_list(self): token = self.get_token() if token: @@ -252,13 +251,16 @@ class Client(object): return self._send_get(_url, headers=self._headers) return None - def ns_delete(self, id): + def ns_delete(self, id, force=None): token = self.get_token() if token: self._headers['Authorization'] = 'Bearer {}'.format(token) - #self._headers['Content-Type'] = 'application/yaml' self._headers['accept'] = 'application/json' - _url = "{0}/nslcm/v1/ns_instances_content/{1}".format(self._base_path, id) + query_path = '' + if force: + query_path = '?FORCE=true' + _url = "{0}/nslcm/v1/ns_instances_content/{1}{2}".format(self._base_path, id, query_path) + return self._send_delete(_url, headers=self._headers) return None @@ -299,6 +301,33 @@ class Client(object): return self._send_get(_url, headers=headers) return None + def ns_alarm_create(self, id, alarm_payload): + token = self.get_token() + headers = {} + if token: + headers['Authorization'] = 'Bearer {}'.format(token) + headers['Content-Type'] = 'application/json' +# headers['accept'] = 'application/json' + + _url = "{0}/test/message/alarm_request".format(self._base_path) + return self._send_post(_url, headers=headers, json=alarm_payload) + return None + + def ns_metric_export(self, id, metric_payload): + + token = self.get_token() + headers = {} + if token: + headers['Authorization'] = 'Bearer {}'.format(token) + headers['Content-Type'] = 'application/json' + #headers['accept'] = 'application/json' + print "DIO" + _url = "{0}/test/message/metric_request".format(self._base_path) + print _url + return self._send_post(_url, headers=headers, json=metric_payload) + return None + + def vnfd_list(self): token = self.get_token() if token: @@ -413,7 +442,12 @@ class Client(object): log.exception(e) #print "Exception during send POST" return {'error': 'error during connection to agent'} - return Util.json_loads_byteified(r.text) + if 'accept' in kwargs['headers']: + accept = kwargs['headers']['accept'] + if accept == 'application/json': + #print "json" + return Util.json_loads_byteified(r.text) + return r def _send_put(self, url, data=None, json=None, **kwargs): try: