Kami commented on a change in pull request #1478:
URL: https://github.com/apache/libcloud/pull/1478#discussion_r479781266
##########
File path: libcloud/container/drivers/lxd.py
##########
@@ -1225,12 +1444,102 @@ def ex_delete_storage_pool_volume(self, pool_id, type,
name):
:return:
"""
- response = self.connection.request("/%s/storage-pools/%s/volumes/%s/%s"
- % (self.version, pool_id,
- type, name),
- method="DELETE")
+ try:
+
+ req = "/%s/storage-pools/%s/volumes/%s/%s" % (self.version,
+ pool_id,
+ type,
+ name)
+ response = self.connection.request(req, method="DELETE")
+
+ response_dict = response.parse_body()
+ assert_response(response_dict=response_dict, status_code=200)
+ except BaseHTTPError as err:
+ raise self._get_lxd_api_exception_for_error(err)
+
+ return True
+
+ def ex_list_networks(self):
+ """
+ Returns a list of networks.
+ Implements GET /1.0/networks
+ Authentication: trusted
+ Operation: sync
+
+ :rtype: list of LXDNetwork objects
+ """
+
+ req = "/%s/networks" % (self.version)
+ response = self.connection.request(req)
+
+ response_dict = response.parse_body()
+ assert_response(response_dict=response_dict, status_code=200)
+
+ nets = response_dict["metadata"]
+ networks = []
+ for net in nets:
+ name = net.split('/')[-1]
+ networks.append(self.ex_get_network(name=name))
Review comment:
I think classes are a good idea in general since they provide a better
and more user-friendly API to the developers (in contrasts of dictionaries
which are usually opaque and hard to work with since you need to inspect the
docs / similar to see what attributes should be there...).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]