def setUp(self): super().setUp() # Ensure there's an initial DNS publication. Outside of tests this is # guaranteed by a migration. DNSPublication(source="Initial").save() # Allow test-local changes to configuration. self.useFixture(RegionConfigurationFixture()) # Immediately make DNS changes as they're needed. self.patch(dns_config_module, "DNS_DEFER_UPDATES", False) # Create a DNS server. self.bind = self.useFixture(BINDServer()) # Use the dnspython resolver for at least some queries. self.resolver = dns.resolver.Resolver() self.resolver.nameservers = ["127.0.0.1"] self.resolver.port = self.bind.config.port patch_dns_config_path(self, self.bind.config.homedir) # Use a random port for rndc. patch_dns_rndc_port(self, allocate_ports("localhost")[0]) # This simulates what should happen when the package is # installed: # Create MAAS-specific DNS configuration files. parser = ArgumentParser() setup_dns.add_arguments(parser) setup_dns.run(parser.parse_args([])) # Register MAAS-specific DNS configuration files with the # system's BIND instance. parser = ArgumentParser() get_named_conf.add_arguments(parser) get_named_conf.run( parser.parse_args( ["--edit", "--config-path", self.bind.config.conf_file])) # Reload BIND. self.bind.runner.rndc("reload")
def run_command(self, *args): parsed_args = self.parser.parse_args([*args]) return run(parsed_args, stdout=self.output, stderr=self.error_output)