Commit Graph

86 Commits

Author SHA1 Message Date
Takashi Kajinami 9f896ab03d Bump hacking
hacking 3.0.x is too old.

Change-Id: I33875c36dbbdb946841f8c583636ccdf88d3331f
2024-01-27 16:55:11 +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
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
Grégoire Unbekandt 92492cf504 Add ability to import image into multi-stores
The import image api now supports a list of stores to import data into.
This list can be specified through a new "stores" field that has been
added to the request body.
During import stage, Glance iterates overs this list and send the data
to each store one by one.
If an invalid backend is requested by the user, an exception is raised.
If an errors occurs during verify, already pushed data is removed and
image state is unchanged.

Change-Id: Id3ac19488c0a693d7042be4a3c83f3b9f12313d0
Implements: blueprint import-multi-stores
2020-02-10 09:39:01 +01: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
Abhishek Kekane cb45edf5c8 Add multi-store support
Made provision for multi-store support. Added new config option
'enabled_backends' which will be a comma separated Key:Value pair
of store identifier and store type.

DocImpact
Depends-On: https://review.openstack.org/573648
Implements: blueprint multi-store

Change-Id: I9cfa066bdce51619a78ce86a8b1f1f8d05e5bfb6
2018-08-01 08:53:47 +00:00
Jenkins 0e41093b2e Merge "Added unit tests for disabled notifications in Notifier" 2016-11-22 04:03:23 +00:00
Alexander Bashmakov 621dfce182 Added unit tests for disabled notifications in Notifier
Notifier unit tests currently cover image, image.member and
task notification groups. Added equivalent tests to make sure
no notifications are emitted if they are disabled using the
disabled_notifications config option.

Change-Id: Iae2288e6d2c75d29c7126baeb0a80ad2f8b7b428
2016-11-07 15:22:25 +00:00
Li Wei e2911439c1 Removing deprecated variable aliases from oslo_messaging
This variable is deprecated.So we should drop it.

Change-Id: I2bd4a8e0d3d9dde1f5afb0927c5abb14f33c6d34
2016-08-24 09:51:29 +08:00
Juan Antonio Osorio Robles a31b963c1b Use messaging notifications transport instead of default
The usage of oslo_messaging.get_transport is not meant for
notifications; And oslo_messaging.get_notification_transport is
favored for those means. So this change introduces the usage of that
function.

If the settings for the notifications are not set with the
configuration that's under the oslo_messaging_notifications group,
this will fall back to the old settings which are under the DEFAULT
group; just like this used to work.

Closes-Bug: #1567231

Change-Id: I137d0f98533d8121334e8538d321fb6c7495f35f
2016-04-07 05:39:01 +00:00
bria4010 3c6d288fab Adds virtual_size to notifications
The virtual_size property was added to the v2 API in Icehouse as a
"core" image property [0], but the field was not added to image
notifications.  This patch addresses that oversight.

[0] https://blueprints.launchpad.net/glance/+spec/split-image-size

Change-Id: I423719a88ba1ef17e7475ab5388fb1720a28011e
Closes-bug: #1554206
2016-03-08 18:22:37 +00:00
Lakshmi N Sampath 4b0ce57c73 Fix for Image members not generating notifications
Image members CRUD doesn't generate notifications which
is impacting searchlight service by not having latest
changes to Image memberships.

If you create an image and later change its members,
the members are not updated via notifications.
You have to run the index sync again to get the updated
member list.

See: https://bugs.launchpad.net/searchlight/+bug/1490697

Membership information is critical for horizon filtering.
Typically, a person is allowed to view an image under the
following conditions:

1) The image is owned by the project I am currently logged into.
2) The image is public
3) The image is owned by another project which has added me
    as a member and I have accepted membership to it.

Without current membership information, 3) above is not possible.

See: https://bugs.launchpad.net/searchlight/+bug/1491085

Change-Id: Ia56e42d3d8da36cfa419d5c3c7d69c9ccf8974fd
Closes-Bug: #1441453
2016-01-25 04:50:58 -08: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
Lianhao Lu 5b7b498f03 Change the default notification exchange to glance
As we agreed that we'll change the default notification exchange name
from 'openstack' to 'glance' in M release.

The openstack convention is to send out all the notifications to the
exchange with the same name as the project name, i.e. nova sends all its
notifications to the exchange 'nova', cinder sends all its notifications
to the exchange 'cinder', etc. In such way, other projects interested in
those notifications (e.g. ceilometer) can listen on different exchanges
for different notifications.

Change-Id: I658fb0896aecea4fd5db1a9d3a8bbb64a91a7224
Closes-Bug: #1467776
2015-11-24 01:45:09 +08:00
liyingjun 927ac7cf14 oslo: migrate namespace-less import paths
This patch migrates oslo.messaging to oslo_messaging

Change-Id: I2c0befa48924c6641c8d3af96e7f35ff92e73e4c
Closes-bug: #1409733
2015-03-17 22:47:39 +08:00
Kamil Rykowski fd547e3717 Notifications for metadefinition resources
Metadefinition resources - namespaces, objects, properties, tags and
resource types - don't provide any notification events when certain
operations are performed on them. This patch includes following events
that will be triggered when necessary:

* metadef_namespace.create - namespace has been created
* metadef_namespace.update - namespace has been updated
* metadef_namespace.delete - namespace has been deleted
* metadef_namespace.delete_properties - all properties have been removed
from namespace
* metadef_namespace.delete_objects - all objects have been removed from
namespace
* metadef_namespace.delete_tags - all tags have been removed from
namespace

* metadef_object.create - object has been created
* metadef_object.update - object has been updated
* metadef_object.delete - object has been deleted

* metadef_property.create - property has been created
* metadef_property.update - property has been updated
* metadef_property.delete - property has been deleted

* metadef_tag.create - tag has been created
* metadef_tag.update - tag has been updated
* metadef_tag.delete - tag has been deleted

* metadef_resource_type.create - resource type has been added to
namespace
* metadef_resource_type.delete - resource type has been removed from
namespace

Additionally new configuration option has been added to allow for
disabling either individual or group of notifications.

DocImpact
UpgradeImpact
Depends-On: Iaa771ead0114e3941667b1e07ff32472d2f77afd

Change-Id: Ie1635793d80188f8f7a07aea91b9f0842900ffa6
Implements: blueprint metadefs-notifications
2015-03-11 11:14:57 +01:00
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
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
Flavio Percoco e9e35c49a9 API support for random access to images
This patch adds support for random access to images to the API v2. It's
possible to partially access the image data by passing the offset where
the image should be fetched from and the size of the chunk expected.

Note that not all stores support random access to image data. In such
cases, the API will return an error mentioning the selected store
doesn't support such a feature.

DocImpact:
Content-Range header is now parsed to support random access to image
data.

Implements blueprint: restartable-image-download

Change-Id: Iade692a8197a9a1d9532711a5c572c505e5e7d20
2014-09-08 15:48:38 +02:00
Flavio Percoco f6e7992a68 Adopt glance.store library in Glance
This commits removes the old `store` package from glance and adopts the
usage of the new glance.store library. The library was designed to
preserve backwards compatibility as much as possible. In fact, most of
the changes in this patch are related to function args ordering and not
function renames or workflow changes.

Some changes that are worth mentioning:

1. Glance store doesn't rely on a global config object. All config
options must be explicitly registered.

2. All store operations now accepted an optional context. This is a
fallout from the context not being required in the `Store` constructor
anymore.

3. Store drivers are behind a private package called `_drivers` and
they're not suppose to be accessed directly. Instead, functions like
`get_store_from_scheme` should be used.

4. Stores are disabled by default

5. All the store specific options are under the `glance_store` group.

DocImpact:
The old store related configuration options have been moved under the
`glance_store` section. However, the old options will go through a
deprecation path. That is, they'll still be read from the `DEFAULT`
section to give deployers enough time to update their config files.

In k-2, the deprecated options will be completely obsolete.

Closes-bug: #1291848
Implements-blueprint: create-store-package

Change-Id: Iaacc70993ad5da292b93de42bbecda73d53b19fd
2014-09-08 15:48:36 +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
Jenkins 0e7611daf4 Merge "notifier: remove notifier_strategy compat support" 2014-06-19 19:17:46 +00:00
Jenkins 17ef9cb169 Merge "Fixes v2 return status on unauthorized download" 2014-06-19 04:41:43 +00:00
Juan Manuel Olle 5cf0659d53 Fixes v2 return status on unauthorized download
If a user is not allowed to download an image because of a policy,
glance v2 API responds with a  HTTP 200 status and no data instead
of HTTP 403 for no cache only.
The problem is that get_data implementation for notification
proxy is a generator, this situation delays the other proxies
get_data calls (including the policy proxy) for the first time
data is retrieved.
Hence, there is a delay in enforcing policy, so 200 is sent before
the API gets the chance to catch the policy exception.

DocImpact
Closes-Bug: #1326781
Change-Id: I1e50a069a6b7f9eed7160cd5908a5fa30274e227
2014-06-18 13:11:11 -03:00
Mark McLoughlin b7a9e53190 notifier: remove notifier_strategy compat support
The notifier_strategy option is deprecated since we merged commit
I8cd84772bc5867e06b2a50ed7e15b9e86f0b94ad during the Icehouse cycle.

Assuming the usual single cycle deprecation period, this can now be
removed.

DocImpact: the notifier_strategy has been removed in favor of the
notification_driver and related oslo.messaging options.

Change-Id: I3ab0133b697a820536e5da84e30b078915a29f6c
2014-06-16 21:36:46 +01:00
Mark McLoughlin 4d6e55f40c notifier: simply notifier_strategy compat support
In order to handle the deprecated notifier_strategy configuration option
we just need to translate the notifier_strategy value as follows:

  default -> transport_url=None, driver='noop'
  noop -> transport_url=None, driver='noop'
  logging -> transport_url=None, driver='log'
  rabbit -> transport_url=rabbit:///, driver='messaging'
  qpid -> transport_url=qpid:///, driver='messaging'
  None -> transport_url=None, driver=None

where the last bit simply means that the user hasn't specified any
notifier_strategy and we should just have oslo.messaging load a notifier
based on oslo.messaging's config options.

It really doesn't need to be any more complicated than that, and we
certainly shouldn't need to poke at what the user may have configured
for transport_url in their config file.

The reason this is important is that CONF.transport_url is a private
configuration option which soon will not be visible to users of the
oslo.messaging API. See I9c3bf74f13a820ce295aa77a2bbcd781778b5926.

Also, simplify the testing of this stuff by mocking the oslo.messaging
APIs used and using the test scenarios outlined above. This also means
we stop poking around in oslo.messaging internals like:

       self.assertEqual(str(nfier._transport._driver._url),
                        'qpid:///')

Naughty, naughty!

Note: it's arguable we should just remove notifier_strategy in Juno
since we deprecated it in Icehouse, but this patch will be useful to
backport to stable/icehouse in any case.

Change-Id: I067248974baee50a2a0afb38bf022b65d1bea57a
2014-06-16 21:22:59 +01: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
Jenkins 0741c4004a Merge "Adds TaskStub class" 2014-04-08 20:41:48 +00: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
Flavio Percoco 164d1ab46f Catch loading failures if transport_url is not set
The current implementation always tries to get a transport from
oslo.messaging assuming the transport_url option has been set. This is
done to keep backwards compatibility. However, since the default
`rpc_backend` is rabbit, it'll always try to load such driver. The
problem raises when `kombu` is not installed and the `notifier_strategy`
is set to qpid. This will make glance-api fail because it'll try to load
the rabbit driver *before* loading the qpid one.

This patch puts the first load attempt in a try / except block. The
error caught (if any) will be re-raised *just* if transport_url has been
configured, otherwise it'll move forward and try to load the notifier
driver using the old configuration options.

The patch also removes an obsolete test.

Change-Id: I00e653704463ea8245e2960050e0d5e6839f278a
Closes-bug: #1302661
2014-04-04 23:07:00 +02: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
Gauvain Pocentek c4ca7a0a00 Fix parsing of AMQP configuration
The deprecated notifier_strategy option is always used even if it is set
to its default value and the new notification_driver option is
explicitly set.

This change makes the notification_driver option work.

Change-Id: Icc2a063a828472132d2e2eda7f12e265db990ea1
Closes-Bug: #1271724
2014-02-14 14:30:33 +01: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
Julia Varlamova fa3575d8fe Enable H202 check
Enable H202 check: assertRaises Exception too broad.

Make changes to glance/tests/unit/test_notifier.py

Change-Id: I258367172e77312ddda06132d2e8371e8fff81e7
2014-02-06 15:30:47 +04:00
Flavio Percoco 7e13cf73f1 Don't override transport_url with old configs
The backwards compatibility support turned out being a forward
compatibility blocker. This patch attempts to first load the notifier
transport using the transport_url and then, if the transport_url was not
configured, it loads the transport by using the old strategy config
params.

Closes-bug: #1263945

Change-Id: I4c80c64e2d1afaf518886b51a50300a576ee6317
2014-01-29 09:23:02 +01:00
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
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
Flavio Percoco 90d6ef8130 Migrate to oslo.messaging
Glance currently uses a custom notifier and it has been maintaining it
for a long time. In a hope of reducing duplicated code and improving
cross-project contributions, this patch replaces the old notifier with
the one, recently developed, in oslo.messaging.

The oslo.messaging project is a port of the old oslo-rpc code to a
standalone, more stable and improved project. It brings all the benefits
that oslo-rpc would've brought as well as an easier way to integrate
with other projects.

This patch also:

    - Reduces the code shipped along with Glance since all the code
      copied from oslo-incubator related to the notifier is not needed
      anymore.
    - Improves the stability of existing, broker based, notifications.
    - Brings HA support.
    - Keeps backward compatibility by translating the old
      `notifier_strategy` into oslo.messaging drivers.

Changes to the code:

    - It is now necessary to pass the request context to the
      notification call.
    - Notifier package is no longer necessary. A notifier module was
      added instead.
    - New, notifier related, configurations were added.
    - A lot of code was removed

Since there's still not an official release, requirements.txt points to
the latest tarball created. A release for oslo.messaging is planned for
Icehouse.

docImpact
Implements bp oslo-messaging

Change-Id: I8cd84772bc5867e06b2a50ed7e15b9e86f0b94ad
2013-12-04 09:05:51 +01: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
Julia Varlamova 5eb852e616 Add tests for glance/notifier/notify_kombu
Add tests for glance/notifier/notify_kombu in
RabbitStrategyTestCase class.
Tests for:
- _close()
- _connect()
- time.sleep() in reconnect()
- processing KombuMaxRetriesReached error in _notify()

Change-Id: I39805ce460ce2b71dcb05e63cb898c5569d726b0
2013-11-20 15:03:00 +04: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