summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangbin Liu <changbin.liu@gmail.com>2013-09-18 21:53:47 -0400
committerChangbin Liu <changbin.liu@gmail.com>2013-09-19 13:37:02 -0400
commit7c8c4b9a65381f4ba1e0a214fa4a830799525ac5 (patch)
treea2c136e1eebc97a037e74cd33bb5cd401d90ccb1
parentbcc2c014b7d647ebc47e9449e41224a75cf342bf (diff)
Change arguments "image" and "flavor" from ID to name
Make orchestrator easier to use. Specify human-readable names instead of resource IDs. Change-Id: I165761c38756e080aaacea7d2836d1e6c92369d8
Notes
Notes (review): Verified+2: Jenkins Approved+1: Andrew Forrest <forrest@research.att.com> Code-Review+2: Andrew Forrest <forrest@research.att.com> Code-Review+2: Scott Daniels <daniels@research.att.com> Submitted-by: Jenkins Submitted-at: Fri, 20 Sep 2013 15:30:46 +0000 Reviewed-on: https://review.openstack.org/47306 Project: stackforge/inception Branch: refs/heads/master
-rw-r--r--etc/inception/inception.conf.sample6
-rw-r--r--inception/__init__.py2
-rw-r--r--inception/orchestrator.py58
3 files changed, 46 insertions, 20 deletions
diff --git a/etc/inception/inception.conf.sample b/etc/inception/inception.conf.sample
index 88eca2a..474e04a 100644
--- a/etc/inception/inception.conf.sample
+++ b/etc/inception/inception.conf.sample
@@ -2,11 +2,11 @@
2 2
3user = ubuntu 3user = ubuntu
4 4
5image = f3d62d5b-a76b-4997-a579-ff946a606132 5image = u1204-130621-gv
6 6
7flavor = 3 7flavor = m1.medium
8 8
9gateway_flavor = 1 9gateway_flavor = m1.tiny
10 10
11key_name = shared 11key_name = shared
12 12
diff --git a/inception/__init__.py b/inception/__init__.py
index 8b3ed75..f54ca26 100644
--- a/inception/__init__.py
+++ b/inception/__init__.py
@@ -16,4 +16,4 @@
16# License for the specific language governing permissions and limitations 16# License for the specific language governing permissions and limitations
17# under the License. 17# under the License.
18 18
19__version__ = '0.0.1' 19__version__ = '0.0.2'
diff --git a/inception/orchestrator.py b/inception/orchestrator.py
index ea3b64f..bdc34e2 100644
--- a/inception/orchestrator.py
+++ b/inception/orchestrator.py
@@ -87,17 +87,17 @@ orchestrator_opts = [
87 default='ubuntu', 87 default='ubuntu',
88 help='login id with sudo for all nodes'), 88 help='login id with sudo for all nodes'),
89 cfg.StrOpt('image', 89 cfg.StrOpt('image',
90 default='f3d62d5b-a76b-4997-a579-ff946a606132', 90 default='u1204-130621-gv',
91 help='id of image used to construct nodes (=u1204-130621-gv)'), 91 help='name of image used to construct nodes'),
92 cfg.StrOpt('chefserver_image', 92 cfg.StrOpt('chefserver_image',
93 default='8848d4cd-1bdf-4627-ae31-ce9bf61440a4', 93 default='u1204-130716-gvc',
94 help='id of image to construct chefserver (=u1204-130716-gvc)'), 94 help='name of image to construct chefserver'),
95 cfg.IntOpt('flavor', 95 cfg.IntOpt('flavor',
96 default=3, 96 default='m1.medium',
97 help='id of machine flavor used for nodes (3=medium)'), 97 help='name of instance flavor used for nodes'),
98 cfg.IntOpt('gateway_flavor', 98 cfg.IntOpt('gateway_flavor',
99 default=1, 99 default='m1.tiny',
100 help='id of machine flavor used to construct GW (1=tiny)'), 100 help='name of instance flavor used to construct gateway node'),
101 cfg.StrOpt('key_name', 101 cfg.StrOpt('key_name',
102 default='shared', 102 default='shared',
103 help='name of public key for node access via ssh'), 103 help='name of public key for node access via ssh'),
@@ -289,11 +289,37 @@ class Orchestrator(object):
289 start all VM servers: gateway, chefserver, controller, and workers, via 289 start all VM servers: gateway, chefserver, controller, and workers, via
290 calling Nova client API 290 calling Nova client API
291 """ 291 """
292 # map image name to ID
293 image_id = None
294 chefserver_image_id = None
295 for image in self.client.images.list():
296 if image.name == self.image:
297 image_id = image.id
298 if image.name == self.chefserver_image:
299 chefserver_image_id = image.id
300 if image_id is None:
301 raise ValueError('Not found image=%s' % self.image)
302 if chefserver_image_id is None:
303 raise ValueError('Not found image=%s' % self.chefserver_image)
304
305 # map flavor name to ID
306 flavor_id = None
307 gateway_flavor_id = None
308 for flavor in self.client.flavors.list():
309 if flavor.name == self.flavor:
310 flavor_id = flavor.id
311 if flavor.name == self.gateway_flavor:
312 gateway_flavor_id = flavor.id
313 if flavor_id is None:
314 raise ValueError('Not found flavor=%s' % self.flavor)
315 if gateway_flavor_id is None:
316 raise ValueError('Not found flavor=%s' % self.gateway_flavor)
317
292 # launch gateway 318 # launch gateway
293 gateway = self.client.servers.create( 319 gateway = self.client.servers.create(
294 name=self.prefix + CONCAT_CHAR + 'gateway', 320 name=self.prefix + CONCAT_CHAR + 'gateway',
295 image=self.image, 321 image=image_id,
296 flavor=self.gateway_flavor, 322 flavor=gateway_flavor_id,
297 key_name=self.key_name, 323 key_name=self.key_name,
298 security_groups=self.security_groups, 324 security_groups=self.security_groups,
299 userdata=self.userdata) 325 userdata=self.userdata)
@@ -303,8 +329,8 @@ class Orchestrator(object):
303 # launch chefserver 329 # launch chefserver
304 chefserver = self.client.servers.create( 330 chefserver = self.client.servers.create(
305 name=self.prefix + CONCAT_CHAR + 'chefserver', 331 name=self.prefix + CONCAT_CHAR + 'chefserver',
306 image=self.chefserver_image, 332 image=chefserver_image_id,
307 flavor=self.flavor, 333 flavor=flavor_id,
308 key_name=self.key_name, 334 key_name=self.key_name,
309 security_groups=self.security_groups, 335 security_groups=self.security_groups,
310 userdata=self.userdata, 336 userdata=self.userdata,
@@ -315,8 +341,8 @@ class Orchestrator(object):
315 # launch controller 341 # launch controller
316 controller = self.client.servers.create( 342 controller = self.client.servers.create(
317 name=self.prefix + CONCAT_CHAR + 'controller', 343 name=self.prefix + CONCAT_CHAR + 'controller',
318 image=self.image, 344 image=image_id,
319 flavor=self.flavor, 345 flavor=flavor_id,
320 key_name=self.key_name, 346 key_name=self.key_name,
321 security_groups=self.security_groups, 347 security_groups=self.security_groups,
322 userdata=self.userdata) 348 userdata=self.userdata)
@@ -327,8 +353,8 @@ class Orchestrator(object):
327 for i in xrange(self.num_workers): 353 for i in xrange(self.num_workers):
328 worker = self.client.servers.create( 354 worker = self.client.servers.create(
329 name=self.prefix + CONCAT_CHAR + 'worker%s' % (i + 1), 355 name=self.prefix + CONCAT_CHAR + 'worker%s' % (i + 1),
330 image=self.image, 356 image=image_id,
331 flavor=self.flavor, 357 flavor=flavor_id,
332 key_name=self.key_name, 358 key_name=self.key_name,
333 security_groups=self.security_groups, 359 security_groups=self.security_groups,
334 userdata=self.userdata) 360 userdata=self.userdata)