diff options
| author | reedip <reedip.banerjee@nectechnologies.in> | 2016-03-20 16:05:49 +0900 |
|---|---|---|
| committer | Reedip <reedip.banerjee@nectechnologies.in> | 2016-03-22 01:55:19 +0000 |
| commit | 9e42daa577b0f15c349c2f4a79b3632ffec97720 (patch) | |
| tree | 75fc0b171ae8a24ad94e2e8ef8bea371265b0d8d /openstackclient/network | |
| parent | 8ecdc57ea680b7e20835bea69a2d18e1460d9406 (diff) | |
| download | python-openstackclient-9e42daa577b0f15c349c2f4a79b3632ffec97720.tar.gz | |
Add Subnet add/remove support to router
The following patch adds the support for
"router add subnet" and "router remove subnet"
to the OSC as a part of migration of Neutron's
CLI commands.
Partial-Bug: #1546849
Implements: blueprint neutron-client-advanced-router
Change-Id: Ia3770c41026194bdb1543d4e67446f81936d44d1
Diffstat (limited to 'openstackclient/network')
| -rw-r--r-- | openstackclient/network/v2/router.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index caf6d5ce..f4f12087 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -106,6 +106,33 @@ class AddPortToRouter(command.Command): parsed_args.router, ignore_missing=False), port_id=port.id) +class AddSubnetToRouter(command.Command): + """Add a subnet to a router""" + + def get_parser(self, prog_name): + parser = super(AddSubnetToRouter, self).get_parser(prog_name) + parser.add_argument( + 'router', + metavar='<router>', + help="Router to which subnet will be added (name or ID)", + ) + parser.add_argument( + 'subnet', + metavar='<subnet>', + help="Subnet to be added (name or ID)", + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.network + subnet = client.find_subnet(parsed_args.subnet, + ignore_missing=False) + client.router_add_interface( + client.find_router(parsed_args.router, + ignore_missing=False), + subnet_id=subnet.id) + + class CreateRouter(command.ShowOne): """Create a new router""" @@ -265,6 +292,33 @@ class RemovePortFromRouter(command.Command): parsed_args.router, ignore_missing=False), port_id=port.id) +class RemoveSubnetFromRouter(command.Command): + """Remove a subnet from a router""" + + def get_parser(self, prog_name): + parser = super(RemoveSubnetFromRouter, self).get_parser(prog_name) + parser.add_argument( + 'router', + metavar='<router>', + help="Router from which the subnet will be removed (name or ID)", + ) + parser.add_argument( + 'subnet', + metavar='<subnet>', + help="Subnet to be removed (name or ID)", + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.network + subnet = client.find_subnet(parsed_args.subnet, + ignore_missing=False) + client.router_remove_interface( + client.find_router(parsed_args.router, + ignore_missing=False), + subnet_id=subnet.id) + + class SetRouter(command.Command): """Set router properties""" |
