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

Proposed by Jamu Kakar on 2010-06-28
Status: Merged
Approved by: Free Ekanayaka on 2010-06-29
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 2010-06-28 Approve on 2010-06-29
Sidnei da Silva (community) 2010-06-28 Approve on 2010-06-28
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.
Sidnei da Silva (sidnei) wrote :

Looks good, +1.

review: Approve
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
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.

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
1=== modified file 'landscape/manager/eucalyptus.py'
2--- landscape/manager/eucalyptus.py 2010-06-02 16:00:31 +0000
3+++ landscape/manager/eucalyptus.py 2010-06-28 13:02:24 +0000
4@@ -14,7 +14,11 @@
5 self._tools = tools
6
7 def get_version_info(self):
8- """Return information about the version of Eucalyptus in use.
9+ """Get information about the version of Eucalyptus in use.
10+
11+ A string matching the following format is returned::
12+
13+ Eucalyptus version: 1.6.2
14
15 @return: A L{Deferred} firing with the string output of the
16 C{--version} command.
17@@ -22,37 +26,80 @@
18 return succeed(self._tools._runTool("euca_conf", ["--version"]))
19
20 def get_walrus_info(self):
21- """Return information about the registered walruses (S3).
22-
23- @return: a L{Deferred} firing with the string output of the
24+ """Get information about the registered walruses (S3).
25+
26+ A string matching the following format is returned::
27+
28+ registered walruses:
29+ walrus 10.0.1.113
30+
31+ @return: A L{Deferred} firing with the string output of the
32 C{--list-walruses} command.
33 """
34 return succeed(self._tools._runTool("euca_conf", ["--list-walruses"]))
35
36 def get_cluster_controller_info(self):
37- """Return information about the registered cluster controllers..
38-
39- @return: a L{Deferred} firing with the string output of the
40+ """Get information about the registered cluster controllers..
41+
42+ A string matching the following format is returned::
43+
44+ registered clusters:
45+ dynamite 10.0.1.113
46+
47+ @return: A L{Deferred} firing with the string output of the
48 C{--list-clusters} command.
49 """
50 return succeed(self._tools._runTool("euca_conf", ["--list-clusters"]))
51
52 def get_storage_controller_info(self):
53- """Return information about the registered storage controllers (EBS).
54-
55- @return: a L{Deferred} firing with the string output of the
56+ """Get information about the registered storage controllers (EBS).
57+
58+ A string matching the following format is returned::
59+
60+ registered storage controllers:
61+ dynamite 10.0.1.113
62+
63+ @return: A L{Deferred} firing with the string output of the
64 C{--list-scs} command.
65 """
66 return succeed(self._tools._runTool("euca_conf", ["--list-scs"]))
67
68 def get_node_controller_info(self):
69- """Return information about the registered node controller.
70-
71- @return: a L{Deferred} firing with the string output of the
72+ """Get information about the registered node controller.
73+
74+ A string matching the following format is returned::
75+
76+ registered nodes:
77+ 10.1.1.71 canyonedge i-2DC5056F i-5DE5176D
78+ 10.1.1.72 canyonedge
79+ 10.1.1.73 canyonedge
80+ 10.1.1.74 canyonedge
81+ 10.1.1.75 canyonedge
82+
83+ @return: A L{Deferred} firing with the string output of the
84 C{--list-nodes} command.
85 """
86 return succeed(self._tools._runTool("euca_conf", ["--list-nodes"]))
87
88+ def get_capacity_info(self):
89+ """Get information about the capacity of the cloud.
90+
91+ A string matching the following format is returned::
92+
93+ AVAILABILITYZONE bruterobe 10.0.1.113
94+ AVAILABILITYZONE |- vm types free / max cpu ram disk
95+ AVAILABILITYZONE |- m1.small 0008 / 0008 1 128 2
96+ AVAILABILITYZONE |- c1.medium 0008 / 0008 1 256 5
97+ AVAILABILITYZONE |- m1.large 0004 / 0004 2 512 10
98+ AVAILABILITYZONE |- m1.xlarge 0004 / 0004 2 1024 20
99+ AVAILABILITYZONE |- c1.xlarge 0002 / 0002 4 2048 20
100+
101+ @return: A L{Deferred} firing with the string output of the
102+ C{euca-describe-availability-zones verbose} command.
103+ """
104+ return succeed(self._tools._runTool("euca-describe-availability-zones",
105+ ["verbose"]))
106+
107
108 class Eucalyptus(ManagerPlugin):
109 """A management plugin for a Eucalyptus cloud."""
110@@ -122,11 +169,13 @@
111 info.get_walrus_info(),
112 info.get_cluster_controller_info(),
113 info.get_storage_controller_info(),
114- info.get_node_controller_info()]
115+ info.get_node_controller_info(),
116+ info.get_capacity_info()]
117
118 def create_message(result):
119 (version_info, walrus_info, cluster_controller_info,
120- storage_controller_info, node_controller_info) = result
121+ storage_controller_info, node_controller_info,
122+ capacity_info) = result
123 version = version_info.split()[-1]
124 data = {"access_key": credentials.accessKey,
125 "secret_key": credentials.secretKey,
126@@ -140,7 +189,8 @@
127 "walrus_info": walrus_info,
128 "cluster_controller_info": cluster_controller_info,
129 "storage_controller_info": storage_controller_info,
130- "node_controller_info": node_controller_info}
131+ "node_controller_info": node_controller_info,
132+ "capacity_info": capacity_info}
133 return gather_results(deferred_list).addCallback(create_message)
134
135 def _get_error_message(self, failure):
136
137=== modified file 'landscape/manager/tests/test_eucalyptus.py'
138--- landscape/manager/tests/test_eucalyptus.py 2010-06-02 16:00:31 +0000
139+++ landscape/manager/tests/test_eucalyptus.py 2010-06-28 13:02:24 +0000
140@@ -40,18 +40,30 @@
141 10.1.1.75 canyonedge
142 """
143
144+fake_capacity_output = """\
145+AVAILABILITYZONE bruterobe 10.0.1.113
146+AVAILABILITYZONE |- vm types free / max cpu ram disk
147+AVAILABILITYZONE |- m1.small 0008 / 0008 1 128 2
148+AVAILABILITYZONE |- c1.medium 0008 / 0008 1 256 5
149+AVAILABILITYZONE |- m1.large 0004 / 0004 2 512 10
150+AVAILABILITYZONE |- m1.xlarge 0004 / 0004 2 1024 20
151+AVAILABILITYZONE |- c1.xlarge 0002 / 0002 4 2048 20
152+"""
153+
154
155 class FakeEucalyptusInfo(object):
156 """A fake version of L{EucalyptusInfo} for use in tests."""
157
158 def __init__(self, version_output=None, walrus_output=None,
159 cluster_controller_output=None,
160- storage_controller_output=None, node_controller_output=None):
161+ storage_controller_output=None, node_controller_output=None,
162+ capacity_output=None):
163 self._version_output = version_output
164 self._walrus_output = walrus_output
165 self._cluster_controller_output = cluster_controller_output
166 self._storage_controller_output = storage_controller_output
167 self._node_controller_output = node_controller_output
168+ self._capacity_output = capacity_output
169
170 def get_version_info(self):
171 return succeed(self._version_output)
172@@ -68,6 +80,9 @@
173 def get_node_controller_info(self):
174 return succeed(self._node_controller_output)
175
176+ def get_capacity_info(self):
177+ return succeed(self._capacity_output)
178+
179
180 class FakeServiceHub(object):
181
182@@ -101,7 +116,7 @@
183 eucalyptus_info_factory=lambda tools: FakeEucalyptusInfo(
184 fake_version_output, fake_walrus_output,
185 fake_cluster_controller_output, fake_storage_controller_output,
186- fake_node_controller_output))
187+ fake_node_controller_output, fake_capacity_output))
188 self.manager.add(plugin)
189 return plugin
190
191@@ -139,7 +154,8 @@
192 "cluster_controller_info": fake_cluster_controller_output,
193 "node_controller_info": fake_node_controller_output,
194 "storage_controller_info": fake_storage_controller_output,
195- "walrus_info": fake_walrus_output}
196+ "walrus_info": fake_walrus_output,
197+ "capacity_info": fake_capacity_output}
198 self.assertMessages(
199 self.broker_service.message_store.get_pending_messages(),
200 [expected])
201
202=== modified file 'landscape/message_schemas.py'
203--- landscape/message_schemas.py 2010-06-11 10:14:25 +0000
204+++ landscape/message_schemas.py 2010-06-28 13:02:24 +0000
205@@ -351,7 +351,9 @@
206 "walrus_info": String(),
207 "cluster_controller_info": String(),
208 "storage_controller_info": String(),
209- "node_controller_info": String()})
210+ "node_controller_info": String(),
211+ "capacity_info": String()},
212+ optional=["capacity_info"])
213
214 EUCALYPTUS_INFO_ERROR = Message(
215 "eucalyptus-info-error",

Subscribers

People subscribed via source and target branches

to all changes: