summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-21 01:55:51 +0000
committerGerrit Code Review <review@openstack.org>2017-03-21 01:55:51 +0000
commit49e866174f2e24ce996cdb588c38b5b08daed5a0 (patch)
tree26e88367bbac744cd61275c3c31b0670d985f2f5
parentfe3bbf63a868a333b3dd7c8ec479046bd1a780ce (diff)
parentf5527877bb6dab09757b6692460bcc376b7d5ec3 (diff)
downloadpython-openstackclient-49e866174f2e24ce996cdb588c38b5b08daed5a0.tar.gz
Merge "Enable to specify which vm fixed-ip to publish"
-rw-r--r--doc/source/command-objects/server.rst5
-rw-r--r--openstackclient/compute/v2/server.py9
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py15
-rw-r--r--releasenotes/notes/allow-to-specify-vm-ip-to-publish-85f7207740c0cc8d.yaml5
4 files changed, 30 insertions, 4 deletions
diff --git a/doc/source/command-objects/server.rst b/doc/source/command-objects/server.rst
index b2ae965a..047bf181 100644
--- a/doc/source/command-objects/server.rst
+++ b/doc/source/command-objects/server.rst
@@ -33,9 +33,14 @@ Add floating IP address to server
.. code:: bash
openstack server add floating ip
+ [--fixed-ip-address <fixed-ip-address>]
<server>
<ip-address>
+.. option:: --fixed-ip-address <fixed-ip-address>
+
+ Fixed IP address to associate with this floating IP address
+
.. describe:: <server>
Server (name or ID) to receive the floating IP address
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 236e4b28..1fe5bb0d 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -235,6 +235,12 @@ class AddFloatingIP(command.Command):
help=_("Floating IP address (IP address only) to assign "
"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
def take_action(self, parsed_args):
@@ -243,7 +249,8 @@ class AddFloatingIP(command.Command):
server = utils.find_resource(
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):
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index 5020dd2e..7691ef59 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -146,24 +146,33 @@ class TestServerAddFloatingIP(TestServer):
'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)
arglist = [
servers[0].id,
'1.2.3.4',
- ]
+ ] + extralist
verifylist = [
('server', servers[0].id),
('ip_address', '1.2.3.4'),
+ ('fixed_ip_address', fixed_ip_address),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
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)
+ 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):
diff --git a/releasenotes/notes/allow-to-specify-vm-ip-to-publish-85f7207740c0cc8d.yaml b/releasenotes/notes/allow-to-specify-vm-ip-to-publish-85f7207740c0cc8d.yaml
new file mode 100644
index 00000000..3d0a4801
--- /dev/null
+++ b/releasenotes/notes/allow-to-specify-vm-ip-to-publish-85f7207740c0cc8d.yaml
@@ -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>`_]