diff --git a/designateclient/tests/v2/test_zones.py b/designateclient/tests/v2/test_zones.py index 63ee81e3..22bd66b9 100644 --- a/designateclient/tests/v2/test_zones.py +++ b/designateclient/tests/v2/test_zones.py @@ -148,6 +148,17 @@ class TestZones(v2.APIV2TestCase, v2.CrudMixin): self.client.zones.axfr(ref["id"]) self.assertRequestBodyIs(None) + def test_task_pool_move(self): + ref = self.new_ref(pool_id=1) + + parts = [self.RESOURCE, ref["id"], "tasks", "pool_move"] + self.stub_url("POST", parts=parts) + + values = ref.copy() + + self.client.zones.pool_move(ref["id"], values) + self.assertRequestBodyIs(json=values) + class TestZoneTransfers(v2.APIV2TestCase, v2.CrudMixin): def test_create_request(self): diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py index d23d7462..e6290875 100644 --- a/designateclient/v2/cli/zones.py +++ b/designateclient/v2/cli/zones.py @@ -309,6 +309,32 @@ class AXFRZoneCommand(command.Command): {"zone_id": parsed_args.id}) +class PoolMoveZoneCommand(command.Command): + """Move a zone to another pool""" + def get_parser(self, prog_name): + parser = super(PoolMoveZoneCommand, self).get_parser(prog_name) + + parser.add_argument('zone_id', help="Zone ID") + parser.add_argument('--pool-id', help="Pool ID") + + common.add_all_common_options(parser) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + common.set_all_common_headers(client, parsed_args) + + data = {} + if parsed_args.pool_id: + data['pool_id'] = parsed_args.pool_id + + client.zones.pool_move(parsed_args.zone_id, data) + + LOG.info("Scheduled move for zone %(zone_id)s", + {"zone_id": parsed_args.zone_id}) + + class CreateTransferRequestCommand(command.ShowOne): """Create new zone transfer request""" diff --git a/designateclient/v2/zones.py b/designateclient/v2/zones.py index 209d4f08..bff59ff4 100644 --- a/designateclient/v2/zones.py +++ b/designateclient/v2/zones.py @@ -89,6 +89,13 @@ class ZoneController(V2Controller): self.client.session.post(url) + def pool_move(self, zone, values): + zone = v2_utils.resolve_by_name(self.list, zone) + + url = self.build_url('/zones/%s/tasks/pool_move' % zone) + + return self._post(url, data=values) + class ZoneTransfersController(V2Controller): def create_request(self, zone, target_project_id, description=None): diff --git a/setup.cfg b/setup.cfg index 86429223..d41ea85b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,6 +53,7 @@ openstack.dns.v2 = zone_abandon = designateclient.v2.cli.zones:AbandonZoneCommand zone_axfr = designateclient.v2.cli.zones:AXFRZoneCommand + zone_move = designateclient.v2.cli.zones:PoolMoveZoneCommand zone_export_create = designateclient.v2.cli.zones:ExportZoneCommand zone_export_list = designateclient.v2.cli.zones:ListZoneExportsCommand