def test_needs_maas_dns_migration(self, check_call): ret = utils.needs_maas_dns_migration() self.assertEqual(True, ret) check_call.side_effect = subprocess.CalledProcessError(1, '') ret = utils.needs_maas_dns_migration() self.assertEqual(False, ret)
def test_needs_maas_dns_migration(self, check_call): ret = utils.needs_maas_dns_migration() self.assertEqual(True, ret) check_call.side_effect = subprocess.CalledProcessError(1, '') ret = utils.needs_maas_dns_migration() self.assertEqual(False, ret)
def migrate_maas_dns(): """ Migrates the MAAS DNS HA configuration to write local IP address information to files. """ if not needs_maas_dns_migration(): log("MAAS DNS migration is not necessary.", INFO) return for relid in relation_ids('ha'): for unit in related_units(relid): resources = parse_data(relid, unit, 'resources') resource_params = parse_data(relid, unit, 'resource_params') if True in [ra.startswith('ocf:maas') for ra in resources.values()]: for resource in resource_params.keys(): if resource.endswith("_hostname"): res_ipaddr = get_ip_addr_from_resource_params( resource_params[resource]) log("Migrating MAAS DNS resource %s" % resource, INFO) write_maas_dns_address(resource, res_ipaddr)
def migrate_maas_dns(): """ Migrates the MAAS DNS HA configuration to write local IP address information to files. """ if not needs_maas_dns_migration(): log("MAAS DNS migration is not necessary.", INFO) return for relid in relation_ids('ha'): for unit in related_units(relid): resources = parse_data(relid, unit, 'resources') resource_params = parse_data(relid, unit, 'resource_params') if True in [ra.startswith('ocf:maas') for ra in resources.values()]: for resource in resource_params.keys(): if resource.endswith("_hostname"): res_ipaddr = get_ip_addr_from_resource_params( resource_params[resource]) log("Migrating MAAS DNS resource %s" % resource, INFO) write_maas_dns_address(resource, res_ipaddr)