diff --git a/hooks/post-series-upgrade b/hooks/post-series-upgrade new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/post-series-upgrade @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/pre-series-upgrade b/hooks/pre-series-upgrade new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/pre-series-upgrade @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/swift_hooks.py b/hooks/swift_hooks.py index 05c3978..bd45741 100755 --- a/hooks/swift_hooks.py +++ b/hooks/swift_hooks.py @@ -790,6 +790,30 @@ def certs_changed(): configure_https() +@hooks.hook('pre-series-upgrade') +def pre_series_upgrade(): + log("Running prepare series upgrade hook", "INFO") + if not openstack.is_unit_paused_set(): + for service in services(): + stopped = service_stop(service) + if not stopped: + raise Exception("{} didn't stop cleanly.".format(service)) + openstack.set_unit_paused() + openstack.set_unit_upgrading() + + +@hooks.hook('post-series-upgrade') +def post_series_upgrade(): + log("Running complete series upgrade hook", "INFO") + openstack.clear_unit_paused() + openstack.clear_unit_upgrading() + if not openstack.is_unit_paused_set(): + for service in services(): + started = service_start(service) + if not started: + raise Exception("{} didn't start cleanly.".format(service)) + + def main(): try: hooks.execute(sys.argv) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 3b9fa6e..23cb123 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -148,8 +148,18 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): # Authenticate admin with keystone self._init_keystone_admin_client(api_version) + force_v1_client = False + if self._get_openstack_release() == self.trusty_icehouse: + # Updating image properties (such as arch or hypervisor) using the + # v2 api in icehouse results in: + # https://bugs.launchpad.net/python-glanceclient/+bug/1371559 + u.log.debug('Forcing glance to use v1 api') + force_v1_client = True + # Authenticate admin with glance endpoint - self.glance = u.authenticate_glance_admin(self.keystone) + self.glance = u.authenticate_glance_admin( + self.keystone, + force_v1_client=force_v1_client) keystone_ip = self.keystone_sentry.info['public-address'] keystone_relation = self.keystone_sentry.relation( @@ -449,13 +459,18 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): read_headers = {'X-Container-Read': ".r:*,.rlistings"} self.swift.post_container(container_name, headers=read_headers) + if float(self.glance.version) < 2.0: + object_count = 1 + else: + object_count = 2 + headers, objects = self.swift.get_container(container_name) - if len(objects) != 2: + if len(objects) != object_count: msg = "Expected 2 swift object, found {}".format(len(objects)) amulet.raise_status(amulet.FAIL, msg=msg) - swift_object_size = objects[1].get('bytes') - swift_object_md5 = objects[1].get('hash') + swift_object_size = objects[object_count - 1].get('bytes') + swift_object_md5 = objects[object_count - 1].get('hash') if img_size != swift_object_size: msg = "Glance image size {} != swift object size {}".format(