Show user network ID for getting instance
Change-Id: Ia1e9112ae69e04f8c3e9e9d1b4a0189c743d7448
This commit is contained in:
parent
036948c516
commit
5590ecdce0
@ -516,7 +516,9 @@ instance_ip_address:
|
|||||||
type: string
|
type: string
|
||||||
instance_ip_addresses:
|
instance_ip_addresses:
|
||||||
description: |
|
description: |
|
||||||
The IP addresses of an instance, including the address type and IP.
|
The IP addresses of an instance, including the address type("private" or
|
||||||
|
"public") and IP. "network" field is added since Xena when the address type
|
||||||
|
is "private".
|
||||||
in: body
|
in: body
|
||||||
require: false
|
require: false
|
||||||
type: array
|
type: array
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"addresses": [
|
"addresses": [
|
||||||
{
|
{
|
||||||
"address": "10.1.0.62",
|
"address": "10.1.0.62",
|
||||||
"type": "private"
|
"type": "private",
|
||||||
|
"network": "3dc8f3c2-f335-11eb-878c-00224d6b7bc1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "172.24.5.114",
|
"address": "172.24.5.114",
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"addresses": [
|
"addresses": [
|
||||||
{
|
{
|
||||||
"address": "10.1.0.62",
|
"address": "10.1.0.62",
|
||||||
"type": "private"
|
"type": "private",
|
||||||
|
"network": "3dc8f3c2-f335-11eb-878c-00224d6b7bc1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "172.24.5.114",
|
"address": "172.24.5.114",
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"addresses": [
|
"addresses": [
|
||||||
{
|
{
|
||||||
"address": "10.1.0.62",
|
"address": "10.1.0.62",
|
||||||
"type": "private"
|
"type": "private",
|
||||||
|
"network": "3dc8f3c2-f335-11eb-878c-00224d6b7bc1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "172.24.5.114",
|
"address": "172.24.5.114",
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"addresses": [
|
"addresses": [
|
||||||
{
|
{
|
||||||
"address": "10.1.0.62",
|
"address": "10.1.0.62",
|
||||||
"type": "private"
|
"type": "private",
|
||||||
|
"network": "3dc8f3c2-f335-11eb-878c-00224d6b7bc1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "172.24.5.114",
|
"address": "172.24.5.114",
|
||||||
|
@ -236,6 +236,9 @@ function configure_trove {
|
|||||||
iniset $TROVE_CONF DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
|
iniset $TROVE_CONF DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
|
||||||
iniset $TROVE_CONF DEFAULT default_datastore $TROVE_DATASTORE_TYPE
|
iniset $TROVE_CONF DEFAULT default_datastore $TROVE_DATASTORE_TYPE
|
||||||
|
|
||||||
|
iniset $TROVE_CONF cache enabled true
|
||||||
|
iniset $TROVE_CONF cache backend dogpile.cache.memory
|
||||||
|
|
||||||
iniset $TROVE_CONF cassandra tcp_ports 7000,7001,7199,9042,9160
|
iniset $TROVE_CONF cassandra tcp_ports 7000,7001,7199,9042,9160
|
||||||
iniset $TROVE_CONF couchbase tcp_ports 8091,8092,4369,11209-11211,21100-21199
|
iniset $TROVE_CONF couchbase tcp_ports 8091,8092,4369,11209-11211,21100-21199
|
||||||
iniset $TROVE_CONF couchdb tcp_ports 5984
|
iniset $TROVE_CONF couchdb tcp_ports 5984
|
||||||
|
@ -91,28 +91,28 @@ Create and access a database instance
|
|||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ openstack database instance show ad40cf6c-6532-4a22-a3f3-7364f0f04a0f
|
$ openstack database instance show ad40cf6c-6532-4a22-a3f3-7364f0f04a0f
|
||||||
+--------------------------+----------------------------------------------------------------------------------------------+
|
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| Field | Value |
|
| Field | Value |
|
||||||
+--------------------------+----------------------------------------------------------------------------------------------+
|
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| addresses | [{'address': '10.0.0.59', 'type': 'private'}, {'address': '172.24.4.242', 'type': 'public'}] |
|
| addresses | [{'address': '10.0.0.59', 'type': 'private', 'network': '09f6aadc-f92d-41d4-8cad-2eb1876054dd'}, {'address': '172.24.4.242', 'type': 'public'}] |
|
||||||
| allowed_cidrs | [] |
|
| allowed_cidrs | [] |
|
||||||
| created | 2020-12-08T21:00:20 |
|
| created | 2020-12-08T21:00:20 |
|
||||||
| datastore | mysql |
|
| datastore | mysql |
|
||||||
| datastore_version | 5.7.29 |
|
| datastore_version | 5.7.29 |
|
||||||
| datastore_version_number | 5.7.29 |
|
| datastore_version_number | 5.7.29 |
|
||||||
| flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
|
| flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
|
||||||
| id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
|
| id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
|
||||||
| ip | 10.0.0.59, 172.24.4.242 |
|
| ip | 10.0.0.59, 172.24.4.242 |
|
||||||
| name | mysql_instance_1 |
|
| name | mysql_instance_1 |
|
||||||
| operating_status | HEALTHY |
|
| operating_status | HEALTHY |
|
||||||
| public | True |
|
| public | True |
|
||||||
| region | RegionOne |
|
| region | RegionOne |
|
||||||
| service_status_updated | 2020-12-08T21:05:51 |
|
| service_status_updated | 2020-12-08T21:05:51 |
|
||||||
| status | ACTIVE |
|
| status | ACTIVE |
|
||||||
| updated | 2020-12-08T21:04:39 |
|
| updated | 2020-12-08T21:04:39 |
|
||||||
| volume | 5 |
|
| volume | 5 |
|
||||||
| volume_used | 0.2 |
|
| volume_used | 0.2 |
|
||||||
+--------------------------+----------------------------------------------------------------------------------------------+
|
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
#. **Access the new database**
|
#. **Access the new database**
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ Set up replication
|
|||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status" -c Role
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+---------+------------------+---------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status | Role |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+---------+------------------+---------+
|
||||||
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
|
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | ACTIVE | HEALTHY | replica |
|
||||||
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
|
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | ACTIVE | HEALTHY | primary |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+---------+------------------+-----------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+---------+------------------+---------+
|
||||||
|
|
||||||
#. Verify replication status.
|
#. Verify replication status.
|
||||||
|
|
||||||
@ -119,14 +119,14 @@ couple minutes.
|
|||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status" -c Role
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status | Role |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
|
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | ACTIVE | HEALTHY | replica |
|
||||||
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
|
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | ACTIVE | HEALTHY | replica |
|
||||||
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
|
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | ACTIVE | HEALTHY | primary |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+-----------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
|
|
||||||
#. Failover(promote) "test-mysql-replica-1" to primary.
|
#. Failover(promote) "test-mysql-replica-1" to primary.
|
||||||
|
|
||||||
@ -138,14 +138,14 @@ couple minutes.
|
|||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status" -c Role
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status | Role |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
|
| 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | ACTIVE | HEALTHY | primary |
|
||||||
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
|
| a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | ACTIVE | HEALTHY | replica |
|
||||||
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
|
| cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | ACTIVE | HEALTHY | replica |
|
||||||
+--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+----------------------+--------+------------------+---------+
|
||||||
|
|
||||||
#. Point your application to the (former) replica.
|
#. Point your application to the (former) replica.
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ Upgrading datastore
|
|||||||
--nic net-id=$netid \
|
--nic net-id=$netid \
|
||||||
--datastore mysql --datastore-version 5.7.29 \
|
--datastore mysql --datastore-version 5.7.29 \
|
||||||
--databases testdb --users user:password
|
--databases testdb --users user:password
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status" -c Addresses
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+--------------------------------------------------------------------------------------------------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status | Addresses |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+--------------------------------------------------------------------------------------------------+
|
||||||
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
|
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private', 'network': '3dc8f3c2-f335-11eb-878c-00224d6b7bc1'}] |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+--------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
Check the MySQL version by connecting with the database:
|
Check the MySQL version by connecting with the database:
|
||||||
|
|
||||||
@ -90,18 +90,18 @@ Upgrading datastore
|
|||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status"
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+---------+------------------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+---------+------------------+
|
||||||
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | UPGRADE | | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
|
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | UPGRADE | |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+---------+------------------+
|
||||||
$ openstack database instance list
|
$ openstack database instance list -c ID -c Name -c Status -c "Operating Status"
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+
|
||||||
| ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
|
| ID | Name | Status | Operating Status |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+
|
||||||
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
|
| 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | ACTIVE | HEALTHY |
|
||||||
+--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
|
+--------------------------------------+--------------------+--------+------------------+
|
||||||
|
|
||||||
Check the MySQL version again:
|
Check the MySQL version again:
|
||||||
|
|
||||||
|
3
releasenotes/notes/xena-show-network.yaml
Normal file
3
releasenotes/notes/xena-show-network.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Show network ID for the instance private address.
|
@ -49,3 +49,4 @@ diskimage-builder!=1.6.0,!=1.7.0,!=1.7.1,>=1.1.2 # Apache-2.0
|
|||||||
docker>=4.2.0 # Apache-2.0
|
docker>=4.2.0 # Apache-2.0
|
||||||
psycopg2-binary>=2.6.2 # LGPL/ZPL
|
psycopg2-binary>=2.6.2 # LGPL/ZPL
|
||||||
semantic-version>=2.7.0 # BSD
|
semantic-version>=2.7.0 # BSD
|
||||||
|
oslo.cache>=1.26.0 # Apache-2.0
|
||||||
|
@ -7,3 +7,4 @@ namespace = oslo.middleware
|
|||||||
namespace = oslo.log
|
namespace = oslo.log
|
||||||
namespace = oslo.policy
|
namespace = oslo.policy
|
||||||
namespace = osprofiler
|
namespace = osprofiler
|
||||||
|
namespace = oslo.cache
|
||||||
|
57
trove/common/cache.py
Normal file
57
trove/common/cache.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Copyright 2021 Catalyst Cloud
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""The code related to integration between oslo.cache module and trove."""
|
||||||
|
|
||||||
|
from oslo_cache import core
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
|
def register_cache_configurations(conf):
|
||||||
|
"""Register all configurations required for oslo.cache.
|
||||||
|
|
||||||
|
The procedure registers all configurations required for oslo.cache.
|
||||||
|
It should be called before configuring of cache region
|
||||||
|
"""
|
||||||
|
core.configure(conf)
|
||||||
|
|
||||||
|
ports_cache_group = cfg.OptGroup('instance_ports_cache')
|
||||||
|
ports_cache_opts = [
|
||||||
|
cfg.IntOpt('expiration_time', default=86400,
|
||||||
|
help='TTL, in seconds, for any cached item in the '
|
||||||
|
'dogpile.cache region used for caching of the '
|
||||||
|
'instance ports.'),
|
||||||
|
cfg.BoolOpt("caching", default=True,
|
||||||
|
help='Toggle to enable/disable caching when getting trove '
|
||||||
|
'instance ports. Please note that the global toggle '
|
||||||
|
'for oslo.cache(enabled=True in [cache] group) '
|
||||||
|
'must be enabled to use this feature.')
|
||||||
|
]
|
||||||
|
conf.register_group(ports_cache_group)
|
||||||
|
conf.register_opts(ports_cache_opts, group=ports_cache_group)
|
||||||
|
|
||||||
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
# variable that stores an initialized cache region for trove
|
||||||
|
_REGION = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_cache_region():
|
||||||
|
global _REGION
|
||||||
|
if not _REGION:
|
||||||
|
_REGION = core.configure_cache_region(
|
||||||
|
conf=register_cache_configurations(cfg.CONF),
|
||||||
|
region=core.create_region())
|
||||||
|
return _REGION
|
@ -12,9 +12,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import netaddr
|
import netaddr
|
||||||
|
from oslo_cache import core
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
|
|
||||||
|
from trove.common import cache
|
||||||
from trove.common import cfg
|
from trove.common import cfg
|
||||||
from trove.common import clients
|
from trove.common import clients
|
||||||
from trove.common import exception
|
from trove.common import exception
|
||||||
@ -26,6 +28,11 @@ MGMT_CIDRS = None
|
|||||||
NEUTRON_EXTENSION_CACHE = {}
|
NEUTRON_EXTENSION_CACHE = {}
|
||||||
PROJECT_ID_EXT_ALIAS = 'project-id'
|
PROJECT_ID_EXT_ALIAS = 'project-id'
|
||||||
|
|
||||||
|
MEMOIZE_PORTS = core.get_memoization_decorator(
|
||||||
|
conf=CONF,
|
||||||
|
region=cache.get_cache_region(),
|
||||||
|
group="instance_ports_cache")
|
||||||
|
|
||||||
|
|
||||||
def check_extension_enabled(client, extension_alias):
|
def check_extension_enabled(client, extension_alias):
|
||||||
"""Check if an extension is enabled in Neutron."""
|
"""Check if an extension is enabled in Neutron."""
|
||||||
@ -93,6 +100,20 @@ def check_subnet_router(client, subnet_id):
|
|||||||
f"associated with router.")
|
f"associated with router.")
|
||||||
|
|
||||||
|
|
||||||
|
@MEMOIZE_PORTS
|
||||||
|
def get_instance_ports(client, instance_id):
|
||||||
|
"""Get ports attached to the trove instance.
|
||||||
|
|
||||||
|
After the trove instance is created, the attached ports are not changed.
|
||||||
|
"""
|
||||||
|
LOG.info(f'Getting ports for instance {instance_id}')
|
||||||
|
return client.list_ports(device_id=instance_id)['ports']
|
||||||
|
|
||||||
|
|
||||||
|
def get_port_fips(client, port_id):
|
||||||
|
return client.list_floatingips(port_id=port_id)['floatingips']
|
||||||
|
|
||||||
|
|
||||||
def create_port(client, name, description, network_id, security_groups,
|
def create_port(client, name, description, network_id, security_groups,
|
||||||
is_public=False, subnet_id=None, ip=None, is_mgmt=False,
|
is_public=False, subnet_id=None, ip=None, is_mgmt=False,
|
||||||
project_id=None):
|
project_id=None):
|
||||||
|
@ -146,7 +146,7 @@ def load_simple_instance_addresses(context, db_info):
|
|||||||
addresses = []
|
addresses = []
|
||||||
user_ports = []
|
user_ports = []
|
||||||
client = clients.create_neutron_client(context, db_info.region_id)
|
client = clients.create_neutron_client(context, db_info.region_id)
|
||||||
ports = client.list_ports(device_id=db_info.compute_instance_id)['ports']
|
ports = neutron.get_instance_ports(client, db_info.compute_instance_id)
|
||||||
for port in ports:
|
for port in ports:
|
||||||
if port['network_id'] not in CONF.management_networks:
|
if port['network_id'] not in CONF.management_networks:
|
||||||
LOG.debug('Found user port %s for instance %s', port['id'],
|
LOG.debug('Found user port %s for instance %s', port['id'],
|
||||||
@ -157,12 +157,17 @@ def load_simple_instance_addresses(context, db_info):
|
|||||||
# TODO(lxkong): IPv6 is not supported
|
# TODO(lxkong): IPv6 is not supported
|
||||||
if netutils.is_valid_ipv4(ip.get('ip_address')):
|
if netutils.is_valid_ipv4(ip.get('ip_address')):
|
||||||
addresses.append(
|
addresses.append(
|
||||||
{'address': ip['ip_address'], 'type': 'private'})
|
{
|
||||||
|
'address': ip['ip_address'],
|
||||||
|
'type': 'private',
|
||||||
|
'network': port['network_id']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
fips = client.list_floatingips(port_id=port['id'])
|
fips = neutron.get_port_fips(client, port['id'])
|
||||||
if len(fips['floatingips']) == 0:
|
if len(fips) == 0:
|
||||||
continue
|
continue
|
||||||
fip = fips['floatingips'][0]
|
fip = fips[0]
|
||||||
addresses.append(
|
addresses.append(
|
||||||
{'address': fip['floating_ip_address'], 'type': 'public'})
|
{'address': fip['floating_ip_address'], 'type': 'public'})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user