Commit Graph

48 Commits

Author SHA1 Message Date
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
Dan Smith 937a70ab83 Refactor TaskFactory and Executor to take an admin ImageRepo
This refactors the task creation path to allow optional passing
of an admin-enabled ImageRepo to tasks. This will be used for
allowing import_image(method='copy-image') to update non-owned
image metadata during a copy.

Change-Id: Ief3440759fda4bd90979caa79641770cb022b7da
2020-07-10 08:59:53 -07:00
Sean McGinnis 94b0876429 Use unittest.mock instead of third party mock
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: I44e7b6f76e2d12f620ec602afc77ce11ba6b9d9a
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-20 15:07:00 +00:00
Corey Bryant c58e5e02af Rename async package to async_
In Python 3.7, "async" is a keyword. To prevent it from
conflicting, rename the async package to async_.

Change-Id: I1eaf87eedb86679d9ca9323aac05f0770c33efea
Closes-Bug: #1781617
2018-08-07 14:42:14 -04:00
Brian Rosmaita 4b8026714f Glare-ectomy
Glare became a separate project during Newton.  The code was copied
out of the Glance tree, but remained in the Glance repository.  It
is no longer being maintained, and that has begun to cause some
problems, for example, blocking a recent stevedore upper constraints
change; see I141b17f9dd2acebe2b23f8fc93206e23bc70b568

This patch removes the Glare code from the Glance repository.  It
includes Alembic database migration scripts, in both the all-in-one
and E-M-C format.  It also includes release notes.

Implements: blueprint glare-ectomy
Change-Id: I3026ca6287a65ab5287bf3843f2a9d756ce15139
2017-03-01 21:46:52 +00:00
Timothy Symanczyk 265659e8c3 Implement and Enable Community Images
This change replaces the existing boolean 'is_public' column for
the 'images' table with enum 'visibility' column featuring the
four explicit visibility values - public, private, shared,
and community.

This change also implements and enables all backend code to
utilize the new values.

Co-Authored-By: Timothy Symanczyk <timothy_symanczyk@symantec.com>
Co-Authored-By: Dharini Chandrasekar <dharini.chandrasekar@intel.com>

Implements: blueprint community-level-v2-image-sharing
Closes-Bug: #1394299
Closes-Bug: #1452443
Depends-On: I6e3268f3712cbc0aadb51d204c694023b92d55a5
Change-Id: I94bc7708b291ce37319539e27b3e88c9a17e1a9f
2017-01-18 17:56:12 +00:00
Gábor Antal 53379a714d Use more specific asserts in unit tests
In many places, there are more specific asserts
which can be used. I replaced the generic assert
with more specific ones, where it was possible.

This change enhances readibility, and on fail, more useful
message is displayed

Change-Id: I76dca80b6bd8886860fb383ee8d35e16cd99762e
2016-08-04 21:17:52 +02:00
yuyafei e0c03c63cf Add __ne__ built-in function
In Python 3 __ne__ by default delegates to __eq__ and inverts the
result, but in Python 2 they urge you to define __ne__ when you
define __eq__ for it to work properly [1].There are no implied
relationships among the comparison operators. The truth of x==y
does not imply that x!=y is false. Accordingly, when defining
__eq__(), one should also define __ne__() so that the operators
will behave as expected.
[1]https://docs.python.org/2/reference/datamodel.html#object.__ne__

Change-Id: I7d41128d88c79ebb5de1c38f8aaf98cc9561367c
2016-07-13 15:33:39 +08:00
Alexander Tivelkov b974a63660 Move Glance Artifact Repository API to separate endpoint
EXPERIMENTAL Glance v3 API has been removed in favor of standalone API
(EXPERIMENTAL Artifacts API of v0.1).
This patch introduces a new process entry point to run on a different
port (9494 by default), with its own configuration file and a paste
config.

A controller stub for old /v3 api remains in the glnace.api package for
the compatibility with existing paste configuration which may reference
it. This stub returns a 301 redirects to glare endpoint if it is present
or 410 errors otherwise.

To reuse  the existing version_negotiation middleware some refactoring
has been made.

Implements blueprint: move-v3-to-glare

Change-Id: I5b7bd4cdcc5f2a40fc4a5f74bcc422fd700c4fb0
2016-02-10 18:34:55 +03: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
wangxiyuan 1883eada3f Fix wrong parameters order in Task
According to Task class in glance.domain.__init__ .py, 'message'
should after 'result' in TaskFactory.new_task.

Closes-bug: #1488303
Change-Id: I70b0a27b5dbff0e762e2d9b162bea29147816c55
2015-09-17 10:23:11 +08:00
Mike Fedosin 35e35a17bd Domain layer for Artifact Repository
Introduces a layered domain model for Artifact Repository designed
similar to the domain model of v2 Images: a number of proxies for
Artifact Objects, their Repositories and collections split into layers
by appropriate functional aspect.

The following layers are added:
 * Database Repository layer - encapsulates DB APIs;
 * Dependencies Layer - encapsulates dependecy management (artifact ids
   are mapped to the actual Artifact References and back);
 * Location Layer - encapsulates store interaction for Blobs (similar to
   location layer of Images API);
 * Updater layer - wraps the collection-based properties of Artifacts
   for proper updates by JSONPatch calls.

Artifact-specific layers are added into "artifacts" subdirectory of
domain package. A gateway which creates layered proxy is added as well.

Implements-blueprint: artifact-repository

FastTrack

Co-Authored-By: Mike Fedosin <mfedosin@mirantis.com>
Co-Authored-By: Inessa Vasilevskaya <ivasilevskaya@mirantis.com>
Co-Authored-By: Alexander Tivelkov <ativelkov@mirantis.com>

Change-Id: I9b6d0e86c6577929230d58e7403fbefab167f36b
2015-06-09 16:00:46 +00:00
Fei Long Wang b6c1893863 Remove is_public from domain layer
The pre-reserved attribute 'is_public' has been removed from the
api layer, this patch will remove it from the domain layer and add
an unit test for that.

Closes-Bug: #1452447

Change-Id: Ie75088d95e7e0ae53df5290b33f3a184adc22239
2015-05-28 22:26:10 +00:00
Flavio Percoco ae3135e1d6 Remove the eventlet executor
We added the eventlet executor waiting for taskflow to land and be ready
for us to consume it. Now that we have it, it's time to remove the
eventlet executor in favor of taskflow's parallel executors.

DocImpact
UpgradeImpact

Partially-implements blueprint: new-upload-workflow

Change-Id: I220a14b2a92949772d5322c9947c42e892cfdbfa
2015-03-06 17:33:56 -04:30
Louis Taylor d759a6fd1a Move from oslo.config to oslo_config
oslo_config was moved out of the oslo namespace in oslo.config>=1.6.0.

Related-to: blueprint drop-namespace-packages

Change-Id: I30ecbf8f9de77496fcb643c7ad9738d79ad359f0
2015-01-12 14:34:22 +00: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
Mike Fedosin 4ad1493d0c A small refactoring of the domain
It fixes some eyesores that have been found in glance domain:
1. Removes duplicate declaration of a varariable 'name'
2. Changes type of several image transitions from 'str' to 'tuple'
3. Sets the correct default values to tags and extra_properties
4. Changes strange constructions like
self.tags = kwargs.pop('tags', None) or [] to
self.tags = kwargs.pop('tags', [])

Change-Id: I9309c7dc70b9910c6c09111f26ee489fa7ab9260
2014-11-28 20:26:43 +03: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 874e643549 Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
2014-10-07 14:55:57 +02:00
Julien Danjou fadbef8511 hacking: upgrade to 0.9.x serie
Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
2014-10-06 14:41:03 +02:00
Nikhil Komawar 186991bb9d Introduces eventlet executor for Glance Tasks
A sample import script to successfully import image from http or https
location is introduced. This should work on a devstack installtion.

Also, the following changes are introduced:-
1. An interface for implementing any other type of executor.
2. Provides namespace for keeping Tasks scripts.
3. A config for choosing deployer specific executor.
4. An interface for writing Tasks scripts.
5. A module for common script related methods.
6. Logic for limiting number of simultaneous tasks execution on the
Glance API server.

partially implements bp async-glance-workers
DocImpact

Change-Id: I382472fffd0fdad43573e72b2e78a9a6ed1e1f1a
2014-09-02 11:45:58 -04:00
Chris Buccella 4224161a71 TaskTest:test_fail() should use asserIstNone
test_fail() in the TasksTest class of tests/unit/test_domain.py uses
assertEqual when testing for None; assertIsNone is more appropriate
here.

This is the kind of thing that would be automatically picked up
by change Ic115342605c472f3a5d255aa570ecb60175ca087

Change-Id: I900334182f056f8b3656339b5bad0b60b334e7dd
2014-05-23 23:20:37 +00:00
Nikhil Komawar fcfb5d04cd Ensures that task.message is of type unicode
It is likely that a task script might store the message in a format
which is not 'Text', like a json message. To ensure that we save the
task message in the appropriate format, we should typecast it.

partially implements bp async-glance-workers

Change-Id: I4eaebb75357d448d4ea458cd7fe5e4ac96b33ace
2014-05-06 14:00:44 -04: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
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
Zhongyue Luo ed52d4538c Removes use of timeutils.set_time_override
The set_time_override function in timeutils was written as a
helper function to mock utcnow for unittests before 'mock' was
generally used. Now that we have mock and fixture, we no longer
need to use it.

Change-Id: I203f7369943b948e0462becbddcba65b2d1576f0
Partial-Bug: #1266962
2014-03-17 15:39:59 +08: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
David Koo 0cbe012602 Restore image status on duplicate image upload
Glance should not allow already uploaded images to be modified by
another upload. Currently, when configured with the local filesystem
backend, Glance prevents duplicate upload of an already uploaded image
BUT it changes the image status to "saving".

This commit adds a status transition state machine to the domain.Image
class and modifies the domain.Image.status setter function to verify
status transitions based on this state machine - only target states that
can be reached from the image's current state are permitted.

Tests have also been agumented to verify that the original image (meta)
data does not change in case of a conflicting upload.

Closes-Bug: #1241379

Change-Id: I62c5acae4c29abf0691d8279b51c59008f9c0047
2014-01-22 10:05:43 +08:00
Jia Dong f035efd043 Decouple the config dependence on glance domain
Move the configurations which core domain objects depend on to
common/config.py, and add a argument "task_time_to_live" of Task's
 __init__ method and TaskFactory's new_task method for delivering
the CONF.task.task_time_to_live value.
For convenience,the argument "task_time_to_live" is set a default value 48.

Change-Id: Iffda1ecd25470824c812d66a27fa64ebbaabcf07
Closes-Bug: #1250633
2014-01-13 10:26:01 +08: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
Arnaud Legendre 11b5487eff Use uuid instead of uuidutils
Each project should directly use the standard uuid module.
uuidutils will be deprecated/removed in this cycle.

This patch replaces every uuidutils.generate_uuid() with
str(uuid.uuid4()) and uuidutils.is_uuid_like()
with utils.is_uuid_like().

Change-Id: I43642d4f1e137c14134b3d544e367b504b9851ac
Closes-Bug: #1253497
2013-12-24 11:43:17 -08: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
iccha.sethi 262bdf68b4 Property Protection Layer
This patch introduces the property protection layer and the tests
associated with it

Related to bp api-v2-property-protection

Change-Id: Iaf2111bf07377ef6a4c89a621888077cc14be776
2013-09-04 17:47:48 +00:00
Dirk Mueller e6e02cd147 Fix test redifinitions
A few testcases had duplicate names, which caused
the original test to be redefined and not executed
anymore. Also one case was apparently entirely duplicate.
Raises unit test coverage by two tests.

Change-Id: Ibf3db93b7fee875877c1bac8797eb88fc9a99874
2013-04-22 04:02:00 +02:00
Mark J. Washenberger d6bad91493 Ensure disk_ and container_format during upload
This patch changes the image domain model so that the transition from
'queued' to 'saving' or 'active' status cannot take place if the image's
disk_format or container_format are not set.

Fixes bug 1131994

Change-Id: I454d9df736edd771f9d5d93eca4cd317116cc985
2013-03-07 09:47:21 -08:00
Jenkins 61d31716e6 Merge "Allowing member to set status of image membership" 2013-02-18 04:34:30 +00:00
Jenkins 0e3f62e420 Merge "Updates OpenStack LLC with OpenStack Foundation" 2013-02-18 04:31:53 +00:00
annegentle a2b9bed75d Updates OpenStack LLC with OpenStack Foundation
Patchset addresses reviewer's comments, rebase against master,
and follows new guidance from Foundation:
http://wiki.openstack.org/Documentation/Copyright

Change-Id: I94367461505778973528eb8835d991f4fb796dab
2013-02-17 19:19:43 -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
isethi 286dd791a5 Image Member Domain Model
This commit is the first layer of image member domain model.
The can_share feature from v1 of glance api will not be
ported to glance v2 api.

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

Change-Id: Ibfb790d438efb0f5b29b4786c02f1155962150c5
2013-02-09 04:20:31 +00:00
Zhongyue Luo ce85c38158 Fix import order nits
Change-Id: I972c463131ba688ab9352590eb53f5b1822ac943
2012-12-31 22:12:53 +08:00
Mark J. Washenberger 43ba08d8aa Add an image domain model and related helpers.
This patch is the first in a series refactoring the logic around image
manipulation. In this patch, we add a domain module that has Images and
ways of constructing them. In anticipation of proxy classes added in
subsequent patches, we also define some base classes to make proxying
simpler.

Partially implements bp:glance-domain-logic-layer

Change-Id: Ie72f2f86cfcbd15e41c32deed3626290f2bf0e6b
2012-11-14 12:52:11 -08:00