Enable to specify which vm fixed-ip to publish
This change enables to specify which vm fixed-ip will be associated to a floating ip using: openstack server add floating ip <vm> <fip> --fixed-ip-address <ip> Closes-Bug: #1624524 Change-Id: I2ddb68c5873bfed7293b0e661d1adbe111681136
This commit is contained in:
parent
98d5641ac5
commit
f5527877bb
@ -33,9 +33,14 @@ Add floating IP address to server
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
openstack server add floating ip
|
openstack server add floating ip
|
||||||
|
[--fixed-ip-address <fixed-ip-address>]
|
||||||
<server>
|
<server>
|
||||||
<ip-address>
|
<ip-address>
|
||||||
|
|
||||||
|
.. option:: --fixed-ip-address <fixed-ip-address>
|
||||||
|
|
||||||
|
Fixed IP address to associate with this floating IP address
|
||||||
|
|
||||||
.. describe:: <server>
|
.. describe:: <server>
|
||||||
|
|
||||||
Server (name or ID) to receive the floating IP address
|
Server (name or ID) to receive the floating IP address
|
||||||
|
@ -235,6 +235,12 @@ class AddFloatingIP(command.Command):
|
|||||||
help=_("Floating IP address (IP address only) to assign "
|
help=_("Floating IP address (IP address only) to assign "
|
||||||
"to server"),
|
"to server"),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--fixed-ip-address",
|
||||||
|
metavar="<fixed-ip-address>",
|
||||||
|
help=_("Fixed IP address to associate with this floating IP "
|
||||||
|
"address"),
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -243,7 +249,8 @@ class AddFloatingIP(command.Command):
|
|||||||
server = utils.find_resource(
|
server = utils.find_resource(
|
||||||
compute_client.servers, parsed_args.server)
|
compute_client.servers, parsed_args.server)
|
||||||
|
|
||||||
server.add_floating_ip(parsed_args.ip_address)
|
server.add_floating_ip(parsed_args.ip_address,
|
||||||
|
parsed_args.fixed_ip_address)
|
||||||
|
|
||||||
|
|
||||||
class AddServerSecurityGroup(command.Command):
|
class AddServerSecurityGroup(command.Command):
|
||||||
|
@ -146,24 +146,33 @@ class TestServerAddFloatingIP(TestServer):
|
|||||||
'add_floating_ip': None,
|
'add_floating_ip': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_server_add_floating_ip(self):
|
def _test_server_add_floating_ip(self, extralist, fixed_ip_address):
|
||||||
servers = self.setup_servers_mock(count=1)
|
servers = self.setup_servers_mock(count=1)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
servers[0].id,
|
servers[0].id,
|
||||||
'1.2.3.4',
|
'1.2.3.4',
|
||||||
]
|
] + extralist
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('server', servers[0].id),
|
('server', servers[0].id),
|
||||||
('ip_address', '1.2.3.4'),
|
('ip_address', '1.2.3.4'),
|
||||||
|
('fixed_ip_address', fixed_ip_address),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
servers[0].add_floating_ip.assert_called_once_with('1.2.3.4')
|
servers[0].add_floating_ip.assert_called_once_with('1.2.3.4',
|
||||||
|
fixed_ip_address)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_server_add_floating_ip(self):
|
||||||
|
self._test_server_add_floating_ip([], None)
|
||||||
|
|
||||||
|
def test_server_add_floating_ip_to_fixed_ip(self):
|
||||||
|
extralist = ['--fixed-ip-address', '5.6.7.8']
|
||||||
|
self._test_server_add_floating_ip(extralist, '5.6.7.8')
|
||||||
|
|
||||||
|
|
||||||
class TestServerAddSecurityGroup(TestServer):
|
class TestServerAddSecurityGroup(TestServer):
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--fixed-ip-address`` option to the ``server add floating ip`` command
|
||||||
|
[Bug `1624524 <https://bugs.launchpad.net/python-openstackclient/+bug/1624524>`_]
|
Loading…
Reference in New Issue
Block a user