Merge "Add flavor argument to router"
This commit is contained in:
@@ -71,6 +71,9 @@ class CreateRouter(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help=_('Description of router.'))
|
||||
parser.add_argument(
|
||||
'--flavor',
|
||||
help=_('ID or name of flavor.'))
|
||||
utils.add_boolean_argument(
|
||||
parser, '--distributed', dest='distributed',
|
||||
help=_('Create a distributed router.'))
|
||||
@@ -82,6 +85,10 @@ class CreateRouter(neutronV20.CreateCommand):
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'admin_state_up': parsed_args.admin_state}
|
||||
if parsed_args.flavor:
|
||||
_flavor_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'flavor', parsed_args.flavor)
|
||||
body['flavor_id'] = _flavor_id
|
||||
neutronV20.update_dict(parsed_args, body,
|
||||
['name', 'tenant_id', 'distributed', 'ha',
|
||||
'description'])
|
||||
|
@@ -35,6 +35,19 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base):
|
||||
position_names, position_values,
|
||||
description='rooter')
|
||||
|
||||
def test_create_router_flavor(self):
|
||||
resource = 'router'
|
||||
cmd = router.CreateRouter(test_cli20.MyApp(sys.stdout), None)
|
||||
name = 'router1'
|
||||
myid = 'myid'
|
||||
flavor = 'router-flavor'
|
||||
args = [name, '--flavor', flavor]
|
||||
position_names = ['name', ]
|
||||
position_values = [name, flavor]
|
||||
self._test_create_resource(resource, cmd, name, myid, args,
|
||||
position_names, position_values,
|
||||
flavor_id='router-flavor')
|
||||
|
||||
def test_create_router_tenant(self):
|
||||
# Create router: --tenant_id tenantid myname.
|
||||
resource = 'router'
|
||||
|
Reference in New Issue
Block a user