Add new API - zone pool move

The new API would be v2/zones/<zone_id>/tasks/pool_move
Only POST would be allowed on this API.

Implements: blueprint zone-move
Change-Id: I41525a005e98244c60078e7004c2a75dd170f06e
This commit is contained in:
kpdev 2021-06-17 15:48:22 +02:00 committed by Kiran Pawar
parent d7bca3562e
commit 84e585dbc2
4 changed files with 45 additions and 0 deletions

View File

@ -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):

View File

@ -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"""

View File

@ -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):

View File

@ -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