Merge lp:~jkakar/landscape-client/cloud-capacity into lp:~landscape/landscape-client/trunk

Proposed by Jamu Kakar
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 271
Merged at revision: 271
Proposed branch: lp:~jkakar/landscape-client/cloud-capacity
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 215 lines (+88/-20)
3 files modified
landscape/manager/eucalyptus.py (+66/-16)
landscape/manager/tests/test_eucalyptus.py (+19/-3)
landscape/message_schemas.py (+3/-1)
To merge this branch: bzr merge lp:~jkakar/landscape-client/cloud-capacity
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Sidnei da Silva (community) Approve
Review via email: mp+28635@code.launchpad.net

Description of the change

This branch introduces the following changes:

- The EUCALYPTUS_INFO message type defines a new (optional)
  'capacity_info' field.

- The output of 'euca-describe-availability-zones verbose' is
  included in messages produced by the Eucalyptus plugin.

Right now, for Cloud Deck, we're planning to implement a very simple
"instance cap" which we know is very basic, but it allows us to
solve the problem of one user DoS'ing a cloud. A better solution,
which I've been discussing with James Troup in the background, will
require us to know the total capacity of the cloud. This change is
about making that information available to Landscape in time for the
client changes to land in Ubuntu 10.10.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) wrote :

Looks good, +1.

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Nice branch! Thanks for the improved docstrings.

[1]

+ A string matching the following format is returned::

Is the double ":" at the end of the sentence intended? There are several spots like this.

[2]

+ optional=["capacity_info"])

Why is it optional? It seems that the code always include that capacity_info in the created message. Also removing the "optional" flag makes no tests fail.

review: Approve
Revision history for this message
Jamu Kakar (jkakar) wrote :

Free:

[1]

Yes, the double-colon means that the following text (indented by two
spaces typically) is an example. It will be rendered in a
fixed-width font in generated documentation. I usually use it for
code examples or for ASCII art diagrams.

[2]

I made it optional because the same message type is used by old
clients. I didn't want to break the messages they report.

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Makes all sense, thanks for explaining.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'landscape/manager/eucalyptus.py'
--- landscape/manager/eucalyptus.py 2010-06-02 16:00:31 +0000
+++ landscape/manager/eucalyptus.py 2010-06-28 13:02:24 +0000
@@ -14,7 +14,11 @@
14 self._tools = tools14 self._tools = tools
1515
16 def get_version_info(self):16 def get_version_info(self):
17 """Return information about the version of Eucalyptus in use.17 """Get information about the version of Eucalyptus in use.
18
19 A string matching the following format is returned::
20
21 Eucalyptus version: 1.6.2
1822
19 @return: A L{Deferred} firing with the string output of the23 @return: A L{Deferred} firing with the string output of the
20 C{--version} command.24 C{--version} command.
@@ -22,37 +26,80 @@
22 return succeed(self._tools._runTool("euca_conf", ["--version"]))26 return succeed(self._tools._runTool("euca_conf", ["--version"]))
2327
24 def get_walrus_info(self):28 def get_walrus_info(self):
25 """Return information about the registered walruses (S3).29 """Get information about the registered walruses (S3).
2630
27 @return: a L{Deferred} firing with the string output of the31 A string matching the following format is returned::
32
33 registered walruses:
34 walrus 10.0.1.113
35
36 @return: A L{Deferred} firing with the string output of the
28 C{--list-walruses} command.37 C{--list-walruses} command.
29 """38 """
30 return succeed(self._tools._runTool("euca_conf", ["--list-walruses"]))39 return succeed(self._tools._runTool("euca_conf", ["--list-walruses"]))
3140
32 def get_cluster_controller_info(self):41 def get_cluster_controller_info(self):
33 """Return information about the registered cluster controllers..42 """Get information about the registered cluster controllers..
3443
35 @return: a L{Deferred} firing with the string output of the44 A string matching the following format is returned::
45
46 registered clusters:
47 dynamite 10.0.1.113
48
49 @return: A L{Deferred} firing with the string output of the
36 C{--list-clusters} command.50 C{--list-clusters} command.
37 """51 """
38 return succeed(self._tools._runTool("euca_conf", ["--list-clusters"]))52 return succeed(self._tools._runTool("euca_conf", ["--list-clusters"]))
3953
40 def get_storage_controller_info(self):54 def get_storage_controller_info(self):
41 """Return information about the registered storage controllers (EBS).55 """Get information about the registered storage controllers (EBS).
4256
43 @return: a L{Deferred} firing with the string output of the57 A string matching the following format is returned::
58
59 registered storage controllers:
60 dynamite 10.0.1.113
61
62 @return: A L{Deferred} firing with the string output of the
44 C{--list-scs} command.63 C{--list-scs} command.
45 """64 """
46 return succeed(self._tools._runTool("euca_conf", ["--list-scs"]))65 return succeed(self._tools._runTool("euca_conf", ["--list-scs"]))
4766
48 def get_node_controller_info(self):67 def get_node_controller_info(self):
49 """Return information about the registered node controller.68 """Get information about the registered node controller.
5069
51 @return: a L{Deferred} firing with the string output of the70 A string matching the following format is returned::
71
72 registered nodes:
73 10.1.1.71 canyonedge i-2DC5056F i-5DE5176D
74 10.1.1.72 canyonedge
75 10.1.1.73 canyonedge
76 10.1.1.74 canyonedge
77 10.1.1.75 canyonedge
78
79 @return: A L{Deferred} firing with the string output of the
52 C{--list-nodes} command.80 C{--list-nodes} command.
53 """81 """
54 return succeed(self._tools._runTool("euca_conf", ["--list-nodes"]))82 return succeed(self._tools._runTool("euca_conf", ["--list-nodes"]))
5583
84 def get_capacity_info(self):
85 """Get information about the capacity of the cloud.
86
87 A string matching the following format is returned::
88
89 AVAILABILITYZONE bruterobe 10.0.1.113
90 AVAILABILITYZONE |- vm types free / max cpu ram disk
91 AVAILABILITYZONE |- m1.small 0008 / 0008 1 128 2
92 AVAILABILITYZONE |- c1.medium 0008 / 0008 1 256 5
93 AVAILABILITYZONE |- m1.large 0004 / 0004 2 512 10
94 AVAILABILITYZONE |- m1.xlarge 0004 / 0004 2 1024 20
95 AVAILABILITYZONE |- c1.xlarge 0002 / 0002 4 2048 20
96
97 @return: A L{Deferred} firing with the string output of the
98 C{euca-describe-availability-zones verbose} command.
99 """
100 return succeed(self._tools._runTool("euca-describe-availability-zones",
101 ["verbose"]))
102
56103
57class Eucalyptus(ManagerPlugin):104class Eucalyptus(ManagerPlugin):
58 """A management plugin for a Eucalyptus cloud."""105 """A management plugin for a Eucalyptus cloud."""
@@ -122,11 +169,13 @@
122 info.get_walrus_info(),169 info.get_walrus_info(),
123 info.get_cluster_controller_info(),170 info.get_cluster_controller_info(),
124 info.get_storage_controller_info(),171 info.get_storage_controller_info(),
125 info.get_node_controller_info()]172 info.get_node_controller_info(),
173 info.get_capacity_info()]
126174
127 def create_message(result):175 def create_message(result):
128 (version_info, walrus_info, cluster_controller_info,176 (version_info, walrus_info, cluster_controller_info,
129 storage_controller_info, node_controller_info) = result177 storage_controller_info, node_controller_info,
178 capacity_info) = result
130 version = version_info.split()[-1]179 version = version_info.split()[-1]
131 data = {"access_key": credentials.accessKey,180 data = {"access_key": credentials.accessKey,
132 "secret_key": credentials.secretKey,181 "secret_key": credentials.secretKey,
@@ -140,7 +189,8 @@
140 "walrus_info": walrus_info,189 "walrus_info": walrus_info,
141 "cluster_controller_info": cluster_controller_info,190 "cluster_controller_info": cluster_controller_info,
142 "storage_controller_info": storage_controller_info,191 "storage_controller_info": storage_controller_info,
143 "node_controller_info": node_controller_info}192 "node_controller_info": node_controller_info,
193 "capacity_info": capacity_info}
144 return gather_results(deferred_list).addCallback(create_message)194 return gather_results(deferred_list).addCallback(create_message)
145195
146 def _get_error_message(self, failure):196 def _get_error_message(self, failure):
147197
=== modified file 'landscape/manager/tests/test_eucalyptus.py'
--- landscape/manager/tests/test_eucalyptus.py 2010-06-02 16:00:31 +0000
+++ landscape/manager/tests/test_eucalyptus.py 2010-06-28 13:02:24 +0000
@@ -40,18 +40,30 @@
40 10.1.1.75 canyonedge40 10.1.1.75 canyonedge
41"""41"""
4242
43fake_capacity_output = """\
44AVAILABILITYZONE bruterobe 10.0.1.113
45AVAILABILITYZONE |- vm types free / max cpu ram disk
46AVAILABILITYZONE |- m1.small 0008 / 0008 1 128 2
47AVAILABILITYZONE |- c1.medium 0008 / 0008 1 256 5
48AVAILABILITYZONE |- m1.large 0004 / 0004 2 512 10
49AVAILABILITYZONE |- m1.xlarge 0004 / 0004 2 1024 20
50AVAILABILITYZONE |- c1.xlarge 0002 / 0002 4 2048 20
51"""
52
4353
44class FakeEucalyptusInfo(object):54class FakeEucalyptusInfo(object):
45 """A fake version of L{EucalyptusInfo} for use in tests."""55 """A fake version of L{EucalyptusInfo} for use in tests."""
4656
47 def __init__(self, version_output=None, walrus_output=None,57 def __init__(self, version_output=None, walrus_output=None,
48 cluster_controller_output=None,58 cluster_controller_output=None,
49 storage_controller_output=None, node_controller_output=None):59 storage_controller_output=None, node_controller_output=None,
60 capacity_output=None):
50 self._version_output = version_output61 self._version_output = version_output
51 self._walrus_output = walrus_output62 self._walrus_output = walrus_output
52 self._cluster_controller_output = cluster_controller_output63 self._cluster_controller_output = cluster_controller_output
53 self._storage_controller_output = storage_controller_output64 self._storage_controller_output = storage_controller_output
54 self._node_controller_output = node_controller_output65 self._node_controller_output = node_controller_output
66 self._capacity_output = capacity_output
5567
56 def get_version_info(self):68 def get_version_info(self):
57 return succeed(self._version_output)69 return succeed(self._version_output)
@@ -68,6 +80,9 @@
68 def get_node_controller_info(self):80 def get_node_controller_info(self):
69 return succeed(self._node_controller_output)81 return succeed(self._node_controller_output)
7082
83 def get_capacity_info(self):
84 return succeed(self._capacity_output)
85
7186
72class FakeServiceHub(object):87class FakeServiceHub(object):
7388
@@ -101,7 +116,7 @@
101 eucalyptus_info_factory=lambda tools: FakeEucalyptusInfo(116 eucalyptus_info_factory=lambda tools: FakeEucalyptusInfo(
102 fake_version_output, fake_walrus_output,117 fake_version_output, fake_walrus_output,
103 fake_cluster_controller_output, fake_storage_controller_output,118 fake_cluster_controller_output, fake_storage_controller_output,
104 fake_node_controller_output))119 fake_node_controller_output, fake_capacity_output))
105 self.manager.add(plugin)120 self.manager.add(plugin)
106 return plugin121 return plugin
107122
@@ -139,7 +154,8 @@
139 "cluster_controller_info": fake_cluster_controller_output,154 "cluster_controller_info": fake_cluster_controller_output,
140 "node_controller_info": fake_node_controller_output,155 "node_controller_info": fake_node_controller_output,
141 "storage_controller_info": fake_storage_controller_output,156 "storage_controller_info": fake_storage_controller_output,
142 "walrus_info": fake_walrus_output}157 "walrus_info": fake_walrus_output,
158 "capacity_info": fake_capacity_output}
143 self.assertMessages(159 self.assertMessages(
144 self.broker_service.message_store.get_pending_messages(),160 self.broker_service.message_store.get_pending_messages(),
145 [expected])161 [expected])
146162
=== modified file 'landscape/message_schemas.py'
--- landscape/message_schemas.py 2010-06-11 10:14:25 +0000
+++ landscape/message_schemas.py 2010-06-28 13:02:24 +0000
@@ -351,7 +351,9 @@
351 "walrus_info": String(),351 "walrus_info": String(),
352 "cluster_controller_info": String(),352 "cluster_controller_info": String(),
353 "storage_controller_info": String(),353 "storage_controller_info": String(),
354 "node_controller_info": String()})354 "node_controller_info": String(),
355 "capacity_info": String()},
356 optional=["capacity_info"])
355357
356EUCALYPTUS_INFO_ERROR = Message(358EUCALYPTUS_INFO_ERROR = Message(
357 "eucalyptus-info-error",359 "eucalyptus-info-error",

Subscribers

People subscribed via source and target branches

to all changes: