summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-09 21:39:21 +0000
committerGerrit Code Review <review@openstack.org>2015-06-09 21:39:21 +0000
commit73957fc5ffaf2ccb1c8aa43b23b8df4f9bd24b43 (patch)
treec33ec176d979d00961aacc49e02b22d1903dc4b6
parent0c724c9975463376f984fd972eeea524cb1def29 (diff)
parent953a12e986449a3bfa8b80409ecf88d93b8becd0 (diff)
downloadpython-novaclient-73957fc5ffaf2ccb1c8aa43b23b8df4f9bd24b43.tar.gz
Merge "Adds support to set admin password from the cli"
-rw-r--r--novaclient/tests/unit/v2/test_servers.py15
-rw-r--r--novaclient/v2/servers.py6
-rw-r--r--novaclient/v2/shell.py9
3 files changed, 27 insertions, 3 deletions
diff --git a/novaclient/tests/unit/v2/test_servers.py b/novaclient/tests/unit/v2/test_servers.py
index c195da50..d16714c7 100644
--- a/novaclient/tests/unit/v2/test_servers.py
+++ b/novaclient/tests/unit/v2/test_servers.py
@@ -205,6 +205,21 @@ class ServersTest(utils.FixturedTestCase):
self.assert_called('POST', '/servers')
self.assertIsInstance(s, servers.Server)
+ def test_create_server_admin_pass(self):
+ test_password = "test-pass"
+ test_key = "fakekey"
+ s = self.cs.servers.create(
+ name="My server",
+ image=1,
+ flavor=1,
+ admin_pass=test_password,
+ key_name=test_key
+ )
+ self.assert_called('POST', '/servers')
+ self.assertIsInstance(s, servers.Server)
+ body = jsonutils.loads(self.requests.last_request.body)
+ self.assertEqual(test_password, body['server']['adminPass'])
+
def test_create_server_userdata_bin(self):
with tempfile.TemporaryFile(mode='wb+') as bin_file:
original_data = os.urandom(1024)
diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py
index f10d85aa..a8848154 100644
--- a/novaclient/v2/servers.py
+++ b/novaclient/v2/servers.py
@@ -849,7 +849,7 @@ class ServerManager(base.BootingManagerWithFind):
key_name=None, availability_zone=None,
block_device_mapping=None, block_device_mapping_v2=None,
nics=None, scheduler_hints=None,
- config_drive=None, disk_config=None, **kwargs):
+ config_drive=None, disk_config=None, admin_pass=None, **kwargs):
# TODO(anthony): indicate in doc string if param is an extension
# and/or optional
"""
@@ -892,6 +892,8 @@ class ServerManager(base.BootingManagerWithFind):
:param disk_config: (optional extension) control how the disk is
partitioned when the server is created. possible
values are 'AUTO' or 'MANUAL'.
+ :param admin_pass: (optional extension) add a user supplied admin
+ password.
"""
if not min_count:
min_count = 1
@@ -908,7 +910,7 @@ class ServerManager(base.BootingManagerWithFind):
max_count=max_count, security_groups=security_groups,
key_name=key_name, availability_zone=availability_zone,
scheduler_hints=scheduler_hints, config_drive=config_drive,
- disk_config=disk_config, **kwargs)
+ disk_config=disk_config, admin_pass=admin_pass, **kwargs)
if block_device_mapping:
resource_url = "/os-volumes_boot"
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index d7112b75..a9234cb7 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -319,7 +319,8 @@ def _boot(cs, args):
block_device_mapping_v2=block_device_mapping_v2,
nics=nics,
scheduler_hints=hints,
- config_drive=config_drive)
+ config_drive=config_drive,
+ admin_pass=args.admin_pass)
return boot_args, boot_kwargs
@@ -502,6 +503,12 @@ def _boot(cs, args):
action="store_true",
default=False,
help=_('Report the new server boot progress until it completes.'))
+@cliutils.arg(
+ '--admin-pass',
+ dest='admin_pass',
+ metavar='<value>',
+ default=None,
+ help='Admin password for the instance')
def do_boot(cs, args):
"""Boot a new server."""
boot_args, boot_kwargs = _boot(cs, args)