Add access_url_base to console_auth_tokens table

Unfortunately this column was missed off when console_auth_tokens
was added to the database. This change adds it in.

The access_url is needed for a protocol check in the console proxies.
Console proxies run per cell and do not run on compute hosts and thus
do not have access to the access_url config options in the compute
hosts nova.conf files.

So, we need to store part of the access_url in the database. We cannot
store the entire access_url because it contains the unhashed token, but
we can keep the base part of the url and generate the full access_url
on demand. An access url base looks something like this:

  http://127.0.0.1:6080/vnc_auto.html

and using it, we can generate the full access_url on demand for the
protocol check in the console proxies.

partially-implements: blueprint convert-consoles-to-objects

Change-Id: I0f672f5667d42b67d869ff9f467dbb64eb6c9ff9
This commit is contained in:
melanie witt 2018-01-05 17:45:05 +00:00
parent 9d1a909bfe
commit fc38e95784
4 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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 Column
from sqlalchemy import MetaData
from sqlalchemy import String
from sqlalchemy import Table
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
table = Table('console_auth_tokens', meta, autoload=True)
new_column = Column('access_url_base', String(255), nullable=True)
if not hasattr(table.c, 'access_url_base'):
table.create_column(new_column)

View File

@ -1599,6 +1599,7 @@ class ConsoleAuthToken(BASE, NovaBase):
internal_access_path = Column(String(255))
instance_uuid = Column(String(36), nullable=False)
expires = Column(Integer, nullable=False)
access_url_base = Column(String(255))
instance = orm.relationship(
"Instance",

View File

@ -977,6 +977,10 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
constraint_names = [constraint['name'] for constraint in constraints]
self.assertIn('uniq_block_device_mapping0uuid', constraint_names)
def _check_375(self, engine, data):
self.assertColumnExists(engine, 'console_auth_tokens',
'access_url_base')
class TestNovaMigrationsSQLite(NovaMigrationsCheckers,
test_base.DbTestCase,

View File

@ -30,4 +30,5 @@ fake_token_dict = {
'internal_access_path': 'fake-path',
'instance_uuid': fake_instance_uuid,
'expires': 100,
'access_url_base': 'http://fake.url.fake/root.html'
}