summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-06-17 15:06:40 +0800
committerTang Chen <chen.tang@easystack.cn>2016-07-20 13:37:48 +0800
commit0aa2304f38da0696576827fc4d71f2cf7cc13ad6 (patch)
tree06913a21f43ff5aef1851a9ae955509816c89f1a /openstackclient
parent07e97b1a8ab76a253a483a5290bcf93fa41c7cc4 (diff)
downloadpython-openstackclient-0aa2304f38da0696576827fc4d71f2cf7cc13ad6.tar.gz
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>
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/floating_ip.py109
1 files changed, 104 insertions, 5 deletions
diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py
index 8fbf049e..454335f1 100644
--- a/openstackclient/network/v2/floating_ip.py
+++ b/openstackclient/network/v2/floating_ip.py
@@ -13,6 +13,8 @@
"""IP Floating action implementations"""
+import logging
+
from osc_lib import utils
from openstackclient.i18n import _
@@ -31,25 +33,26 @@ def _get_attrs(client_manager, parsed_args):
attrs = {}
network_client = client_manager.network
+ # Name of a network could be empty string.
if parsed_args.network is not None:
network = network_client.find_network(parsed_args.network,
ignore_missing=False)
attrs['floating_network_id'] = network.id
- if parsed_args.subnet is not None:
+ if parsed_args.subnet:
subnet = network_client.find_subnet(parsed_args.subnet,
ignore_missing=False)
attrs['subnet_id'] = subnet.id
- if parsed_args.port is not None:
+ if parsed_args.port:
port = network_client.find_port(parsed_args.port,
ignore_missing=False)
attrs['port_id'] = port.id
- if parsed_args.floating_ip_address is not None:
+ if parsed_args.floating_ip_address:
attrs['floating_ip_address'] = parsed_args.floating_ip_address
- if parsed_args.fixed_ip_address is not None:
+ if parsed_args.fixed_ip_address:
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
return attrs
@@ -110,6 +113,30 @@ class CreateFloatingIP(common.NetworkAndComputeShowOne):
return (columns, data)
+class CreateIPFloating(CreateFloatingIP):
+ """Create floating IP"""
+
+ # TODO(tangchen): Remove this class and ``ip floating create`` command
+ # two cycles after Mitaka.
+
+ # This notifies cliff to not display the help for this command
+ deprecated = True
+
+ log = logging.getLogger('deprecated')
+
+ def take_action_network(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip create" instead.'))
+ return super(CreateIPFloating, self).take_action_network(
+ client, parsed_args)
+
+ def take_action_compute(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip create" instead.'))
+ return super(CreateIPFloating, self).take_action_compute(
+ client, parsed_args)
+
+
class DeleteFloatingIP(common.NetworkAndComputeDelete):
"""Delete floating IP(s)"""
@@ -135,6 +162,30 @@ class DeleteFloatingIP(common.NetworkAndComputeDelete):
client.floating_ips.delete(obj.id)
+class DeleteIPFloating(DeleteFloatingIP):
+ """Delete floating IP(s)"""
+
+ # TODO(tangchen): Remove this class and ``ip floating delete`` command
+ # two cycles after Mitaka.
+
+ # This notifies cliff to not display the help for this command
+ deprecated = True
+
+ log = logging.getLogger('deprecated')
+
+ def take_action_network(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip delete" instead.'))
+ return super(DeleteIPFloating, self).take_action_network(
+ client, parsed_args)
+
+ def take_action_compute(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip delete" instead.'))
+ return super(DeleteIPFloating, self).take_action_compute(
+ client, parsed_args)
+
+
class ListFloatingIP(common.NetworkAndComputeLister):
"""List floating IP(s)"""
@@ -186,8 +237,32 @@ class ListFloatingIP(common.NetworkAndComputeLister):
) for s in data))
+class ListIPFloating(ListFloatingIP):
+ """List floating IP(s)"""
+
+ # TODO(tangchen): Remove this class and ``ip floating list`` command
+ # two cycles after Mitaka.
+
+ # This notifies cliff to not display the help for this command
+ deprecated = True
+
+ log = logging.getLogger('deprecated')
+
+ def take_action_network(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip list" instead.'))
+ return super(ListIPFloating, self).take_action_network(
+ client, parsed_args)
+
+ def take_action_compute(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip list" instead.'))
+ return super(ListIPFloating, self).take_action_compute(
+ client, parsed_args)
+
+
class ShowFloatingIP(common.NetworkAndComputeShowOne):
- """Show floating IP details"""
+ """Display floating IP details"""
def update_parser_common(self, parser):
parser.add_argument(
@@ -211,3 +286,27 @@ class ShowFloatingIP(common.NetworkAndComputeShowOne):
columns = _get_columns(obj._info)
data = utils.get_dict_properties(obj._info, columns)
return (columns, data)
+
+
+class ShowIPFloating(ShowFloatingIP):
+ """Display floating IP details"""
+
+ # TODO(tangchen): Remove this class and ``ip floating show`` command
+ # two cycles after Mitaka.
+
+ # This notifies cliff to not display the help for this command
+ deprecated = True
+
+ log = logging.getLogger('deprecated')
+
+ def take_action_network(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip show" instead.'))
+ return super(ShowIPFloating, self).take_action_network(
+ client, parsed_args)
+
+ def take_action_compute(self, client, parsed_args):
+ self.log.warning(_('This command has been deprecated. '
+ 'Please use "floating ip show" instead.'))
+ return super(ShowIPFloating, self).take_action_compute(
+ client, parsed_args)