Eis-D-Z commented on a change in pull request #1478:
URL: https://github.com/apache/libcloud/pull/1478#discussion_r475758595
##########
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:
The /1.0/networks returns just a list of URLs ( [networks endpoint LXD
API](https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10networks) ), the
previous contributor made a whole LXDNetwork class which needs a bit more data.
As it is now an additional request for each network is required. If you think
that there's no need to have a whole network class let me know.
----------------------------------------------------------------
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]