def send_cmd(self, endpoint='', postfields_dict=None,
formfile=None, filename=None,
- put_method=False):
+ put_method=False, patch_method=False):
data = BytesIO()
curl_cmd = self._get_curl_cmd(endpoint)
if put_method:
curl_cmd.setopt(pycurl.PUT, 1)
+ elif patch_method:
+ curl_cmd.setopt(pycurl.CUSTOMREQUEST, "PATCH")
else:
curl_cmd.setopt(pycurl.POST, 1)
curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write)
postfields_dict=postfields_dict,
formfile=formfile,
filename=filename,
- put_method=False)
+ put_method=False, patch_method=False)
def put_cmd(self, endpoint='', postfields_dict=None,
formfile=None, filename=None):
postfields_dict=postfields_dict,
formfile=formfile,
filename=filename,
- put_method=True)
+ put_method=True, patch_method=False)
+
+ def patch_cmd(self, endpoint='', postfields_dict=None,
+ formfile=None, filename=None):
+ return self.send_cmd(endpoint=endpoint,
+ postfields_dict=postfields_dict,
+ formfile=formfile,
+ filename=filename,
+ put_method=False, patch_method=True)
def get2_cmd(self, endpoint):
data = BytesIO()
def update(self, vim_name, vim_account):
vim = self.get(vim_name)
- resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']),
+ #resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']),
+ resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']),
postfields_dict=vim_account)
- if not resp or '_id' not in resp:
- raise ClientException('failed to update vim: '.format(
- resp))
+ #print 'RESP: {}'.format(resp)
+ if not resp or 'id' not in resp:
+ raise ClientException('failed to update vim: '.format(resp))
else:
- print resp['_id']
+ print resp['id']
def update_vim_account_dict(self, vim_account, vim_access):
vim_account['vim_type'] = vim_access['vim-type']