Merge "Allocation API: support allocation backfilling"
This commit is contained in:
commit
c4d60daa91
@ -44,7 +44,7 @@ from ironicclient import exc
|
||||
# http://specs.openstack.org/openstack/ironic-specs/specs/kilo/api-microversions.html # noqa
|
||||
# for full details.
|
||||
DEFAULT_VER = '1.9'
|
||||
LAST_KNOWN_API_VERSION = 56
|
||||
LAST_KNOWN_API_VERSION = 58
|
||||
LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -34,7 +34,6 @@ class CreateBaremetalAllocation(command.ShowOne):
|
||||
parser.add_argument(
|
||||
'--resource-class',
|
||||
dest='resource_class',
|
||||
required=True,
|
||||
help=_('Resource class to request.'))
|
||||
parser.add_argument(
|
||||
'--trait',
|
||||
@ -75,6 +74,11 @@ class CreateBaremetalAllocation(command.ShowOne):
|
||||
"is returned if allocation fails and --wait is used. "
|
||||
"Optionally takes a timeout value (in seconds). The "
|
||||
"default value is 0, meaning it will wait indefinitely."))
|
||||
parser.add_argument(
|
||||
'--node',
|
||||
help=_("Backfill this allocation from the provided node that has "
|
||||
"already been deployed. Bypasses the normal allocation "
|
||||
"process."))
|
||||
|
||||
return parser
|
||||
|
||||
@ -82,8 +86,12 @@ class CreateBaremetalAllocation(command.ShowOne):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
baremetal_client = self.app.client_manager.baremetal
|
||||
|
||||
if not parsed_args.node and not parsed_args.resource_class:
|
||||
raise exc.ClientException(
|
||||
_('--resource-class is required except when --node is used'))
|
||||
|
||||
field_list = ['name', 'uuid', 'extra', 'resource_class', 'traits',
|
||||
'candidate_nodes']
|
||||
'candidate_nodes', 'node']
|
||||
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
|
||||
if k in field_list and v is not None)
|
||||
|
||||
|
@ -16,6 +16,7 @@ import copy
|
||||
import mock
|
||||
from osc_lib.tests import utils as osctestutils
|
||||
|
||||
from ironicclient import exc
|
||||
from ironicclient.osc.v1 import baremetal_allocation
|
||||
from ironicclient.tests.unit.osc.v1 import fakes as baremetal_fakes
|
||||
|
||||
@ -177,9 +178,29 @@ class TestCreateBaremetalAllocation(TestBaremetalAllocation):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
||||
self.assertRaises(osctestutils.ParserException,
|
||||
self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.assertRaises(exc.ClientException,
|
||||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
def test_baremetal_allocation_backfill(self):
|
||||
arglist = [
|
||||
'--node', baremetal_fakes.baremetal_uuid,
|
||||
]
|
||||
|
||||
verifylist = [
|
||||
('node', baremetal_fakes.baremetal_uuid),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
args = {
|
||||
'node': baremetal_fakes.baremetal_uuid,
|
||||
}
|
||||
|
||||
self.baremetal_mock.allocation.create.assert_called_once_with(**args)
|
||||
|
||||
|
||||
class TestShowBaremetalAllocation(TestBaremetalAllocation):
|
||||
|
@ -30,7 +30,7 @@ class AllocationManager(base.CreateManager):
|
||||
resource_class = Allocation
|
||||
_resource_name = 'allocations'
|
||||
_creation_attributes = ['extra', 'name', 'resource_class', 'uuid',
|
||||
'traits', 'candidate_nodes']
|
||||
'traits', 'candidate_nodes', 'node']
|
||||
|
||||
def list(self, resource_class=None, state=None, node=None, limit=None,
|
||||
marker=None, sort_key=None, sort_dir=None, fields=None):
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds the ``--node`` argument to ``baremetal allocation create`` to support
|
||||
allocation backfilling.
|
Loading…
Reference in New Issue
Block a user