Adds support to set admin password from the cli
You can set admin password as nova boot --image <image> --flavor <flavor> --admin-pass <pass> vm-name Change-Id: I119aba428c15d736e64d990be47cc5c13bb83738 Closes-Bug: #1248517
This commit is contained in:
parent
773eea811d
commit
953a12e986
novaclient
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user