commit fd9a235de3b3592366818ab7799e73f6be029b15 Author: Zhaokun Fu Date: Thu Aug 3 19:51:27 2017 -0700 compute: Add --password option for openstack server create Change-Id: Iaf923200efe023655a58ac5acac0b087d2fd5366 Story: #1708570 Task: #13780 diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index e5a7a32..da0cf09 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -556,6 +556,11 @@ class CreateServer(command.ShowOne): 'volume.'), ) parser.add_argument( + '--password', + metavar='', + help=_("Set the password to this server"), + ) + parser.add_argument( '--flavor', metavar='', required=True, @@ -1054,6 +1059,7 @@ class CreateServer(command.ShowOne): userdata=userdata, key_name=parsed_args.key_name, availability_zone=parsed_args.availability_zone, + admin_pass=parsed_args.password, block_device_mapping_v2=block_device_mapping_v2, nics=nics, scheduler_hints=hints, diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index 59282b4..9a8fb3a 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -831,6 +831,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[], scheduler_hints={}, @@ -857,6 +858,7 @@ class TestServerCreate(TestServer): '--property', 'Beta=b', '--security-group', 'securitygroup', '--use-config-drive', + '--password', 'passw0rd', '--hint', 'a=b', '--hint', 'a=c', self.new_server.name, @@ -869,6 +871,7 @@ class TestServerCreate(TestServer): ('security_group', ['securitygroup']), ('hint', {'a': ['b', 'c']}), ('config_drive', True), + ('password', 'passw0rd'), ('server_name', self.new_server.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -897,6 +900,7 @@ class TestServerCreate(TestServer): userdata=None, key_name='keyname', availability_zone=None, + admin_pass='passw0rd', block_device_mapping_v2=[], nics=[], scheduler_hints={'a': ['b', 'c']}, @@ -983,6 +987,7 @@ class TestServerCreate(TestServer): userdata=None, key_name='keyname', availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[], scheduler_hints={}, @@ -1069,6 +1074,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[{'net-id': 'net1_uuid', 'v4-fixed-ip': '', @@ -1133,6 +1139,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, @@ -1182,6 +1189,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, @@ -1227,6 +1235,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='none', scheduler_hints={}, @@ -1392,6 +1401,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[], scheduler_hints={}, @@ -1442,6 +1452,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[], scheduler_hints={}, @@ -1497,6 +1508,7 @@ class TestServerCreate(TestServer): userdata=mock_file, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics=[], scheduler_hints={}, @@ -1543,6 +1555,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[{ 'device_name': 'vda', 'uuid': self.volume.id, @@ -1595,6 +1608,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[{ 'device_name': 'vdf', 'uuid': self.volume.id, @@ -1646,6 +1660,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[{ 'device_name': 'vdf', 'uuid': self.volume.id, @@ -1699,6 +1714,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[{ 'device_name': 'vde', 'uuid': self.volume.id, @@ -1754,6 +1770,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[{ 'device_name': 'vds', 'uuid': self.snapshot.id, @@ -1809,6 +1826,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[ { 'device_name': 'vdb', @@ -1945,6 +1963,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='none', meta=None, @@ -2000,6 +2019,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='none', meta=None, @@ -2089,6 +2109,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='none', meta=None, @@ -2169,6 +2190,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, @@ -2253,6 +2275,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, @@ -2338,6 +2361,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, @@ -2425,6 +2449,7 @@ class TestServerCreate(TestServer): userdata=None, key_name=None, availability_zone=None, + admin_pass=None, block_device_mapping_v2=[], nics='auto', scheduler_hints={}, diff --git a/releasenotes/notes/bug-1708570-bb19e1213e887723.yaml b/releasenotes/notes/bug-1708570-bb19e1213e887723.yaml new file mode 100644 index 0000000..1a1cbdb --- /dev/null +++ b/releasenotes/notes/bug-1708570-bb19e1213e887723.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``--password`` option to ``server create`` command, allowing users to + set the admin password when creating a new instance.