From 3e7fb755bde9690b50d28b431d7cc95ef48494df Mon Sep 17 00:00:00 2001
From: reedip <reedip.banerjee@nectechnologies.in>
Date: Fri, 22 Apr 2016 15:54:18 +0900
Subject: [PATCH] Fix tap-flow CLI to take service parameter

Earlier, tap-flow CLI could not take the service parameter,
which may be attributed to the destination attribute of parse_args.
The following code fixes the issue, while also modifying the
--service parameter to --tap-service for more similarity with
TaaS.

Change-Id: I813d039afbc26808d593d3a91d0acd7df6377724
Closes-Bug: #1539584
---
 neutron_taas/taas_client/tapflow.py                 | 13 ++++++-------
 .../tests/unit/taas_client/test_cli20_tapflow.py    |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/neutron_taas/taas_client/tapflow.py b/neutron_taas/taas_client/tapflow.py
index c88a7405..12c68b22 100644
--- a/neutron_taas/taas_client/tapflow.py
+++ b/neutron_taas/taas_client/tapflow.py
@@ -66,11 +66,10 @@ class CreateTapFlow(extension.ClientExtensionCreate, TapFlow):
             metavar="SOURCE_PORT",
             help=_('Source port to which the Tap Flow is connected.'))
         parser.add_argument(
-            '--service',
+            '--tap-service',
             required=True,
-            dest='service_id',
-            metavar="SERVICE",
-            help=_('Tap Service to which the flow belongs.'))
+            metavar="TAP_SERVICE",
+            help=_('Tap Service to which the Tap Flow belongs.'))
         parser.add_argument(
             '--direction',
             required=True,
@@ -84,11 +83,11 @@ class CreateTapFlow(extension.ClientExtensionCreate, TapFlow):
         source_port = neutronv20.find_resourceid_by_name_or_id(
             client, 'port',
             parsed_args.port)
-        service_id = neutronv20.find_resourceid_by_name_or_id(
+        tap_service_id = neutronv20.find_resourceid_by_name_or_id(
             client, 'tap_service',
-            parsed_args.service_id)
+            parsed_args.tap_service)
         body = {'source_port': source_port,
-                'tap_service_id': service_id}
+                'tap_service_id': tap_service_id}
         neutronv20.update_dict(parsed_args, body, ['tenant_id', 'direction'])
         _updatable_args2body(parsed_args, body)
         return {self.resource: body}
diff --git a/neutron_taas/tests/unit/taas_client/test_cli20_tapflow.py b/neutron_taas/tests/unit/taas_client/test_cli20_tapflow.py
index 21821650..1e8b0003 100644
--- a/neutron_taas/tests/unit/taas_client/test_cli20_tapflow.py
+++ b/neutron_taas/tests/unit/taas_client/test_cli20_tapflow.py
@@ -65,7 +65,7 @@ class CLITestV20TapFlowJSON(test_cli20.CLITestV20Base):
         my_id = 'my-id'
         args = ['--tenant-id', tenant_id,
                 '--port', port_id,
-                '--service', service_id,
+                '--tap-service', service_id,
                 '--direction', direction] + arg_attr
         pos_names = ['source_port', 'tap_service_id', 'direction'] + name_attr
         pos_values = [port_id, service_id, direction] + val_attr