Merge "Updated from global requirements"
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 5d12e17..78d6aea 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -80,8 +80,8 @@
                 cls.network = cls.create_network()
                 cls.subnet = cls.create_subnet(cls.network)
                 cls.port = cls.create_port(cls.network)
-                cls.client.add_router_interface_with_port_id(
-                    cls.router['id'], cls.port['id'])
+                cls.client.add_router_interface(cls.router['id'],
+                                                port_id=cls.port['id'])
                 # NOTE: Sometimes we have seen this test fail with dvr in,
                 # multinode tests, since the dhcp port is not created before
                 # the test gets executed and so the router is not scheduled
@@ -99,8 +99,8 @@
     @classmethod
     def resource_cleanup(cls):
         if cls.is_dvr_router:
-            cls.client.remove_router_interface_with_port_id(
-                cls.router['id'], cls.port['id'])
+            cls.client.remove_router_interface(cls.router['id'],
+                                               port_id=cls.port['id'])
         super(L3AgentSchedulerTestJSON, cls).resource_cleanup()
 
     @test.idempotent_id('b7ce6e89-e837-4ded-9b78-9ed3c9c6a45a')
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index db4561f..f209f89 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -250,8 +250,8 @@
     @classmethod
     def create_router_interface(cls, router_id, subnet_id):
         """Wrapper utility that returns a router interface."""
-        interface = cls.client.add_router_interface_with_subnet_id(
-            router_id, subnet_id)
+        interface = cls.client.add_router_interface(router_id,
+                                                    subnet_id=subnet_id)
         return interface
 
     @classmethod
@@ -260,8 +260,9 @@
         interfaces = body['ports']
         for i in interfaces:
             try:
-                cls.client.remove_router_interface_with_subnet_id(
-                    router['id'], i['fixed_ips'][0]['subnet_id'])
+                cls.client.remove_router_interface(
+                    router['id'],
+                    subnet_id=i['fixed_ips'][0]['subnet_id'])
             except lib_exc.NotFound:
                 pass
         cls.client.delete_router(router['id'])
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index 739e6f9..3495b76f 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -45,19 +45,19 @@
         self.assertNotIn(router_id, routers_list)
 
     def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
-        interface = self.client.add_router_interface_with_subnet_id(
-            router_id, subnet_id)
+        interface = self.client.add_router_interface(router_id,
+                                                     subnet_id=subnet_id)
         self.addCleanup(self._remove_router_interface_with_subnet_id,
                         router_id, subnet_id)
         self.assertEqual(subnet_id, interface['subnet_id'])
         return interface
 
     def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
-        body = self.client.remove_router_interface_with_subnet_id(
-            router_id, subnet_id)
+        body = self.client.remove_router_interface(router_id,
+                                                   subnet_id=subnet_id)
         self.assertEqual(subnet_id, body['subnet_id'])
 
     def _remove_router_interface_with_port_id(self, router_id, port_id):
-        body = self.client.remove_router_interface_with_port_id(router_id,
-                                                                port_id)
+        body = self.client.remove_router_interface(router_id,
+                                                   port_id=port_id)
         self.assertEqual(port_id, body['port_id'])
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 74c1d51..dbb0d14 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -68,9 +68,8 @@
         for port in ports:
             if (port['device_owner'].startswith('network:router_interface')
                 and port['device_id'] in [r['id'] for r in self.routers]):
-                self.client.remove_router_interface_with_port_id(
-                    port['device_id'], port['id']
-                )
+                self.client.remove_router_interface(port['device_id'],
+                                                    port_id=port['id'])
             else:
                 if port['id'] in [p['id'] for p in self.ports]:
                     self.ports_client.delete_port(port['id'])
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 67f2c83..a8ca266 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -191,10 +191,10 @@
         self.addCleanup(self.client.delete_router, router['id'])
         port = self.ports_client.create_port(network_id=network['id'])
         # Add router interface to port created above
-        self.client.add_router_interface_with_port_id(
-            router['id'], port['port']['id'])
-        self.addCleanup(self.client.remove_router_interface_with_port_id,
-                        router['id'], port['port']['id'])
+        self.client.add_router_interface(router['id'],
+                                         port_id=port['port']['id'])
+        self.addCleanup(self.client.remove_router_interface, router['id'],
+                        port_id=port['port']['id'])
         # List ports filtered by router_id
         port_list = self.ports_client.list_ports(device_id=router['id'])
         ports = port_list['ports']
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 406ad44..0b64be4 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -137,8 +137,8 @@
         subnet = self.create_subnet(network)
         router = self._create_router(data_utils.rand_name('router-'))
         # Add router interface with subnet id
-        interface = self.client.add_router_interface_with_subnet_id(
-            router['id'], subnet['id'])
+        interface = self.client.add_router_interface(router['id'],
+                                                     subnet_id=subnet['id'])
         self.addCleanup(self._remove_router_interface_with_subnet_id,
                         router['id'], subnet['id'])
         self.assertIn('subnet_id', interface.keys())
@@ -158,8 +158,9 @@
         port_body = self.ports_client.create_port(
             network_id=network['id'])
         # add router interface to port created above
-        interface = self.client.add_router_interface_with_port_id(
-            router['id'], port_body['port']['id'])
+        interface = self.client.add_router_interface(
+            router['id'],
+            port_id=port_body['port']['id'])
         self.addCleanup(self._remove_router_interface_with_port_id,
                         router['id'], port_body['port']['id'])
         self.assertIn('subnet_id', interface.keys())
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index 90da6fd..7b07d42 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -84,8 +84,8 @@
     @test.attr(type=['negative'])
     @test.idempotent_id('04df80f9-224d-47f5-837a-bf23e33d1c20')
     def test_router_remove_interface_in_use_returns_409(self):
-        self.client.add_router_interface_with_subnet_id(
-            self.router['id'], self.subnet['id'])
+        self.client.add_router_interface(self.router['id'],
+                                         subnet_id=self.subnet['id'])
         self.assertRaises(lib_exc.Conflict,
                           self.client.delete_router,
                           self.router['id'])
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index ddfc75d..9e98d90 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -312,8 +312,8 @@
         return resp_body['router']
 
     def _add_router_interface(router_id, subnet_id):
-        network_admin_client.add_router_interface_with_subnet_id(
-            router_id, subnet_id)
+        network_admin_client.add_router_interface(router_id,
+                                                  subnet_id=subnet_id)
 
     network_name = name + "-network"
     network = _create_network(network_name)
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 8a47406..33f19b1 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -469,8 +469,7 @@
                          in client.list_router_interfaces(rid)['ports']
                          if port["device_owner"] == "network:router_interface"]
                 for port in ports:
-                    client.remove_router_interface_with_port_id(rid,
-                                                                port['id'])
+                    client.remove_router_interface(rid, port_id=port['id'])
                 client.delete_router(rid)
             except Exception:
                 LOG.exception("Delete Router exception.")
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 8012ad7..e26a014 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -841,8 +841,8 @@
         for subnet in router['subnet']:
             subnet_id = _get_resource_by_name(client.networks,
                                               'subnets', subnet)['id']
-            client.networks.remove_router_interface_with_subnet_id(router_id,
-                                                                   subnet_id)
+            client.networks.remove_router_interface(router_id,
+                                                    subnet_id=subnet_id)
         client.networks.delete_router(router_id)
 
 
@@ -856,8 +856,8 @@
             subnet_id = _get_resource_by_name(client.networks,
                                               'subnets', subnet)['id']
             # connect routers to their subnets
-            client.networks.add_router_interface_with_subnet_id(router_id,
-                                                                subnet_id)
+            client.networks.add_router_interface(router_id,
+                                                 subnet_id=subnet_id)
         # connect routers to external network if set to "gateway"
         if router['gateway']:
             if CONF.network.public_network_id:
diff --git a/tempest/common/dynamic_creds.py b/tempest/common/dynamic_creds.py
index 95ad229..8d3a24d 100644
--- a/tempest/common/dynamic_creds.py
+++ b/tempest/common/dynamic_creds.py
@@ -233,8 +233,8 @@
         return resp_body['router']
 
     def _add_router_interface(self, router_id, subnet_id):
-        self.network_admin_client.add_router_interface_with_subnet_id(
-            router_id, subnet_id)
+        self.network_admin_client.add_router_interface(router_id,
+                                                       subnet_id=subnet_id)
 
     def get_credentials(self, credential_type):
         if self._creds.get(str(credential_type)):
@@ -333,8 +333,9 @@
             if (not self.network_resources or
                     (self.network_resources.get('router') and creds.subnet)):
                 try:
-                    net_client.remove_router_interface_with_subnet_id(
-                        creds.router['id'], creds.subnet['id'])
+                    net_client.remove_router_interface(
+                        creds.router['id'],
+                        subnet_id=creds.subnet['id'])
                 except lib_exc.NotFound:
                     LOG.warning('router with name: %s not found for delete' %
                                 creds.router['name'])
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 6b0b1f9..c6b22df 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -180,25 +180,23 @@
         """
         return self._update_router(router_id, set_enable_snat=True, **kwargs)
 
-    def add_router_interface_with_subnet_id(self, router_id, subnet_id):
+    def add_router_interface(self, router_id, **kwargs):
+        """Add router interface.
+
+        Available params: see http://developer.openstack.org/
+                              api-ref-networking-v2-ext.html#addRouterInterface
+        """
         uri = '/routers/%s/add_router_interface' % router_id
-        update_body = {"subnet_id": subnet_id}
-        return self.update_resource(uri, update_body)
+        return self.update_resource(uri, kwargs)
 
-    def add_router_interface_with_port_id(self, router_id, port_id):
-        uri = '/routers/%s/add_router_interface' % router_id
-        update_body = {"port_id": port_id}
-        return self.update_resource(uri, update_body)
+    def remove_router_interface(self, router_id, **kwargs):
+        """Remove router interface.
 
-    def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
+        Available params: see http://developer.openstack.org/
+                              api-ref-networking-v2-ext.html#removeRouterInterface
+        """
         uri = '/routers/%s/remove_router_interface' % router_id
-        update_body = {"subnet_id": subnet_id}
-        return self.update_resource(uri, update_body)
-
-    def remove_router_interface_with_port_id(self, router_id, port_id):
-        uri = '/routers/%s/remove_router_interface' % router_id
-        update_body = {"port_id": port_id}
-        return self.update_resource(uri, update_body)
+        return self.update_resource(uri, kwargs)
 
     def list_router_interfaces(self, uuid):
         uri = '/ports?device_id=%s' % uuid
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
index 10911f7..0a7da92 100644
--- a/tempest/services/network/resources.py
+++ b/tempest/services/network/resources.py
@@ -89,14 +89,13 @@
 
     def add_to_router(self, router_id):
         self._router_ids.add(router_id)
-        self.network_client.add_router_interface_with_subnet_id(
-            router_id, subnet_id=self.id)
+        self.network_client.add_router_interface(router_id,
+                                                 subnet_id=self.id)
 
     def delete(self):
         for router_id in self._router_ids.copy():
-            self.network_client.remove_router_interface_with_subnet_id(
-                router_id,
-                subnet_id=self.id)
+            self.network_client.remove_router_interface(router_id,
+                                                        subnet_id=self.id)
             self._router_ids.remove(router_id)
         self.subnets_client.delete_subnet(self.id)
 
diff --git a/tempest/tests/common/test_dynamic_creds.py b/tempest/tests/common/test_dynamic_creds.py
index 4379756..de2000d 100644
--- a/tempest/tests/common/test_dynamic_creds.py
+++ b/tempest/tests/common/test_dynamic_creds.py
@@ -322,9 +322,9 @@
         self._mock_router_create('1234', 'fake_router')
         router_interface_mock = self.patch(
             'tempest.services.network.json.network_client.NetworkClient.'
-            'add_router_interface_with_subnet_id')
+            'add_router_interface')
         primary_creds = creds.get_primary_creds()
-        router_interface_mock.assert_called_once_with('1234', '1234')
+        router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
         network = primary_creds.network
         subnet = primary_creds.subnet
         router = primary_creds.router
@@ -354,9 +354,9 @@
         self._mock_router_create('1234', 'fake_router')
         router_interface_mock = self.patch(
             'tempest.services.network.json.network_client.NetworkClient.'
-            'add_router_interface_with_subnet_id')
+            'add_router_interface')
         creds.get_primary_creds()
-        router_interface_mock.assert_called_once_with('1234', '1234')
+        router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
         router_interface_mock.reset_mock()
         # Create alternate tenant and network
         self._mock_user_create('12345', 'fake_alt_user')
@@ -365,7 +365,8 @@
         self._mock_subnet_create(creds, '12345', 'fake_alt_subnet')
         self._mock_router_create('12345', 'fake_alt_router')
         creds.get_alt_creds()
-        router_interface_mock.assert_called_once_with('12345', '12345')
+        router_interface_mock.assert_called_once_with('12345',
+                                                      subnet_id='12345')
         router_interface_mock.reset_mock()
         # Create admin tenant and networks
         self._mock_user_create('123456', 'fake_admin_user')
@@ -390,7 +391,7 @@
         router_mock = router.start()
         remove_router_interface_mock = self.patch(
             'tempest.services.network.json.network_client.NetworkClient.'
-            'remove_router_interface_with_subnet_id')
+            'remove_router_interface')
         return_values = ({'status': 200}, {'ports': []})
         port_list_mock = mock.patch.object(creds.ports_admin_client,
                                            'list_ports',
@@ -419,11 +420,11 @@
         # Verify remove router interface calls
         calls = remove_router_interface_mock.mock_calls
         self.assertEqual(len(calls), 3)
-        args = map(lambda x: x[1], calls)
+        args = map(lambda x: (x[1][0], x[2]), calls)
         args = list(args)
-        self.assertIn(('1234', '1234'), args)
-        self.assertIn(('12345', '12345'), args)
-        self.assertIn(('123456', '123456'), args)
+        self.assertIn(('1234', {'subnet_id': '1234'}), args)
+        self.assertIn(('12345', {'subnet_id': '12345'}), args)
+        self.assertIn(('123456', {'subnet_id': '123456'}), args)
         # Verify network delete calls
         calls = net_mock.mock_calls
         self.assertEqual(len(calls), 3)
@@ -461,9 +462,9 @@
         self._mock_router_create('1234', 'fake_alt_router')
         router_interface_mock = self.patch(
             'tempest.services.network.json.network_client.NetworkClient.'
-            'add_router_interface_with_subnet_id')
+            'add_router_interface')
         alt_creds = creds.get_alt_creds()
-        router_interface_mock.assert_called_once_with('1234', '1234')
+        router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
         network = alt_creds.network
         subnet = alt_creds.subnet
         router = alt_creds.router
@@ -485,10 +486,10 @@
         self._mock_router_create('1234', 'fake_admin_router')
         router_interface_mock = self.patch(
             'tempest.services.network.json.network_client.NetworkClient.'
-            'add_router_interface_with_subnet_id')
+            'add_router_interface')
         self._mock_list_roles('123456', 'admin')
         admin_creds = creds.get_admin_creds()
-        router_interface_mock.assert_called_once_with('1234', '1234')
+        router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
         network = admin_creds.network
         subnet = admin_creds.subnet
         router = admin_creds.router