Commit Graph

58 Commits

Author SHA1 Message Date
Pranali Deore 3790cfd4a1 Remove dead code of auth and policy layers
In Xena we have mangaed to move all policy checks to API layer,
now removing the dead code from policy and authorization layer

NOTE: Some of the code is still being used from policy layer,
hence keeping it there only at this moment.

Change-Id: Ibee749cde20687d8c243cf84ae80b4de67d8ef3d
2022-06-14 10:15:55 +00:00
Stephen Finucane 9679ffc463 Remove six.moves.http_client usage
This is a rather beefy change due to the number of usages of this
import. The changes are trivial though.

Change-Id: I7badeeaca438b0291f4ed86670e7f217e6372c61
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 14:54:05 +00:00
Abhishek Kekane d54449af44 Utilize newly added tasks database fields
Made provision to pass image_id, request_id and user_id information
while creating new task.

Partially-Implements: blueprint messages-api
Change-Id: I299a222eeef81431143db3ba7fc08365c924326b
2021-02-24 05:17:43 +00:00
Charles Short 8954959817 Introduce ''mock_object'' method to base test class
We would like to fully remove mox from the test tree. Even for tests
that don't use mox's validation, many of them are using the symbol
patching with self.stubs.Set. We can do the same thing with the
monkeypatch fixture instead.

This introduces self.stub_out to nova/test.py and an example of what a
stubs => stub_out change would look like.

The teardown function in the converted test was removed at the same
time, as those should no longer be used.

Part of the mox community goal for Rocky.

Change-Id: I8f471ff8fee600ebb4e8907bf240007b7b4fe59f
Signed-off-by: Chuck Short <chucks@redhat.com>
2018-08-09 12:40:12 -04:00
wangqi b7dc3f234b Modify the empty list ensure method
Change-Id: I32c21637c39b20a20c9a42042408ab76c8c96d7a
2018-04-19 08:26:08 +00:00
Gábor Antal 8a8e5bf56c Extracted HTTP response codes to constants in tests
There are several places in the source code where
HTTP response codes are used as numeric values.

These values are used from six.moves and the
numeric values are replaced by constants.

All of the used status codes were replaced with symbolic constants
from six.moves.http_client.
More about six.moves.http_client can be found at [2],
under the table "Supported renames:".

Also, this change improves code readibility.

This patchset does not extract numeric values from
the code itself, but it can be found at [1].

[1]: Ib9e26dcea927e96e65c626c18421621d3a29a64d
[2]: https://pythonhosted.org/six/#module-six.moves

Change-Id: Idfc7b043552f428f01ac3e47b270ee0639a8f5bc
Closes-Bug: #1520159
2016-10-06 15:17:06 +00:00
Julien Danjou 4d5330088f Replace oslo_utils.timeutils
This change introduces glance.common.timeutils that provides the
timeutils previously consumed from oslo_utils.

Oslo is deprecating some timeutils functionality which of Glance
depends on. Suggested replacement (isoformat) would break glance APIs
so it's cleaner to carry this functionality in Glance rather than
re-invent the wheel.

Co-Authored-By: Erno Kuvaja <jokke@usr.fi>
Co-Authored-By: Sabari Kumar Murugesan <smurugesan@vmware.com>

Change-Id: I91e1cc9a273249fd88749cecf21200f3f5e2bab1
2015-12-10 10:53:46 +00:00
NiallBunting fcbfddd590 Reactivating admin public image returns 500
The actual call is reactivate not activate. Therefore to stop the
internal server error occuring the activate needs to be renamed.

Change-Id: I9c74a3cd2bd460c6947477052af07838ef278d59
Closes-bug: 1515305
2015-11-12 18:40:36 +00:00
NiallBunting 15c08d822a Cause forbidden when deactivating image(non-admin)
If a user tries to deactivate an image that is hosted by the admin that
has public visiblity, it will currently return a 500 error. This changes
that behaviour to return a Forbidden.

Closes-Bug: 1485940
Change-Id: Id7f645fc599e57f6c0842bba2b7a2f3db52784ae
2015-10-14 10:47:26 +00:00
Doug Hellmann ae21f4dffa Drop use of 'oslo' namespace package
The Oslo libraries have moved all of their code out of the 'oslo'
namespace package into per-library packages. The namespace package was
retained during kilo for backwards compatibility, but will be removed by
the liberty-2 milestone. This change removes the use of the namespace
package, replacing it with the new package names.

The patches in the libraries will be put on hold until application
patches have landed, or L2, whichever comes first. At that point, new
versions of the libraries without namespace packages will be released as
a major version update.

Please merge this patch, or an equivalent, before L2 to avoid problems
with those library releases.

Blueprint: remove-namespace-packages
https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages

Change-Id: Ifa8baab33cdb3e606cf175a8c29c3a4ef6c44480
2015-04-28 18:57:45 +00:00
Julien Danjou a360ed98bb Switch to mox3
As mox3 is a drop-in Python 3 replacement for mox, let's switch to it.

Change-Id: I0174398c492fdd5e53672dd0f654f220583b75d4
2015-01-26 10:59:26 +01:00
Louis Taylor 41d45dfb1c Move from oslo.utils to oslo_utils
oslo_utils has been moved out of the oslo namespace.

bp drop-namespace-packages

Change-Id: Ie818e72b31efd2a6ab182444967bdfaca9366f4a
2015-01-09 20:01:42 +00:00
liyingjun 2365a3fb5f Fix assertEqual arguments order
assertEqual method's arguments should be in ('expected', 'actual')
order.

Change-Id: I88b5b0558720a91236b62b6e4a3590901e817f85
Closes-bug: 1277104
2014-09-19 00:25:18 +08:00
Julien Danjou 581cb4ca43 Switch to oslo.serialization
Change-Id: I983bb5b6e2c7fbbd8556ff0f99212803cb0269e9
2014-10-07 14:58:55 +02:00
Julien Danjou 874e643549 Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
2014-10-07 14:55:57 +02:00
Jenkins 001dd0112e Merge "Uses None instead of mutables for function param defaults" 2014-04-22 00:25:54 +00:00
Jenkins 3db3b67388 Merge "Replace assert* with more suitable asserts in unit tests" 2014-04-17 21:09:05 +00:00
Sergey Nikitin 84dbe32a6d Replace assert* with more suitable asserts in unit tests
The following replacements were done in unit tests to have
clearer messages in case of failure:
- assertTrue(* is None) with assertIsNone
- assertTrue(* is not None) with assertIsNotNone
- assertTrue(* in *) with assertIn
- assertTrue(* not in *) with assertNotIn
- assertFalse(* in *) with assertNotIn
- assertTrue(* == *) with assertEqual
- assertTrue(* != *) with assertNotEqual

Change-Id: I0c47f991c3974e441335e71c9d26fab8a127f2ca
2014-04-17 10:35:46 +04:00
Arnaud Legendre 7f512fd0ac Get rid of TaskDetails in favor of TaskStub
Change I0b406e4662cfd3cb496b71be77ad10a90c178baa introduces a new
class TaskStub. This class is designed to be a subset of what a
task is in the domain layer: it doesn't contain input, message and
result. TaskStub should be used when listing tasks in order to avoid
extra-overhead of transporting these text fields.
As a result, the TaskDetails introduced by change
I0b406e4662cfd3cb496b71be77ad10a90c178baa doesn't need to exist.

With this patch, the domain layer contains Task and TaskStub instead
of Task, TaskStub and TaskDetails.

partially implements bp async-glance-workers

Change-Id: I2a20b0c5033c6920749370355c2d672dec707c28
2014-04-16 11:14:58 -07:00
Brian Cline bebe906ee7 Uses None instead of mutables for function param defaults
Addressing bug 1307878, changes use of mutable lists and dicts as
default arguments and defaults them within the function. Otherwise,
those defaults can be unexpectedly persisted with the function between
invocations and erupt into mass hysteria on the streets.

To my knowledge there aren't known cases of the current use causing
specific issues, but needs addressing (even stylistically) to avoid
problems in the future -- ones that may crop up as extremely subtle or
intermittent bugs...or worse, security vulnerabilities.

In Glance's case there are ACL-related methods using this, so
although I haven't confirmed one way or the other yet, I've marked it
with SecurityImpact so that a more knowledgeable set of eyes can
review it in this context as well.

Closes-Bug: #1307878
SecurityImpact

Change-Id: Ic17c330eff701ff63701c0029b26db7093a1d73d
2014-04-15 02:29:23 -05:00
Nikhil Komawar 0118103eec Adds TaskStub class
Partial Task patch, Id I4fbadc9a97e3147128c7c733384c7bb50918806f
removed the result and message vars of the Tasks class. However,
the succeed and fail methods were using those to update them
respectively. This patch introduces a new TaskStub class which
enables the PartialTask functionality without looking result
and message attrs of the Task class.

Fixes bug 1284975

Change-Id: I0b406e4662cfd3cb496b71be77ad10a90c178baa
2014-04-08 11:58:00 -04:00
Jenkins 7130d9fe18 Merge "Add support for PartialTask list" 2014-02-22 12:10:27 +00:00
Jia Dong 8d4312a2c9 Modify assert statement when comparing with None
Replace assertEqual(None, *) with assertIsNone in glance's
tests to have more clear messages in case of failure.

Also, replace assertTrue(* is not None) with assertIsNotNone
for the same reason.

Change-Id: If41a71bd750057c7136b03bef94c04517092134c
Closes-Bug: #1280522
2014-02-19 14:37:41 +08:00
Venkatesh Sampath 010c0801bd Add support for PartialTask list
- partial-task: Task that includes all the values except the 'Text'
columns(input, result & message).
- This patch is to have the database to return a partial-task list on users
invoking 'GET /v2/tasks'.
- Returning list of partial tasks will help in reducing the response time when the
user queries for the list of tasks.
- This patch also includes changes for making implementation and return values of
display task detail (GET /v2/tasks/{task_id}) and list tasks (GET /v2/tasks)
more explicit.

partially implements bp async-glance-workers

Change-Id: I4fbadc9a97e3147128c7c733384c7bb50918806f
2014-02-12 17:05:23 +05:30
Jenkins 2c4bd69565 Merge "Change assertTrue(isinstance()) by optimal assert" 2014-01-19 05:04:52 +00:00
wanghong 3d03291df8 Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of assertTrue(isinstance(A, B)) or
assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B)
provided by testtools.

Change-Id: Ia8d38f73c159c7ef943a8f6cfe72b945cc493947
Closes-bug: #1268480
2014-01-15 19:01:51 +08:00
Noboru arai 8de10b0f34 Remove vim header
No need to set tabstop tons of times, this can be set in your vimrc
file instead.

More disucssion:
http://openstack.10931.n7.nabble.com/Remove-vim-modelines-td21780.html

Change-Id: I3b830a5bb831a63c188109e6fad66ba48884fff3
Partial-Bug: #1229324
2014-01-14 16:03:28 +00:00
Nassim Babaci 70d2c8c2d8 fix comments and docstrings misspelled words
Change-Id: I355b6fedf372b1273ceaebe22e8e890aa9c913c9
Closes-bug: #1267103
2014-01-08 17:03:44 +01:00
Yanis Guenane 16c3a33c0b Migrate json to glance.openstack.common.jsonutils
Every call to json.loads/json.dumps have been changed to
jsonutils.loads/jsonutils.dumps respectively. Import json has been removed
also replaced by import glance.openstack.common.jsonutils

654d80b416dc5f413cb791aa838ec8688bf7da44 Create openstack.common.jsonutils

Change-Id: I8ef580e5eb91526dfaef37050ce1f5c6d88d56b5
Closes-bug: #1257922
2014-01-05 14:38:07 +00:00
Dirk Mueller d6114f914c Fix and enable gating on H306
Fix fallout of Hacking check: Imports should be in alphabetical order

Change-Id: I179711c8448208592490ffa47d51419779940014
2014-01-01 16:44:19 +01:00
Yanis Guenane ec08ca1a87 Make code base E125 and E126 compliant
This commit makes the glance code base E125 and E126 compliant :
  * E125 continuation line does not distinguish itself from next logical line
  * E126 continuation line over-indented for hanging indent

Change-Id: I7120149bedb665fb66320498fe98948602a6cd52
Closes-bug: #1263437
2013-12-30 13:03:24 +00:00
Venkatesh Sampath be23b19905 Enable tasks REST API for async worker
- add REST API layer for async worker(tasks) to
support tasks operations.
- update to include sparse task for tasks.index
- add domain proxies for handling  authorization,
policy enforce, notification while processing
task requests.
- add Task domain entity and TaskFactory to create
new Task domain entity objects.
- add integration test for testing tasks api

Co-authored-by: Fei Long Wang <flwang@cn.ibm.com>

Partially implement blueprint async-glance-workers

Change-Id: I072cbf351c06f59a7702733b652bfa63e5abbaa6
2013-12-13 22:58:53 -05:00
Fei Long Wang d79861560b Adds domain level support for tasks
Includes:-
  - Domain Task class
  - Domain TaskFactory class
  - DB TaskRepo class
  - Necessary proxy classes for all of the above
  - Tasks related exceptions
  - Unit tests as applicable

Partially implement blueprint async-glance-workers

Change-Id: I619224bcc55b62303f3539454649528f2edc6e9d
2013-11-26 16:35:12 -05:00
Jenkins 93edd1bdc6 Merge "Changed header from LLC to Foundation based on trademark policies" 2013-11-12 13:41:45 +00:00
Dirk Mueller 753885d3cd assertEquals is deprecated, use assertEqual
Also change to assertTrue/False where assertEqual(True,/False) was
used.

Change-Id: I9e592d9c40c3da61b5e7af7e7ad5247645249eff
2013-11-07 02:34:48 +01:00
Dirk Mueller 518bbf7298 Changed header from LLC to Foundation based on trademark policies
Fixes: Bug 1214176

Change-Id: I4e394c33d810fe7d48066ff7cb6143f7eae25f13
2013-09-10 18:29:53 +02:00
Alex Meade d17e87ff7f Pass configure_via_auth down to auth plugin
Pass down the configure_via_auth value to the auth plugin to say whether or not
it should look in the service catalog for the glance registry endpoint. This
stops authentication by glance registry client from needlessly looking for an
"image" service endpoint when the user may not have it in their service catalog.

Fixes bug 1187888

Change-Id: I1c4a726ff0d6a345a27446500135f4f27cea5e39
2013-06-05 14:56:14 -04:00
Tatyana Leontovich 3182d875ca Improve unit tests for glance.common.auth module
Add additional case to the test glance.tests.unit.test.auth.required_creds,
to verify that plugin created without required
credential pieces raises an exception

Fixes: bug #1152009
Change-Id: I3fdd9224173bdb33a9bd2ab348e22675d735099f
2013-04-30 00:10:00 -07:00
Flaper Fesp 855162b0b1 Check if creds are present and not None
Currently, KeystoneStrategy checks whether the required credentials are
present in the creds dict but it doesn't check whether they are valid or
not.

This patch checks whether the required creds are present and not None
otherwise a MissingCredentials exception will be raised.

Note: No need for checking parameters' values types since they'll be
instances of basestring once set otherwise they'll be None.

Fixes bug 1157765

Change-Id: I664a604c3cbf2fca60a88c4d887cd9a4b678c8a5
2013-03-21 18:04:35 +01:00
Mark J. Washenberger 8cc4b45dbf Cannot change locations on immutable images
This change extends immutability to the contents of image locations.

Change-Id: I5bfe9b73733eb92e0d27bd0222f6ad1a89ce5d78
2013-03-02 11:19:32 -08:00
Brian Waldon 222a00fef9 Update db layer to expose multiple image locations
* The DB API now exposes a 'locations' image attribute rather than
  'location'. The new field is guaranteed to be a list of zero of
  more items
* The v1 and v2 APIs only look for the first item in the list of
  locations.
* Related to bp multiple-image-locations

Change-Id: I830b383d8a8e50a01e461658fb9abe384de1a353
2013-03-02 10:07:17 -08:00
Mark J. Washenberger a12e81d5b4 Extend the domain model to v2 image data
This completes blueprint glance-domain-logic-layer

Change-Id: I5d0e9f54cfc745f484a8db8f29f64caeb832ec98
2013-02-20 23:30:52 -08:00
isethi 9c24bead99 Allowing member to set status of image membership
Only the owner of an image can add members to the image.
By default the status of the image member is requested.
The member can change the status of the image membership
to accepted or rejected. This is done to prevent spamming
the user's image list. A member cannot see the other members
of the image.

Related to bp glance-api-v2-image-sharing

Change-Id: I0d0deba4b0df52b2f8d105b779fb7de746229d3a
2013-02-17 23:47:08 +00:00
isethi 44ceb21390 Adding image members in glance v2 api
Adding image members to glance v2 api. A user can create image member,
list image members and delete image member for a given image.
Also adds the necessary authorization.

Related to bp glance-api-v2-image-sharing

Change-Id: Ifc0607d693f7b0218ebd7fc4824a64e9eba995b3
2013-02-14 21:24:07 +00:00
Monty Taylor 43f8697696 Replace custom tearDown with fixtures and cleanup.
testtools.addCleanup is a more resilient way to perform cleanup activities,
as it will continue to clean things up even if there are unforseen problems.

Specifically, replace custom management of tempdirs with fixtures.TempDir
and replace tearDown methods that can be easily replaced with calls to
addCleanup in the setUp method. There are at least two temp dir creations that
did not have a corresponding cleanup in this patch, which is another reason
for using useFixture(fixtures.TempDir) instead of calls to mkdtemp.

Part of blueprint grizzly-testtools.

Change-Id: I4eb548010612bd5a8d30e8e2304fa66d3d5ffb7c
2013-01-17 16:39:40 -05:00
Monty Taylor b5e60b7e78 Use testtools for unittest base class.
While doing this, remove some of the nose-isms, which don't play nicely.

Part of blueprint grizzly-testtools

Change-Id: I9ea398b25195ad5f9c5db876c3dbb49ef4a5ee99
2013-01-12 19:17:08 +00:00
Mark J. Washenberger 308b832eb1 Add domain proxies that stop unauthorized actions
This patch introduces domain objects that handle context-based
authorization checks. With this approach, we can eventually remove
ownership checks from the database apis.

Part of implementing bp:glance-domain-logic-layer

Change-Id: I30c7444220013f17dab6479f1b00f1598ab424d0
2012-11-27 11:56:05 -08:00
Zhongyue Luo 305a9c12b5 Clean up pep8 E124 violations
Fixed E124 errors
All other ignores are to be removed in the next sequence of patches

Change-Id: Ic96ebf5dff645dfdc47478beeb6965d6ad266243
2012-09-24 09:32:11 +08:00
Zhongyue Luo 9f9f22cd80 Clean up pep8 E122, E123 violations
Fixed E122, E123 errors.
All other ignores are to be removed in the next sequence of patches.

Change-Id: I4b3edd9d1b2804ea7de255136da01b19f32abe1c
2012-09-19 16:41:51 +08:00
Dan Prince 78dbcfa9e5 Make get_endpoint a generic reusable function.
This patch refactors the get_endpoint function to make it more generic
and top level so that it can be more easily accessed and tested.

Adds service_type, endpoint_region, and endpoint_type options to
the get_endpoint function as well.

Added a new test suite specifically for get_endpoint.

The motivation for this change is that we'll need to be able to
parse the 'object-store' endpoint for each tenant in order to
enable multi-tenant storage in the swift storage backend.

Partially implements blueprint: swift-tenant-specific-storage

Change-Id: Icf773a1eb057fc9d65cf54890afa4638f2aee0b4
2012-07-12 14:55:45 -04:00