Remove deprecated OSC baremetal commands

Following commands were deprecated one year ago, now we remove them
from the tree:

* openstack baremetal create
* openstack baremetal delete
* openstack baremetal list
* openstack baremetal show
* openstack baremetal set
* openstack baremetal unset

Note that `openstack baremetal create` is used to create a single node
as well as create resources from file(s). Only the deprecated part
(create a single node) is removed in this patch.

Closes-Bug: #1715643
Change-Id: I0aed7cb970adf23db033c2a951026d649134caa9
This commit is contained in:
KaiFeng Wang 2017-09-07 15:39:48 +08:00
parent 36e0ff793e
commit 64a8006d65
5 changed files with 38 additions and 156 deletions

View File

@ -10,69 +10,28 @@
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import logging
from osc_lib.command import command
from ironicclient.common.i18n import _
from ironicclient import exc
from ironicclient.osc.v1 import baremetal_node
from ironicclient.v1 import create_resources
class CreateBaremetal(baremetal_node.CreateBaremetalNode):
"""Create resources from files or Register a new node (DEPRECATED).
Create resources from files (by only specifying the files) or register
a new node by specifying one or more optional arguments (DEPRECATED,
use 'openstack baremetal node create' instead).
"""
class CreateBaremetal(command.Command):
"""Create resources from files"""
log = logging.getLogger(__name__ + ".CreateBaremetal")
def get_description(self):
return _("Create resources from files (by only specifying the files) "
"or register a new node by specifying one or more optional "
"arguments (DEPRECATED, use 'openstack baremetal node "
"create' instead)")
# TODO(vdrok): Remove support for new node creation after 11-July-2017
# during the 'Queens' cycle.
def get_parser(self, prog_name):
parser = super(CreateBaremetal, self).get_parser(prog_name)
# NOTE(vdrok): It is a workaround to allow --driver to be optional for
# openstack create command while creation of nodes via this command is
# not removed completely
parser = argparse.ArgumentParser(parents=[parser],
conflict_handler='resolve',
description=self.__doc__)
parser.add_argument(
'--driver',
metavar='<driver>',
help=_('Specify this and any other optional arguments if you want '
'to create a node only. Note that this is deprecated; '
'please use "openstack baremetal node create" instead.'))
parser.add_argument(
"resource_files", metavar="<file>", default=[], nargs="*",
"resource_files", metavar="<file>", nargs="+",
help=_("File (.yaml or .json) containing descriptions of the "
"resources to create. Can be specified multiple times. If "
"you want to create resources, only specify the files. Do "
"not specify any of the optional arguments."))
"resources to create. Can be specified multiple times."))
return parser
def take_action(self, parsed_args):
if parsed_args.driver:
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node create'.")
return super(CreateBaremetal, self).take_action(parsed_args)
if not parsed_args.resource_files:
raise exc.ValidationError(_(
"If --driver is not supplied to openstack create command, "
"it is considered that it will create ironic resources from "
"one or more .json or .yaml files, but no files provided."))
create_resources.create_resources(self.app.client_manager.baremetal,
parsed_args.resource_files)
# NOTE(vdrok): CreateBaremetal is still inherited from ShowOne class,
# which requires the return value of the function to be of certain
# type, leave this workaround until creation of nodes is removed and
# then change it so that this inherits from command.Command
return tuple(), tuple()

View File

@ -470,18 +470,6 @@ class DeleteBaremetalNode(command.Command):
raise exc.ClientException("\n".join(failures))
class DeleteBaremetal(DeleteBaremetalNode):
"""Unregister a baremetal node. DEPRECATED"""
# TODO(thrash): Remove after 11-July-2017 during the 'Queens' cycle.
log = logging.getLogger(__name__ + ".DeleteBaremetal")
def take_action(self, parsed_args):
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node delete'.")
super(DeleteBaremetal, self).take_action(parsed_args)
class DeployBaremetalNode(ProvisionStateWithWait):
"""Set provision state of baremetal node to 'deploy'"""
@ -656,18 +644,6 @@ class ListBaremetalNode(command.Lister):
'Properties': oscutils.format_dict},) for s in data))
class ListBaremetal(ListBaremetalNode):
"""List baremetal nodes. DEPRECATED"""
# TODO(thrash): Remove after 11-July-2017 during the 'Queens' cycle.
log = logging.getLogger(__name__ + ".ListBaremetal")
def take_action(self, parsed_args):
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node list'.")
return super(ListBaremetal, self).take_action(parsed_args)
class MaintenanceSetBaremetalNode(command.Command):
"""Set baremetal node to maintenance mode"""
@ -1157,18 +1133,6 @@ class SetBaremetalNode(command.Command):
self.log.warning("Please specify what to set.")
class SetBaremetal(SetBaremetalNode):
"""Set baremetal properties. DEPRECATED"""
# TODO(thrash): Remove after 11-July-2017 during the 'Queens' cycle.
log = logging.getLogger(__name__ + ".SetBaremetal")
def take_action(self, parsed_args):
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node set'.")
return super(SetBaremetal, self).take_action(parsed_args)
class ShowBaremetalNode(command.ShowOne):
"""Show baremetal node details"""
@ -1223,18 +1187,6 @@ class ShowBaremetalNode(command.ShowOne):
return self.dict2columns(node)
class ShowBaremetal(ShowBaremetalNode):
"""Show baremetal node details. DEPRECATED"""
# TODO(thrash): Remove after 11-July-2017 during the 'Queens' cycle.
log = logging.getLogger(__name__ + ".ShowBaremetal")
def take_action(self, parsed_args):
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node show'.")
return super(ShowBaremetal, self).take_action(parsed_args)
class UndeployBaremetalNode(ProvisionStateWithWait):
"""Set provision state of baremetal node to 'deleted'"""
@ -1448,18 +1400,6 @@ class UnsetBaremetalNode(command.Command):
self.log.warning("Please specify what to unset.")
class UnsetBaremetal(UnsetBaremetalNode):
"""Unset baremetal properties. DEPRECATED"""
# TODO(thrash): Remove after 11-July-2017 during the 'Queens' cycle.
log = logging.getLogger(__name__ + ".UnsetBaremetal")
def take_action(self, parsed_args):
self.log.warning("This command is deprecated. Instead, use "
"'openstack baremetal node unset'.")
super(UnsetBaremetal, self).take_action(parsed_args)
class ValidateBaremetalNode(command.Lister):
"""Validate a node's driver interfaces"""

View File

@ -11,10 +11,10 @@
# under the License.
#
import copy
import mock
from ironicclient import exc
from osc_lib.tests import utils as oscutils
from ironicclient.osc.v1 import baremetal_create
from ironicclient.tests.unit.osc.v1 import fakes as baremetal_fakes
from ironicclient.v1 import create_resources
@ -25,46 +25,11 @@ class TestBaremetalCreate(baremetal_fakes.TestBaremetal):
super(TestBaremetalCreate, self).setUp()
self.cmd = baremetal_create.CreateBaremetal(self.app, None)
def test_baremetal_create_with_driver(self):
self.baremetal_mock = self.app.client_manager.baremetal
self.baremetal_mock.reset_mock()
self.baremetal_mock.node.create.return_value = (
baremetal_fakes.FakeBaremetalResource(
None,
copy.deepcopy(baremetal_fakes.BAREMETAL),
loaded=True,
))
arglist = ['--driver', 'fake_driver']
verifylist = [('driver', 'fake_driver')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
columns, data = self.cmd.take_action(parsed_args)
self.assertEqual(('chassis_uuid',
'instance_uuid',
'maintenance',
'name',
'power_state',
'provision_state',
'uuid'), columns)
self.assertEqual(
(baremetal_fakes.baremetal_chassis_uuid_empty,
baremetal_fakes.baremetal_instance_uuid,
baremetal_fakes.baremetal_maintenance,
baremetal_fakes.baremetal_name,
baremetal_fakes.baremetal_power_state,
baremetal_fakes.baremetal_provision_state,
baremetal_fakes.baremetal_uuid), tuple(data))
self.baremetal_mock.node.create.assert_called_once_with(
driver='fake_driver')
def test_baremetal_create_no_args(self):
parsed_args = self.check_parser(self.cmd, [], [])
self.assertRaises(exc.ValidationError,
self.cmd.take_action, parsed_args)
arglist = []
verifylist = []
self.assertRaises(oscutils.ParserException, self.check_parser,
self.cmd, arglist, verifylist)
@mock.patch.object(create_resources, 'create_resources', autospec=True)
def test_baremetal_create_resource_files(self, mock_create):
@ -72,7 +37,6 @@ class TestBaremetalCreate(baremetal_fakes.TestBaremetal):
verifylist = [('resource_files', ['file.yaml', 'file.json'])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.assertEqual((tuple(), tuple()), self.cmd.take_action(parsed_args))
self.cmd.take_action(parsed_args)
mock_create.assert_called_once_with(self.app.client_manager.baremetal,
['file.yaml', 'file.json'])

View File

@ -0,0 +1,24 @@
---
upgrade:
- |
The following previously deprecated commands were removed:
* ``openstack baremetal delete``
* ``openstack baremetal list``
* ``openstack baremetal show``
* ``openstack baremetal set``
* ``openstack baremetal unset``
The equivalent commands are:
* ``openstack baremetal node delete``
* ``openstack baremetal node list``
* ``openstack baremetal node show``
* ``openstack baremetal node set``
* ``openstack baremetal node unset``
The support of creating a single node by ``openstack baremetal create``
is removed, the equivalent command is ``openstack baremetal node create``.
The only valid usage of ``openstack baremetal create`` now is to create
various resources (chassis, node, port, portgroup, etc.) from resource
file(s).

View File

@ -35,14 +35,12 @@ openstack.baremetal.v1 =
baremetal_chassis_show = ironicclient.osc.v1.baremetal_chassis:ShowBaremetalChassis
baremetal_chassis_unset = ironicclient.osc.v1.baremetal_chassis:UnsetBaremetalChassis
baremetal_create = ironicclient.osc.v1.baremetal_create:CreateBaremetal
baremetal_delete = ironicclient.osc.v1.baremetal_node:DeleteBaremetal
baremetal_driver_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriver
baremetal_driver_passthru_call = ironicclient.osc.v1.baremetal_driver:PassthruCallBaremetalDriver
baremetal_driver_passthru_list = ironicclient.osc.v1.baremetal_driver:PassthruListBaremetalDriver
baremetal_driver_property_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriverProperty
baremetal_driver_raid_property_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriverRaidProperty
baremetal_driver_show = ironicclient.osc.v1.baremetal_driver:ShowBaremetalDriver
baremetal_list = ironicclient.osc.v1.baremetal_node:ListBaremetal
baremetal_node_abort = ironicclient.osc.v1.baremetal_node:AbortBaremetalNode
baremetal_node_adopt = ironicclient.osc.v1.baremetal_node:AdoptBaremetalNode
baremetal_node_boot_device_set = ironicclient.osc.v1.baremetal_node:BootdeviceSetBaremetalNode
@ -98,9 +96,6 @@ openstack.baremetal.v1 =
baremetal_volume_target_set = ironicclient.osc.v1.baremetal_volume_target:SetBaremetalVolumeTarget
baremetal_volume_target_show = ironicclient.osc.v1.baremetal_volume_target:ShowBaremetalVolumeTarget
baremetal_volume_target_unset = ironicclient.osc.v1.baremetal_volume_target:UnsetBaremetalVolumeTarget
baremetal_set = ironicclient.osc.v1.baremetal_node:SetBaremetal
baremetal_show = ironicclient.osc.v1.baremetal_node:ShowBaremetal
baremetal_unset = ironicclient.osc.v1.baremetal_node:UnsetBaremetal
[pbr]
autodoc_index_modules = True