You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/02/02 18:15:34 UTC
[1/2] git commit: LIBCLOUD-507: Add ex_limits call to return a
dictionary or resource limits associated with the account. Examples of
resource limits would be the maximum number of instances, volumes,
snapshots and networks.
Updated Branches:
refs/heads/trunk 8eb07e4a1 -> 2840b6f5a
LIBCLOUD-507: Add ex_limits call to return a dictionary or resource limits associated with the account. Examples of resource limits would be the maximum number of instances, volumes, snapshots and networks.
Closes #240.
Signed-off-by: Tomaz Muraus <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ee8d43cc
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ee8d43cc
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ee8d43cc
Branch: refs/heads/trunk
Commit: ee8d43ccfc136ef6b7c4113c683042c2093ab965
Parents: 8eb07e4
Author: Chris DeRamus <ch...@divvycloud.com>
Authored: Sun Feb 2 10:18:12 2014 -0500
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Feb 2 18:11:21 2014 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/cloudstack.py | 33 ++++++++++++++++++++
.../cloudstack/listResourceLimits_default.json | 1 +
libcloud/test/compute/test_cloudstack.py | 11 +++++++
3 files changed, 45 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee8d43cc/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index 5c49dc3..4e6a36b 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -1482,6 +1482,39 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
zoneid=location.id,
params=params)
+ def ex_limits(self):
+ """
+ Extra call to get account's resource limits, such as
+ the amount of instances, volumes, snapshots and networks.
+
+ CloudStack uses integers as the resource type so we will convert
+ them to a more human readable string using the resource map
+
+ :return: dict
+ :rtype: ``dict``
+ """
+
+ result = self._sync_request(command='listResourceLimits',
+ method='GET')
+
+ limits = {}
+ resource_map = {
+ 0: 'max_instances',
+ 1: 'max_public_ips',
+ 2: 'max_volumes',
+ 3: 'max_snapshots',
+ 4: 'max_images',
+ 5: 'max_projects',
+ 6: 'max_networks',
+ 7: 'max_vpc'
+ }
+
+ for limit in result.get('resourcelimit', []):
+ resource = resource_map[int(limit['resourcetype'])]
+ limits[resource] = int(limit['max'])
+
+ return limits
+
def _to_node(self, data, public_ips=None):
"""
:param data: Node data object.
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee8d43cc/libcloud/test/compute/fixtures/cloudstack/listResourceLimits_default.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listResourceLimits_default.json b/libcloud/test/compute/fixtures/cloudstack/listResourceLimits_default.json
new file mode 100644
index 0000000..2f0dd87
--- /dev/null
+++ b/libcloud/test/compute/fixtures/cloudstack/listResourceLimits_default.json
@@ -0,0 +1 @@
+{ "listresourcelimitsresponse" : { "count":8 ,"resourcelimit" : [ {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"0","max":20}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"1","max":-1}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"2","max":20}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"3","max":20}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"4","max":20}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"5","max":-1}, {"account":"fakeuser@mycompany
.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"6","max":20}, {"account":"fakeuser@mycompany.com","domainid":"bd0b5c60-cd1e-4bf0-8d90-72c4b0de7520","domain":"fakeuser@mycompany.com","resourcetype":"7","max":20} ] } }
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee8d43cc/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 146241e..c54d423 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -485,6 +485,17 @@ class CloudStackCommonTestCase(TestCaseMixin):
self.assertEqual(rule.private_end_port, private_end_port)
self.assertEqual(len(node.extra['port_forwarding_rules']), 2)
+ def test_ex_limits(self):
+ limits = self.driver.ex_limits()
+ self.assertEqual(limits['max_images'], 20)
+ self.assertEqual(limits['max_networks'], 20)
+ self.assertEqual(limits['max_public_ips'], -1)
+ self.assertEqual(limits['max_vpc'], 20)
+ self.assertEqual(limits['max_instances'], 20)
+ self.assertEqual(limits['max_projects'], -1)
+ self.assertEqual(limits['max_volumes'], 20)
+ self.assertEqual(limits['max_snapshots'], 20)
+
class CloudStackTestCase(CloudStackCommonTestCase, unittest.TestCase):
def test_driver_instantiation(self):
[2/2] git commit: Update CHANGES.
Posted by to...@apache.org.
Update CHANGES.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2840b6f5
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2840b6f5
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2840b6f5
Branch: refs/heads/trunk
Commit: 2840b6f5ac320a0cc1c4c85b7c4d77b0fe27e902
Parents: ee8d43c
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Feb 2 18:15:17 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Feb 2 18:15:17 2014 +0100
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2840b6f5/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index d8fcdcb..8c7dc3c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -23,6 +23,10 @@ Compute
(LIBCLOUD-505, GITHUB-238)
[Chris DeRamus]
+- Add ex_limits method to the CloudStack driver.
+ (LIBCLOUD-507, GITHUB-240)
+ [Chris DeRamus]
+
Load Balancer
~~~~~~~~~~~~~