From 33ae05ee8687af39b3bddc5b448ace2a412dbf68 Mon Sep 17 00:00:00 2001 From: Travis Tripp Date: Mon, 25 Jan 2016 14:01:09 -0700 Subject: [PATCH] Change Metadefs OS::Nova::Instance to OS::Nova::Server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The metadata definitions in etc/metadefs allow each namespace to be associated with a resource type in OpenStack. Now that Horizon is supporting adding metadata to instances (just got in during the mitaka cycle - so unrealeased), I realized that we used OS::Nova::Instance instead of OS::Nova::Server in Glance. This doesn’t align with Heat [0] or Searchlight [1]. There are a couple of metadef files that have OS::Nova::Instance that need to change to OS::Nova::Server. I see also that OS::Nova:Instance is in one of the db scripts. That script simply adds some initial "resource types" to the database. [3]. It should be noted that there is no hard dependency on that resource type to be in the DB script. You can add new resource types at any time via API or JSON files and they are automatically added. I'm not sure if the change to the db script needs to be done in a different patch or not, but that can easily be accommodated. See bug for additional links. Change-Id: I196ce1d9a62a61027ccd444b17a30b2c018d9c84 Closes-Bug: 1537903 --- doc/source/glancemetadefcatalogapi.rst | 2 +- doc/source/metadefs-concepts.rst | 4 +-- etc/metadefs/software-databases.json | 2 +- etc/metadefs/software-runtimes.json | 2 +- etc/metadefs/software-webservers.json | 2 +- .../versions/035_add_metadef_tables.py | 2 +- .../044_update_metadef_os_nova_server.py | 31 +++++++++++++++++++ .../notes/bug-1537903-54b2822eac6cfc09.yaml | 11 +++++++ 8 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 glance/db/sqlalchemy/migrate_repo/versions/044_update_metadef_os_nova_server.py create mode 100644 releasenotes/notes/bug-1537903-54b2822eac6cfc09.yaml diff --git a/doc/source/glancemetadefcatalogapi.rst b/doc/source/glancemetadefcatalogapi.rst index 5e0db51e63..f4cefc16fa 100644 --- a/doc/source/glancemetadefcatalogapi.rst +++ b/doc/source/glancemetadefcatalogapi.rst @@ -282,7 +282,7 @@ The data is returned as a JSON-encoded mapping in the following format:: }, { "created_at": "2014-08-28T17:13:04Z", - "name": "OS::Nova::Instance", + "name": "OS::Nova::Server", "updated_at": "2014-08-28T17:13:04Z" } ] diff --git a/doc/source/metadefs-concepts.rst b/doc/source/metadefs-concepts.rst index e4f4018a43..64b13fe660 100644 --- a/doc/source/metadefs-concepts.rst +++ b/doc/source/metadefs-concepts.rst @@ -62,8 +62,9 @@ OpenStack services today: | + *extra specs* | + *image metadata* | + *properties* | | Host Aggregate | + *metadata* | + *tags* | | + *metadata* | VolumeType | | -| Instances | + *extra specs* | | +| Servers | + *extra specs* | | | + *metadata* | + *qos specs* | | +| + *scheduler_hints* | | | | + *tags* | | | +-------------------------+---------------------------+----------------------+ @@ -182,4 +183,3 @@ aggregate_instance_extra_specs:companyx:fastio=true In some cases, there may be multiple different filters that may use the same property with different prefixes. In this case, the correct prefix needs to be set based on which filter is enabled. - diff --git a/etc/metadefs/software-databases.json b/etc/metadefs/software-databases.json index fcbf5d9d73..973c0920b3 100644 --- a/etc/metadefs/software-databases.json +++ b/etc/metadefs/software-databases.json @@ -13,7 +13,7 @@ "properties_target": "image" }, { - "name": "OS::Nova::Instance", + "name": "OS::Nova::Server", "properties_target": "metadata" }, { diff --git a/etc/metadefs/software-runtimes.json b/etc/metadefs/software-runtimes.json index 244ae3e41b..78070728a1 100644 --- a/etc/metadefs/software-runtimes.json +++ b/etc/metadefs/software-runtimes.json @@ -13,7 +13,7 @@ "properties_target": "image" }, { - "name": "OS::Nova::Instance", + "name": "OS::Nova::Server", "properties_target": "metadata" } ], diff --git a/etc/metadefs/software-webservers.json b/etc/metadefs/software-webservers.json index b626c74b20..3fd7540cfa 100644 --- a/etc/metadefs/software-webservers.json +++ b/etc/metadefs/software-webservers.json @@ -13,7 +13,7 @@ "properties_target": "image" }, { - "name": "OS::Nova::Instance", + "name": "OS::Nova::Server", "properties_target": "metadata" } ], diff --git a/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py b/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py index 47e1f32180..1602e7397a 100644 --- a/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py +++ b/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py @@ -24,7 +24,7 @@ from glance.db.sqlalchemy.migrate_repo.schema import ( RESOURCE_TYPES = [u'OS::Glance::Image', u'OS::Cinder::Volume', u'OS::Nova::Flavor', u'OS::Nova::Aggregate', - u'OS::Nova::Instance'] + u'OS::Nova::Server'] def _get_metadef_resource_types_table(meta): diff --git a/glance/db/sqlalchemy/migrate_repo/versions/044_update_metadef_os_nova_server.py b/glance/db/sqlalchemy/migrate_repo/versions/044_update_metadef_os_nova_server.py new file mode 100644 index 0000000000..26daf87c3d --- /dev/null +++ b/glance/db/sqlalchemy/migrate_repo/versions/044_update_metadef_os_nova_server.py @@ -0,0 +1,31 @@ +# Copyright (c) 2016 Hewlett Packard Enterprise Software, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from sqlalchemy import MetaData, Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + resource_types_table = Table('metadef_resource_types', meta, autoload=True) + + resource_types_table.update(values={'name': 'OS::Nova::Server'}).where( + resource_types_table.c.name == 'OS::Nova::Instance').execute() + + +def downgrade(migrate_engine): + # NOTE(TravT): This is a bug fix (1537903). It shouldn't be downgraded. + return diff --git a/releasenotes/notes/bug-1537903-54b2822eac6cfc09.yaml b/releasenotes/notes/bug-1537903-54b2822eac6cfc09.yaml new file mode 100644 index 0000000000..f35f354150 --- /dev/null +++ b/releasenotes/notes/bug-1537903-54b2822eac6cfc09.yaml @@ -0,0 +1,11 @@ +--- +upgrade: + - Metadata definitions previously associated with OS::Nova::Instance + have been changed to be associated with OS::Nova::Server in order to + align with Heat and Searchlight. You may either upgrade them using + glance-manage db load_metadefs [path] [merge] [prefer_new] or + glance-manage db upgrade 44. +fixes: + - Metadata definitions previously associated with OS::Nova::Instance + have been changed to be associated with OS::Nova::Server in order to + align with Heat and Searchlight.