def swift_storage_relation_changed(): rings_url = relation_get('rings_url') swift_hash = relation_get('swift_hash') if '' in [rings_url, swift_hash] or None in [rings_url, swift_hash]: log('swift_storage_relation_changed: Peer not ready?') sys.exit(0) CONFIGS.write('/etc/rsync-juju.d/050-swift-storage.conf') CONFIGS.write('/etc/swift/swift.conf') fetch_swift_rings(rings_url)
def test_fetch_swift_rings(self): url = 'http://someproxynode/rings' swift_utils.SWIFT_CONF_DIR = tempfile.mkdtemp() try: swift_utils.fetch_swift_rings(url) wgets = [] for s in ['account', 'object', 'container']: _c = call(['wget', '%s/%s.ring.gz' % (url, s), '--retry-connrefused', '-t', '10', '-O', '/etc/swift/%s.ring.gz' % s]) wgets.append(_c) self.assertEqual(wgets, self.check_call.call_args_list) except: shutil.rmtree(swift_utils.SWIFT_CONF_DIR)
def test_fetch_swift_rings(self): url = 'http://someproxynode/rings' swift_utils.SWIFT_CONF_DIR = tempfile.mkdtemp() try: swift_utils.fetch_swift_rings(url) wgets = [] for s in ['account', 'object', 'container']: _c = call([ 'wget', '%s/%s.ring.gz' % (url, s), '--retry-connrefused', '-t', '10', '-O', '/etc/swift/%s.ring.gz' % s ]) wgets.append(_c) self.assertEqual(wgets, self.check_call.call_args_list) except: shutil.rmtree(swift_utils.SWIFT_CONF_DIR)
def swift_storage_relation_changed(): setup_ufw() rings_url = relation_get('rings_url') swift_hash = relation_get('swift_hash') if '' in [rings_url, swift_hash] or None in [rings_url, swift_hash]: log('swift_storage_relation_changed: Peer not ready?') sys.exit(0) CONFIGS.write('/etc/rsync-juju.d/050-swift-storage.conf') CONFIGS.write('/etc/swift/swift.conf') # NOTE(hopem): retries are handled in the function but it is possible that # we are attempting to get rings from a proxy that is no # longer publiscising them so lets catch the error, log a # message and hope that the good rings_url us waiting to be # consumed. try: fetch_swift_rings(rings_url) except CalledProcessError: log("Failed to sync rings from {} - no longer available from that " "unit?".format(rings_url), level=WARNING)