Commit Graph

39 Commits

Author SHA1 Message Date
Erno Kuvaja 3dde3204d5 Remove Images API v1 entry points
This change removes option to configure Images API v1
This change removes Images API v1 endpoints from the router
This change removes all v1 tests
This change removes the v1 dependant glance-cache-manage command

This change does not remove all v1 codebase. Further cleanup and
decoupling will be needed.

Change-Id: Ia086230cc8c92f7b7dfd5b001923110d5bc55d4d
2018-07-13 10:21:49 +01:00
Matthew Treinish c09d157960
Add external lock to image cache sqlite driver db init
This commit adds an external lock to sqlite when launching multiple
worker processes (using uwsgi) the db init will fail for one since the 2
workers will race for initializing the DB. The method is idempotent so
we can safely run it twice in succession, but the lock is necessary to
provides us protection against running it at the same time.

Depends-On: I9a66a8636d12037ff9aa4fb73cc3f9b9343dd7e9
Change-Id: I654c3a5604a89402ba94d9cea44699a48583a7e0
2017-06-18 03:52:18 -04:00
Cyril Roelandt 401f544d0c Python3: Fix glance.tests.functional.test_bin_glance_cache_manage
The tests were faulty here.

Change-Id: I7ee53bd6890536ec0c9cb6a0ae43c84c2c391f10
2016-12-01 17:43:16 +01: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
kairat_kushaev ecf8aea1e4 Remove verbose option from glance tests
verbose option is going to be deleted soon (see 
https://review.openstack.org/#/c/206437/ for more info
why it deprecated in oslo.log) because it confuses users 
(we already have debug option). So we need to delete it from glance
tests.

Change-Id: Iade46a6097d153f2df0da73554bbfd3e2b1704f5
2016-05-26 15:00:11 +00:00
Erno Kuvaja e8e71dba4d Rationalize test asserts
Utilizing assertIn and assertNotIn in a consistent way rather than
assertTrue( x <not> in y) and assertFalse(x in y).

Change-Id: Ic43d107c40a5a50b852ee476b1167c21e5ad86e8
2015-07-09 13:48:49 +00:00
Louis Taylor 2278bcff3b Set filesystem_store_datadir in tests
The new release of glance_store (0.5.0) included
I1d4f95cba47d21f1eb7e580314d01ac8d3481586, which raises errors if
filesystem_store_datadir or filesystem_store_datadirs is not set. Glance
currently is not correctly populating either of those options in certain
unit or functional tests, causing a lot of test failures. This patch
aims to unblock the gate by overriding the CONF option.

Change-Id: I3a9e0c7bfa4a9f38b41e93dce9652c4cc4811a9b
Closes-Bug: #1454384
2015-05-13 11:07:31 +01: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
Erno Kuvaja a4f5bf6ab9 Unify using six.moves.range rename everywhere
Mainly to improve consistency, use range() from six.moves
renames across glance.

Behaves consistently like py2 xrange() and py3 range().

Removes unnecessary range() from glace/api/v2/images.py

Change-Id: Id21f923d05600b902f2239e25ef01716c07e74a3
2015-02-25 12:05:36 +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
Roman Vasilets cb2456ea5e Wrong order of assertEquals args(Glance)
Args of assertEquals method in glance.tests are arranged
in wrong order. In result when test fails it shows incorrect
information about observed and actual data. It's found more
than 2000 times. Right order of arguments is "expected, actual".

Change-Id: Ifea4809f5a696b608a19e36a9ed9e5eec46c8a21
Co-Authored-By: Li Yingjun <liyingjun1988@gmail.com>
Closes-Bug: 1277104
2014-11-13 17:10:09 +02: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
Julien Danjou fadbef8511 hacking: upgrade to 0.9.x serie
Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
2014-10-06 14:41:03 +02:00
Bartosz Fic 0b246bb5f5 Replaces assertEqual with assertTrue and assertFalse
In order to improve coding practices and be aligned to a standard,
self.assertEqual(...,True) statements where replaced with
self.assertTrue and self.assertFalse.

Change-Id: I4150a343493beae03d6f71c88e84f60d14fb60e1
Closes-Bug: #1230127
2014-09-12 10:51:02 +02:00
Julia Varlamova 67c79540c7 Enable hacking H301 and disable H304, H302
Enable hacking H301: one import per line. H304 and H302 check enables too,
so we temporarily disable it since it does not pass.

Fix imports in files below.

Add # noqa to migration scripts.

Change-Id: I6a8d4dcd9c3195d2848f218aafe304b1240ab60c
2014-02-18 16:05:18 +04:00
lizheming 56089303f0 fix bug:range() is not same in py3.x and py2.x
in python3.x, there is no method named xrange(),it
has replaced by range(),which is equal to xrange() in
python2.x. so we must fix this issue.we use six module
to fix this issue.

Change-Id: If4fd7478865e8024025af3e57e42f2a24e1e2bbc
Closes-Bug: #1268439
2014-01-21 12:46:20 +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 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
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
Chang Bo Guo 30696aa243 Clean up numeric expressions with oslo constants
Replace numeric expressions with olso constants to make code
more readable. This patch won't replace single 1024 if 1024 not
in an expression like number * 1024.

Change-Id: Ic1137774f0f9a2be89a7c2706d6eb52eb906ff1f
2013-11-21 20:05:19 -08:00
Jenkins 93edd1bdc6 Merge "Changed header from LLC to Foundation based on trademark policies" 2013-11-12 13:41:45 +00:00
Noboru Arai 635ceac079 checking length of argument list in "glance-cache-image" command
Currently, "image id" is got by "pop" method without checking length
of argument list in "queue_image" method(glance/cmd/cache_manage.py)

Consequently, only last element of argument list is used,
other elements are ignored.
 ex)
  glance-cache-image queue-image <image-id1> <image-id2> <image-id3>
  -> <image-id3> is selected and queued.
     <image-id1>/<image-id2> is ignored.

Because "glance-cache-image" command is user command(*),
I think that elements which are ignored should not be existed
and checking of length is essential.

In order to check length, I replaced "try/except" statement with
"if/else" statement.

Also, I modified 2 methods at the same point.
 -delete_queued_image
 -delete_cached_image

 * http://docs.openstack.org/developer/glance/cache.html

Change-Id: I5cff1f9b5fe8f718ca74f1c9f58dba469396dc8f
Closes-Bug: #1236709
2013-10-18 16:51:22 +09: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
Wu Wenxiang 51c5185eea Remove start index 0 in range()
Remove the useless arg ("start index" = 0) in files, since its default
value is 0, to make code cleaner.

Change-Id: I9d91ab8a8033b9a6c9b77608dea92c91a994c7fc
2013-09-06 16:20:33 +08:00
Wu Wenxiang 844a228c3c Remove unused local vars
Remove unused local vars in test files to make code cleaner.

Change-Id: If97fad2d6b85730ea1cebc477f5f092c1c17976d
2013-08-30 20:07:00 +08:00
John Bresnahan e3b54dd71d Allow tests to run without installation
This patch makes modifications to the way that programs which the various
tests depend on are forked and executed.  This will allow the tests to be
run without installing glance to a python installation (ie: python setup.py
{develop/install} will not be needed).

fixes bug: 1197800

Change-Id: I9687cb7a5b22747d9cea0a1c24057383a8901476
2013-08-14 15:10:55 -10:00
John Bresnahan 039f3d8a59 Convert scripts to entry points
The executable programs used by Glance have historically been scripts
in the ./bin directory.  This patch converts all of the scripts to
entry_points.  This change makes these programs python modules.  Thus
they can be imported and methods in them can be called just like any
other module.  This will allow the tests to call into these programs
directly instead of having to fork out a process.

The conf.py file in the doc tree was causing a name collision with
the python module cmd.  The glance/glance directory was being added
to sys.path which made glance.cmd import with the name cmd.  This
patch also fixes that problem.

blueprint: refactoring-better-faster-stronger-functional-tests
Change-Id: I67ae14b7403af31a5944befcd2ec27a690e81f15
2013-04-29 14:08:29 -10:00
Brian Lamar 6a7ae170e2 Test date with UTC instead of local timezone.
iso_format test uses local timezone so it can fail at certain times
of the day depending on which timezone the tests are run in.

Fixes bug 1139131

Change-Id: I8fe423d96c438b46a9307fe1ecf648707183ff1c
2013-03-01 22:54:54 -05:00
Flaper Fesp 35be498112 Prints list-cached dates in isoformat
Converts dates printed by list-cached to a human readable format
(isoformat). It now checks whether the image last_access time is == 0.0
and prints "Not Accessed Yet" if so.

* Updates openstack.common.timeutils
* Fixes bug 1102334

Change-Id: I46f023471ec87fdf74c18f33309279a2f39a4e2a
2013-01-29 18:34:37 +01:00
Brian Waldon 05f1e1a8c4 Separate glance cache client from main client
This is relocating the necessary functionality for the glance
cache management tool into a new client class.

Related to bp separate-client

Change-Id: Ib89db1245aca5032a8d93876e07c562cb1fb5d4d
2012-09-07 17:39:35 -07:00
Brian Waldon 12098c1596 Adding versioned namespaces in test dir
This is being done in preparation for the v2 API.

Change-Id: Ie2fc4df77740b6d1cd629a21942850fd24eb7d60
2012-03-25 13:28:45 -07:00
Eoghan Glynn 62c913c3ad Require container & disk formats on image create
Fixes lp 933702

For images created via the glance CLI, the container and disk formats
were previously defaulted if not explicitly set. However if created via
the python or REST APIs, these attributes were not defaulted if unset.

There is no real sensible default for these formats, so now an image
create fails with 400 "Bad Request" if the format metadata are missing.

Also we ensure unset image metadata are not reported in x-image-meta-*
headers in order to disambiguate None and empty string values.

Change-Id: I8189383f5f9adf42a8cdac7f8dc7e9327baf46da
2012-02-20 18:06:51 +00:00
Eoghan Glynn 5835b30cc2 Avoid the need for users to manually edit PasteDeploy config in order to switch pipelines.
Define multiple pipelines in glace-api.conf to reflect the
various supported deployment flavors (minimal, with caching,
with cache management, with keystone-based auth etc.).

Add an optional paste_deploy.flavor config variable to allow the
user select the appropriate pipeline without having to edit the
paste config (i.e. uncommenting lines as before). For example
in glance-api.conf, a setting of:

  [paste_deploy]
  flavor = keystone+caching

identifies the following pipeline in glace-api-paste.ini:

  [pipeline:glance-api-keystone+caching]
  pipeline = versionnegotiation authtoken auth-context cache apiv1app

the advantage being that the user need not be concerned with
the precise sequence of filters required to realize the QoS
they desire.

Modify the functional tests that patch configuration (i.e. the
keystone and caching tests) to use the new deployment_flavor
mechanism.

Extend the TestConfigOpts to support option groups.

Change-Id: Ide843ada11bce115b7dc650440397853c6409b03
2012-01-17 12:00:33 +00:00
Eoghan Glynn 14593a3b96 Split out paste deployment config from the core glance
*.conf files into corresponding *-paste.ini files.

Fixes LP #815208

Change-Id: I5acb8488cc25bb3c7dd735c8c2b0fe62fcea8e5e
2012-01-17 11:40:26 +00:00
Mark McLoughlin 57c4e9b6c6 Convert glance to use the new cfg module
The changes here are substantial and widespread, but in summary:

  - We use cfg to parse the CLI and config files, rather than optparse
    and PasteDeploy

  - A schema is defined for all configuration options close to the code
    which uses the option

  - 2 ConfigOpts sub-classes are added to config.py basically just
    defining how to find config files; this means we can now use e.g.
    glance.conf for base config values which glance-api.conf can
    override

  - load_paste_app() is changed to load the paste app from the last
    config file in the stack and pass the app the ConfigOpts instance

  - The generic app and filter factories in wsgi.py are modified to
    pass a ConfigOpts instance to the apps and filters

  - A ConfigOpts subclass is added for the unit tests which writes out
    config values to a temporary config file and uses cfg to parse that

I've tried to keep the switch as unobtrusive as possible leaving further
cleanups for later e.g.

  - Moving PasteDeploy config out of the config files - I think it would
    be good to aim for having users modify the PasteDeploy config files
    only in fairly rare circumstances. To achieve this, we might define
    a number of common pipelines in the PasteDeploy config and allow
    the user to choose between those pipelines in the glance config.

  - We should add help strings to all the opts, even just for the sake
    of documenting them

  - We should move a bunch of the options into groups - e.g. all the
    rabbit options

  - We no longer rely on config files for default values, so the default
    config files could contain nothing but comments - i.e. explaining
    each option and showing what the default for it is - making it
    obvious where a user has explicitly set a value

There are a couple of behavioural changes which I don't think are
signifcant but are worth mentioning:

  - We used to support passing a config file as a positional argument
    but don't anymore; AFAICT, it was only used by glance-manage when
    launching servers and I've changed that to pass --config-file

  - log_opt_values() doesn't log unknown opts, so won't log any values
    for opts which get registered at runtime later

Change-Id: Iafa998a2a8d860f1ad57e2cd2afee69686ed58ba
2011-12-08 22:32:52 +00:00
Mark McLoughlin ba44d1c384 Add generic PasteDeploy app and filter factories
These generic factories allow us to dump the copied and pasted
app_factory and filter_factory methods in the codebase.

The main difference is the paste configuration changes from:

  [app:apiv1app]
  paste.app_factory = glance.api.v1:app_factory
  ...
  [filter:cache]
  paste.filter_factory = glance.api.middleware.cache:filter_factory

to this:

  [app:apiv1app]
  paste.app_factory = glance.common.wsgi:app_factory
  glance.app_factory = glance.api.v1:API
  ...
  [filter:cache]
  paste.filter_factory = glance.common.wsgi:filter_factory
  glance.filter_factory = glance.api.middleware.cache:CacheFilter

Apart from reducing code duplication, this will also allow us to have
the generic factories inject other data into the apps and filters.

Change-Id: I1d2be5630ab61d29b8948ff88d58e6e1b11c2e5f
2011-12-07 12:42:03 +00:00
Jay Pipes 8878046089 Fixes LP Bug#837817 - bin/glance cache disabled
This patch removes the cache management commands
from the main bin/glance client and puts them in
a bin/glance-cache-manage program. It also adds
a number of cache management calls to manage the
cache queue via the HTTP API.

The reason I moved the cache management commands
into a separate utility is that I'm thinking towards
the future, where we have a separate admin API, and
having a separate management utility seemed like the
best way to go.

Change-Id: Ic916a72f39516a06be27ea6c8ef69eb9e1a70936
2011-11-15 07:02:02 -05:00