This adds support for the recommended CLI using the OpenStackClient,
without modifying the existing Blazar shell CLI.
The existing shell command classes are used, by introducing a check in
the base comand class to use either the client passed by Blazar shell,
or the client using the osc_lib client_manager.
The argument --physical-reservation is also removed for the create lease
command when using the OpenStack client.
Implements: blueprint openstackclient-support
Change-Id: I97a7b91f0d05efc887307ac167e5c368276d4f81
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: I692abac2bf1fe118c27af043e71f315c8354c8a0
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The seal function was introduced in unittest.mock in Python 3.7. It is
preventing us from using unittest.mock instead of mock.
We can restore it when the minimum runtime is Python 3.7 or later.
Change-Id: Ieb26af07da0c4084fb8c4ea2c4d461eb5595f583
pep8 job is failing because the version of flake8
(flake8<2.7.0,>=2.6.0) requested by hacking<1.2.0 is not
compatible with pyflakes>=2.1.1. Therefore the patch increases
the max version of hacking.
Also the patch fixes a few pep8 errors.
Change-Id: Ib9f1cb5a77947cfb1ab28a7f26e97edba007466c
Currently Blazar has hard-coded support for only two login methods:
'token' and 'password'. There are many more auth mechanisms supported by
Keystone and the clients. The complexity of parsing arguments and
constructing an auth/session entity is taken care of in the
keystoneauth1.loading module, which this commit takes advantage of.
Change-Id: I7173d1880c8938ac54a0fb3495417f5ce40db4e7
Some of the tests rely on a hard-coded date being actually in the past
when the test runs. This fixes that by fixing the value of utctime when
the test executes to a date in the past relative to the test input.
Change-Id: Iccb57dca5c1130a0e6ca88e9ca387fc218891369
The test_args2body_start_now unit test started failing because the end
date was set to August 9, 2020 which is now in the past.
Change-Id: I8cc4f4ec7bf2af5bdfef37253801fd4c970b7977
Blazar APIs support directly fetching a resource (whether host, floating
ip, or lease) with its ID. However, the default logic for this includes
a block that supports additionally looking up the resource by name (to
allow looking up e.g., a lease by it's name.) This requires fetching the
entire list of all resources and iterating over them until a match is
found, which is very inefficient. Moreover, this branch would be taken
even if the input was already a UUID.
This commit changes that behavior so that if a UUID is provided, it is
used to directly fetch the resource, which seems to be what the original
intent was in the first place.
Change-Id: I5b1ccf4abfe4aa9068bc011764cac4b3507ef697
The lease-update command needs to know about all possible keys that can
be passed as reservation parameters. Also treat required_floatingips as
a list, like in commit 9183950833.
Change-Id: Iad95ebf662fb052000f05aa3d76f76308704fd1d
Related-Bug: #1843258
An API request to create a floating IP reservation is expected to pass
the required_floatingips parameter as a list, not as a string. Modify
the CLI to parse required_floatingips as a JSON array so it can be
passed to the API in the right format.
Change-Id: Ia84ceb881f0889266c8f0349a1ffb047597bac2d
Closes-Bug: #1843258
The network_id parameter was not defined in CREATE_RESERVATION_KEYS. As
a result, it could not be parsed by the command-line client.
Change-Id: Icad6533ea32967601cf8d3bd4ccee659bb0b5abd
Closes-Bug: #1840759
The resource variable, originally containing the resource type, i.e.
'lease', was reassigned with a lease object before being used in the
exception message. As a result, the message displayed a dictionary of
lease values, instead of "type 'lease'".
Change-Id: If4cb03cfb4a895c11e3952f0f1b79e0c7d14de8c
Closes-Bug: #1786030
When the Blazar CLI client is run without specifying a start date, it
uses the current time on the client machine. If the lease creation
request is sent to the Blazar service just before the end of a minute,
e.g. at 12:34:59, the Blazar manager might only process it during the
next minute (i.e. after 12:35:00). In this case, the manager will reject
the request with:
Start date must be later than current date
This can also be an issue if the clocks on the client and server are not
synchronized closely.
This patch uses the special start date value 'now' which is resolved to
the current time on the server rather than on the client. Note that this
can result in leases that are one minute shorter than what the user
might expect, as the end date is still specified by the client.
It also clarifies help messages for start and end dates.
Change-Id: Ib761d8f4f15e44e28452497f282447472f0cf918
Closes-Bug: #1783296
Exceptions from the API were not properly caught when it uses
keystone session client path. As a result, error messages in the
response body from blazar REST APIs were not displayed.
This patch fixes it creating the new SessionClient class, which
is basically the same as its parent class, but it can raise
BlazarClientException if requests to the blazar server failed.
Change-Id: I98ba3949742f2a987beb7e16400608b8ebb60065
Closes-Bug: #1777548
The region name value provided via an environment variable or a command
line argument was not passed to the client object, meaning that the
wrong endpoint could be selected in a multi-region cloud.
Change-Id: Ia8bbec7e429d5a2385b7f38310512a93fbfb9ce1
The Blazar CLI doesn't support show, update and delete host operations
with hostname. It only accepts id because host uses a key called
hypervisor_hostname, rather one called name like for leases.
This patch enables the Blazar CLI to support hostname as well.
Change-Id: I3a7a3307099ed518d89de37039f9366770a21ce2
Closes-Bug: #1702266
This patch adds instance reservation update support to the Blazar
command-line client.
Change-Id: I2a5ab7f6d05c0351930f69d894005329ed637dd7
Depends-On: Ibdf7a730ae45ff6d8c17de62b0fc69262df2db79
As mentioned in [1], we should avoid using six.iteritems() to achieve
iterators. We can use dict.items() instead, as it will return iterators
in Python 3 as well, and it is more readable.
In Python 2, the overhead of dict.items() creating a new list should be
negligible for most use cases in OpenStack [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Change-Id: I620c9cc201c62f033a5467aa52625b56e19933cb
After merged the patch I08c8b753972c27b4e6bbe07a8aa51e0e72fbc56d,
blazarclient can't be used with blazar_url and auth_token since this
patch only allows sessions for the initiation of client.
For backward compatibility, blazarclient should be initiated with
blazar_url and auth_token as before.
This patch enables using blazarclient with a set of blazar_url and
auth_token or session by reviving BaseClientManager class with adding
a logic to chose an auth method based on given params.
Change-Id: I25a665145b0503cc04e49bc85c39e2f6dca36925
Closes-Bug: #1724757
For authentication, the community recommends the use of keystoneauth1
instead of python-keystoneclient. Therefore, Blazar should follow
this trend and migrate to keystoneauth1.
This patch enables blazarclient to use keystoneauth1 for authentications
and REST API requests and also enables use of project_id, project_name,
project_domain_id, project_domain_name, user_domain_id and user_domain_name
for authentication.
Change-Id: I08c8b753972c27b4e6bbe07a8aa51e0e72fbc56d
Closes-Bug: #1661215
This patch stops using oslo_utils.timeutils.strtime(), as it was
deprecated in version 1.6 and will be removed in a future version.
Change-Id: I6690420c8ce001ed12f47f78e657b4ad26bec816
The mockpatch module of oslotest is deprecated since version 1.13
and may be removed in version 2.0. Use fixtures.Mock* classes instead.
Change-Id: I0ea834d41664efe84aa28ef2362467e2ad8b1928
This patch adds a before_end_date option to the lease-create command. It
also adds a before_end parameter to the physical_reservation option.
Partially Implements: blueprint on-end-options
Depends-On: I90fb90d9d53814791d863f4ce5dab28388d3688d
Change-Id: I2a6f3477509f5b549edbdc25cb2c6ac457c7c100
python-blazarclient does not accept multiple properties when
creating leases. This is because of the wrong regular expression
used for separating given options.
This patch fixs the regular expression and enables the use of
multiple properties in python-blazarclient.
Change-Id: I35dc3cd213e70890abe20c6f17cd4fb90fcb3ea9
Closes-Bug: #1699679
Commit b2fa6bf534 [1] was accessing the
wrong variable, resulting in failures to create leases from the CLI with
the --physical-reservation option.
This patch fixes the error.
[1] https://review.openstack.org/#/c/489033/
Change-Id: I58e753ed1af0d80e5b5e1f9429f2dfea2d14ec07
Closes-Bug: #1708963
In Python 3, all strings are unicode and the unicode() function has been
removed. For compatibility with both Python 2 and 3, use six.text_type()
instead.
Partially implements: blueprint python-3
Change-Id: I0934e546d0309ddc986fd48b0f13fa5631813dc8
python-blazarclient sends all request parameters in the request body as
strings even though the blazar service only accepts integer values for
some parameters.
For instance, the instance reservation feature accepts an integer for
the 'vcpus' parameter, but the blazar client sends a string value for
the parameter with the --reservation vcpus=1 option.
This patch enables the --reservation option to convert integer style
parameters to integer values.
Closes-Bug: #1707552
Change-Id: Ife1124e14adc0183fe5d4680031bc00ca3647ed5