Parameter support both id and name
The parameter of router operation not only supports id also supports name, so it should modify the hint. Change-Id: Ib5ddb771fb87181bcf638499703c03ebcc9cc680 Closes-bug: #1288656
This commit is contained in:
@@ -113,8 +113,8 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RouterInterfaceCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help=_('ID of the router.'))
|
||||
'router', metavar='ROUTER',
|
||||
help=_('ID or name of the router.'))
|
||||
parser.add_argument(
|
||||
'interface', metavar='INTERFACE',
|
||||
help=_('The format is "SUBNET|subnet=SUBNET|port=PORT". '
|
||||
@@ -139,14 +139,14 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
|
||||
value = parsed_args.interface
|
||||
|
||||
_router_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
neutron_client, self.resource, parsed_args.router_id)
|
||||
neutron_client, self.resource, parsed_args.router)
|
||||
|
||||
_interface_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
neutron_client, resource, value)
|
||||
body = {'%s_id' % resource: _interface_id}
|
||||
|
||||
portinfo = self.call_api(neutron_client, _router_id, body)
|
||||
print(self.success_message(parsed_args.router_id, portinfo),
|
||||
print(self.success_message(parsed_args.router, portinfo),
|
||||
file=self.app.stdout)
|
||||
|
||||
|
||||
@@ -181,11 +181,11 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(SetGatewayRouter, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help=_('ID of the router.'))
|
||||
'router', metavar='ROUTER',
|
||||
help=_('ID or name of the router.'))
|
||||
parser.add_argument(
|
||||
'external_network_id', metavar='external-network-id',
|
||||
help=_('ID of the external network for the gateway.'))
|
||||
'external_network', metavar='EXTERNAL-NETWORK',
|
||||
help=_('ID or name of the external network for the gateway.'))
|
||||
parser.add_argument(
|
||||
'--disable-snat', action='store_true',
|
||||
help=_('Disable source NAT on the router gateway.'))
|
||||
@@ -196,14 +196,14 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
_router_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
neutron_client, self.resource, parsed_args.router_id)
|
||||
neutron_client, self.resource, parsed_args.router)
|
||||
_ext_net_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
neutron_client, 'network', parsed_args.external_network_id)
|
||||
neutron_client, 'network', parsed_args.external_network)
|
||||
router_dict = {'network_id': _ext_net_id}
|
||||
if parsed_args.disable_snat:
|
||||
router_dict['enable_snat'] = False
|
||||
neutron_client.add_gateway_router(_router_id, router_dict)
|
||||
print(_('Set gateway for router %s') % parsed_args.router_id,
|
||||
print(_('Set gateway for router %s') % parsed_args.router,
|
||||
file=self.app.stdout)
|
||||
|
||||
|
||||
@@ -216,8 +216,8 @@ class RemoveGatewayRouter(neutronV20.NeutronCommand):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RemoveGatewayRouter, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'router_id', metavar='router-id',
|
||||
help=_('ID of the router.'))
|
||||
'router', metavar='ROUTER',
|
||||
help=_('ID or name of the router.'))
|
||||
return parser
|
||||
|
||||
def run(self, parsed_args):
|
||||
@@ -225,7 +225,7 @@ class RemoveGatewayRouter(neutronV20.NeutronCommand):
|
||||
neutron_client = self.get_client()
|
||||
neutron_client.format = parsed_args.request_format
|
||||
_router_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
neutron_client, self.resource, parsed_args.router_id)
|
||||
neutron_client, self.resource, parsed_args.router)
|
||||
neutron_client.remove_gateway_router(_router_id)
|
||||
print(_('Removed gateway from router %s') % parsed_args.router_id,
|
||||
print(_('Removed gateway from router %s') % parsed_args.router,
|
||||
file=self.app.stdout)
|
||||
|
||||
Reference in New Issue
Block a user