summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-04 13:05:30 +0000
committerGerrit Code Review <review@openstack.org>2016-06-04 13:05:30 +0000
commit55a7ba890d9c3a53b7728efe41053b79ba1e60d3 (patch)
tree2c093d1e78fee714a3cf3e57f9ccbf91ad3cec04
parent416792f079e7d15d8747736ee792d1f5c30aa389 (diff)
parent6f2c1734e3d66e261f231711455821321c1fc254 (diff)
downloadpython-openstackclient-55a7ba890d9c3a53b7728efe41053b79ba1e60d3.tar.gz
Merge "Fix --enable options on commands"
-rw-r--r--doc/source/command-beta.rst12
-rw-r--r--doc/source/command-objects/network-segment.rst4
-rw-r--r--doc/source/man/openstack.rst6
-rw-r--r--functional/tests/network/v2/test_network_segment.py6
-rw-r--r--openstackclient/common/command.py10
-rw-r--r--openstackclient/network/v2/network_segment.py17
-rw-r--r--openstackclient/shell.py2
-rw-r--r--openstackclient/tests/common/test_command.py15
-rw-r--r--openstackclient/tests/fakes.py2
-rw-r--r--openstackclient/tests/network/v2/test_network_segment.py6
-rw-r--r--releasenotes/notes/bp-routed-networks-3eea4978c93aa126.yaml2
-rw-r--r--releasenotes/notes/bug-1588384-eb6976fcfb90cb4c.yaml7
12 files changed, 54 insertions, 35 deletions
diff --git a/doc/source/command-beta.rst b/doc/source/command-beta.rst
index 53a44204..f0a4f851 100644
--- a/doc/source/command-beta.rst
+++ b/doc/source/command-beta.rst
@@ -33,7 +33,7 @@ example list
List examples
.. caution:: This is a beta command and subject to change.
- Use global option ``--enable-beta-commands`` to
+ Use global option ``--os-beta-command`` to
enable this command.
.. program:: example list
@@ -52,7 +52,7 @@ The command help must label the command as a beta.
"""Display example details
(Caution: This is a beta command and subject to change.
- Use global option --enable-beta-commands to enable
+ Use global option --os-beta-command to enable
this command)
"""
@@ -60,13 +60,9 @@ Implementation
--------------
The command must raise a ``CommandError`` exception if beta commands
-are not enabled via ``--enable-beta-commands`` global option.
+are not enabled via ``--os-beta-command`` global option.
.. code-block:: python
def take_action(self, parsed_args):
- if not self.app.options.enable_beta_commands:
- msg = _('Caution: This is a beta command and subject to '
- 'change. Use global option --enable-beta-commands '
- 'to enable this command.')
- raise exceptions.CommandError(msg)
+ self.validate_os_beta_command_enabled()
diff --git a/doc/source/command-objects/network-segment.rst b/doc/source/command-objects/network-segment.rst
index 8e177d6a..56a11e1e 100644
--- a/doc/source/command-objects/network-segment.rst
+++ b/doc/source/command-objects/network-segment.rst
@@ -15,7 +15,7 @@ network segment list
List network segments
.. caution:: This is a beta command and subject to change.
- Use global option ``--enable-beta-commands`` to
+ Use global option ``--os-beta-command`` to
enable this command.
.. program:: network segment list
@@ -39,7 +39,7 @@ network segment show
Display network segment details
.. caution:: This is a beta command and subject to change.
- Use global option ``--enable-beta-commands`` to
+ Use global option ``--os-beta-command`` to
enable this command.
.. program:: network segment show
diff --git a/doc/source/man/openstack.rst b/doc/source/man/openstack.rst
index e14f1f95..7af380a3 100644
--- a/doc/source/man/openstack.rst
+++ b/doc/source/man/openstack.rst
@@ -132,6 +132,9 @@ OPTIONS
This key should be the value of one of the HMAC keys defined in the
configuration files of OpenStack services to be traced.
+:option:`--os-beta-command`
+ Enable beta commands which are subject to change
+
:option:`--log-file` <LOGFILE>
Specify a file to log output. Disabled by default.
@@ -144,9 +147,6 @@ OPTIONS
:option:`--debug`
Show tracebacks on errors and set verbosity to debug
-:option:`--enable-beta-commands`
- Enable beta commands which are subject to change
-
COMMANDS
========
diff --git a/functional/tests/network/v2/test_network_segment.py b/functional/tests/network/v2/test_network_segment.py
index a9980938..b5b5dcd9 100644
--- a/functional/tests/network/v2/test_network_segment.py
+++ b/functional/tests/network/v2/test_network_segment.py
@@ -34,7 +34,7 @@ class NetworkSegmentTests(test.TestCase):
# Get the segment for the network.
opts = cls.get_show_opts(['ID', 'Network'])
- raw_output = cls.openstack('--enable-beta-commands '
+ raw_output = cls.openstack('--os-beta-command '
'network segment list '
' --network ' + cls.NETWORK_NAME +
' ' + opts)
@@ -48,13 +48,13 @@ class NetworkSegmentTests(test.TestCase):
def test_network_segment_list(self):
opts = self.get_list_opts(['ID'])
- raw_output = self.openstack('--enable-beta-commands '
+ raw_output = self.openstack('--os-beta-command '
'network segment list' + opts)
self.assertIn(self.NETWORK_SEGMENT_ID, raw_output)
def test_network_segment_show(self):
opts = self.get_show_opts(['network_id'])
- raw_output = self.openstack('--enable-beta-commands '
+ raw_output = self.openstack('--os-beta-command '
'network segment show ' +
self.NETWORK_SEGMENT_ID + opts)
self.assertEqual(self.NETWORK_ID + "\n", raw_output)
diff --git a/openstackclient/common/command.py b/openstackclient/common/command.py
index fee4559e..144a0db1 100644
--- a/openstackclient/common/command.py
+++ b/openstackclient/common/command.py
@@ -20,6 +20,9 @@ from cliff import lister
from cliff import show
import six
+from openstackclient.common import exceptions
+from openstackclient.i18n import _
+
class CommandMeta(abc.ABCMeta):
@@ -37,6 +40,13 @@ class Command(command.Command):
self.log.debug('run(%s)', parsed_args)
return super(Command, self).run(parsed_args)
+ def validate_os_beta_command_enabled(self):
+ if not self.app.options.os_beta_command:
+ msg = _('Caution: This is a beta command and subject to '
+ 'change. Use global option --os-beta-command '
+ 'to enable this command.')
+ raise exceptions.CommandError(msg)
+
class Lister(Command, lister.Lister):
pass
diff --git a/openstackclient/network/v2/network_segment.py b/openstackclient/network/v2/network_segment.py
index d8a91fd2..818ffc02 100644
--- a/openstackclient/network/v2/network_segment.py
+++ b/openstackclient/network/v2/network_segment.py
@@ -16,7 +16,6 @@
# TODO(rtheis): Add description and name properties when support is available.
from openstackclient.common import command
-from openstackclient.common import exceptions
from openstackclient.common import utils
from openstackclient.i18n import _
@@ -25,7 +24,7 @@ class ListNetworkSegment(command.Lister):
"""List network segments
(Caution: This is a beta command and subject to change.
- Use global option --enable-beta-commands to enable
+ Use global option --os-beta-command to enable
this command)
"""
@@ -46,11 +45,7 @@ class ListNetworkSegment(command.Lister):
return parser
def take_action(self, parsed_args):
- if not self.app.options.enable_beta_commands:
- msg = _('Caution: This is a beta command and subject to '
- 'change. Use global option --enable-beta-commands '
- 'to enable this command.')
- raise exceptions.CommandError(msg)
+ self.validate_os_beta_command_enabled()
network_client = self.app.client_manager.network
@@ -94,7 +89,7 @@ class ShowNetworkSegment(command.ShowOne):
"""Display network segment details
(Caution: This is a beta command and subject to change.
- Use global option --enable-beta-commands to enable
+ Use global option --os-beta-command to enable
this command)
"""
@@ -108,11 +103,7 @@ class ShowNetworkSegment(command.ShowOne):
return parser
def take_action(self, parsed_args):
- if not self.app.options.enable_beta_commands:
- msg = _('Caution: This is a beta command and subject to '
- 'change. Use global option --enable-beta-commands '
- 'to enable this command.')
- raise exceptions.CommandError(msg)
+ self.validate_os_beta_command_enabled()
client = self.app.client_manager.network
obj = client.find_segment(
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index 9968d73f..9179ad01 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -251,7 +251,7 @@ class OpenStackShell(app.App):
help="Print API call timing info",
)
parser.add_argument(
- '--enable-beta-commands',
+ '--os-beta-command',
action='store_true',
help="Enable beta commands which are subject to change",
)
diff --git a/openstackclient/tests/common/test_command.py b/openstackclient/tests/common/test_command.py
index 7467d9eb..722a4c06 100644
--- a/openstackclient/tests/common/test_command.py
+++ b/openstackclient/tests/common/test_command.py
@@ -15,6 +15,8 @@
import mock
from openstackclient.common import command
+from openstackclient.common import exceptions
+from openstackclient.tests import fakes as test_fakes
from openstackclient.tests import utils as test_utils
@@ -31,3 +33,16 @@ class TestCommand(test_utils.TestCase):
self.assertTrue(hasattr(cmd, 'log'))
self.assertEqual('openstackclient.tests.common.test_command.'
'FakeCommand', cmd.log.name)
+
+ def test_validate_os_beta_command_enabled(self):
+ cmd = FakeCommand(mock.Mock(), mock.Mock())
+ cmd.app = mock.Mock()
+ cmd.app.options = test_fakes.FakeOptions()
+
+ # No exception is raised when enabled.
+ cmd.app.options.os_beta_command = True
+ cmd.validate_os_beta_command_enabled()
+
+ cmd.app.options.os_beta_command = False
+ self.assertRaises(exceptions.CommandError,
+ cmd.validate_os_beta_command_enabled)
diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py
index 7fb1daa9..ad4705a4 100644
--- a/openstackclient/tests/fakes.py
+++ b/openstackclient/tests/fakes.py
@@ -99,7 +99,7 @@ class FakeApp(object):
class FakeOptions(object):
def __init__(self, **kwargs):
- self.enable_beta_commands = False
+ self.os_beta_command = False
class FakeClient(object):
diff --git a/openstackclient/tests/network/v2/test_network_segment.py b/openstackclient/tests/network/v2/test_network_segment.py
index 2822581c..0a99eced 100644
--- a/openstackclient/tests/network/v2/test_network_segment.py
+++ b/openstackclient/tests/network/v2/test_network_segment.py
@@ -25,7 +25,7 @@ class TestNetworkSegment(network_fakes.TestNetworkV2):
super(TestNetworkSegment, self).setUp()
# Enable beta commands.
- self.app.options.enable_beta_commands = True
+ self.app.options.os_beta_command = True
# Get a shortcut to the network client
self.network = self.app.client_manager.network
@@ -89,7 +89,7 @@ class TestListNetworkSegment(TestNetworkSegment):
self.assertEqual(self.data, list(data))
def test_list_no_beta_commands(self):
- self.app.options.enable_beta_commands = False
+ self.app.options.os_beta_command = False
parsed_args = self.check_parser(self.cmd, [], [])
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
parsed_args)
@@ -174,7 +174,7 @@ class TestShowNetworkSegment(TestNetworkSegment):
verifylist = [
('network_segment', self._network_segment.id),
]
- self.app.options.enable_beta_commands = False
+ self.app.options.os_beta_command = False
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
parsed_args)
diff --git a/releasenotes/notes/bp-routed-networks-3eea4978c93aa126.yaml b/releasenotes/notes/bp-routed-networks-3eea4978c93aa126.yaml
index 82080f7e..30661e6d 100644
--- a/releasenotes/notes/bp-routed-networks-3eea4978c93aa126.yaml
+++ b/releasenotes/notes/bp-routed-networks-3eea4978c93aa126.yaml
@@ -3,5 +3,5 @@ features:
- Add support for the ``network segment`` command object via the
``network segment list`` and ``network segment show`` commands.
These are beta commands and subject to change. Use global option
- ``--enable-beta-commands`` to enable these commands.
+ ``--os-beta-command`` to enable these commands.
[Blueprint `routed-networks <https://blueprints.launchpad.net/neutron/+spec/routed-networks>`_]
diff --git a/releasenotes/notes/bug-1588384-eb6976fcfb90cb4c.yaml b/releasenotes/notes/bug-1588384-eb6976fcfb90cb4c.yaml
new file mode 100644
index 00000000..797d6732
--- /dev/null
+++ b/releasenotes/notes/bug-1588384-eb6976fcfb90cb4c.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+ - Fix the ``--enable`` option on all commands by changing the
+ ``--enable-beta-commands`` global option to ``--os-beta-command``.
+ There are no upgrade impacts for the global option rename since
+ the old name isn't used.
+ [Bug `1588384 <https://bugs.launchpad.net/python-openstackclient/+bug/1588384>`_]