curl_cmd.close()
# TODO 202 accepted should be returned somehow
if data.getvalue():
- return json.loads(data.getvalue().decode())
- elif http_code == 404:
- return "NOT FOUND"
- elif http_code >= 300:
- return "Failed"
+ return http_code, json.loads(data.getvalue().decode())
else:
- return
+ return http_code, None
def send_cmd(self, endpoint='', postfields_dict=None,
formfile=None, filename=None,
def delete(self, name):
ns = self.get(name)
- resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,ns['_id']))
- # print 'RESP: {}'.format(resp)
- if resp is None:
+ http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,ns['_id']))
+ #print 'RESP: {}'.format(resp)
+ if http_code == 202:
+ print 'Deletion in progress'
+ elif http_code == 204:
print 'Deleted'
else:
raise ClientException("failed to delete ns {}: {}".format(name, resp))
def delete(self, name):
nsd = self.get(name)
- resp = self._http.delete_cmd('{}/{}'.format(self._apiBase, nsd['_id']))
- #print 'RESP: '.format(resp)
- if resp is None:
+ http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase, nsd['_id']))
+ #print 'RESP: {}'.format(resp)
+ if http_code == 202:
+ print 'Deletion in progress'
+ elif http_code == 204:
print 'Deleted'
else:
raise ClientException("failed to delete nsd {}: {}".format(name, resp))
def delete(self, name):
sdn_controller = self.get(name)
- resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,sdn_controller['_id']))
- #print 'RESP: '.format(resp)
- if 'result' not in resp:
- raise ClientException("failed to delete vim {} - {}".format(name, resp))
- else:
+ http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,sdn_controller['_id']))
+ #print 'RESP: {}'.format(resp)
+ if http_code == 202:
+ print 'Deletion in progress'
+ elif http_code == 204:
+ print 'Deleted'
+ elif 'result' in resp:
print 'Deleted'
+ else:
+ raise ClientException("failed to delete vim {} - {}".format(name, resp))
def list(self, filter=None):
"""Returns a list of SDN controllers
vim_id = vim_name
if not utils.validate_uuid4(vim_name):
vim_id = self.get_id(vim_name)
- resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vim_id))
- if resp is None:
+ http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vim_id))
+ #print 'RESP: {}'.format(resp)
+ if http_code == 202:
+ print 'Deletion in progress'
+ elif http_code == 204:
print 'Deleted'
else:
raise ClientException("failed to delete vim {} - {}".format(vim_name, resp))
def delete(self, name):
vnfd = self.get(name)
- resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vnfd['_id']))
- #print 'RESP: '.format(resp)
- if resp is None:
+ http_code, resp = self._http.delete_cmd('{}/{}'.format(self._apiBase,vnfd['_id']))
+ #print 'RESP: {}'.format(resp)
+ if http_code == 202:
+ print 'Deletion in progress'
+ elif http_code == 204:
print 'Deleted'
else:
raise ClientException("failed to delete vnfd {}: {}".format(name, resp))