Deprecate -l option for port creation in OSC plugin
The openstack client guideline says that options should be full english words. Closes-bug: #1610316 Change-Id: Ie000564ed1ad82a7cdbf064fb9c951038457a8c4
This commit is contained in:
@@ -48,12 +48,23 @@ class CreateBaremetalPort(show.ShowOne):
|
||||
help="Record arbitrary key/value metadata. "
|
||||
"Can be specified multiple times.")
|
||||
parser.add_argument(
|
||||
'-l', '--local-link-connection',
|
||||
'--local-link-connection',
|
||||
metavar="<key=value>",
|
||||
action='append',
|
||||
help="Key/value metadata describing Local link connection "
|
||||
"information. Valid keys are switch_info, switch_id, "
|
||||
"port_id. Can be specified multiple times.")
|
||||
"port_id; switch_id and port_id are obligatory. Can be "
|
||||
"specified multiple times.")
|
||||
parser.add_argument(
|
||||
'-l',
|
||||
dest='local_link_connection_deprecated',
|
||||
metavar="<key=value>",
|
||||
action='append',
|
||||
help="DEPRECATED. Please use --local-link-connection instead. "
|
||||
"Key/value metadata describing Local link connection "
|
||||
"information. Valid keys are switch_info, switch_id, "
|
||||
"port_id; switch_id and port_id are obligatory. Can be "
|
||||
"specified multiple times.")
|
||||
parser.add_argument(
|
||||
'--pxe-enabled',
|
||||
metavar='<boolean>',
|
||||
@@ -66,6 +77,18 @@ class CreateBaremetalPort(show.ShowOne):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
baremetal_client = self.app.client_manager.baremetal
|
||||
|
||||
if parsed_args.local_link_connection_deprecated:
|
||||
self.log.warning("Please use --local-link-connection instead of "
|
||||
"-l, as it is deprecated and will be removed in "
|
||||
"future releases.")
|
||||
# It is parsed to either None, or to an array
|
||||
if parsed_args.local_link_connection:
|
||||
parsed_args.local_link_connection.extend(
|
||||
parsed_args.local_link_connection_deprecated)
|
||||
else:
|
||||
parsed_args.local_link_connection = (
|
||||
parsed_args.local_link_connection_deprecated)
|
||||
|
||||
field_list = ['address', 'extra', 'node_uuid', 'pxe_enabled',
|
||||
'local_link_connection']
|
||||
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
import mock
|
||||
from openstackclient.tests import utils as oscutils
|
||||
|
||||
from ironicclient.osc.v1 import baremetal_port
|
||||
@@ -69,6 +70,56 @@ class TestCreateBaremetalPort(TestBaremetalPort):
|
||||
|
||||
self.baremetal_mock.port.create.assert_called_once_with(**args)
|
||||
|
||||
def _test_baremetal_port_create_llc_warning(self, additional_args,
|
||||
additional_verify_items):
|
||||
arglist = [
|
||||
baremetal_fakes.baremetal_port_address,
|
||||
'--node', baremetal_fakes.baremetal_uuid,
|
||||
]
|
||||
arglist.extend(additional_args)
|
||||
|
||||
verifylist = [
|
||||
('node_uuid', baremetal_fakes.baremetal_uuid),
|
||||
('address', baremetal_fakes.baremetal_port_address),
|
||||
]
|
||||
verifylist.extend(additional_verify_items)
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.log = mock.Mock()
|
||||
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
args = {
|
||||
'address': baremetal_fakes.baremetal_port_address,
|
||||
'node_uuid': baremetal_fakes.baremetal_uuid,
|
||||
'local_link_connection': {'switch_id': 'aa:bb:cc:dd:ee:ff',
|
||||
'port_id': 'eth0'}
|
||||
}
|
||||
|
||||
self.baremetal_mock.port.create.assert_called_once_with(**args)
|
||||
self.cmd.log.warning.assert_called()
|
||||
|
||||
def test_baremetal_port_create_llc_warning_some_deprecated(self):
|
||||
self._test_baremetal_port_create_llc_warning(
|
||||
additional_args=['-l', 'port_id=eth0', '--local-link-connection',
|
||||
'switch_id=aa:bb:cc:dd:ee:ff'],
|
||||
additional_verify_items=[
|
||||
('local_link_connection_deprecated', ['port_id=eth0']),
|
||||
('local_link_connection', ['switch_id=aa:bb:cc:dd:ee:ff'])]
|
||||
)
|
||||
|
||||
def test_baremetal_port_create_llc_warning_all_deprecated(self):
|
||||
self._test_baremetal_port_create_llc_warning(
|
||||
additional_args=['-l', 'port_id=eth0', '-l',
|
||||
'switch_id=aa:bb:cc:dd:ee:ff'],
|
||||
additional_verify_items=[('local_link_connection_deprecated',
|
||||
['port_id=eth0',
|
||||
'switch_id=aa:bb:cc:dd:ee:ff'])]
|
||||
)
|
||||
|
||||
|
||||
class TestShowBaremetalPort(TestBaremetalPort):
|
||||
def setUp(self):
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- Deprecated ``-l`` argument of ``openstack baremetal port create`` command
|
||||
in favor of ``--local-link-connection``, as by openstack client guidelines,
|
||||
the options should be full words.
|
||||
Reference in New Issue
Block a user