Permalink
Browse files

Make `boot --ipgroup <name>` work.

Closes #3.
  • Loading branch information...
1 parent 31e2c85 commit 8c9525ced52d19a8f3de7a719b9dc711ba218a1e @jacobian jacobian committed Aug 16, 2010
Showing with 23 additions and 2 deletions.
  1. +9 −2 cloudservers/shell.py
  2. +14 −0 tests/test_shell.py
View
@@ -190,7 +190,7 @@ def do_backup_schedule_delete(self, args):
@arg('--ipgroup',
default = None,
metavar = '<group>',
- help = "IP group ID (see 'cloudservers ipgroup-list').")
+ help = "IP group name or ID (see 'cloudservers ipgroup-list').")
@arg('--meta',
metavar = "<key=value>",
action = 'append',
@@ -215,6 +215,13 @@ def do_boot(self, args):
flavor = args.flavor or self.cs.flavors.find(ram=256)
image = args.image or self.cs.images.find(name="Ubuntu 10.04 LTS (lucid)")
+ # Map --ipgroup <name> to an ID.
+ # XXX do this for flavor/image?
+ if args.ipgroup:
+ ipgroup = self._find_ipgroup(args.ipgroup)
+ else:
+ ipgroup = None
+
metadata = dict(v.split('=') for v in args.meta)
files = {}
@@ -245,7 +252,7 @@ def do_boot(self, args):
except IOError, e:
raise CommandError("Can't open '%s': %s" % (keyfile, e))
- server = self.cs.servers.create(args.name, image, flavor, args.ipgroup, metadata, files)
+ server = self.cs.servers.create(args.name, image, flavor, ipgroup, metadata, files)
print_dict(server._info)
def do_flavor_list(self, args):
View
@@ -138,6 +138,20 @@ def test_boot_invalid_keyfile():
invalid_file = os.path.join(os.path.dirname(__file__), 'asdfasdfasdfasdf')
assert_raises(CommandError, shell, 'boot some-server --image 1 --key %s' % invalid_file)
+def test_boot_ipgroup():
+ shell('boot --image 1 --ipgroup 1 some-server')
+ assert_called(
+ 'POST', '/servers',
+ {'server': {'flavorId': 1, 'name': 'some-server', 'imageId': 1, 'sharedIpGroupId': 1}}
+ )
+
+def test_boot_ipgroup_name():
+ shell('boot --image 1 --ipgroup group1 some-server')
+ assert_called(
+ 'POST', '/servers',
+ {'server': {'flavorId': 1, 'name': 'some-server', 'imageId': 1, 'sharedIpGroupId': 1}}
+ )
+
def test_flavor_list():
shell('flavor-list')
assert_called('GET', '/flavors/detail')

0 comments on commit 8c9525c

Please sign in to comment.