def get_crm_leader(service, resource=None): if not resource: resource = 'res_.*_vip' leader = set() for unit in mojo_utils.get_juju_units(service): crm_out = juju_utils.remote_run(unit, 'sudo crm status') for line in crm_out.splitlines(): line = line.lstrip() if re.match(resource, line): leader.add(line.split()[-1]) if len(leader) != 1: raise Exception('Unexpected leader count: ' + str(len(leader))) return leader.pop().split('-')[-1]
def check_dns_entry_in_bind(ip, record_name, juju_status=None): """Check that record for ip address in bind if a bind server is available. @param ip: str IP address to lookup @param record_name: str record name @param juju_status: dict Current juju status """ bind_units = mojo_utils.get_juju_units('designate-bind') for unit in bind_units: addr = mojo_utils.get_juju_unit_ip(unit) logging.info("Checking {} is {} against {} ({})".format( record_name, ip, unit, addr)) check_dns_record_exists(addr, record_name, ip, retry_count=6)