summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-09-25 10:37:03 +0000
committerGerrit Code Review <review@openstack.org>2019-09-25 10:37:03 +0000
commitd5b5a20de15a016d341c5e9d3092478f7a12c3e8 (patch)
tree0d6eadaf69e43fa9032a0f7bf37c218a4329fa96
parent5d236ce6ba2cadc982862ce0372a61423f7f5288 (diff)
parentd1c5dc61d60b29428484a38703a0064933cc7c0e (diff)
downloadpython-novaclient-d5b5a20de15a016d341c5e9d3092478f7a12c3e8.tar.gz
Merge "Add a check for --config-drive option on nova boot"
-rw-r--r--doc/source/cli/nova.rst3
-rw-r--r--novaclient/tests/unit/v2/test_shell.py35
-rw-r--r--novaclient/v2/servers.py4
-rw-r--r--novaclient/v2/shell.py6
-rw-r--r--releasenotes/notes/bug-1825061-2beb95db4d6df0cb.yaml5
5 files changed, 34 insertions, 19 deletions
diff --git a/doc/source/cli/nova.rst b/doc/source/cli/nova.rst
index 11573f7d..712a5ec1 100644
--- a/doc/source/cli/nova.rst
+++ b/doc/source/cli/nova.rst
@@ -1089,7 +1089,8 @@ quality of service support, microversion ``2.72`` is required.
versions '2.42' - '2.latest')
``--config-drive <value>``
- Enable config drive.
+ Enable config drive. The value must be a
+ boolean value.
``--poll``
Report the new server boot progress until it
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index a57c3794..ad233c5e 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -240,42 +240,42 @@ class ShellTest(utils.TestCase):
}},
)
- def test_boot_config_drive(self):
+ def test_boot_access_ip(self):
self.run_command(
- 'boot --flavor 1 --image %s --config-drive 1 some-server' %
- FAKE_UUID_1)
+ 'boot --flavor 1 --image %s --access-ip-v4 10.10.10.10 '
+ '--access-ip-v6 ::1 some-server' % FAKE_UUID_1)
self.assert_called_anytime(
'POST', '/servers',
{'server': {
'flavorRef': '1',
'name': 'some-server',
'imageRef': FAKE_UUID_1,
- 'min_count': 1,
+ 'accessIPv4': '10.10.10.10',
+ 'accessIPv6': '::1',
'max_count': 1,
- 'config_drive': True
+ 'min_count': 1
}},
)
- def test_boot_access_ip(self):
+ def test_boot_config_drive(self):
self.run_command(
- 'boot --flavor 1 --image %s --access-ip-v4 10.10.10.10 '
- '--access-ip-v6 ::1 some-server' % FAKE_UUID_1)
+ 'boot --flavor 1 --image %s --config-drive 1 some-server' %
+ FAKE_UUID_1)
self.assert_called_anytime(
'POST', '/servers',
{'server': {
'flavorRef': '1',
'name': 'some-server',
'imageRef': FAKE_UUID_1,
- 'accessIPv4': '10.10.10.10',
- 'accessIPv6': '::1',
+ 'min_count': 1,
'max_count': 1,
- 'min_count': 1
+ 'config_drive': True
}},
)
- def test_boot_config_drive_custom(self):
+ def test_boot_config_drive_false(self):
self.run_command(
- 'boot --flavor 1 --image %s --config-drive /dev/hda some-server' %
+ 'boot --flavor 1 --image %s --config-drive false some-server' %
FAKE_UUID_1)
self.assert_called_anytime(
'POST', '/servers',
@@ -285,10 +285,17 @@ class ShellTest(utils.TestCase):
'imageRef': FAKE_UUID_1,
'min_count': 1,
'max_count': 1,
- 'config_drive': '/dev/hda'
}},
)
+ def test_boot_config_drive_invalid_value(self):
+ ex = self.assertRaises(
+ exceptions.CommandError, self.run_command,
+ 'boot --flavor 1 --image %s --config-drive /dev/hda some-server' %
+ FAKE_UUID_1)
+ self.assertIn("The value of the '--config-drive' option must be "
+ "a boolean value.", six.text_type(ex))
+
def test_boot_invalid_user_data(self):
invalid_file = os.path.join(os.path.dirname(__file__),
'no_such_file')
diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py
index 9870be0b..1351189b 100644
--- a/novaclient/v2/servers.py
+++ b/novaclient/v2/servers.py
@@ -1375,8 +1375,8 @@ class ServerManager(base.BootingManagerWithFind):
any networking for the server.
:param scheduler_hints: (optional extension) arbitrary key-value pairs
specified by the client to help boot an instance
- :param config_drive: (optional extension) value for config drive
- either boolean, or volume-id
+ :param config_drive: (optional extension) a boolean value to enable
+ config drive
:param disk_config: (optional extension) control how the disk is
partitioned when the server is created. possible
values are 'AUTO' or 'MANUAL'.
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 2dfd5c92..5aab35af 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -506,7 +506,9 @@ def _boot(cs, args):
elif str(args.config_drive).lower() in ("false", "0", "", "none"):
config_drive = None
else:
- config_drive = args.config_drive
+ raise exceptions.CommandError(
+ _("The value of the '--config-drive' option must be "
+ "a boolean value."))
boot_kwargs = dict(
meta=meta,
@@ -906,7 +908,7 @@ def _boot(cs, args):
metavar="<value>",
dest='config_drive',
default=False,
- help=_("Enable config drive."))
+ help=_("Enable config drive. The value must be a boolean value."))
@utils.arg(
'--poll',
dest='poll',
diff --git a/releasenotes/notes/bug-1825061-2beb95db4d6df0cb.yaml b/releasenotes/notes/bug-1825061-2beb95db4d6df0cb.yaml
new file mode 100644
index 00000000..573ad7fc
--- /dev/null
+++ b/releasenotes/notes/bug-1825061-2beb95db4d6df0cb.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+ - |
+ A check for a value of the '--config-drive' option has been added on the
+ ``nova boot`` command. A boolean value is only allowed in the option now.