summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingxian Kong <anlin.kong@gmail.com>2019-10-01 23:41:52 +1300
committerLingxian Kong <anlin.kong@gmail.com>2019-10-03 19:22:45 +0000
commite45b6a63490649ac0b3fbce27e7c79d547814840 (patch)
tree85207c098e62ce744b0a4f3773fadc1e9dec45b6
parente8a6a60f24abc76b5b040fe3dee916865b9623d4 (diff)
downloadtrove-e45b6a63490649ac0b3fbce27e7c79d547814840.tar.gz
Use correct Swift credential for instance backup
DevStack is deploying Trove in service tenant model, for swift backed instance backup, the swift container should be transparent to the end users. Story: 2006647 Task: 36883 Change-Id: I5859f4c9911fc2c129c8f23611c6607044fbc145
-rw-r--r--devstack/plugin.sh13
-rw-r--r--integration/scripts/conf/test_begin.conf2
-rw-r--r--trove/common/single_tenant_remote.py57
-rw-r--r--trove/guestagent/guest_log.py4
-rw-r--r--trove/tests/api/mgmt/datastore_versions.py2
5 files changed, 36 insertions, 42 deletions
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index e6afa5c2..f5ee71ec 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -200,7 +200,7 @@ function configure_trove {
cp $TROVE_LOCAL_API_PASTE_INI $TROVE_API_PASTE_INI
# (Re)create trove conf files
- rm -f $TROVE_CONF
+ rm -f $TROVE_CONF $TROVE_GUESTAGENT_CONF
TROVE_AUTH_ENDPOINT=$KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION
@@ -238,6 +238,7 @@ function configure_trove {
iniset $TROVE_CONF DEFAULT remote_nova_client trove.common.single_tenant_remote.nova_client_trove_admin
iniset $TROVE_CONF DEFAULT remote_cinder_client trove.common.single_tenant_remote.cinder_client_trove_admin
iniset $TROVE_CONF DEFAULT remote_neutron_client trove.common.single_tenant_remote.neutron_client_trove_admin
+ iniset $TROVE_CONF DEFAULT remote_swift_client trove.common.single_tenant_remote.swift_client_trove_admin
iniset $TROVE_CONF DEFAULT default_datastore $TROVE_DATASTORE_TYPE
iniset $TROVE_CONF cassandra tcp_ports 7000,7001,7199,9042,9160
@@ -271,6 +272,16 @@ function configure_trove {
iniset $TROVE_GUESTAGENT_CONF DEFAULT ignore_users os_admin
iniset $TROVE_GUESTAGENT_CONF DEFAULT log_dir /var/log/trove/
iniset $TROVE_GUESTAGENT_CONF DEFAULT log_file trove-guestagent.log
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT nova_proxy_admin_user trove
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT nova_proxy_admin_tenant_name $SERVICE_PROJECT_NAME
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT nova_proxy_admin_pass $SERVICE_PASSWORD
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT nova_proxy_admin_user_domain_name default
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT nova_proxy_admin_project_domain_name default
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT os_region_name $REGION_NAME
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT remote_nova_client trove.common.single_tenant_remote.nova_client_trove_admin
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT remote_cinder_client trove.common.single_tenant_remote.cinder_client_trove_admin
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT remote_neutron_client trove.common.single_tenant_remote.neutron_client_trove_admin
+ iniset $TROVE_GUESTAGENT_CONF DEFAULT remote_swift_client trove.common.single_tenant_remote.swift_client_trove_admin
setup_trove_logging $TROVE_GUESTAGENT_CONF
# To avoid 'Connection timed out' error of sudo command inside the guest agent
diff --git a/integration/scripts/conf/test_begin.conf b/integration/scripts/conf/test_begin.conf
index 370eba60..4d9b92ba 100644
--- a/integration/scripts/conf/test_begin.conf
+++ b/integration/scripts/conf/test_begin.conf
@@ -51,7 +51,7 @@
"tenant_id":"%service_tenant_id%",
"requirements": {
"is_admin":true,
- "services": ["trove", "swift"]
+ "services": ["trove", "swift", "glance"]
}
},
{ "auth_user":"alt_demo",
diff --git a/trove/common/single_tenant_remote.py b/trove/common/single_tenant_remote.py
index 74dec1be..7860b299 100644
--- a/trove/common/single_tenant_remote.py
+++ b/trove/common/single_tenant_remote.py
@@ -13,52 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from trove.common import cfg
-from trove.common.remote import normalize_url
-
+from cinderclient.v2 import client as CinderClient
from keystoneauth1 import loading
from keystoneauth1 import session
-
-from cinderclient.v2 import client as CinderClient
from neutronclient.v2_0 import client as NeutronClient
from novaclient.client import Client as NovaClient
+import swiftclient
-CONF = cfg.CONF
+from trove.common import cfg
+from trove.common.remote import normalize_url
+CONF = cfg.CONF
_SESSION = None
-"""
-trove.conf
-...
-
-The following should be set in the trove CONF file for this
-single_tenant_remote config to work correctly.
-
-nova_proxy_admin_user =
-nova_proxy_admin_pass =
-nova_proxy_admin_tenant_name =
-nova_proxy_admin_tenant_id =
-nova_proxy_admin_user_domain_name =
-nova_proxy_admin_project_domain_name =
-trove_auth_url =
-nova_compute_service_type =
-nova_compute_url =
-cinder_service_type =
-os_region_name =
-
-remote_nova_client = \
- trove.common.single_tenant_remote.nova_client_trove_admin
-remote_cinder_client = \
- trove.common.single_tenant_remote.cinder_client_trove_admin
-remote_neutron_client = \
- trove.common.single_tenant_remote.neutron_client_trove_admin
-...
-
-"""
-
-
def get_keystone_session():
global _SESSION
@@ -143,3 +111,18 @@ def neutron_client_trove_admin(context, region_name=None):
client.management_url = CONF.neutron_url
return client
+
+
+def swift_client_trove_admin(context, region_name=None):
+ ks_session = get_keystone_session()
+ client = swiftclient.Connection(
+ session=ks_session,
+ insecure=CONF.swift_api_insecure,
+ os_options={
+ 'region_name': region_name or CONF.os_region_name,
+ 'service_type': CONF.swift_service_type,
+ 'endpoint_type': CONF.swift_endpoint_type
+ }
+ )
+
+ return client
diff --git a/trove/guestagent/guest_log.py b/trove/guestagent/guest_log.py
index c91db986..ec84a554 100644
--- a/trove/guestagent/guest_log.py
+++ b/trove/guestagent/guest_log.py
@@ -23,7 +23,7 @@ from swiftclient.client import ClientException
from trove.common import cfg
from trove.common import exception
from trove.common.i18n import _
-from trove.common.remote import create_swift_client
+from trove.common import remote
from trove.common import stream_codecs
from trove.common import timeutils
from trove.guestagent.common import operating_system
@@ -130,7 +130,7 @@ class GuestLog(object):
def swift_client(self):
if not self._cached_swift_client or (
self._cached_context != self.context):
- self._cached_swift_client = create_swift_client(self.context)
+ self._cached_swift_client = remote.swift_client(self.context)
self._cached_context = self.context
return self._cached_swift_client
diff --git a/trove/tests/api/mgmt/datastore_versions.py b/trove/tests/api/mgmt/datastore_versions.py
index 903c4df6..a2112ab1 100644
--- a/trove/tests/api/mgmt/datastore_versions.py
+++ b/trove/tests/api/mgmt/datastore_versions.py
@@ -45,7 +45,7 @@ class MgmtDataStoreVersion(object):
self.images = []
if test_config.glance_client is not None:
glance_user = test_config.users.find_user(
- Requirements(services=["glance"]))
+ Requirements(is_admin=True, services=["glance"]))
self.glance_client = create_glance_client(glance_user)
images = self.glance_client.images.list()
for image in images: