17 Commits

Author SHA1 Message Date
Cyril Roelandt
79d1f1c4f1 Python3.11: fix unit test crashes
In Python3.11, global flags must be placed right at the start of a
regular expression.

The following regex:

	'.*?(?m)^List NAS shares with filters.'

muts become:

	'(?m).*?^List NAS shares with filters.'

However, since we are using re.MULTILINE, we actually do not need to use
a global flag.

Closes-Bug: #1982946
Change-Id: Ia4367ba5dbb73373986fee4d7662c12a60499b12
2022-07-27 14:53:16 +02:00
Stephen Finucane
1562ec6fb1 Remove six
This is no longer needed in a Python 3-only world.

Change-Id: I84231b7e8d952b562870838a2fa4ef0d86179183
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-07-13 19:12:27 +01:00
Goutham Pacha Ravi
2d4df937d5 Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since python-manilaclient
no longer supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

Also fix some issues with imports that
weren't following our import conventions
of grouping imports [3]

[1] https://docs.python.org/3/library/unittest.mock.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html
[3] https://docs.openstack.org/hacking/latest/user/hacking.html#imports

Change-Id: I3e199e1a117ddf7739fce8858694a801a26ed08f
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-06-22 17:26:26 -07:00
junboli
b0b08cc650 allow '--help' to print subcomands info
Currently, we only allow $manila help subcomand to print
subcomands info, if we are using $manila subcomand --help,
it will print all the subcomands info, that is not what we
want, this change is to allow '--help' to print subcomands
info. finally we can see the following comands are equals:

$ manila --help list
$ manila list --help
$ manila help list

Change-Id: I926defd6c5d3b8d87b038e2c63db694b40a88359
Close-bug: #1771097
2018-05-23 10:33:49 +08:00
junboli
caf07cabf3 Fix manila endpoint in catalog not find error
This issue occurs when we list share without add manilav1 endpoint,
there will be "could not find Manila endpoint in catalog".

Since manilav1 has been deprecated for a couple of releases, so there
is no need to add manilav1 endpoint when using manila v2 API.

This change is to fix it without add manilav1 endpoint, we can also
perform manila command with manilav2 endpoint when using manila v2
API.

Change-Id: I68b499e153e1aba3a5a285f07d71e31b6af65bca
Closes-Bug: #1558995
Closes-Bug: #1734016
2018-02-26 10:33:08 +08:00
Kudyukin Dmitry
b9f897ec70 Fix for use endpoint_type in _discover_client method
In _discover_client method endpoint_type gets DEFAULT_MANILA_ENDPOINT_TYPE
rather getting endpoint type from shell. In case
DEFAULT_MANILA_ENDPOINT_TYPE unavaliable client fails.

Co-Authored-By: Thomas Bechtold <tbechtold@suse.com>
Closes-Bug: #1620491

Change-Id: I132fa448994b2f42e7fd8873425f81c88dbde8ee
2017-10-09 16:46:03 +02:00
ChangBo Guo(gcb)
c8bb1a2755 Remove copy of incubated Oslo code
The Oslo team has moved all previously incubated code from the
openstack/oslo-incubator repository into separate library repositories
and released those libraries to the Python Package Index. Many of our
big tent project teams are still using the old, unsupported, incubated
versions of the code. The Oslo team has been working to remove that
incubated code from projects, and the time has come to finish that work.

As one of community-wide goals in Ocata, please see:
https://github.com/openstack/governance/blob/master/goals/ocata/remove-incubated-oslo-code.rst

Note: This commit also fix pep8 violations.
Change-Id: I03288adb94c702d1d63df88ef9ba33a2ff59eaa3
2016-09-28 10:06:45 +08:00
Marc Koderer
f387243e36 Add validation for token and bypass_url
Specifying only token or only bypass_url leads to a client error.
Better to have a corresponding sanity check on shell level to
include the needed parameters/env variables.

Change-Id: I55dac599d4dadc273eacab14746bf449d3495f2b
Closes-bug: #1604820
2016-08-12 15:48:47 +02:00
Marc Koderer
65996e210f Use consistent env variable naming
Old env variables are still supported but the default ones should
consistently use OS_ as prefix.

Change-Id: Idd26a587cade7f6a27115c4e8cf220cd43b1703e
Closes-bug: #1603387
2016-07-18 09:54:12 +02:00
Jenkins
cdbbba7019 Merge "Fix "single_alias" action for CLI commands" 2016-05-27 14:27:51 +00:00
Valeriy Ponomaryov
5a3ef94c5b Add possibility to provide auth token via CLI
Python part of Manilaclient does support auth by token, but
CLI part does not. Therefore, add two new optional args
with related env vars:
--os-token [OS_TOKEN]
--bypass-url [MANILACLIENT_BYPASS_URL]

Also, disable checks for other auth data if these two are provided.

Change-Id: I567294dfb61e702410c3f0fadc15a04667075434
Closes-Bug: #1572095
2016-05-16 20:02:06 +03:00
Valeriy Ponomaryov
ea5c3e7b28 Fix "single_alias" action for CLI commands
For the moment if default value for CLI option with
"single_alias" action is different than None we cannot redefine it.
Fix it and cover with unit tests.

Also, fix existing aliases and add some where good to have.

Change-Id: Ic61426d9bd894b01f9b035d6d19bb7bd113f96ad
Closes-Bug: #1552771
2016-05-16 13:24:37 +03:00
John Spray
6bad71c9e6 Add 'cephx' authentication type
This duplicates the validation that is
done server side, as is the case for
the existing auth types. This auth type
is supported for cephfs protocol.

Also a unit test that was unnecessarily
testing a helper text was removed.

Co-Authored-By: Ramana Raja <rraja@redhat.com>

Change-Id: If33e6d847d3c1e6a72ce334b645b45538576058d
2016-03-04 01:05:14 +05:30
cFouts
c34e3b7d2c Nova Style API Version Support for Client
The Manila client needs the following changes to support microversions:

*   Maintain backwards compatibility with Kilo. When the client detects
    that the server doesn't support microversions it will fall back to
    using the v1 API.
*   The --os-share-api-version option supports overriding the version.
*   If 1.0 is specified as the version the client will load the v1
    client and use the server's v1 API.
*   The client will send a request for the server's API version and
    determine if the client's supported versions and the server's
    supported versions overlap. If not the client will display an error
    and quit. See diagram 1 below.
*   The client supports the @wraps annotation. The annotation is used
    with the v2/shell.py commands and any class that inherits from
    the Manager class in manilaclient/base.py.
*   If an appropriate command version isn't found for commands using
    @wraps then the client will display an error and quit.

following commit: ab49d645befd04c84272f0d24e1b604012d191dd.

Diagram 1:
  Client:
         2.5           2.8
          |-------------|

  Server1:
     2.0           2.5
      |-------------|
     Client uses version 2.5

  Server2:
               2.7           2.10
                |-------------|
               Client uses version 2.8

  Server3:
                  2.9           2.12
                   |-------------|
                  Client displays error and quits

  Server4:
     1.0 (Kilo Server)
      |-|
     Client detects pre-microversion server and loads v1 client

Example usage of wraps annotation:
*   Support 2.0 - 2.4: @api_versions.wraps("2.0", "2.4")
*   Support 2.5 - latest: @api_versions.wraps("2.5")

Implements: blueprint manila-client-advanced-microversion-support

Change-Id: I3733fe85424e39566addc070d42609e508259f19
2015-11-16 19:03:55 +00:00
Valeriy Ponomaryov
997cc43433 Add Keystone v3 API support
Keystone is used for authentication in Manila and the latter's
client does not support latest version of it that exists for long time.

So, add support of Keystone v3 API and make Manila client to use it
at first priority if it is available.

Change-Id: I3e2f505f46f7ab60c66bcb0b1d65a38bea602df4
Closes-Bug: #1499260
2015-10-13 21:12:55 +03:00
Sun Jun
faaa07a722 Add hint for HDFS protocol while creating shares
Add hint for creating shares with HDFS protocol, Since HDFS
native protocol driver has been merged.

Change-Id: Ic8724b585d1bf0ee1f2b7f8eaa0ed79927b1a292
2015-02-14 10:53:13 +08:00
vponomaryov
745adb323f Move tests into manilaclient package
tests/__init__.py implies a package in the global namespace called tests.
That's not what these are, they are tests in the manilaclient namespace.

Also moved unit tests to dir 'unit', it is done so because 'functional' tests
are expected to be added.

Change-Id: I801214b865e9cef8db7511f209dcf3c26b75d70f
2014-10-20 15:41:18 +03:00