Make port-id and net-id keys mutually exclusive
These keys are never used together, and port-id always takes precedence in Nova API when present. This patch makes these parameters mutually exclusive and updates help strings accordingly. Change-Id: I207dc637cb69d9ab3ff6024a657d2c1890057b4d Closes-Bug: #1314097
This commit is contained in:
parent
02ee4fc79e
commit
9f6679ebd3
|
@ -539,6 +539,11 @@ class ShellTest(utils.TestCase):
|
||||||
'--nic v4-fixed-ip=10.0.0.1 some-server')
|
'--nic v4-fixed-ip=10.0.0.1 some-server')
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_nics_netid_and_portid(self):
|
||||||
|
cmd = ('boot --image 1 --flavor 1 '
|
||||||
|
'--nic port-id=some=port,net-id=some=net some-server')
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
def test_boot_files(self):
|
def test_boot_files(self):
|
||||||
testfile = os.path.join(os.path.dirname(__file__), 'testfile.txt')
|
testfile = os.path.join(os.path.dirname(__file__), 'testfile.txt')
|
||||||
data = open(testfile).read()
|
data = open(testfile).read()
|
||||||
|
|
|
@ -469,6 +469,11 @@ class ShellTest(utils.TestCase):
|
||||||
'--nic v4-fixed-ip=10.0.0.1 some-server')
|
'--nic v4-fixed-ip=10.0.0.1 some-server')
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_nics_netid_and_portid(self):
|
||||||
|
cmd = ('boot --image 1 --flavor 1 '
|
||||||
|
'--nic port-id=some=port,net-id=some=net some-server')
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
def test_boot_num_instances(self):
|
def test_boot_num_instances(self):
|
||||||
self.run_command('boot --image 1 --flavor 1 --num-instances 3 server')
|
self.run_command('boot --image 1 --flavor 1 --num-instances 3 server')
|
||||||
self.assert_called_anytime(
|
self.assert_called_anytime(
|
||||||
|
|
|
@ -227,7 +227,7 @@ def _boot(cs, args):
|
||||||
err_msg = (_("Invalid nic argument '%s'. Nic arguments must be of "
|
err_msg = (_("Invalid nic argument '%s'. Nic arguments must be of "
|
||||||
"the form --nic <net-id=net-uuid,v4-fixed-ip=ip-addr,"
|
"the form --nic <net-id=net-uuid,v4-fixed-ip=ip-addr,"
|
||||||
"v6-fixed-ip=ip-addr,port-id=port-uuid>, with at minimum "
|
"v6-fixed-ip=ip-addr,port-id=port-uuid>, with at minimum "
|
||||||
"net-id or port-id specified.") % nic_str)
|
"net-id or port-id (but not both) specified.") % nic_str)
|
||||||
nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "",
|
nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "",
|
||||||
"port-id": ""}
|
"port-id": ""}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ def _boot(cs, args):
|
||||||
else:
|
else:
|
||||||
raise exceptions.CommandError(err_msg)
|
raise exceptions.CommandError(err_msg)
|
||||||
|
|
||||||
if not nic_info['net-id'] and not nic_info['port-id']:
|
if bool(nic_info['net-id']) == bool(nic_info['port-id']):
|
||||||
raise exceptions.CommandError(err_msg)
|
raise exceptions.CommandError(err_msg)
|
||||||
|
|
||||||
nics.append(nic_info)
|
nics.append(nic_info)
|
||||||
|
@ -401,11 +401,11 @@ def _boot(cs, args):
|
||||||
help=_("Create a NIC on the server. "
|
help=_("Create a NIC on the server. "
|
||||||
"Specify option multiple times to create multiple NICs. "
|
"Specify option multiple times to create multiple NICs. "
|
||||||
"net-id: attach NIC to network with this UUID "
|
"net-id: attach NIC to network with this UUID "
|
||||||
"(required if no port-id), "
|
"(either port-id or net-id must be provided), "
|
||||||
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
|
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
|
||||||
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
|
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
|
||||||
"port-id: attach NIC to port with this UUID "
|
"port-id: attach NIC to port with this UUID "
|
||||||
"(required if no net-id)"))
|
"(either port-id or net-id must be provided)."))
|
||||||
@utils.arg('--config-drive',
|
@utils.arg('--config-drive',
|
||||||
metavar="<value>",
|
metavar="<value>",
|
||||||
dest='config_drive',
|
dest='config_drive',
|
||||||
|
|
|
@ -138,7 +138,7 @@ def _boot(cs, args):
|
||||||
err_msg = ("Invalid nic argument '%s'. Nic arguments must be of the "
|
err_msg = ("Invalid nic argument '%s'. Nic arguments must be of the "
|
||||||
"form --nic <net-id=net-uuid,v4-fixed-ip=ip-addr,"
|
"form --nic <net-id=net-uuid,v4-fixed-ip=ip-addr,"
|
||||||
"v6-fixed-ip=ip-addr,port-id=port-uuid>, with at minimum "
|
"v6-fixed-ip=ip-addr,port-id=port-uuid>, with at minimum "
|
||||||
"net-id or port-id specified." % nic_str)
|
"net-id or port-id (but not both) specified." % nic_str)
|
||||||
nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "",
|
nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "",
|
||||||
"port-id": ""}
|
"port-id": ""}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ def _boot(cs, args):
|
||||||
else:
|
else:
|
||||||
raise exceptions.CommandError(err_msg)
|
raise exceptions.CommandError(err_msg)
|
||||||
|
|
||||||
if not nic_info['net-id'] and not nic_info['port-id']:
|
if bool(nic_info['net-id']) == bool(nic_info['port-id']):
|
||||||
raise exceptions.CommandError(err_msg)
|
raise exceptions.CommandError(err_msg)
|
||||||
|
|
||||||
nics.append(nic_info)
|
nics.append(nic_info)
|
||||||
|
@ -277,11 +277,11 @@ def _boot(cs, args):
|
||||||
help="Create a NIC on the server. "
|
help="Create a NIC on the server. "
|
||||||
"Specify option multiple times to create multiple NICs. "
|
"Specify option multiple times to create multiple NICs. "
|
||||||
"net-id: attach NIC to network with this UUID "
|
"net-id: attach NIC to network with this UUID "
|
||||||
"(required if no port-id), "
|
"(either port-id or net-id must be provided), "
|
||||||
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
|
"v4-fixed-ip: IPv4 fixed address for NIC (optional), "
|
||||||
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
|
"v6-fixed-ip: IPv6 fixed address for NIC (optional), "
|
||||||
"port-id: attach NIC to port with this UUID "
|
"port-id: attach NIC to port with this UUID "
|
||||||
"(required if no net-id)")
|
"(either port-id or net-id must be provided).")
|
||||||
@utils.arg('--config-drive',
|
@utils.arg('--config-drive',
|
||||||
metavar="<value>",
|
metavar="<value>",
|
||||||
dest='config_drive',
|
dest='config_drive',
|
||||||
|
|
Loading…
Reference in New Issue