Merge "Show instance access information"
This commit is contained in:
commit
31be2613c6
@ -260,6 +260,9 @@ Response Parameters
|
||||
- server_id: server_id
|
||||
- volume_id: volume_id
|
||||
- encrypted_rpc_messaging: encrypted_rpc_messaging
|
||||
- access: access
|
||||
- access.is_public: access_is_public
|
||||
- access.allowed_cidrs: access_allowed_cidrs
|
||||
|
||||
|
||||
Response Example
|
||||
|
@ -63,6 +63,11 @@ class Float(sqlalchemy.types.Float):
|
||||
super(Float, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class Json(sqlalchemy.types.JSON):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Json, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def create_tables(tables):
|
||||
for table in tables:
|
||||
logger.info("creating table %(table)s", {'table': table})
|
||||
|
@ -0,0 +1,28 @@
|
||||
# Copyright 2020 Catalyst Cloud
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.schema import Column
|
||||
from sqlalchemy.schema import MetaData
|
||||
|
||||
from trove.db.sqlalchemy.migrate_repo.schema import Json
|
||||
from trove.db.sqlalchemy.migrate_repo.schema import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
instances = Table('instances', meta, autoload=True)
|
||||
instances.create_column(Column('access', Json(), nullable=True))
|
@ -489,6 +489,13 @@ class SimpleInstance(object):
|
||||
def encrypted_rpc_messaging(self):
|
||||
return True if self.db_info.encrypted_key is not None else False
|
||||
|
||||
@property
|
||||
def access(self):
|
||||
if hasattr(self.db_info, 'access'):
|
||||
return self.db_info.access
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class DetailInstance(SimpleInstance):
|
||||
"""A detailed view of an Instance.
|
||||
@ -1260,7 +1267,7 @@ class Instance(BuiltInstance):
|
||||
configuration_id=configuration_id,
|
||||
slave_of_id=slave_of_id, cluster_id=cluster_id,
|
||||
shard_id=shard_id, type=instance_type,
|
||||
region_id=region_name)
|
||||
region_id=region_name, access=access)
|
||||
instance_id = db_info.id
|
||||
instance_name = name
|
||||
LOG.debug(f"Creating new instance {instance_id}")
|
||||
@ -1836,7 +1843,7 @@ class DBInstance(dbmodels.DatabaseModelBase):
|
||||
'volume_size', 'tenant_id', 'server_status',
|
||||
'deleted', 'deleted_at', 'datastore_version_id',
|
||||
'configuration_id', 'slave_of_id', 'cluster_id',
|
||||
'shard_id', 'type', 'region_id', 'encrypted_key']
|
||||
'shard_id', 'type', 'region_id', 'encrypted_key', 'access']
|
||||
_table_name = 'instances'
|
||||
|
||||
def __init__(self, task_status, **kwargs):
|
||||
|
@ -250,11 +250,11 @@ class InstanceController(wsgi.Controller):
|
||||
LOG.debug("req : '%s'\n\n", req)
|
||||
|
||||
context = req.environ[wsgi.CONTEXT_KEY]
|
||||
server = models.load_instance_with_info(models.DetailInstance,
|
||||
context, id)
|
||||
self.authorize_instance_action(context, 'show', server)
|
||||
instance = models.load_instance_with_info(models.DetailInstance,
|
||||
context, id)
|
||||
self.authorize_instance_action(context, 'show', instance)
|
||||
return wsgi.Result(
|
||||
views.InstanceDetailView(server, req=req).data(), 200
|
||||
views.InstanceDetailView(instance, req=req).data(), 200
|
||||
)
|
||||
|
||||
def delete(self, req, tenant_id, id):
|
||||
|
@ -38,7 +38,8 @@ class InstanceView(object):
|
||||
"links": self._build_links(),
|
||||
"flavor": self._build_flavor_info(),
|
||||
"datastore": {"type": None, "version": None},
|
||||
"region": self.instance.region_name
|
||||
"region": self.instance.region_name,
|
||||
"access": {}
|
||||
}
|
||||
if self.instance.datastore_version:
|
||||
instance_dict['datastore'] = {
|
||||
@ -66,6 +67,9 @@ class InstanceView(object):
|
||||
if self.instance.slaves:
|
||||
instance_dict['replicas'] = self._build_slaves_info()
|
||||
|
||||
if self.instance.access:
|
||||
instance_dict['access'] = self.instance.access
|
||||
|
||||
LOG.debug(instance_dict)
|
||||
return {"instance": instance_dict}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user