The CLI now support the following syntax both for openstack resource
providers list and allocation candidate list commands:
--required T1,T2 --required T3
and it means (T1 or T2) and T3.
In the allocation candidate list command the above can be used both
outside and in a --group context.
Story: 2005345
Story: 2005346
Depends-On: https://review.opendev.org/c/openstack/placement/+/826719
Change-Id: I38ff55bdd072f3a9c1ed03e28192d045cb4096cf
Add a guards for empty allocations in the allocation parsing code of
allocation show and allocation unset.
Closes-Bug: #1942740
Change-Id: Ic0e6e981d6602a76935f6bc6d9ffb0a707a5b1a9
This patch adds a functional test case to reproduce the bug when an
allocation show command on an empty (non existent) allocation causes
KeyError as the code expects project_id in the response but the
response is {"allocations":{}}. Also similarly for allocation unset
where microversion 1.38 fails on parsing out consumer_type from the
empty allocation too.
Related-Bug: #1942740
Change-Id: Iea27c9376480e3e94d12eec56b466331e5c6f171
This change fixes a regresssion intoduced
by the supprot for microverion auto-negotiation
which resulted in the inablity to generate
bash autocompltion.
When the client_manager does not have a api session established
such as when being invoked for auto completion this
change modifies get_version to return version.MAX_VERSION_NO_GAP
Story: #2008958
Task: #42592
Change-Id: I90e1e3caeaa22ff51df515226b3ac5c7b64c88b6
There were tests to verify that 'resource provider inventory set'
command with --dry-run and --aggregate option changes nothing on
the server side but there was no test to verify the result of that
command. This patch adds the test.
Change-Id: I8d2c25a654928d8d46d5e1d0ee203600c9a72600
The ``openstack resource provider allocation unset`` command now
supports ``--resource-class`` option, which accepts string of a
resource class. This will remove allocations for the given resource
class from all the providers. If ``--provider`` option is also
specified, allocations to remove will be limited to the given resource
class of the given resource provider.
example1::
# remove VGPU allocation from provider P for this consumer.
allocation unset <consumer_uuid> --provider P --resource-class VGPU
example2::
# remove VGPU allocations from all providers for this consumer.
allocation unset <consumer_uuid> --resource-class VGPU
Change-Id: I91baf9de5205ec15023706a1646556850302d3d9
Story: #2006779
Task: #37304
The placement client (osc-placement) supports the
``OS_PLACEMENT_API_VERSION`` environment variable,
but it is not described in the ``openstack -h`` command.
So this patch adds the description as well as other
environment variables.
Change-Id: I41a3718bfa27ecf370c7375b4f761cda47866b1a
The default value of ``--os-placement-api-version`` is now changed to ``1``
from ``1.0``, which by default enables negotiation with server to choose
max microversion supported both by server and client.
Change-Id: I0ad02ee5c3e57aa126bfba739738280bbf3a97d0
Story: #2005448
Task: #30497
To improve the usability for those who are not familiar with
microversion, this patch adds microversion negotiation to pick up max
microversion supported both by client and by server.
This negotiation is enabled by specifying only major api version,
``--os-placement-api-version 1``. Note that the default microversion
remains to be ``1.0`` in this patch and will be switched to the
negotiated version in the following patch.
Change-Id: I2998ff0f3941bf226a942969adf75564a8d5a065
Story: #2005448
Task: #30497
Microversion 1.37 adds support for re-parenting and un-parenting RPs.
The client supports these operations with the new microversion out of
the box. So this patch just marks the microversion as supported.
Story: 2008764
Task: 42132
Depends-On: https://review.opendev.org/c/openstack/placement/+/784020
Change-Id: I62f5a620e6639c29d4a8ed99f7e42b72f7af1a74
The ``openstack allocation candidate list`` command now supports
``--group`` and ``--group-policy`` option. The ``--group`` option is
accepts integer to group granular requests. If specified, following
given options of resources, required/forbidden traits, and aggregates
are associated to that group and will be satisfied by the same resource
provider in the response. Can be repeated to get candidates from
multiple resource providers in the same resource provider tree.
If multiple groups are supplied, the separate groups may or may not
be satisfied by the same provider. If you want the groups to be
satisfied by different providers, set ``--group_policy`` to
``isolate``.
For example:
``openstack allocation candidate list \
--group 1 --resource VCPU=3 --required HW_CPU_X86_SSE \
--group 2 --resource VCPU=4 \
--group_policy isolate``
The granular request is supported in 1.25, but this is tested via
microversion 1.29 since the API is unaware of nested provider
before that version. Note that 1.26-1.29 has no impact to client:
1.25 - Adds support for granular resource requests via numbered
querystring groups in GET /allocation_candidates.
1.26 - Add ability to specify inventory with reserved value equal
to total.
1.27 - Include all resource class inventories in `provider_summaries`
field in response of `GET /allocation_candidates` API even if
the resource class is not in the requested resources.
1.28 - Add support for consumer generation
1.29 - Support nested providers in `GET /allocation_candidates` API.
Change-Id: Ib32181abd12db0c2983065ea9846e911033d53f1
The ``openstack allocation candidate list`` and the ``openstack
allocation candidate list`` command now supports ``--member-of``
option, which accepts a list of comma-separated UUIDs of the
resource provider aggregates. If this is specified, the returned
resource providers must be associated with at least one of the
aggregates identified by uuid. This option can be repeated to
add(restrict) the condition with ``--os-placement-api-version 1.24``
or greater.
This deprecates the ``--aggregate-uuid`` option because it is
difficult to keep using this option to support multiple ``member_of``
feature added in microversion 1.24.
Change-Id: I0f3068c411c504380918f27f994734528fe55c77
Co-Autored-By: Tetsuro Nakamura <tetsuro.nakamura.bc@hco.ntt.co.jp>
Story: #2006940
Task: #37613
The Python 2.7 Support has been dropped since Ussuri.
So remove hacking rules for compatibility between python 2 and 3.
Change-Id: I5ec70dc8153dc0ab0bf0323ffb814822566da6cc
The 'resource provider inventory list' and 'resource provider inventory
show' commands describe everything about some given inventory *except*
their usage, which is a pretty important metric in quickly assessing
availability of a given resource. Instead, usage is hidden behind the
'resource provider usage show' command. There doesn't appear to be any
reason for this to the case, aside from wanting to directly map to the
placement API which shouldn't be a goal. Make these commands more
friendly by including usage information. We may want to consider
deprecating the 'resource provider usage show' command in the future,
but that's left for another day.
Change-Id: Iafedac3ff7a5ae60e6027741c44904babf64d3f1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
mock has been removed from requirements files of its deps
which used to install mock for this repo gate.
Fixing gate by moving it to unittest.mock.
Change-Id: I5e0ef2a74d03333ebd9d4be1ef7fcb040e54ed30
This repo is now testing only with Python 3, so let's make
a few cleanups:
- Remove python 2.7 stanza from setup.py
- Add requires on python >= 3.6 to setup.cfg so that pypi and pip
know about the requirement
- Remove obsolete sections from setup.cfg
- Update classifiers
- Update requirements, no need for python_version anymore
- Switch to using sphinx-build
- Use newer openstackdocstheme version
- Remove install_command from tox.ini, the default is fine
- Update to hacking 3.0, fix warnings
Change-Id: If66a87c519ce82ee7890ac3e133afef13fb35bd2
The functional test for allocation create did test that it displays
the warning message if the microversion is not high enough, but didn't
validate the returned json result.
This patch changes it to validate the actual result as well as the
warning message.
Change-Id: I8280075a020fb4a10b82b710d5e0ca997a3028fd
If server response does not have an appropriate json format,
the message was useless. For example, if placement-api is down,
we had something like this:
$ openstack resource provider delete
Expecting value: line 1 column 1 (char 0)
This was because the code assumed that the response had details in
it. That is correct for 4xx errors, but that's not the case for 5xx
errors. This patch changes it not to retrieve the details from
response on 5xx error, and just raise keystone exceptions.
Now we have something like this:
$ openstack resource provider delete
Service Unavailable (HTTP 503)
Story: #2005437
Story: #2005438
Task: #30478
Task: #30479
Change-Id: I07fa0b626b7529699179c8cd8e254fd66455c930
Co-Autored-By: Tetsuro Nakamura <tetsuro.nakamura.bc@hco.ntt.co.jp>
This adds support to the resource provider allocation set command
for microversion 1.28 which uses consumer generations to ensure
atomic updates of consumer allocations.
Change-Id: I8f85ee4ff4c39fba69a78bbe642f79a706504df8
Story: #2006912
Task: #37557
Adds the "openstack resource provider allocation unset" command which
allows removing resource provider(s) from the set of allocations for
the given consumer. This can be useful when a consumer has allocations
against more than one resource provider and
"openstack resource provider allocation delete" is undesirable as it
removes all allocations for the consumer. The new unset command requires
"--os-placement-api-version 1.12" or greater.
Note that the --provider option can be specified multiple times.
If the resulting allocations are all gone and 1.28 or greater is not
being used, a DELETE is called rather than PUT since
PUT /allocations/{consumer_id} before 1.28 does not allow an empty
"allocations" dict in the request body. In this case nothing is output
similar to the "openstack resource provider allocation delete" command.
Change-Id: I627bfd1ff699d075028da6afafbe7fb9b2f13058
Story: #2006779
Task: #37304
When using the old style of '--os-url' we didn't need to be
explicit, it deduced the right type. And python-openstackclient
>= 4.0.0 it does for --os-endpoint. But when using '--os-endpoint'
with <4.0.0 we need to state 'admin_token' explicitly.
This form works in both 3.19.x and 4.0.x.
Change-Id: Ie9c76a23658b46997dcb17ba3fb7f1e700eca506
The functional tests use an explicit endpoint and token for auth
to the placement fixture. Before openstack client 4.0.0 os-url
was a way to specify the endpoint. Now os-endpoint is the way.
Update accordingly.
Note that this doesn't impact the behavior of the plugin itself,
just the tests.
Change-Id: Id4f8f0224f61c1741e6a1a8369ec053bb1824e8a
This adds a new '--dry-run' option which gives the ability to preview
changes before effecting them.
Story: 2006318
Task: 36190
Change-Id: I24bbe9657c0b83a93f0d4c762992c16e91b4ec47
This adds a new '--amend' option which can update resource provider
inventory without requiring the user to pass a full replacement for
inventory. It does a GET for existing inventory, applies user provided
updates, and does a PUT of the updated inventory.
Story: 2006318
Task: 36049
Change-Id: I4ed1016852144377485959e65077803f5f2c672c
This adds a new '--aggregate' option which can set resource provider
inventory for all resource providers that are members of the specified
aggregate.
The main motivation for this option is to give operators a tool to
make setting overcommit allocation ratios on a per-aggregate basis
easier, after the functionality from the old
Aggregate[Core|Ram|Disk]Filter scheduler filters was removed back in
Ocata [1].
[1]
http://lists.openstack.org/pipermail/openstack-dev/2018-January/126283.html
Story: 2006318
Task: 36189
Change-Id: Ib0cbb58d0adbbcfe83ee48d2ff6c9af1a516a7ae
The 1.22 microversion of placement adds support for
excluding resource providers and allocation candidates
with specified traits. A forbidden trait may be specified
with --forbidden option.
Change-Id: I4760fe6119e29d80f63ec7bd6c4a5f2395a9291e
The change in https://review.openstack.org/#/c/652100/ has improved
the error message for the required placement api version::
Operation or argument is not supported with version 1.0
had become::
Operation or argument is not supported with version 1.0; \
requires at least version 1.1
However, this was only applied for aggregate use cases. This patch
follows it up to apply the improved error message generically to other
commands than aggregate and other version compare function than
"greater than or equal to".
Change-Id: I28226a1dbc003a8b6366e528469152c141b40593
Story: #2005448
Task: #30498
Change the functional tests to use the PlacementFixture instead
of devstack as the source of a placement API. This speeds up
the tests considerably and lowers the number of dependencies.
There are four primary changes:
* For each test a PlacementFixture is instantiated, using the
usual in-RAM db and in-process placement.
* Because of some exceedingly confusing optimizations in
osc_lib and python-openstackclient, done to improve start
up time, a session to placement was caching the service
url. This meant that after a first test succeeded, every
subsequent one would not because it was trying to talk
to a fake hostname that was no longer being intercepted.
The workaround for this was to monkeypatch the method
in the ClientCache class which provides access to a client (per
service-type). The replacement method makes a new client
every time.
* The previous tests would subprocess out to a real call of
the openstack command and then interpret the results.
Now, a run() method on OpenStackShell is called instead.
This accepts arguments in the same way, but we need to
a) capture stderr and stdout, b) make a try/except for
SystemExit to get some error responses (mostly from
the argparse lib which has a tendency to exit for you
instead of politely telling you it wants to), c) deal
with errors from commands ourself rather than using
exceptions from the subprocess module.
Switching to this form means that logging becomes in-process
and more visible. To accomodate this the Capture fixture
from placement is used. This was chosen because we are already
pulling in the PlacementFixture. If this seems icky, I can fix
it with a local one. This was the shorter path.
* The legacy dsvm jobs have been removed in favor of "standard"
functional jobs for 2.7 and 3.6 that require openstack/placement.
The playbooks associated with the legacy jobs are removed.
tox.ini is adjusted to reflect this new setup. Because tox-siblings
functional is being used, we don't want to share tox envs with the unit
tests. The 3.5 functional job is removed because we no longer target
that.
After running these for a while it became clear that there were
intermittent failures being caused by subunit attachments being too
large. This was eventually traced back to logging from all packages
being set to DEBUG even when something else was requested. That was
traced back to a poor interaction between the way that osc does
logging and the way oslo_logging does logging (used by placement and
thus the placement fixture). The workaround, embodied in the
RESET_LOGGING list in osc_placement/tests/functional/base.py, is to
get and reset the log level for a subset of the packages that are
used.
Change-Id: I7deda200b372ff6a7ba67b0c4fa0e53c4fa16ffc
Story: 2005411
Task: 30428
The aggregate set/list commands require at least version 1.1 but
if you don't specify any version we default to 1.0 and you get this
unhelpful message:
Operation or argument is not supported with version 1.0
This change adds a simple min_version kwarg to the version compare
method such that if we fail the version check and the kwarg is passed
we use it to improve the message so the user doesn't have to read
the help of the command to figure out what they did wrong, e.g.:
Operation or argument is not supported with version 1.0; \
requires at least version 1.1
This only handles the aggregate set/list commands and could be used
elsewhere but this is just a start.
Change-Id: I28a859918ab78c8aa47e54928cb14339c7c75498
Story: #2005448
Task: #30498
The "name" metavar is wrong since it is for the resource
provider UUID argument. This fixes the metavar to match
the argument.
Story: #2005446
Task: #30490
Change-Id: I1e9076a36c6cd27212bd76ee04307296fc937168