Add "router remove port" to osc
This patch proposes the migration of port deletion of Neutron's "router-interface-delete" to OSC's "router remove port". Change-Id: Ifceabce080aacac9f6410c809fcc097760e0c5ee Partial-Bug: #1546849 Implements: blueprint neutron-client-advanced-router
This commit is contained in:
parent
2e94f2803f
commit
8ecdc57ea6
@ -6,6 +6,7 @@ Network v2
|
|||||||
|
|
||||||
router add port
|
router add port
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Add a port to a router
|
Add a port to a router
|
||||||
|
|
||||||
.. program:: router add port
|
.. program:: router add port
|
||||||
@ -102,6 +103,29 @@ List routers
|
|||||||
|
|
||||||
List additional fields in output
|
List additional fields in output
|
||||||
|
|
||||||
|
router remove port
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Remove a port from a router
|
||||||
|
|
||||||
|
.. program:: router remove port
|
||||||
|
.. code:: bash
|
||||||
|
|
||||||
|
os router remove port
|
||||||
|
<router>
|
||||||
|
<port>
|
||||||
|
|
||||||
|
.. _router_remove_port:
|
||||||
|
|
||||||
|
.. describe:: <router>
|
||||||
|
|
||||||
|
Router from which port will be removed (name or ID)
|
||||||
|
|
||||||
|
.. describe:: <port>
|
||||||
|
|
||||||
|
Port to be removed (name or ID)
|
||||||
|
|
||||||
|
|
||||||
router set
|
router set
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -241,6 +241,30 @@ class ListRouter(command.Lister):
|
|||||||
) for s in data))
|
) for s in data))
|
||||||
|
|
||||||
|
|
||||||
|
class RemovePortFromRouter(command.Command):
|
||||||
|
"""Remove a port from a router"""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(RemovePortFromRouter, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'router',
|
||||||
|
metavar='<router>',
|
||||||
|
help="Router from which port will be removed (name or ID)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'port',
|
||||||
|
metavar='<port>',
|
||||||
|
help="Port to be removed (name or ID).",
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = self.app.client_manager.network
|
||||||
|
port = client.find_port(parsed_args.port, ignore_missing=False)
|
||||||
|
client.router_remove_interface(client.find_router(
|
||||||
|
parsed_args.router, ignore_missing=False), port_id=port.id)
|
||||||
|
|
||||||
|
|
||||||
class SetRouter(command.Command):
|
class SetRouter(command.Command):
|
||||||
"""Set router properties"""
|
"""Set router properties"""
|
||||||
|
|
||||||
|
@ -269,6 +269,46 @@ class TestListRouter(TestRouter):
|
|||||||
self.assertEqual(self.data_long, list(data))
|
self.assertEqual(self.data_long, list(data))
|
||||||
|
|
||||||
|
|
||||||
|
class TestRemovePortFromRouter(TestRouter):
|
||||||
|
'''Remove port from a Router '''
|
||||||
|
|
||||||
|
_port = network_fakes.FakePort.create_one_port()
|
||||||
|
_router = network_fakes.FakeRouter.create_one_router(
|
||||||
|
attrs={'port': _port.id})
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestRemovePortFromRouter, self).setUp()
|
||||||
|
self.network.router_remove_interface = mock.Mock()
|
||||||
|
self.cmd = router.RemovePortFromRouter(self.app, self.namespace)
|
||||||
|
self.network.find_router = mock.Mock(return_value=self._router)
|
||||||
|
self.network.find_port = mock.Mock(return_value=self._port)
|
||||||
|
|
||||||
|
def test_remove_port_no_option(self):
|
||||||
|
arglist = []
|
||||||
|
verifylist = []
|
||||||
|
|
||||||
|
# Missing required args should bail here
|
||||||
|
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||||
|
self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
def test_remove_port_required_options(self):
|
||||||
|
arglist = [
|
||||||
|
self._router.id,
|
||||||
|
self._router.port,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('router', self._router.id),
|
||||||
|
('port', self._router.port),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network.router_remove_interface.assert_called_with(
|
||||||
|
self._router, **{'port_id': self._router.port})
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|
||||||
class TestSetRouter(TestRouter):
|
class TestSetRouter(TestRouter):
|
||||||
|
|
||||||
# The router to set.
|
# The router to set.
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``router remove port`` command
|
||||||
|
[Bug `1546849 <https://bugs.launchpad.net/bugs/1546849>`_]
|
@ -342,6 +342,7 @@ openstack.network.v2 =
|
|||||||
router_create = openstackclient.network.v2.router:CreateRouter
|
router_create = openstackclient.network.v2.router:CreateRouter
|
||||||
router_delete = openstackclient.network.v2.router:DeleteRouter
|
router_delete = openstackclient.network.v2.router:DeleteRouter
|
||||||
router_list = openstackclient.network.v2.router:ListRouter
|
router_list = openstackclient.network.v2.router:ListRouter
|
||||||
|
router_remove_port = openstackclient.network.v2.router:RemovePortFromRouter
|
||||||
router_set = openstackclient.network.v2.router:SetRouter
|
router_set = openstackclient.network.v2.router:SetRouter
|
||||||
router_show = openstackclient.network.v2.router:ShowRouter
|
router_show = openstackclient.network.v2.router:ShowRouter
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user