summaryrefslogtreecommitdiffstats
path: root/nova/db/sqlalchemy/models.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Sync db.models with migrations."Jenkins2013-07-011-21/+32
|\
| * Sync db.models with migrations.Svetlana Shturm2013-07-011-21/+32
| | | | | | | | | | | | | | | | | | | | | | | | This patch syncs models with migrations for: - Snapshot - SnapshotIdMapping - TaskLog - VirtualInterface Blueprint: db-sync-models-with-migrations Change-Id: I4f2d5d4ca16f63522d6ebd70661992e4013085f0
* | Merge "Sync db.models and migrations."Jenkins2013-07-011-11/+22
|\ \
| * | Sync db.models and migrations.Svetlana Shturm2013-06-251-11/+22
| |/ | | | | | | | | | | | | | | | | | | | | This patch syncs models with migrations for: - DNSDomain - AggregateMetadata - BandwidthUsage Blueprint: db-sync-models-with-migrations Change-Id: I09c48bac5ed780a7ec1b89cc8ce0684f4903d9dd
* / Sync db.models.Quota* with migrations.Svetlana Shturm2013-06-201-8/+15
|/ | | | | | Blueprint: db-sync-models-with-migrations Change-Id: Ic97690b650151eb7086cbd40093c0f3c373133e2
* Add unique constraints to Cell.Yuriy Zveryanskyy2013-06-171-0/+4
| | | | | | | | | | | | | In documentation: "name: Name of the current cell. This must be unique for each cell" Added unique constraint 'uniq_cell_name0deleted' ('name','deleted') to Cell model and migrate sripts. Added new exception `CellsExists`. Updated cell_create() in db.api. Tests updated respectively. blueprint db-enforce-unique-keys Change-Id: Ib76e167089cb4756e4438613b49013ebf0874afe
* Fix and enable H403 testsDirk Mueller2013-06-121-1/+2
| | | | | | Multi-line doc-strings should end on a new, separate line. Change-Id: I4cf0cfe92b634ef77971863a4df41ef43531bc20
* Merge "Give a way to save why a service has been disabled."Jenkins2013-06-121-0/+1
|\
| * Give a way to save why a service has been disabled.Andrea Rosa2013-06-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements blueprint record-reason-for-disabling-service We added a field to the service table to log a reason when a service has been disabled. We added a new API extension called os-extended-services. The new extension will extend the os-services extension adding: - A method for disabling a service and specify a reason for that. PUT /v2/{tenant_id}/os-services/disable-log-reason When the os-extended-extension is loaded the call: GET /V2/{tenant_id}/os-services will return the list of services with reason information it that exists. DocImpact Change-Id: I87a4affc45160796ff11c7b03e591e6aba73d62a
* | Merge "Fix db.models.Instance description"Jenkins2013-06-121-41/+55
|\ \
| * | Fix db.models.Instance descriptionBoris Pavlovic2013-06-081-41/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table Add 6 missing indexes in Instance model definition. blueprint db-sync-models-with-migrations Change-Id: I01025789f00dcf058754ee1def726e3b48ec7fda
* | | Merge "Fix db.models.Certificate description"Jenkins2013-06-121-3/+7
|\| |
| * | Fix db.models.Certificate descriptionBoris Pavlovic2013-06-081-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table Add 2 missing indexes in Certificate model definition. blueprint db-sync-models-with-migrations Change-Id: Ida607c2b8899e145116d46cffdc49b7176b05550
* | | Merge "Fix db.models.ComputeNodeStats description"Jenkins2013-06-121-4/+11
|\| |
| * | Fix db.models.ComputeNodeStats descriptionBoris Pavlovic2013-06-081-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table Add 2 missing indexes in ComputeNodeStats model definition. blueprint db-sync-models-with-migrations Change-Id: I10761a6c1b32a457c855aff9603bf2edec44de17
* | | Merge "Fix db.models.ComputeNode description"Jenkins2013-06-121-15/+16
|\| | | |/ |/|
| * Fix db.models.ComputeNode descriptionBoris Pavlovic2013-06-081-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table There is no indexes in ComputeNode model definition. blueprint db-sync-models-with-migrations Change-Id: I13c92bdd33eede97bb7b2fc45cbedca556992060
* | Nova instance group DB supportGary Kotton2013-06-111-0/+69
| | | | | | | | | | | | DB support for blueprint instance-group-api-extension Change-Id: I615af9826ef61fd63d4cd8017908f943969bf177
* | Merge "DB migration to the new BDM data format"Jenkins2013-06-111-4/+12
|\ \ | |/ |/|
| * DB migration to the new BDM data formatNikola Dipanov2013-06-101-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch migrates the DB to the new data format. In addition it also utilizes routines introduced in the change I9370333059b8c9aaf92010470b8475a913d329b2 in a way that will allow us to transition into using the new data in Nova logic one step at a time. This is accomplished in a following manner in the DB/conductor layer, which is supposed to allow for subsequent changes to be as granular as possible: * Read operations - data is always read as is found in the DB - meaning in the new format, and transformed after every call. This will allow us to make granular changes in the API/Compute layers. * Data is converted inside the DB methods that do writes, and an additional 'legacy' flag is added (set to True by default). It is up to the calling method to make sure it supplies the DB layer with the format it is intending to write, to avoid guessing. An exception to the above is when using conductor due to rpcapi versioning, so this patch adds a 'legacy' flag to the block_device_mapping_get_all_by_instance conductor method and bumps the version of the API. This patch also fixes some of the block device fixtures in tests, when it was required to be aware of the new data structure (mostly when mocking DB methods that return the new data format). This patch is not supposed to provide any new functionality to Nova. blueprint: improve-block-device-handling Change-Id: If30afdb59d4c4268b97d3d10270df2cc729a0c4c
* | Fix db.models.Service descriptionBoris Pavlovic2013-06-081-3/+5
|/ | | | | | | | | | | | | | | | | | | | DB models definition should be up-to-date with DB schema obtained after applying of migrations. Currently, there are no tests enforcing this and it's really hard to analyze what indexes should be added, and what indexes we have at the moment. So the first step is it to fix all models, and add missing descriptions about Indexes and UniqueConstraints in __table_args__ and use explicit 'nullable' parameter in columns description. Add missing 'nullable' parameters to all Columns Add empty __table_args__ parameter to Table There is no indexes and no unique constraints in this table at this moment. blueprint db-sync-models-with-migrations Change-Id: I9b31e8976f514e370d6b46076b469fe5e5c8e0f1
* Rename unique constraints due to new convention.Victor Sergeyev2013-06-071-3/+40
| | | | | | | | | | | | | | | | | | | We have found that current constraint name convention allows us to create constraints with duplicate names. It happens if we add constraints in different tables with the same column names (for example, `name`, `deleted`). In this case we can not create new constraint in mysql due to database limitation (it requires constraint name to be unique within a database). To solve this issue unique constraint name convention has been changed from "uniq_c1_x_c2_x_c3" to "uniq_t0c10c20c3" where `t` is a table name and columns `c1`, `c2`, `c3` are in UniqueConstraint. Fixed unique constraints in models description. Synced db code from oslo (function `_raise_if_duplicate_entry_error()` modified respectively to new unique constraint name convention). blueprint db-enforce-unique-keys Fixes: bug 1182054 Change-Id: I4122dfb910a07a1a423781ebc22e9ce50596a05d
* Add missing unique constraint to KeyPair model.Victor Sergeyev2013-05-141-0/+1
| | | | | | | | | Added a missing unique constraint ("name", "user_id") to KeyPair model (this constraint was in db schema but not in model definition). blueprint db-enforce-unique-keys Change-Id: Id231bca256e0cb39fcd8068acc7039240326fde2
* Add the availability_zone to the volume.usage notificationsMichael Kerrin2013-04-301-0/+1
| | | | | | | | | | | | The volume.usage notifications are used to enable traffic based billing on volumes. The availability_zone of the instance is an important piece of information that can enable more specialized billing of customers. This makes the volume.usage events consistent with the volume.create.start/end snapshot.create.start/end, etc. emitted from cinder, which contain the availability_zone field. Change-Id: I9b6b03174cd03235d0e6cf01e34a6da13bd9bb70
* Update NovaBase model per changes on oslo.db.sqlalchemyZhongyue Luo2013-04-271-2/+4
| | | | | | | | | | | Fixed NovaBase to inherit from models.TimestampMixin Added metadata attribute Added db.sqlalchemy to openstack-common.conf Oslo sync command: python update.py --modules db.sqlalchemy --base nova --dest-dir ../nova Change-Id: Ie4ad8e8b235e146ddb946cdf7f15d74e060ee4a3
* Add tenant/ user id to volume usage notificationsOllie Leahy2013-04-091-1/+3
| | | | | | | | | | Volume usage notifications are generated to enable traffic based billing on volumes. Include tenant id and user id to make these notifications more useful to billing systems. Fixes bug # 1158292 Change-Id: Ic71c10f0fc5d9e8c5a0e2f538de072e7ccca20ee
* Merge "Don't load system_metadata when it isn't joined."Jenkins2013-03-131-1/+1
|\
| * Don't load system_metadata when it isn't joined.Vishvananda Ishaya2013-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we always load system_metadata, it will throw a sqlalchemy error if it isn't joined in the column. Rather than putting it in extra keys we need to explicitly join it if it is missing. Adds a test to make sure that system_metadata is returned properly from the migration call even though the extra keys parameter was removed. Fixes bug 1146000 Change-Id: I05365906ed528a06fe5704449dab72c857fefa65
* | Remove instance['instance_type'] relationship from db apiDan Smith2013-03-111-7/+0
|/ | | | | | | | | | | | This removes the entire relationship between an instance and the flavor it was created from. As such, it removes two tests entirely which examined the old behavior. This is one change in a series aimed at removing the use of instance-linked instance_type objects, in favor of the decoupled type data in system_metadata. See bug 1140119 for more details. Change-Id: I8b525a900bf2dc6b193e54aae35fc32248e4cff4
* Merge "Shrink size of aggregate_metadata_get_by_host sql query"Jenkins2013-02-281-18/+5
|\
| * Shrink size of aggregate_metadata_get_by_host sql queryJoe Gordon2013-02-281-18/+5
| | | | | | | | | | | | | | | | | | | | | | * Remove unnecessary secondary joins in Aggregate model. * Remove unnecessary backrefs (only needed to create bidirectional relationship) aggregate_metadata_get_by_host goes from 6 JOINS down to two JOINS. Fix bug 1133495 Change-Id: I72966fa205973ec638816b07bfdcd54f1102feb5
* | Remove old commented out code in sqlalchemy modelsJoe Gordon2013-02-281-6/+0
|/ | | | Change-Id: I0e49d00ce8790c8498976c2bf7bcfd9b69bfb5a4
* Use oslo-config-2013.1b4Mark McLoughlin2013-02-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The cfg API is now available via the oslo-config library, so switch to it and remove the copied-and-pasted version. Add the 2013.1b4 tarball to tools/pip-requires - this will be changed to 'oslo-config>=2013.1' when oslo-config is published to pypi. This will happen in time for grizzly final. Add dependency_links to setup.py so that oslo-config can be installed from the tarball URL specified in pip-requires. Remove the 'deps = pep8==1.3.3' from tox.ini as it means all the other deps get installed with easy_install which can't install oslo-config from the URL. Make tools/hacking.py include oslo in IMPORT_EXCEPTIONS like it already does for paste. It turns out imp.find_module() doesn't correct handle namespace packages. Retain dummy cfg.py file until keystoneclient middleware has been updated (I18c450174277c8e2d15ed93879da6cd92074c27a). Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
* Default SG rules for the Security Group "Default"Morgan Fainberg2013-02-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | Added in the API os-security-group-default-rules This allows create, delete, list, and get (of individual rules) for rules that will be pre-populated into the Security Group "default" that is populated in all projects on creation. These rules will not be applied retroactively, as it is designed to allow the creation of a "reasonable" base-line set of sg rules. The new rules live in a separate table that mirrors the relevant structures of the security_group_rules table. Added unit tests/API samples for the new API calls Related to bp default-rules-for-default-security-group DocImpact Change-Id: I7ab51e68aff562bb869538197a0eca158fc3220c
* create new cidr type for data storageSean Dague2013-02-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | it turns out that the 149 migration was overly agressive in its IPAddress conversion, as we actually have a few columns that are really CIDR values. This means that 39 chars isn't enough space to store even a normalized IPv6 cidr in the worst case (you need 4 more to support /127). We must also normalize IPv6 address cidrs otherwise 43 chars isn't long enough. This was more of a problem in theory, than in practice, as real IPv6 addresses rarely are non compressible. This adds a migration to bump up the CIDR columns to 43 characters. There is an infinitessimal chance that someone using mysql and long IPv6 values might loose data in 149 because of truncation. This doesn't address that, which would require modifying 149. The native pg CIDR column type is not used because it would require additional scrubbing of the data as CIDR is invalid if any host bits are set (and it will fail on type conversion). Fixes bug #1127696 Change-Id: I54539ac9c257d726bc4db5943169b5284cc847d3
* Merge "Use oslo database code"Jenkins2013-02-071-69/+3
|\
| * Use oslo database codeEric Windisch2013-02-051-69/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Bring in the new database code from oslo. Uses get_session() from oslo as well as changing NovaBase to derive from a common class. Remove test_sqlalchemy.py now that this code is test in oslo. Implements blueprint db-common. Change-Id: I090754981c871250dd981cbbe1a08e7181440120
* | Merge "Record instance actions and events"Jenkins2013-02-051-1/+5
|\ \ | |/ |/|
| * Record instance actions and eventsAndrew Laski2013-02-011-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Record when an action is initiated on an instance, and the underlying events related to completing that action. Actions will typically occur at the API level and should match what a user intended to do with an instance. Events will typically track what happens behind the scenes and may include things that would be unclear for a user if exposed, but should be beneficial to an admin/deployer. Adds a new wrapper to the compute manager. The wrapper will record when an event begins and finishes from the point of view of the compute manager. It will also record errors if they occur. Blueprint instance-actions Change-Id: I801f3e796d091e146413f84c2ccfab95ad2e1af4
* | Optimize floating ip list to make one db queryVishvananda Ishaya2013-02-021-1/+15
|/ | | | | | | | | | | | | Currently the floating ip code will make 2 db queries for every single associated floating ip when list is called. This adds a couple of joins in the db layer to avoid having to make so many calls. This dramatically improves floating-ip-list. On a simple one node test the time dropped from 2.35 seconds down to 0.5 seconds for a list with 10 associated floating ips. Part of blueprint optimize-nova-network Change-Id: I0571013393b2dbad42c15e690c7783d5ceecaeb2
* Fix SQL Error with fixed ips under devstack/postgresqlDavanum Srinivas2013-01-291-1/+1
| | | | | | | | | Postgresql does not allow sql that mix integer and booleans. Switch to check if deleted flag is set to 0 Fixes LP# 1109889 Change-Id: Icf03aa9591d398ba7d12f0db91e43df140e0df50
* Merge "Fix floating ips with external gateway"Jenkins2013-01-291-0/+6
|\
| * Fix floating ips with external gatewayVishvananda Ishaya2013-01-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If dnsmasq is configured to use an external gateway, then floating ips on other interfaces do not work properly. This is because outgoing traffic is no longer snatted to the floating ip. This patch fixes it by adding an ebtables rule to force traffic from ips that have a floating ip associated to route instead of bridge. Fixes bug 1096985 Change-Id: I8e4904660d42fe51c44b66686bed9f5d622693bd
* | Merge "Avoid db lookup in info_from_instance()."Jenkins2013-01-251-1/+1
|\ \
| * | Avoid db lookup in info_from_instance().Russell Bryant2013-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The method info_from_instance() in nova.notifications was doing a db lookup for the system_metadata for an instance. This patch updates that code to get that data from the instance that's passed in instead. The rest of the patch are related changes to make that happen. metadata_to_dict() was needed here. It lived in nova.compute.utils. nova.compute.utils already imported nova.notifications, so using it from there would have created a circular import. Move the method to nova.utils instead and update the tree to use it from its new location. I also noticed that the xen driver had a copy of metdata_to_dict(). This patch removes it and uses the common implementation in nova.utils. 'system_metadata' was added to _extra_keys of the Instance db model so that it would show up in a serialized instance. Tests failed without it as the result of getting instances via the conductor API did not include system_metadata. Now it's there. Part of bp no-db-compute. Change-Id: I451355fb26ae29f13b71438f7896c448b59f97b0
* | | Enable N302: Import modules onlyJoe Gordon2013-01-251-20/+20
|/ / | | | | | | | | | | Fix all N302 issues, and re-enable. Change-Id: Ic94d144c915b228b7ff2fd9c5951875e159ffcdd
* | Provide creating real unique constraints for columnsBoris Pavlovic2013-01-231-25/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Main issue is that we can't create unique constraint for columns, because we are using soft deletion of entries (set `deleted` column to True). The main idea is to use `deleted` columns to create unique constraint for columns. For example (`col1`, `deleted`). To make (`col1`, `deleted`) unique after entry deletion, we should assign the value of `id` to `deleted` column. Change type of `deleted` column from Boolean to table.id.type for all tables. Change models.soft_delete() method to assign table.id instead of True to `deleted` column. Change query.soft_delete() method to assign literal_column("id") instead of True Change in db.models all occurrences of Table.deleted == False => Table.deleted == correct_type (0 or "") Value of `deleted` property of entries is used in public nova api. To keep API as is, we should change XMLDictSerializer by converting the type of `deleted` property to string representation of boolean. Change db.api.model_query() method to make it work with different types of `deleted` column. If we are using as model that is not subclass of NovaBase we should set parameter base_model as subclass of NovaBase that corresponds to model. Change in db.api all occurrences of using model_query with model that is not subclass of NovaBase. blueprint db-unique-keys Change-Id: Ie1f67f49a5d085e6371efb63fc23a1c8b25d9464
* | Fix the wrong datatype in task_log table.Wenhao Xu2013-01-221-2/+2
|/ | | | | | | | Change period_begining and period_ending to Datetime type. Add the migration script. Change-Id: Ic5d61d6e7e847a1943825a0cb342b0b015bc0b70 Fixes: bug #1102477
* Add host to instance_faults table.Rick Harris2013-01-171-0/+1
| | | | | | | | Instances can be rescheduled or migrated to different hosts; so, to make troubleshooting easier, it's convenient to store the host in which the failure occured with the instance fault record. Change-Id: Ib2b9a5bab5d95739b730f0eab15884c2db33a782
* Merge "use postgresql INET datatype for storing IPs"Jenkins2013-01-171-19/+20
|\