add key_name to servers.create

This commit is contained in:
Anthony Young 2011-09-20 00:20:52 -07:00
parent 1ed1f5e863
commit 4aaa47705b
3 changed files with 10 additions and 3 deletions

View File

@ -25,7 +25,7 @@ class BootingManagerWithFind(base.ManagerWithFind):
def _boot(self, resource_url, response_key, name, image, flavor,
meta=None, files=None, zone_blob=None, userdata=None,
reservation_id=None, return_raw=False, min_count=None,
max_count=None, security_groups=None):
max_count=None, security_groups=None, key_name=None):
"""
Create (boot) a new server.
@ -47,6 +47,7 @@ class BootingManagerWithFind(base.ManagerWithFind):
:param return_raw: If True, don't try to coearse the result into
a Resource object.
:param security_groups: list of security group names
:param key_name: name of keypair to inject into the instance
"""
body = {"server": {
"name": name,
@ -63,6 +64,8 @@ class BootingManagerWithFind(base.ManagerWithFind):
body["server"]["reservation_id"] = reservation_id
if zone_blob:
body["server"]["zone_blob"] = zone_blob
if key_name:
body["server"]["key_name"] = key_name
if not min_count:
min_count = 1

View File

@ -326,7 +326,8 @@ class ServerManager(local_base.BootingManagerWithFind):
def create(self, name, image, flavor, meta=None, files=None,
zone_blob=None, reservation_id=None, min_count=None,
max_count=None, security_groups=None, userdata=None):
max_count=None, security_groups=None, userdata=None,
key_name=None):
"""
Create (boot) a new server.
@ -348,6 +349,8 @@ class ServerManager(local_base.BootingManagerWithFind):
server this can be a file type object as well or a
string.
:param reservation_id: a UUID for the set of servers being requested.
:param key_name: name of previously created keypair to inject
into the instance
"""
if not min_count:
min_count = 1
@ -359,7 +362,7 @@ class ServerManager(local_base.BootingManagerWithFind):
meta=meta, files=files, userdata=userdata,
zone_blob=zone_blob, reservation_id=reservation_id,
min_count=min_count, max_count=max_count,
security_groups=security_groups)
security_groups=security_groups, key_name=key_name)
def update(self, server, name=None):
"""

View File

@ -34,6 +34,7 @@ class ServersTest(utils.TestCase):
flavor=1,
meta={'foo': 'bar'},
userdata="hello moto",
key_name="fakekey",
files={
'/etc/passwd': 'some data', # a file
'/tmp/foo.txt': StringIO.StringIO('data'), # a stream