Merge "Do not require port argument when updating floating IP"
This commit is contained in:
commit
00194b4e20
doc/source/cli/command-objects
openstackclient
@ -198,7 +198,7 @@ Set floating IP properties
|
||||
.. code:: bash
|
||||
|
||||
openstack floating ip set
|
||||
--port <port>
|
||||
[--port <port>]
|
||||
[--fixed-ip-address <ip-address>]
|
||||
[--qos-policy <qos-policy> | --no-qos-policy]
|
||||
[--tag <tag>] [--no-tag]
|
||||
@ -257,8 +257,8 @@ Unset floating IP Properties
|
||||
.. code:: bash
|
||||
|
||||
openstack floating ip unset
|
||||
--port
|
||||
--qos-policy
|
||||
[--port]
|
||||
[--qos-policy]
|
||||
[--tag <tag> | --all-tag]
|
||||
<floating-ip>
|
||||
|
||||
|
@ -347,11 +347,10 @@ class SetFloatingIP(command.Command):
|
||||
parser.add_argument(
|
||||
'floating_ip',
|
||||
metavar='<floating-ip>',
|
||||
help=_("Floating IP to associate (IP address or ID)"))
|
||||
help=_("Floating IP to modify (IP address or ID)"))
|
||||
parser.add_argument(
|
||||
'--port',
|
||||
metavar='<port>',
|
||||
required=True,
|
||||
help=_("Associate the floating IP with port (name or ID)")),
|
||||
parser.add_argument(
|
||||
'--fixed-ip-address',
|
||||
@ -383,9 +382,11 @@ class SetFloatingIP(command.Command):
|
||||
parsed_args.floating_ip,
|
||||
ignore_missing=False,
|
||||
)
|
||||
port = client.find_port(parsed_args.port,
|
||||
ignore_missing=False)
|
||||
attrs['port_id'] = port.id
|
||||
if parsed_args.port:
|
||||
port = client.find_port(parsed_args.port,
|
||||
ignore_missing=False)
|
||||
attrs['port_id'] = port.id
|
||||
|
||||
if parsed_args.fixed_ip_address:
|
||||
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
|
||||
|
||||
|
@ -747,6 +747,31 @@ class TestSetFloatingIP(TestFloatingIPNetwork):
|
||||
self.network.update_ip.assert_called_once_with(
|
||||
self.floating_ip, **attrs)
|
||||
|
||||
def test_qos_policy_option(self):
|
||||
qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
|
||||
self.network.find_qos_policy = mock.Mock(return_value=qos_policy)
|
||||
arglist = [
|
||||
"--qos-policy", qos_policy.id,
|
||||
self.floating_ip.id,
|
||||
]
|
||||
verifylist = [
|
||||
('qos_policy', qos_policy.id),
|
||||
('floating_ip', self.floating_ip.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
attrs = {
|
||||
'qos_policy_id': qos_policy.id,
|
||||
}
|
||||
self.network.find_ip.assert_called_once_with(
|
||||
self.floating_ip.id,
|
||||
ignore_missing=False,
|
||||
)
|
||||
self.network.update_ip.assert_called_once_with(
|
||||
self.floating_ip, **attrs)
|
||||
|
||||
def test_port_and_qos_policy_option(self):
|
||||
qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
|
||||
self.network.find_qos_policy = mock.Mock(return_value=qos_policy)
|
||||
@ -775,6 +800,29 @@ class TestSetFloatingIP(TestFloatingIPNetwork):
|
||||
self.network.update_ip.assert_called_once_with(
|
||||
self.floating_ip, **attrs)
|
||||
|
||||
def test_no_qos_policy_option(self):
|
||||
arglist = [
|
||||
"--no-qos-policy",
|
||||
self.floating_ip.id,
|
||||
]
|
||||
verifylist = [
|
||||
('no_qos_policy', True),
|
||||
('floating_ip', self.floating_ip.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
attrs = {
|
||||
'qos_policy_id': None,
|
||||
}
|
||||
self.network.find_ip.assert_called_once_with(
|
||||
self.floating_ip.id,
|
||||
ignore_missing=False,
|
||||
)
|
||||
self.network.update_ip.assert_called_once_with(
|
||||
self.floating_ip, **attrs)
|
||||
|
||||
def test_port_and_no_qos_policy_option(self):
|
||||
arglist = [
|
||||
"--no-qos-policy",
|
||||
@ -810,16 +858,13 @@ class TestSetFloatingIP(TestFloatingIPNetwork):
|
||||
arglist = ['--no-tag']
|
||||
verifylist = [('no_tag', True)]
|
||||
expected_args = []
|
||||
arglist.extend(['--port', self.floating_ip.port_id,
|
||||
self.floating_ip.id])
|
||||
verifylist.extend([
|
||||
('port', self.floating_ip.port_id),
|
||||
('floating_ip', self.floating_ip.id)])
|
||||
arglist.extend([self.floating_ip.id])
|
||||
verifylist.extend([('floating_ip', self.floating_ip.id)])
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertTrue(self.network.update_ip.called)
|
||||
self.assertFalse(self.network.update_ip.called)
|
||||
self.network.set_tags.assert_called_once_with(
|
||||
self.floating_ip,
|
||||
tests_utils.CompareBySet(expected_args))
|
||||
|
Loading…
x
Reference in New Issue
Block a user