From 8bc106654ca8ab52d98f28fc55513e7931a02c3f Mon Sep 17 00:00:00 2001 From: "sonu.kumar" Date: Tue, 14 Jun 2016 15:12:38 +0530 Subject: [PATCH] Add `openstack zone transfer accept list` cli to designateclient This patch add cli for listing accepted zone ownership transfer and corresponding test cases. Related-Bug: #1499539 Change-Id: I3eec36c73b2dacd4eed3b8578c4d51593b43104d depends-on: I3dc042f666be43649bb3dec6e92cc67d1c32578f --- designateclient/tests/v2/test_zones.py | 14 ++++++++++++++ designateclient/v2/cli/zones.py | 21 +++++++++++++++++++++ designateclient/v2/zones.py | 4 ++++ doc/source/shell-v2-examples.rst | 6 ++++++ doc/source/shell-v2.rst | 1 + setup.cfg | 1 + 6 files changed, 47 insertions(+) diff --git a/designateclient/tests/v2/test_zones.py b/designateclient/tests/v2/test_zones.py index 2723992..5470be7 100644 --- a/designateclient/tests/v2/test_zones.py +++ b/designateclient/tests/v2/test_zones.py @@ -249,6 +249,20 @@ class TestZoneTransfers(v2.APIV2TestCase, v2.CrudMixin): response = self.client.zone_transfers.get_accept(accept_id) self.assertEqual(ref, response) + def test_list_accepts(self): + accept_id = "098bee04-fe30-4a83-8ccd-e0c496755816" + + ref = { + "id": accept_id, + "status": "COMPLETE" + } + + parts = ["zones", "tasks", "transfer_accepts"] + self.stub_url('GET', parts=parts, json={"transfer_accepts": ref}) + + self.client.zone_transfers.list_accepts() + self.assertRequestBodyIs("") + class TestZoneExports(v2.APIV2TestCase, v2.CrudMixin): def new_ref(self, **kwargs): diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py index 234d910..7035e56 100644 --- a/designateclient/v2/cli/zones.py +++ b/designateclient/v2/cli/zones.py @@ -382,6 +382,27 @@ class AcceptTransferRequestCommand(show.ShowOne): return six.moves.zip(*sorted(six.iteritems(data))) +class ListTransferAcceptsCommand(lister.Lister): + """List Zone Transfer Accepts""" + + columns = ['id', 'zone_id', 'project_id', + 'zone_transfer_request_id', 'status', 'key'] + + def get_parser(self, prog_name): + parser = super(ListTransferAcceptsCommand, self).get_parser( + prog_name) + + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.dns + + data = client.zone_transfers.list_requests() + + cols = self.columns + return cols, (utils.get_item_properties(s, cols) for s in data) + + class ShowTransferAcceptCommand(show.ShowOne): """Show Zone Transfer Accept""" diff --git a/designateclient/v2/zones.py b/designateclient/v2/zones.py index fa9abad..c960da7 100644 --- a/designateclient/v2/zones.py +++ b/designateclient/v2/zones.py @@ -125,6 +125,10 @@ class ZoneTransfersController(V2Controller): url = '/zones/tasks/transfer_accepts/%s' % accept_id return self._get(url) + def list_accepts(self): + url = '/zones/tasks/transfer_accepts' + return self._get(url, response_key="transfer_accepts") + class ZoneExportsController(V2Controller): def create(self, zone): diff --git a/doc/source/shell-v2-examples.rst b/doc/source/shell-v2-examples.rst index dc53a17..fa4a2e0 100644 --- a/doc/source/shell-v2-examples.rst +++ b/doc/source/shell-v2-examples.rst @@ -356,6 +356,12 @@ Show Zone Transfer Accept $openstack zone transfer accept show a8750f50-d7e6-403a-89d2-e209d62ef60e +List Zone Transfer Accept + +.. code-block:: shell-session + + $openstack zone transfer accept list + Working with tld ----------------- diff --git a/doc/source/shell-v2.rst b/doc/source/shell-v2.rst index 1eff928..dff87bc 100644 --- a/doc/source/shell-v2.rst +++ b/doc/source/shell-v2.rst @@ -118,6 +118,7 @@ zone transfer request show Show Zone Transfer Request Details zone transfer request set Set a Zone Transfer Request zone transfer request delete Delete a Zone Transfer Request zone transfer accept request Accept a Zone Transfer Request +zone transfer accept list List Zone Transfer Accepts zone transfer accept show Show Zone Transfer Accept zone abandon Abandon a zone zone axfr AXFR a zone diff --git a/setup.cfg b/setup.cfg index 98988e4..a81689a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -126,6 +126,7 @@ openstack.dns.v2 = zone_transfer_request_set = designateclient.v2.cli.zones:SetTransferRequestCommand zone_transfer_request_delete = designateclient.v2.cli.zones:DeleteTransferRequestCommand zone_transfer_accept_request = designateclient.v2.cli.zones:AcceptTransferRequestCommand + zone_transfer_accept_list = designateclient.v2.cli.zones:ListTransferAcceptsCommand zone_transfer_accept_show = designateclient.v2.cli.zones:ShowTransferAcceptCommand recordset_create = designateclient.v2.cli.recordsets:CreateRecordSetCommand