Commit Graph

35 Commits

Author SHA1 Message Date
Cyril Roelandt 71e3c036d7 Deprecate the "glance-cache-manage" command
Change-Id: I5fe40f1ebd6acd25d4ed2e05d20a409511be08af
2024-01-23 17:55:12 +01:00
Stephen Finucane 931809c037 Remove remaining six.moves usage
Change-Id: Ibca3884e1ea3d0fb170bcc9e70a176d144ee24cc
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 16:37:11 +00:00
Hervé Beraud 64e3c41167 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I82b61a2d7687ff109051815e01619eb612ea9073
2020-06-02 20:14:31 +02:00
Dirk Mueller 595c1b17ff
Raise hacking to latest 2.0.0 release
We were capped at a very old version of hacking. Hacking itself caps the
various linters it uses to remain consistent, so our pep8 job was not
checking quite a bit that current versions have added.

This raises that limit to the latest to get up to the level of other
projects and addresses the errors the updated linters uncovered.

Change-Id: I89a9d73fbd59606a649e26077acebc5c42873d67
Co-authored-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-27 14:11:08 -05:00
Abhishek Kekane d03e80a735 Add cache-manage utility using v2 API
In Rocky, the v1 dependent glance-cache-manage command was removed while
removing Images API v1 entry points.

As a part of edge-computing image caching will play a big role. To
provide support of image caching, added cache-manage utility using
V2 API. This utility will have the same interface as Queens
glance-cache-manage utility [0] as far as possible.

[0] https://docs.openstack.org/glance/queens/cli/glancecachemanage.html

In addition to above command line options added below new options for doamin
information to use in v3 authentication:
--os-domain-id
--os-user-domain-id
--os-project-domain-id

Implements: blueprint cache-manage
Change-Id: I127c84f8ea610cc20eb3ac2f4f6a9a47a7233f5f
2019-02-27 06:43:13 +00:00
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
Sean McGinnis 1c13d8a232 Remove use of deprecated optparse module
The optparse module has been deprecated for some time and all apps
should be updated to use argparse instead. This switches our one
remaining command that was using it to the newer argparse usage.

Change-Id: I8f801fb804515ecf2a8b402b2923135379730098
Closes-bug: #1553030
2017-10-01 07:08:00 -05:00
sudhir_agarwal c078cc2b6f Remove unused None from dict.get()
Since the default value is None when can't get a key from a dict,
So there is no need to use dict.get('key', None).

Change-Id: Ie8008e83f432263e7a97e482e83f240b1056feee
2017-07-05 12:49:10 +00:00
Chen Fan a83653ee97 cache_manage: fix a print bug in exit main
There is no output print format symbol %, add it and for
man exit, we should use sys.exit

Change-Id: I16cfded354a5a4a10c0524fd5b7cb9f4f9c9e6dd
2016-08-01 14:07:14 +00:00
Bertrand Lallau 4ad190bc13 Remove unnecessary executable permissions
Removes executable permissions on python modules not requiring it.

Change-Id: I6d930ea1fc62433377959257f0a0e5e3da11d97c
2016-05-23 21:48:22 +02:00
Julien Danjou d8afed9c46 utils: remove PrettyTable custom class in favor of the eponym libary
Change-Id: Ic981f4d6085dcddbfce23c988fc145058a0f4b43
2016-01-26 10:18:04 +01:00
wangxiyuan 5d9814d38c Fix help command in cache manange and replicator
Now, 'glance-cache-manage help' and 'glance-replicator help' don't
work. They returned wrong result. It is not user friendly at all.

Closes-bug: #1533927
Change-Id: I9b5ff7eaff4b27a5e964231dd4dfbf02a3fac7db
2016-01-22 11:08:15 +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
Victor Stinner 1c186e23fd Use oslo_utils.encodeutils.exception_to_unicode()
* Replace glance.common.utils.exception_to_str() with
  oslo_utils.encodeutils.exception_to_unicode().
* Remove exception_to_str() from glance.common.utils
* Add "from oslo_utils import encodeutils" and remove "from
  glance.common import utils" (when utils is no more used)
* glance/api/v2/images.py: replace utils.exception_to_str() with
  six.text_type() to cast the oslo_i18n message to Unicode

Glance exception_to_str() function was not compatible with Python 3,
whereas exception_to_unicode() is compatible with Python 3, it's in Oslo
common libraries and it's well tested.

This patch was first generated by a tool (modified version of sixer),
and then fixed to respect the PEP8 (especially the constraint of 80
columns).

Change-Id: I86008c8adc0c5664f96573c1015cc15e2d06e3e2
2015-07-17 18:31:03 +02:00
Victor Stinner 6652f4b029 Fix Python 3 issues
* Replace unicode with six.text_type
* Replace "raise a, b, c" with six.reraise(a, b, c)
* Replace dict.iteritems() with six.iteritems(dict)
* Replace StringIO.StringIO with six.BytesIO for image content
* Get AssertionError from builtins, don't use the exceptions module
  which was removed in Python 3
* Open configuration file in text mode (not in binary mode) in
  functional tests
* Use absolute imports in artifacts_sample and image_artifact plugins
  instead of relative imports.
* Fix usage of __import__() function: the level parameter expects a
  positive integer, use level=0, not level=-1
* Get the input function from six.moves: use raw_input() on Python 2 and
  input() on Python 3. raw_input() was renamed to input() in Python 3.
* Unpacking parameters in function definition is no more possible:
  unpack the tuple manually in test_glance_replicator.py
* On Python 3, socket.fromfd() now returns directly the right socket
  type. It's not more needed to cast manually the result of
  socket.fromfd().

For more information on Python 3, see:
https://wiki.openstack.org/wiki/Python3

Change-Id: Iaa1a392590154058eab4645fb288d1534f66e528
2015-06-12 09:15:02 +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
Julien Danjou 874e643549 Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
2014-10-07 14:55:57 +02:00
Christian Berendt 1069159701 remove default=None for config options
In the cfg module default=None is set as the default value.

Change-Id: Iad40a7bacef410e54d684cb438d4459f828f70df
Closes-Bug: #1323975
2014-05-28 08:52:34 +02:00
Leandro I. Costantino 627d5fbc13 Replace unicode() for six.text_type
To support Python3, unicode() calls has been replaced by
six.text_type.
Added utils.exception_to_str(): is the proper way to convert
an exception to string, since it manages logic related to
encoding.

Change-Id: I27101390e4f95e5c7690b1b445b7e75b8bcb9a08
Closes-Bug: #1284677
2014-05-05 15:40:02 -03:00
Andreas Jaeger bccda7adf6 Improve help strings
Follow oslo.config style guide for help strings better to create
consistent help strings:
* Capitalize first word of each help string
* Finish help strings with "."

Change-Id: Iac0a0fc0ea6c0cf23f2523fe6030a842810b6909
2014-02-09 21:56:52 +01:00
Jenkins 9c0ada37c9 Merge "Bump hacking to 0.8 and get python 3.x compatibility" 2014-01-16 01:44:54 +00: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
Sergio Cazzolato 2eca65eb5f Bump hacking to 0.8 and get python 3.x compatibility
Bump hacking dependency to 0.8 to get python 3.x compatibility
Fixes done in order to avoid errors after enabling hacking 0.8

Change-Id: Ic878fe2e1bd3f65f7f95a9b5c7a192dac81b749d
Closes-Bug: #1257282
2014-01-09 23:25:22 -05: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
Jenkins 93edd1bdc6 Merge "Changed header from LLC to Foundation based on trademark policies" 2013-11-12 13:41:45 +00:00
Dirk Mueller 6ba3ebbf8d Start using PyFlakes and Hacking
Instead of globally ignoring Pyflakes and Hacking
warnings, blacklist explitly only those that trigger
numerously. Fix the rest alongway and start to gate
on those that are now passing.

Change-Id: Ia19dc708cf0ccab2da5b46d1652f16e901499c24
2013-11-05 14:23:53 +01: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
Chang Bo Guo e8e293d43e Use built-in print() instead of print statement
In python 3 print statement is not supported, so we should use
only print() functions.

Fixes bug 1226943

Change-Id: I0ae4cc7e5996ed30c69e153ba51438c56e56c09a
2013-09-24 08:12:26 -07: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
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
Jenkins 54ab0ce0f4 Merge "Remove references to clean arg from cache-manage" 2013-07-22 21:50:16 +00:00
Paul Bourke 84bf7e057a Remove references to clean arg from cache-manage
The usage message for glance-cache-manage lists "clean" as an available
command, but this functionality is part of a separate tool,
glance-cache-cleaner.

Remove any references to this to avoid confusion.

DocImpact
Fixes bug 1189451

Change-Id: I2aba8164ab9ef0c3bef31870cb3771233a722d27
2013-07-15 16:12:43 +00:00
Paul Bourke bd2ca4f982 Fix 'glance-cache-manage -h' default interpolation
Some options were showing up as %(default)s when running
"glance-cache-manage -h".

Fixes bug 1197472

Change-Id: I1c7586cbc52445e3bdca28a71378f40ecb5b07a9
2013-07-03 16:56:21 +00:00
Mark McLoughlin a0209e8757 Add GLANCE_LOCALEDIR env variable
Part of fixing bug #995287

Syncs these two commits from oslo-incubator:

  Support overriding oslo localedir too
  Add a gettextutils.install() helper function

to get a new gettextutils.install() function which allows the default
localedir to be overwritten via an environment variable.

Note that gettextutils.install() must be called before any other glance
modules are imported since some modules attempt to translate strings
at import time (e.g. the help strings for config options in config.py).
This is broken and inefficient, but fixing it involves adding something
like spinx's l_() function and would be very invaisve.

Also, note that calling gettextutils.install() in glance.cmd.__init__
means that no program which uses a different translation domain should
ever import any of the modules under glance.cmd.

Change-Id: I86562b3a65d371673bb21f7179eecc7602bc0775
2013-05-08 09:23:32 +01: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