Skip to content

Commit 0aa2304

Browse files
Tang ChenDean Troyer
andcommitted
Transfer "ip floating CRUD" to "floating ip CRUD"
This patch does the following things to transfer "ip floating xxx" to "floating ip xxx": * Add new command "floating ip create/delete/list/show", and doc. * Deprecate "ip floating create/delete/list/show" command. Change-Id: Ib071acaac81988431244e858bddafa7f93403df5 Implements: blueprint rework-ip-commands Closes-bug: 1555990 Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
1 parent 07e97b1 commit 0aa2304

7 files changed

Lines changed: 214 additions & 18 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
===========
2+
floating ip
3+
===========
4+
5+
Compute v2, Network v2
6+
7+
floating ip create
8+
------------------
9+
10+
Create floating IP
11+
12+
.. program:: floating ip create
13+
.. code:: bash
14+
15+
os floating ip create
16+
[--subnet <subnet>]
17+
[--port <port>]
18+
[--floating-ip-address <floating-ip-address>]
19+
[--fixed-ip-address <fixed-ip-address>]
20+
<network>
21+
22+
.. option:: --subnet <subnet>
23+
24+
Subnet on which you want to create the floating IP (name or ID)
25+
*Network version 2 only*
26+
27+
.. option:: --port <port>
28+
29+
Port to be associated with the floating IP (name or ID)
30+
*Network version 2 only*
31+
32+
.. option:: --floating-ip-address <floating-ip-address>
33+
34+
Floating IP address
35+
*Network version 2 only*
36+
37+
.. option:: --fixed-ip-address <fixed-ip-address>
38+
39+
Fixed IP address mapped to the floating IP
40+
*Network version 2 only*
41+
42+
.. describe:: <network>
43+
44+
Network to allocate floating IP from (name or ID)
45+
46+
floating ip delete
47+
------------------
48+
49+
Delete floating IP(s)
50+
51+
.. program:: floating ip delete
52+
.. code:: bash
53+
54+
os floating ip delete <floating-ip> [<floating-ip> ...]
55+
56+
.. describe:: <floating-ip>
57+
58+
Floating IP(s) to delete (IP address or ID)
59+
60+
floating ip list
61+
----------------
62+
63+
List floating IP(s)
64+
65+
.. program:: floating ip list
66+
.. code:: bash
67+
68+
os floating ip list
69+
70+
floating ip show
71+
----------------
72+
73+
Display floating IP details
74+
75+
.. program:: floating ip show
76+
.. code:: bash
77+
78+
os floating ip show <floating-ip>
79+
80+
.. describe:: <floating-ip>
81+
82+
Floating IP to display (IP address or ID)

doc/source/command-objects/ip-floating.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ip floating create
2929
------------------
3030

3131
Create new floating IP address
32+
(Deprecated, please use ``floating ip create`` instead)
3233

3334
.. program:: ip floating create
3435
.. code:: bash
@@ -68,6 +69,7 @@ ip floating delete
6869
------------------
6970

7071
Delete floating IP(s)
72+
(Deprecated, please use ``floating ip delete`` instead)
7173

7274
.. program:: ip floating delete
7375
.. code:: bash
@@ -83,6 +85,7 @@ ip floating list
8385
----------------
8486

8587
List floating IP addresses
88+
(Deprecated, please use ``floating ip list`` instead)
8689

8790
.. program:: ip floating list
8891
.. code:: bash
@@ -114,6 +117,7 @@ ip floating show
114117
----------------
115118

116119
Display floating IP details
120+
(Deprecated, please use ``floating ip show`` instead)
117121

118122
.. program:: ip floating show
119123
.. code:: bash

functional/tests/compute/v2/test_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,25 @@ def test_server_attach_detach_floating_ip(self):
249249
self.wait_for_status("ACTIVE")
250250
# attach ip
251251
opts = self.get_opts(["id", "floating_ip_address"])
252-
raw_output = self.openstack('ip floating create ' +
252+
raw_output = self.openstack('floating ip create ' +
253253
self.IP_POOL +
254254
opts)
255255
ip, ipid, rol = tuple(raw_output.split('\n'))
256256
self.assertNotEqual("", ipid)
257257
self.assertNotEqual("", ip)
258-
raw_output = self.openstack('ip floating add ' + ip + ' ' + self.NAME)
258+
raw_output = self.openstack('server add floating ip ' + self.NAME +
259+
' ' + ip)
259260
self.assertEqual("", raw_output)
260261
raw_output = self.openstack('server show ' + self.NAME)
261262
self.assertIn(ip, raw_output)
262263

263264
# detach ip
264-
raw_output = self.openstack('ip floating remove ' + ip + ' ' +
265-
self.NAME)
265+
raw_output = self.openstack('server remove floating ip ' + self.NAME +
266+
' ' + ip)
266267
self.assertEqual("", raw_output)
267268
raw_output = self.openstack('server show ' + self.NAME)
268269
self.assertNotIn(ip, raw_output)
269-
raw_output = self.openstack('ip floating delete ' + ipid)
270+
raw_output = self.openstack('floating ip delete ' + ipid)
270271
self.assertEqual("", raw_output)
271272

272273
def test_server_reboot(self):

functional/tests/network/v2/test_floating_ip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def setUpClass(cls):
3535
)
3636
opts = cls.get_opts(cls.FIELDS)
3737
raw_output = cls.openstack(
38-
'ip floating create ' + cls.NETWORK_NAME + opts)
38+
'floating ip create ' + cls.NETWORK_NAME + opts)
3939
cls.ID = raw_output.strip('\n')
4040

4141
@classmethod
4242
def tearDownClass(cls):
43-
raw_output = cls.openstack('ip floating delete ' + cls.ID)
43+
raw_output = cls.openstack('floating ip delete ' + cls.ID)
4444
cls.assertOutput('', raw_output)
4545
raw_output = cls.openstack('subnet delete ' + cls.SUBNET_NAME)
4646
cls.assertOutput('', raw_output)
@@ -49,10 +49,10 @@ def tearDownClass(cls):
4949

5050
def test_floating_ip_list(self):
5151
opts = self.get_opts(self.HEADERS)
52-
raw_output = self.openstack('ip floating list' + opts)
52+
raw_output = self.openstack('floating ip list' + opts)
5353
self.assertIn(self.ID, raw_output)
5454

5555
def test_floating_ip_show(self):
5656
opts = self.get_opts(self.FIELDS)
57-
raw_output = self.openstack('ip floating show ' + self.ID + opts)
57+
raw_output = self.openstack('floating ip show ' + self.ID + opts)
5858
self.assertEqual(self.ID + "\n", raw_output)

openstackclient/network/v2/floating_ip.py

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
"""IP Floating action implementations"""
1515

16+
import logging
17+
1618
from osc_lib import utils
1719

1820
from openstackclient.i18n import _
@@ -31,25 +33,26 @@ def _get_attrs(client_manager, parsed_args):
3133
attrs = {}
3234
network_client = client_manager.network
3335

36+
# Name of a network could be empty string.
3437
if parsed_args.network is not None:
3538
network = network_client.find_network(parsed_args.network,
3639
ignore_missing=False)
3740
attrs['floating_network_id'] = network.id
3841

39-
if parsed_args.subnet is not None:
42+
if parsed_args.subnet:
4043
subnet = network_client.find_subnet(parsed_args.subnet,
4144
ignore_missing=False)
4245
attrs['subnet_id'] = subnet.id
4346

44-
if parsed_args.port is not None:
47+
if parsed_args.port:
4548
port = network_client.find_port(parsed_args.port,
4649
ignore_missing=False)
4750
attrs['port_id'] = port.id
4851

49-
if parsed_args.floating_ip_address is not None:
52+
if parsed_args.floating_ip_address:
5053
attrs['floating_ip_address'] = parsed_args.floating_ip_address
5154

52-
if parsed_args.fixed_ip_address is not None:
55+
if parsed_args.fixed_ip_address:
5356
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
5457

5558
return attrs
@@ -110,6 +113,30 @@ def take_action_compute(self, client, parsed_args):
110113
return (columns, data)
111114

112115

116+
class CreateIPFloating(CreateFloatingIP):
117+
"""Create floating IP"""
118+
119+
# TODO(tangchen): Remove this class and ``ip floating create`` command
120+
# two cycles after Mitaka.
121+
122+
# This notifies cliff to not display the help for this command
123+
deprecated = True
124+
125+
log = logging.getLogger('deprecated')
126+
127+
def take_action_network(self, client, parsed_args):
128+
self.log.warning(_('This command has been deprecated. '
129+
'Please use "floating ip create" instead.'))
130+
return super(CreateIPFloating, self).take_action_network(
131+
client, parsed_args)
132+
133+
def take_action_compute(self, client, parsed_args):
134+
self.log.warning(_('This command has been deprecated. '
135+
'Please use "floating ip create" instead.'))
136+
return super(CreateIPFloating, self).take_action_compute(
137+
client, parsed_args)
138+
139+
113140
class DeleteFloatingIP(common.NetworkAndComputeDelete):
114141
"""Delete floating IP(s)"""
115142

@@ -135,6 +162,30 @@ def take_action_compute(self, client, parsed_args):
135162
client.floating_ips.delete(obj.id)
136163

137164

165+
class DeleteIPFloating(DeleteFloatingIP):
166+
"""Delete floating IP(s)"""
167+
168+
# TODO(tangchen): Remove this class and ``ip floating delete`` command
169+
# two cycles after Mitaka.
170+
171+
# This notifies cliff to not display the help for this command
172+
deprecated = True
173+
174+
log = logging.getLogger('deprecated')
175+
176+
def take_action_network(self, client, parsed_args):
177+
self.log.warning(_('This command has been deprecated. '
178+
'Please use "floating ip delete" instead.'))
179+
return super(DeleteIPFloating, self).take_action_network(
180+
client, parsed_args)
181+
182+
def take_action_compute(self, client, parsed_args):
183+
self.log.warning(_('This command has been deprecated. '
184+
'Please use "floating ip delete" instead.'))
185+
return super(DeleteIPFloating, self).take_action_compute(
186+
client, parsed_args)
187+
188+
138189
class ListFloatingIP(common.NetworkAndComputeLister):
139190
"""List floating IP(s)"""
140191

@@ -186,8 +237,32 @@ def take_action_compute(self, client, parsed_args):
186237
) for s in data))
187238

188239

240+
class ListIPFloating(ListFloatingIP):
241+
"""List floating IP(s)"""
242+
243+
# TODO(tangchen): Remove this class and ``ip floating list`` command
244+
# two cycles after Mitaka.
245+
246+
# This notifies cliff to not display the help for this command
247+
deprecated = True
248+
249+
log = logging.getLogger('deprecated')
250+
251+
def take_action_network(self, client, parsed_args):
252+
self.log.warning(_('This command has been deprecated. '
253+
'Please use "floating ip list" instead.'))
254+
return super(ListIPFloating, self).take_action_network(
255+
client, parsed_args)
256+
257+
def take_action_compute(self, client, parsed_args):
258+
self.log.warning(_('This command has been deprecated. '
259+
'Please use "floating ip list" instead.'))
260+
return super(ListIPFloating, self).take_action_compute(
261+
client, parsed_args)
262+
263+
189264
class ShowFloatingIP(common.NetworkAndComputeShowOne):
190-
"""Show floating IP details"""
265+
"""Display floating IP details"""
191266

192267
def update_parser_common(self, parser):
193268
parser.add_argument(
@@ -211,3 +286,27 @@ def take_action_compute(self, client, parsed_args):
211286
columns = _get_columns(obj._info)
212287
data = utils.get_dict_properties(obj._info, columns)
213288
return (columns, data)
289+
290+
291+
class ShowIPFloating(ShowFloatingIP):
292+
"""Display floating IP details"""
293+
294+
# TODO(tangchen): Remove this class and ``ip floating show`` command
295+
# two cycles after Mitaka.
296+
297+
# This notifies cliff to not display the help for this command
298+
deprecated = True
299+
300+
log = logging.getLogger('deprecated')
301+
302+
def take_action_network(self, client, parsed_args):
303+
self.log.warning(_('This command has been deprecated. '
304+
'Please use "floating ip show" instead.'))
305+
return super(ShowIPFloating, self).take_action_network(
306+
client, parsed_args)
307+
308+
def take_action_compute(self, client, parsed_args):
309+
self.log.warning(_('This command has been deprecated. '
310+
'Please use "floating ip show" instead.'))
311+
return super(ShowIPFloating, self).take_action_compute(
312+
client, parsed_args)

releasenotes/notes/ip-command-rework-8d3fe0858f51e6b8.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ features:
1010
- Add new commands ``server add/remove fixed ip``. They are used to
1111
replace the old commands ``ip fixed add/remove``.
1212
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]
13+
- Add new commands ``floating ip create/delete/list/show``. It is used to
14+
replace the old commands ``ip floating create/delete/list/show``.
15+
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]
1316
deprecations:
1417
- Deprecate command ``ip floating pool list``.
1518
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]
1619
- Deprecate commands ``ip floating add/remove``.
1720
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]
1821
- Deprecate commands ``ip fixed add/remove``.
1922
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]
23+
- Deprecate commands ``ip floating create/delete/list/show``.
24+
[Blueprint rework-ip-commands `<https://blueprints.launchpad.net/python-openstackclient/+spec/rework-ip-commands>`_]

setup.cfg

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,20 @@ openstack.network.v2 =
337337
address_scope_set = openstackclient.network.v2.address_scope:SetAddressScope
338338
address_scope_show = openstackclient.network.v2.address_scope:ShowAddressScope
339339

340+
floating_ip_create = openstackclient.network.v2.floating_ip:CreateFloatingIP
341+
floating_ip_delete = openstackclient.network.v2.floating_ip:DeleteFloatingIP
342+
floating_ip_list = openstackclient.network.v2.floating_ip:ListFloatingIP
343+
floating_ip_show = openstackclient.network.v2.floating_ip:ShowFloatingIP
344+
340345
floating_ip_pool_list = openstackclient.network.v2.floating_ip_pool:ListFloatingIPPool
341346

342347
ip_availability_list = openstackclient.network.v2.ip_availability:ListIPAvailability
343348
ip_availability_show = openstackclient.network.v2.ip_availability:ShowIPAvailability
344349

345-
ip_floating_create = openstackclient.network.v2.floating_ip:CreateFloatingIP
346-
ip_floating_delete = openstackclient.network.v2.floating_ip:DeleteFloatingIP
347-
ip_floating_list = openstackclient.network.v2.floating_ip:ListFloatingIP
348-
ip_floating_show = openstackclient.network.v2.floating_ip:ShowFloatingIP
350+
ip_floating_create = openstackclient.network.v2.floating_ip:CreateIPFloating
351+
ip_floating_delete = openstackclient.network.v2.floating_ip:DeleteIPFloating
352+
ip_floating_list = openstackclient.network.v2.floating_ip:ListIPFloating
353+
ip_floating_show = openstackclient.network.v2.floating_ip:ShowIPFloating
349354

350355
ip_floating_pool_list = openstackclient.network.v2.floating_ip_pool:ListIPFloatingPool
351356

0 commit comments

Comments
 (0)