def _post(self, path, op='update', **kwargs):
"""
Issues a POST request to the MAAS REST API.
"""
try:
response = self.client.post(path, **kwargs)
payload = response.read()
log.debug("Request %s results: [%s] %s", path, response.getcode(),
payload)
if response.getcode() == OK:
return Response(True, yaml.load(payload))
else:
return Response(False, payload)
except HTTPError as e:
log.error("Error encountered: %s for %s with params %s",
str(e), path, str(kwargs))
return Response(False, None)
except Exception as e:
log.error("Post request raised exception: %s", e)
return Response(False, None)
评论列表
文章目录