Commit Graph

52 Commits

Author SHA1 Message Date
Abhishek Kekane b6bd03d4bc Add new tables for cache operations
Added expand script and model to define `cached_images` and
`node_reference` database tables.

Related blueprint centralized-cache-db

Change-Id: I9991a4e945bd4d231e942096445fd5374ff7ff2a
2024-02-09 08:40:46 +00:00
Stephen Finucane 5636008dfe db: Update import location of declarative_base
This moved in 1.4.

Change-Id: Ie3d30669dffd80aa21025a7a407c373b80b2e3cc
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-07-24 17:14:22 +01:00
Abhishek Kekane 6f20983ff8 Expand tasks database table to add more columns
Added 3 new columns 'image_id', 'request_id' and 'user_id' to task
table. This is a base patch for adding new API to show task
information to the user.

Partially-Implements: blueprint messages-api
Change-Id: I4946c25375f1dc54d8f550f21c97bdf5b3005877
2021-02-24 05:13:23 +00:00
Brian Rosmaita 0b24dbd620 Multihash implementation for Glance
Partially implements blueprint multihash.

Requires glance_store 0.26.1

Co-authored-by: Scott McClymont <scott.mcclymont@verizonwireless.com>
Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com>

Change-Id: Ib28ea1f6c431db6434dbab2a234018e82d5a6d1a
2018-07-31 21:28:38 -04:00
Abhishek Kekane a308c44406 Hide old images
Added new boolean column "os_hidden" in images table. Images where
"os_hidden" = True will be omitted from the image list presented
to the user. This will apply to all image visibilities. However,
the images will continue to be discoverable. User can use
filter "os_hidden=true" in GET v2/images call to see all hidden
images.

Implements: blueprint hidden-images
Change-Id: If8f02ca94fdb8e1ac7a81853cd392988900172d1
2018-07-25 16:37:56 +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
Mike Fedosin 2e2adb3935 Fix model sync for SQLite
This code fixes the situation when several
models are mismatched for SQLite because of
type inconsistencies between Integer and
BigInteger in sqlalchemy.

Change-Id: I52b3a0158db8e3dc48f19509d1f9f80420ee40ea
Closes-bug: #1526804
Closes-bug: #1526675
2015-12-17 20:35:06 -04:30
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
Jenkins 97145e66ed Merge "OpenStack typo" 2015-11-27 14:05:45 +00:00
Shuquan Huang c6f7d39e48 OpenStack typo
According to the word choice convention in
http://docs.openstack.org/contributor-guide/writing-style/word-choice.html
We should use OpenStack instead of Openstack.

Closes-bug: #1516634

Change-Id: If4fd264635549c5b21c80e91b606142c5f9ae3a4
2015-11-17 10:43:20 +08:00
Steve Lewis a4c6f12636 Support new v2 API image filters
Provide support in Glance API for querying the image list for
created_at and updated_at times using guidance from the API Working
Group recommendations for filtering. Filtering is applied at the DB
layer.

DocImpact
ApiImpact
MitakaPriority
Change-Id: Ie94295bb82779ec17ab773928c71ae4a9ee8fbcc
Implements bp: v2-additional-filtering
2015-11-16 15:45:17 -08:00
Flavio Percoco 647d2895a7 Make utf8 the default charset for mysql
Newer versions of oslo_db added a sanity check to ensure that table's
charsets are utf8. This patch makes this change explicit and re-enables
the sanity check that was disabled in Ifffbdd50c38a1d25215faa6a966c2d2a63935711

Change-Id: Icbc41bd3964a6124d3e0d906cb85944fdc312844
Closes-bug: #1411489
2015-07-17 18:49:43 +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
Louis Taylor e42fad7385 Move from oslo.db to oslo_db
oslo_db was moved out of the oslo namespace in
oslo.db>=1.4.0.

Change-Id: I13620d26ff12c55b2294b3b051669e0e98513a10
Related-to: blueprint drop-namespace-packages
2015-01-12 19:03:20 +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
Oleksii Chuprykov 9def368d07 Alter models and add migration
We must have correct models i.e. models that correspond
a database schema to use sqlalchemy features.
Update models.py and add migration script to correct
database schema and get rid of the difference between
schema and models.

Partial-Bug: #1365436
Change-Id: I9b4571906d39bcdb35048caa58d16ad5e888cce4
2014-11-25 17:17:15 +02: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
Eugeniya Kudryashova 6185e9d97e Move to oslo.db
Replace common oslo code glance.openstack.common.db
by usage of oslo.db library and remove common code.

Change-Id: I27216e03763f72e8665121d4440ba2828349eac5
2014-07-21 12:31:10 +03: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
Victor Sergeyev 99f4ad8172 Sync common db code from Oslo
This sync contains commit ``ce69e7f Don't store engine instances in oslo.db ``
which removed global engine from oslo.db code. So, added code
for work with sqla engines and sessions to Glance - get_engine()
and get_session() functions in glance.db.sqlalchemy.api module.

Also this remove database slave connection and tpool features, because
they was removed from oslo code and seeps to be unused in Glance.

Full list of changes:

7959826 db: move all options into database group
dda24eb Introduce mysql_sql_mode option, remove old warning
0b5af67 Introduce a method to set any MySQL session SQL mode
8dccc7b Handle ibm_db_sa DBDuplicateEntry integrity errors
0f24d82 Fix migration.db_version when no tables
ac84a40 Update log translation domains
c0d357b Add model_query() to db.sqlalchemy.utils module
84254fc Fix a small typo in api.py
b8a676c Remove CONF.database.connection default value
86707cd Remove None for dict.get()
0545121 Fix duplicating of SQL queries in logs
fcf517d Update oslo log messages with translation domains
fa05b7c Restore the ability to load the DB backend lazily
630d395 Don't use cfg.CONF in oslo.db
ce69e7f Don't store engine instances in oslo.db
35dc1d7 py3kcompat: remove
b4f72b2 Don't raise MySQL 2013 'Lost connection' errors
271adfb Format sql in db.sqlalchemy.session docstring
0334cb3 Handle exception messages with six.text_type
eff69ce Drop dependency on log from oslo db code
7a11a04 Automatic retry db.api query if db connection lost
11f2add Clean up docstring in db.sqlalchemy.session
1b5147f Only enable MySQL TRADITIONAL mode if we're running against MySQL
39e1c5c Move db tests base.py to common code
986dafd Fix parsing of UC errors in sqlite 3.7.16+/3.8.2+
9a203e6 Use dialect rather than a particular DB API driver
1779029 Move helper DB functions to db.sqlalchemy.utils
bcf6d5e Small edits on help strings
ae01e9a Transition from migrate to alembic
70ebb19 Fix mocking of utcnow() for model datetime cols
7aa94df Add a db check for CHARSET=utf8
aff0171 Remove "vim: tabstop=4 shiftwidth=4 softtabstop=4" from headers
fa0f36f Fix database connection string is secret
8575d87 Removed copyright from empty files
d08d27f Fix the obsolete exception message
8b2b0b7 Use hacking import_exceptions for gettextutils._
9bc593e Add docstring for exception handlers of session
855644a Removal of _REPOSITORY global variable.
ea6caf9 Remove string.lowercase usage
a33989e Remove eventlet tpool from common db.api
e40903b Database hook enabling traditional mode at MySQL
f2115a0 Replace xrange in for loop with range
c802fa6 SQLAlchemy error patterns improved
1c1f199 Remove unused import
97d8cf4 Remove lazy loading of database backend

Co-authored-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>

Related to blueprint db-use-oslo-common-code

Change-Id: Ia73abba8309ccc2ad10a0f636b410984c6b6e5d8
2014-02-27 14:14:21 +02:00
Flavio Percoco 1679422e0a Add a virtual_size attribute to the Image model
In order to distinguish file size from the virtual image size, we need
to add a new field to the Image model to represent that. This patch adds
a new field called `virtual_size` to the Image model and the migration
for it.

The existing size attribute is kept as is in order to keep backwards
compatibility. Most of the users consider that attribute to be the
physical image size, which is what we're trying to achieve here.

The API implementation will be done in a follow-up patch.

Partially-Implements bp: split-image-size

Change-Id: Ie968e8bcfaeda79de003fe8fd7a3b58c3e45f592
2014-02-13 15:13:10 +01:00
Zhi Yan Liu 30f6260711 Adding status field to image location -- DB migration
Adding a status field to image's each location property, each location
status can be 'active', 'pending_delete' and 'deleted'.

Under location's status information Scrubber service can make cleanup
based on DB records also but not a dedicated queue-file for each image.

This is first part of this change which covered DB core migration.

Partially-Implements BP: image-location-status

Change-Id: I013b70d55ef14a3ceaca962f9bc48296cb8b2552
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-01-29 22:47:35 +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
Nikhil Komawar c107b6953d Cleans up imports in models.py
Some of the imports were placed in incorrect order.

Change-Id: I14555b5c3bd6871d4b1e0cea7e03c191ffd6cf33
2014-01-10 14:41:44 -05: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
Boris Pavlovic 048a40c0b5 Use common Oslo database session
Use common oslo database code for work with session, connection, engines
instead of glance implementations.
Work with config options modified due to new common code config.
Removed unused glance code and tests for it.

Details:

glance/cmd/manage.py
- removed load load the glance-registry config. We load sql connection
  in common code now.

glance/db/sqlalchemy/api.py
- removed functions _wrap_db_error(), _is_db_connection_error(),
  _get_maker(), get_engine(), _ping_listener() and config
  `sql_connection_opt`. We have all these thigs in module
  `glance.openstack.common.db.sqlalchemy`.
- modified functions setup_db_env(), add_cli_options(), clear_db_env().
- functions _get_session() and get_engine() now call same functions
  from module `glance.openstack.common.db.sqlalchemy`.
- replaced sqlalchemy exception `sqlalchemy.exc.IntegrityError` to
  database duplicate exception - `db_exc.DBDuplicateEntry`.

Removed redundant tests - we use common code , so a lot of features was
already tested in Oslo.

Global variable _ENGINE was replaced by common function get_engine().

DocImpact
New database config options came from Oslo. See Table below
-------------------------------------------------------------------
Database config options ([group] option)
-----------------------------|-------------------------------------
       Glance                | Oslo
-----------------------------|-------------------------------------
[DEFAULT] sql_connection     |  [database] connection
[DEFAULT] sql_idle_timeout   |  [database] idle_timeout
[DEFAULT] sql_max_retries    |  [database] max_retries
[DEFAULT] sql_retry_interval |  [database] retry_interval
[DEFAULT] db_auto_create     |  NONE
[DEFAULT] sqlalchemy_debug   |  [database] connection_debug
[DEFAULT] use_tpool          |  [database] use_tpool
NONE                         |  [database] slave_connection
NONE                         |  [database] min_pool_size
NONE                         |  [database] max_pool_size
NONE                         |  [database] slave_connection
NONE                         |  [database] min_pool_size
NONE                         |  [database] max_pool_size
NONE                         |  [database] max_overflow
NONE                         |  [database] connection_trace
NONE                         |  [database] pool_timeout
-------------------------------------------------------------------

blueprint db-use-oslo-common-code

Change-Id: I3ff976545b1a82ff8df780e34128fcaf6f892b8c
2014-01-03 05:37:41 +04: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
Nikhil Komawar 21cfc3f465 Makes tasks owner not nullable in models.py
The tasks table scheme in migration for adding tasks to Glance DB has a
flag for disabling from setting a NULL owner.

In order to keep the behavior consistent across the glance codebase,
this patch adds owner as not nullable in the models.py.

Fixes bug: 1257949

Change-Id: Id9fff4277f427b7d83d80b5a0a8029968f70e0df
2013-12-05 17:01:01 -05:00
Venkatesh Sampath c3ebafa795 Introduce Task Info Table
- move 'input', 'message' and 'result' columns to table 'task_info'
- introduce migration script for the above db changes.
- appropriate tests are included

Co-authored-by: Nikhil Komawar <nikhil.komawar@rackspace.com>

partly implements bp async-glance-workers

Change-Id: I9867d609f4729572b72a44d1f05e353acf6c98d9
2013-12-05 16:30:38 +00:00
Victor Sergeyev 9a1049f9f6 Use common db model class from Oslo
Modified common model class - added common `models.ModelBase` and
`models.TimestampMixin` classes as base class instead of object.
Renamed base model class from `ModelBase` to `GlanceBase`.
Removed duplicated code.

blueprint db-use-oslo-common-code

Change-Id: I6038adcfcb6b985736ac8d9374ac0a2fe1cdcc96
2013-11-25 17:16:48 +02: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
Fei Long Wang 6abd845ca7 Enable tasks data model and table for async worker
Add tasks data model and table for async worker to
store the tasks data persistently.

Partially implement blueprint async-glance-workers

Change-Id: I2b2d70295da4905bf75cffc2b2eadec174d1abfc
2013-10-17 00:46:59 +08:00
John Bresnahan 60ab0c8c56 Convert location meta data from pickle to string.
This patch fixes a potential security issue.
Fixes bug: 1213241

Change-Id: I6414d16ec72f26ceabbaf1364ad737f19f18381e
2013-09-13 12:11:34 -10:00
Venkatesh Sampath 677d1b0775 add missing index for 'owner' column on images table.
Fixes bug 1214830

Change-Id: I13355cd53460188a5154aa3f50277c3e92335e28
2013-09-05 12:13:55 +05:30
Jenkins 1ed4feca1d Merge "Sync models with migrations" 2013-08-29 01:47:56 +00:00
Fei Long Wang d203d4d3be Implement image query by tag
Sometimes, user want to query images by tag since it's an
intuitive way to distinct different image. The REST API
would be like: v2/images?tag=x86&tag=64bit

docImpact
Implement bp image-query-by-tag

Change-Id: I42946fa838ed896823e17fd4c51995209d9d2ad3
2013-08-22 07:37:27 +08:00
Jasakov Artem ed9e6c0acb Sync models with migrations
Models should be the same as the state in DB after migration
blueprint db-sync-models-with-migrations

Change-Id: Iea57866206776c14677dfa78e868143b6fb153a9
2013-07-31 12:11:25 +04:00
Amala Basha 5670f142d4 index checksum image property
checksum image property will be indexed so that users can search for an
image by specifying the checksum

Change-Id: I31543afed31512f8f5f613640012bc7c1d7ea993
Implements: blueprint index-using-checksum-image-property
2013-07-16 16:21:34 +05:30
John Bresnahan 89e9043fba Add location specific information to image locations db
This patch adds a column to the image_locations table.  The column
will store location specific information.  As a location is added
to an image there may be some meta data about that information that
needs to be stored with it.  For example, if it is a file:// URL,
information about the NFS server (host name, mount point) would be
needed in order for the URL to be useful.

blueprint: direct-url-meta-data
blueprint: multiple-image-locations

Change-Id: I6a96163abc8e4388e84cae2a8952f89d433210ff
2013-07-09 06:49:10 -10:00
Flaper Fesp f72ed76ed8 Implement registry API v2
This patch implements registry's API v2 based on the blueprint
registry-api-v2.

Major changes:
    * The new registry API is implemented using a small rpc protocol
      over http. Resources must be registered and the exposed methods
      will be automatically discovered (they must start with rpc_).
    * Registry's API now returns data as returned by the db-api. The
      idea behind this is to provide a db-like api that can be used as a
      db-driver leaving to glance-api the responsibility for cleaning
      up what will go out to the client.

Minor changes:
    * Split unit/v1/test_api.py in 2 separate test files (for
        consistency with v2 unit)
    * Added test_registry to unit/v2/

Implements blueprint registry-api-v2

Change-Id: Ia9f6eb60f52bb093e807a8a89d4df89fb80c4336
2013-05-07 00:59:11 +02:00
Flaper Fesp 9449f90d21 Make "private" functions that shouldn't be exported
Currently, the db_api defines some functions that are used for accessing
images data but some of them are for internal use only. In an effort to
improve consistency, I've made some of those functions - the ones that
are not accessed outside the db_api - private by prepending their names
with an "_".

Most of this functions were defined within sqlalchemy and as such didn't
required any change in the simple driver, others though, required a
change in both drivers, i.e. get_session.

This patch implements part of the blueprint registry-api-v2.

NOTE: During the review, try to find functions that should be private
and haven't been changed.

Change-Id: I6342dc94ebf2a35d6bc9bd7698b81a94ffa13373
2013-04-12 11:04:53 +02:00
Eoghan Glynn c4f97dfa6e Fix uniqueness constraint on image_members table.
Fixes bug #1098700.

Previously, deleting then re-creating an image member failed with
500 ServerError due to the registry service failing to commit
the update to the image_members table.

The problem arose because the declared uniqueness constraint on that
table only spanned the image_id and member columns, but did not take
into account that deleted rows are left in situ with the deleted_at
and deleted columns set as appropriate. Hence the unique constraint
was violated by the addition of the new row.

We modify the uniqueness constraint via a migration script to take
account of the deleted_at column also (NULL for live memberships).

Note that the new ability to recreate an image membership cannot be
be asserted in a functional test, as these tests are based on sqlite
which does not support 'ALTER TABLE DROP CONSTRAINT'.

Change-Id: I175801ba95ecd9295791bb12e9096f59efa19c02
2013-03-13 16:03:12 -07:00
Jenkins f400a54232 Merge "Declare index on ImageMember model" 2013-03-13 21:55:08 +00:00
Mark J. Washenberger eff956b6c8 Declare index on ImageMember model
This index was added in migration 008. However, it was not on the model,
which meant any autocreated db would not have it.

Fixes bug 1154777

Change-Id: I34590ffebaf547be9a12e5a85216cda145d9e8db
2013-03-13 13:33:14 -07:00
Alessio Ababilov 43c0a7ea54 Fix circular import in glance/db/sqlalchemy
Fix running test_migration solely.

api.py depends on models.py that depends on api.py.
Import statements in these files are such that api.py
must be imported before models.py. That's why usually
test_migrations doesn't fail when all tests are launched.
However, thus test_migration depends on test running order
making testing procedure unreliable, including parallel testing.

Move glance.db.sqlalchemy.api import to the only place
where it's required in models.py

Change-Id: Ib20dde8edd3473595aac1ca8bbaa5a0d3116a697
Fixes: bug #1154058
2013-03-12 14:46:20 +02:00
Brian Waldon fd9d069a6e Add migration 19 - move image location data
Migration 19 moves image location data from images.location to
the new image_locations table. The sqlalchemy db driver has been
updated to look at this new table, but the complexity of multiple
locations is not yet exposed to the reset of the system.

Related to bp multiple-image-locations

Change-Id: I6c4c684f522d9b41b9930e7f79a4e6fb3e3f5c39
2013-02-20 14:35:44 -08:00
isethi b4b126d41c Add status column to image_members
Related to bp glance-api-v2-image-sharing

Change-Id: Id8896f9dcb717ab8a466829b3b1cd9fde4b67a36
2013-02-15 15:58:48 +00:00
Alex Meade a26f3613ba Use generate_uuid from openstack common.
Change-Id: Ie1b55df2301b5ca276571117386a0625e039adc2
2012-11-12 15:39:58 -05:00