diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index 2a1514552..7b33d90fd 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -695,6 +695,29 @@ class ShellTest(utils.TestCase): }, ) + def test_boot_with_multiple_nics(self): + cmd = ('boot --image %s --flavor 1 ' + '--nic net-id=net_a,v4-fixed-ip=10.0.0.1 ' + '--nic net-id=net_b some-server' % + FAKE_UUID_1) + self.run_command(cmd) + self.assert_called_anytime( + 'POST', '/servers', + { + 'server': { + 'flavorRef': '1', + 'name': 'some-server', + 'imageRef': FAKE_UUID_1, + 'min_count': 1, + 'max_count': 1, + 'networks': [ + {'uuid': 'net_a', 'fixed_ip': '10.0.0.1'}, + {'uuid': 'net_b'} + ], + }, + }, + ) + def test_boot_nics_with_tag(self): cmd = ('boot --image %s --flavor 1 ' '--nic net-id=a=c,v4-fixed-ip=10.0.0.1,tag=foo some-server' % diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 708a649bf..677e2c02f 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -268,12 +268,11 @@ def _parse_nics(cs, args): supports_auto_alloc = cs.api_version >= api_versions.APIVersion('2.37') supports_nic_tags = _supports_nic_tags(cs) - nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "", - "port-id": "", "net-name": ""} + nic_keys = {'net-id', 'v4-fixed-ip', 'v6-fixed-ip', 'port-id', 'net-name'} if supports_auto_alloc and supports_nic_tags: # API version >= 2.42 - nic_info.update({"tag": ""}) + nic_keys.add('tag') err_msg = (_("Invalid nic argument '%s'. Nic arguments must be of " "the form --nic = API version >= 2.32 - nic_info.update({"tag": ""}) + nic_keys.add('tag') err_msg = (_("Invalid nic argument '%s'. Nic arguments must be of " "the form --nic