diff --git a/hooks/glance_relations.py b/hooks/glance_relations.py index 05c44656..3fd2f517 100755 --- a/hooks/glance_relations.py +++ b/hooks/glance_relations.py @@ -49,7 +49,6 @@ from glance_utils import ( HAPROXY_CONF, ceph_config_file, setup_ipv6, - swift_temp_url_key, assess_status, reinstall_paste_ini, is_api_ready, @@ -235,13 +234,6 @@ def image_service_joined(relation_id=None): juju_log("%s: image-service_joined: To peer glance-api-server=%s" % (CHARM, relation_data['glance-api-server'])) - if ('object-store' in CONFIGS.complete_contexts() and - 'identity-service' in CONFIGS.complete_contexts()): - relation_data.update({ - 'swift-temp-url-key': swift_temp_url_key(), - 'swift-container': 'glance' - }) - relation_set(relation_id=relation_id, **relation_data) diff --git a/hooks/glance_utils.py b/hooks/glance_utils.py index 146aee80..6215d068 100644 --- a/hooks/glance_utils.py +++ b/hooks/glance_utils.py @@ -45,7 +45,6 @@ from charmhelpers.core.host import ( CompareHostReleases, lsb_release, mkdir, - pwgen, service_stop, service_start, ) @@ -433,48 +432,6 @@ def check_optional_relations(configs): return "unknown", "" -def swift_temp_url_key(): - """Generate a temp URL key, post it to Swift and return its value. - If it is already posted, the current value of the key will be returned. - """ - import requests - keystone_ctxt = context.IdentityServiceContext(service='glance', - service_user='glance')() - if not keystone_ctxt: - log('Missing identity-service relation. Skipping generation of ' - 'swift temporary url key.') - return - - auth_url = '%s://%s:%s/v2.0/' % (keystone_ctxt['service_protocol'], - keystone_ctxt['service_host'], - keystone_ctxt['service_port']) - from swiftclient import client - from swiftclient import exceptions - - @retry_on_exception(15, base_delay=10, - exc_type=(exceptions.ClientException, - requests.exceptions.ConnectionError)) - def connect_and_post(): - log('Connecting swift client...') - swift_connection = client.Connection( - authurl=auth_url, user='glance', - key=keystone_ctxt['admin_password'], - tenant_name=keystone_ctxt['admin_tenant_name'], - auth_version='2.0') - - account_stats = swift_connection.head_account() - if 'x-account-meta-temp-url-key' in account_stats: - log("Temp URL key was already posted.") - return account_stats['x-account-meta-temp-url-key'] - - temp_url_key = pwgen(length=64) - swift_connection.post_account(headers={'x-account-meta-temp-url-key': - temp_url_key}) - return temp_url_key - - return connect_and_post() - - def assess_status(configs): """Assess status of current unit Decides what the state of the unit should be based on the current