Commit Graph

17 Commits

Author SHA1 Message Date
haixin 3831e5500f remove usage of six library from unit tests
Replace six with Python 3 style code.

Change-Id: I5077e71663f6b60bd774f30fcf64b36d4078cf8e
2021-01-28 10:47:40 +08:00
Goutham Pacha Ravi 598223985a Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since manila no longer
supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

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

Add a hacking test to ensure we don't regress
on this.

[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

Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: If857a49fbf526983e712282a25d7e8bef5093533
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-04-17 16:24:27 -07:00
silvacarloss 14d3e268a0 Add share network with multiple subnets
This patch adds the possibility to create share networks with
multiple subnets in Manila. It also updates the share server api
to receive "share_network_subnet_id" instead of "share_network_id".

Each share network subnet must be associated with only one
availability zone. Each share network must have a single default
share network subnet.

DocImpact
APIImpact
Depends-On: I13bb48e7c03e16c26946ccf9d48e80592391a3d1
Partially-implements: bp share-network-multiple-subnets
Change-Id: Id8814a8b26c9b9dcb1fe71d0d7e9b79e8b8a9210
Closes-Bug: #1588144
Co-Authored-By: lseki <luciomitsuru.seki@fit-tecnologia.org.br>
Co-Authored-By: dviroel <viroel@gmail.com>
2019-09-13 11:27:18 -03:00
Goutham Pacha Ravi 4b0c953f7f Fix API version inferred w/ un-versioned URLs
With [1], we fixed the issue with v1 API URLs when
configuring manila with a reverse proxy, like uwsgi.
However, the version discovery can be made against a
"unversioned" URL, i.e, the "/" endpoint.

Example version discovery target when there's no reverse
proxy:

   curl -i -X GET www.openstack-overcloud.com:8786/

Example version discovery target when manila is configured
with a web proxy:

   curl -i -X GET www.openstack-overcloud.com/shared-file-system/

Currently, the API assumes that a v2 endpoint is requested
and hence sets a default API version in the request, which
results in the wrong headers communicated to the client.

Fix this issue. The release note added with [1] should
suffice for this fix.

[1] I0363d7174f3d7ddefa8ced59b182faed665e9c36
Change-Id: I50d1024ee8485b8290c24fa850e60755b518fff3
Closes-Bug: #1818081
2019-03-13 17:42:07 -07:00
Goutham Pacha Ravi 0d8310ec7a Fix version selector when for proxy-style URLs
When manila API is served behind a proxy, the
"script_name" in the request can have the proxy
component in it. So, this patch fixes the version
selection logic by looking for the version in the
script name string instead of equivalence.

In addition, this patch adds some missing unit
tests and fixes tests that invoke a mocked
wsgi app for testing request context.

Change-Id: I0363d7174f3d7ddefa8ced59b182faed665e9c36
Partial-Bug: #1815038
Closes-Bug: #1818081
2019-03-11 16:42:25 +00:00
Béla Vancsics f33ac181b0 Use assert(Not)In/Greater(Equal)/LessEqual/IsNotNone
Instead of using assertTrue(A * B) / assertFalse(A * B)
developers should use assertNotIn, assertIn, assertGreater,
assertGreaterEqual or assertLessEqual or assertIsNotNone.
They are compatible with Python 2.7[1] and 3.4[2]

[1]: https://docs.python.org/2.7/library/unittest.html
[2]: https://docs.python.org/3.4/library/unittest.html

Change-Id: I26ab3bc3cad5e1dddc812388b864d51c73f53f58
2016-09-30 09:43:49 +02:00
David Sariel 4a61faa065 Removed ignored checks from tox.ini and fixed pep8 issues
Due to the hacking version update several pep8 checks where ignored
in the flakes8 section of the tox.ini. Removed ignored checks and fixed
appropriate pep8 issues.

The list of fixed issues:
    - H105 Don't use author tags
    - H238 Old style class declaration, use new style (inherit from `object`)
    - H501 Do not use self.__dict__ for string formatting

Closes-Bug: 1530719
Change-Id: I890ba4c54b0da10060767620ff5ff7e480d79a9c
2016-02-14 14:56:55 +02:00
houming-wang 9a74a01855 Fix wrong flake8 exception and pep8 violations
In the tox.ini, [flake8] section, "exclude =
.venv,.tox,dist,doc,openstack,*egg". From this rule, all 'openstack'
directories are excluded. This rule is intended to exclude
manila/openstack/common code check, but this is wrong
because it also exclude checks against manila/api/openstack and
manila/tests/api/openstack. We should fix it

Change-Id: Ie820e3931e83a82c40b0d9b9d943787a5d6ec363
Closes-Bug: #1529092
2015-12-24 21:45:39 -05:00
Goutham Pacha Ravi 379ee2f31c Refactor authorize() method in wsgi.py
Almost every API method written in Manila performs
a policy check against relevant policies in etc/policy.json.
A method - authorize() was introduced in
manila/api/openstack/wsgi.py
in commit e4428f5e6c
to perform these policy checks.

This patch refactors the authorize() method as a decorator
for consistency and easy usage in APIs that choose to
implement the policy check prior to any core logic.

Prior unit tests are modified for the APIs impacted through
this change.

The Cgsnapshots controller's policies are corrected for
name consistency without impacting behavior.

Change-Id: Ib34e166ab65513f8f02215c6569175fc9a913244
Closes-Bug: #1515397
2015-11-19 16:56:44 +00:00
Yusuke Hayashi cb0a5c9829 Replace assertEqual(None, *) with assertIsNone in tests
Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.

Closes-Bug: #1280522
Change-Id: I2d5285add72678b5a61b4f66879c4d066afc34c7
2015-08-23 09:07:13 +09:00
Clinton Knight 145165a22e Implement Manila REST API microversions
The OpenStack API working group recommends all projects adopt
Nova-style microversions for versioning their REST APIs.  This
commit ports the Nova microversion code and docs to Manila.

With this patch, the API version is bumped to 1.1, and the
versions API (which has always returned horribly outdated
values) is the first API that is versioned.  The 1.1 version
of the versions API includes the minimum and current API
version values.

Implements bp: manila-rest-api-microversions
Change-Id: Ifa8e394335a4eb3ad21f53a873530aee241c00e8
2015-08-13 19:51:19 +00:00
Valeriy Ponomaryov ed6ed47202 Fix string/binary conversions for py34 compatibility
Default type of strings in py 2 and 3 are different. So, convert them
explicitly when it is needed for py 2/3 compatibility.

Partially-Implements: bp py3-compatibility
Change-Id: I9b2d7e97fdc7d073a16e729ce0e90b92281fdf8d
2015-08-07 15:33:36 +03:00
Igor Malinovskiy a26824818f Remove Limited XML API Support from Manila
Remove the broken XML support presently available in Manila
in order to comply with the general direction among other
OpenStack projects to support JSON only.

Change-Id: Ibb542fa223f7f7d1bf95f3d1f568987ef839cd12
Closes-Bug: #1440782
2015-04-13 15:43:47 +03:00
Valeriy Ponomaryov dbeab7b650 Add object caching in manila REST API requests
Allow the core API to cache resources, such as DB results, so that
extensions can use data already retrieved within the same API request
eliminating additional expensive DB calls.

Loosely based on Cinder commits 233430b51ddbd207f22eee98386ffbb766fd777f
and 4aeb7256ef4cc75bae4ff9258a5bcf6092b3c834. Which are based on Nova
commit 9f9fbc54e7336da10fc3056bdaca2ec7d01c7f94

Use caching for share types to avoid concurrency issue when listing of
share types request was getting response from another request.

Change-Id: I8bb3d9af0ee36d0c7b80f979ef1ce6eafb2f6ced
Closes-Bug: #1441602
2015-04-10 18:26:46 +03:00
chen-li fbb861fb87 py3: use function next() instead of next() method on iterator objects
Python 3 introduced a next() function to replace the next() method on
iterator objects. Rather than calling the method on the iterator, the next()
function is called with the iterable object as it's sole parameter, which
calls the underlying __next__() method.

The next() function was backported to Python 2.6 which allows us to use either
the 2.x or 3.x way simultaneously.

Partially-implements blueprint py3-compatibility

Change-Id: Icf4440132d476b55a98ca5c057c749091c363ba7
2014-12-30 16:35:24 +08:00
Marc Koderer ecf603bc05 Remove vim headers
As discussed in [1] remove all vim headers from manila files.

[1]: http://lists.openstack.org/pipermail/openstack-dev/2013-October/017353.html

Change-Id: I341486c66ffe4dad7db8608fdc66868ceb7ad95a
Closes-Bug: #1229324
2014-10-06 15:00:27 +02:00
Yulia Portnova dc4ce932ed Renamed cinder to manila.
Fixed setup.py, fixed bin scripts.
2013-09-02 09:59:07 +03:00