Add parser options for description on resources

This adds the description field to the parsers for all
of the resources that gained description fields in the
dependent patch.

Change-Id: I939b517c5320ea9dd3f387c12adee1ed8876adec
Related-Bug: #1483480
Depends-On: I6e1ef53d7aae7d04a5485810cc1db0a8eb125953
This commit is contained in:
Kevin Benton 2016-03-02 17:29:18 -08:00
parent 45b4516a33
commit 2db432fbf5
14 changed files with 85 additions and 31 deletions

View File

@ -49,6 +49,9 @@ class CreateFloatingIP(neutronV20.CreateCommand):
parser.add_argument(
'floating_network_id', metavar='FLOATING_NETWORK',
help=_('Network name or ID to allocate floating IP from.'))
parser.add_argument(
'--description',
help=_('Description of the floating IP.'))
parser.add_argument(
'--port-id',
help=_('ID of the port to be associated with the floating IP.'))
@ -78,7 +81,7 @@ class CreateFloatingIP(neutronV20.CreateCommand):
body = {'floating_network_id': _network_id}
neutronV20.update_dict(parsed_args, body,
['port_id', 'tenant_id',
'fixed_ip_address',
'fixed_ip_address', 'description',
'floating_ip_address', 'subnet_id'])
dns.args2body_dns_create(parsed_args, body, 'domain')
dns.args2body_dns_create(parsed_args, body, 'name')

View File

@ -184,6 +184,9 @@ class CreateNetwork(neutronV20.CreateCommand, qos_policy.CreateQosPolicyMixin):
parser.add_argument(
'name', metavar='NAME',
help=_('Name of network to create.'))
parser.add_argument(
'--description',
help=_('Description of network.'))
self.add_arguments_qos_policy(parser)
availability_zone.add_az_hint_argument(parser, self.resource)
@ -197,7 +200,8 @@ class CreateNetwork(neutronV20.CreateCommand, qos_policy.CreateQosPolicyMixin):
'vlan_transparent',
'provider:network_type',
'provider:physical_network',
'provider:segmentation_id'])
'provider:segmentation_id',
'description'])
self.args2body_qos_policy(parsed_args, body)
availability_zone.args2body_az_hint(parsed_args, body)

View File

@ -44,6 +44,9 @@ def _add_updatable_args(parser):
parser.add_argument(
'--name',
help=_('Name of this port.'))
parser.add_argument(
'--description',
help=_('Description of this port.'))
parser.add_argument(
'--fixed-ip', metavar='subnet_id=SUBNET,ip_address=IP_ADDR',
action='append',
@ -71,7 +74,8 @@ def _add_updatable_args(parser):
def _updatable_args2body(parsed_args, body, client):
neutronV20.update_dict(parsed_args, body,
['device_id', 'device_owner', 'name'])
['device_id', 'device_owner', 'name',
'description'])
ips = []
if parsed_args.fixed_ip:
for ip_spec in parsed_args.fixed_ip:

View File

@ -68,6 +68,9 @@ class CreateRouter(neutronV20.CreateCommand):
parser.add_argument(
'name', metavar='NAME',
help=_('Name of router to create.'))
parser.add_argument(
'--description',
help=_('Description of router.'))
utils.add_boolean_argument(
parser, '--distributed', dest='distributed',
help=_('Create a distributed router.'))
@ -80,7 +83,8 @@ class CreateRouter(neutronV20.CreateCommand):
def args2body(self, parsed_args):
body = {'admin_state_up': parsed_args.admin_state}
neutronV20.update_dict(parsed_args, body,
['name', 'tenant_id', 'distributed', 'ha'])
['name', 'tenant_id', 'distributed', 'ha',
'description'])
availability_zone.args2body_az_hint(parsed_args, body)
return {self.resource: body}
@ -100,6 +104,9 @@ class UpdateRouter(neutronV20.UpdateCommand):
parser.add_argument(
'--name',
help=_('Name of this router.'))
parser.add_argument(
'--description',
help=_('Description of router.'))
utils.add_boolean_argument(
parser, '--admin-state-up', dest='admin_state',
help=_('Specify the administrative state of the router'
@ -128,7 +135,7 @@ class UpdateRouter(neutronV20.UpdateCommand):
if hasattr(parsed_args, 'admin_state'):
body['admin_state_up'] = parsed_args.admin_state
neutronV20.update_dict(parsed_args, body,
['name', 'distributed'])
['name', 'distributed', 'description'])
if parsed_args.no_routes:
body['routes'] = None
elif parsed_args.routes:

View File

@ -305,6 +305,9 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand):
resource = 'security_group_rule'
def add_known_arguments(self, parser):
parser.add_argument(
'--description',
help=_('Description of security group rule.'))
parser.add_argument(
'security_group_id', metavar='SECURITY_GROUP',
help=_('Security group name or ID to add rule.'))
@ -354,7 +357,8 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand):
generate_default_ethertype(parsed_args.protocol)}
neutronV20.update_dict(parsed_args, body,
['protocol', 'port_range_min', 'port_range_max',
'remote_ip_prefix', 'tenant_id'])
'remote_ip_prefix', 'tenant_id',
'description'])
if parsed_args.remote_group_id:
_remote_group_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'security_group',

View File

@ -52,6 +52,9 @@ def add_updatable_arguments(parser):
parser.add_argument(
'--name',
help=_('Name of this subnet.'))
parser.add_argument(
'--description',
help=_('Description of this subnet.'))
gateway_sg = parser.add_mutually_exclusive_group()
gateway_sg.add_argument(
'--gateway', metavar='GATEWAY_IP',
@ -112,7 +115,8 @@ def updatable_args2body(parsed_args, body, for_create=True, ip_version=None):
neutronV20.update_dict(parsed_args, body,
['name', 'allocation_pools',
'host_routes', 'dns_nameservers'])
'host_routes', 'dns_nameservers',
'description'])
if parsed_args.no_gateway:
body['gateway_ip'] = None
elif parsed_args.gateway:

View File

@ -27,6 +27,9 @@ def _format_prefixes(subnetpool):
def add_updatable_arguments(parser):
parser.add_argument(
'--description',
help=_('Description of subnetpool.'))
parser.add_argument(
'--min-prefixlen', type=int,
help=_('Subnetpool minimum prefix length.'))
@ -49,7 +52,8 @@ def add_updatable_arguments(parser):
def updatable_args2body(parsed_args, body, for_create=True):
neutronV20.update_dict(parsed_args, body,
['name', 'prefixes', 'default_prefixlen',
'min_prefixlen', 'max_prefixlen', 'is_default'])
'min_prefixlen', 'max_prefixlen', 'is_default',
'description'])
class ListSubnetPool(neutronV20.ListCommand):

View File

@ -30,11 +30,12 @@ class CLITestV20FloatingIpsJSON(test_cli20.CLITestV20Base):
cmd = fip.CreateFloatingIP(test_cli20.MyApp(sys.stdout), None)
name = 'fip1'
myid = 'myid'
args = [name]
args = [name, '--description', 'floats like a butterfly']
position_names = ['floating_network_id']
position_values = [name]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
position_names, position_values,
description='floats like a butterfly')
def test_create_floatingip_and_port(self):
# Create floatingip: fip1.

View File

@ -53,6 +53,19 @@ class CLITestV20NetworkJSON(test_cli20.CLITestV20Base):
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_create_network_description(self):
# Create net: --tenant_id tenantid myname.
resource = 'network'
cmd = network.CreateNetwork(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
myid = 'myid'
args = ['--description', 'Nice network', name]
position_names = ['name', ]
position_values = [name, ]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values,
description='Nice network')
def test_create_network_tenant(self):
# Create net: --tenant_id tenantid myname.
resource = 'network'
@ -510,9 +523,11 @@ class CLITestV20NetworkJSON(test_cli20.CLITestV20Base):
cmd = network.UpdateNetwork(test_cli20.MyApp(sys.stdout), None)
self._test_update_resource(resource, cmd, 'myid',
['myid', '--name', 'myname',
'--tags', 'a', 'b'],
{'name': 'myname', 'tags': ['a', 'b'], }
)
'--tags', 'a', 'b', '--description',
'This network takes the scenic route'],
{'name': 'myname', 'tags': ['a', 'b'],
'description': 'This network takes the '
'scenic route'})
def test_update_network_with_unicode(self):
# Update net: myid --name u'\u7f51\u7edc' --tags a b.

View File

@ -35,12 +35,13 @@ class CLITestV20PortJSON(test_cli20.CLITestV20Base):
name = 'myname'
myid = 'myid'
netid = 'netid'
args = [netid]
args = [netid, '--description', 'DESC']
position_names = ['network_id']
position_values = []
position_values.extend([netid])
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
position_names, position_values,
description='DESC')
def test_create_port_extra_dhcp_opts_args(self):
# Create port: netid --extra_dhcp_opt.
@ -555,9 +556,11 @@ class CLITestV20PortJSON(test_cli20.CLITestV20Base):
self._test_update_resource(resource, cmd, 'myid',
['myid', '--name', 'myname',
'--admin-state-up', 'False',
'--description', 'garbage',
'--tags', 'a', 'b'],
{'name': 'myname',
'admin_state_up': 'False',
'description': 'garbage',
'tags': ['a', 'b'], })
def test_update_port_secgroup(self):

View File

@ -28,11 +28,12 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base):
cmd = router.CreateRouter(test_cli20.MyApp(sys.stdout), None)
name = 'router1'
myid = 'myid'
args = [name, ]
args = [name, '--description', 'rooter']
position_names = ['name', ]
position_values = [name, ]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
position_names, position_values,
description='rooter')
def test_create_router_tenant(self):
# Create router: --tenant_id tenantid myname.
@ -163,9 +164,9 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base):
resource = 'router'
cmd = router.UpdateRouter(test_cli20.MyApp(sys.stdout), None)
self._test_update_resource(resource, cmd, 'myid',
['myid', '--name', 'myname'],
{'name': 'myname'}
)
['myid', '--name', 'myname',
'--description', ':D'],
{'name': 'myname', 'description': ':D'})
def test_update_router_admin_state(self):
# Update router: myid --admin-state-up <True|False>.

View File

@ -164,7 +164,7 @@ class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
direction, '--ethertype', ethertype, '--protocol', protocol,
'--port_range_min', port_range_min, '--port_range_max',
port_range_max, '--remote_group_id', remote_group_id,
security_group_id]
security_group_id, '--description', 'PCI policy 1421912']
position_names = ['remote_ip_prefix', 'direction', 'ethertype',
'protocol', 'port_range_min', 'port_range_max',
'remote_group_id', 'security_group_id']
@ -172,7 +172,8 @@ class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
port_range_min, port_range_max, remote_group_id,
security_group_id]
self._test_create_resource(resource, cmd, None, myid, args,
position_names, position_values)
position_names, position_values,
description='PCI policy 1421912')
def test_create_security_group_rule_with_integer_protocol_value(self):
resource = 'security_group_rule'

View File

@ -40,11 +40,12 @@ class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
netid = 'netid'
cidr = '10.10.10.0/24'
gateway = 'gatewayvalue'
args = ['--gateway', gateway, netid, cidr]
args = ['--gateway', gateway, netid, cidr, '--description', 'cave']
position_names = ['ip_version', 'network_id', 'cidr', 'gateway_ip']
position_values = [4, netid, cidr, gateway]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
position_names, position_values,
description='cave')
def test_create_subnet_network_cidr_seperated(self):
# For positional value, network_id and cidr can be separated.
@ -627,9 +628,10 @@ class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
cmd = subnet.UpdateSubnet(test_cli20.MyApp(sys.stdout), None)
self._test_update_resource(resource, cmd, 'myid',
['myid', '--name', 'myname',
'--description', 'cavern',
'--tags', 'a', 'b'],
{'name': 'myname', 'tags': ['a', 'b'], }
)
{'name': 'myname', 'tags': ['a', 'b'],
'description': 'cavern'})
def test_update_subnet_allocation_pools(self):
# Update subnet: myid --name myname --tags a b.

View File

@ -41,11 +41,12 @@ class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base):
prefix2 = '12.11.13.0/24'
args = [name, '--min-prefixlen', str(min_prefixlen),
'--pool-prefix', prefix1, '--pool-prefix', prefix2,
'--shared']
'--shared', '--description', 'public pool']
position_names = ['name', 'min_prefixlen', 'prefixes', 'shared']
position_values = [name, min_prefixlen, [prefix1, prefix2], True]
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
position_names, position_values,
description='public pool')
def test_create_subnetpool_not_shared(self):
# Create subnetpool: myname.
@ -153,9 +154,9 @@ class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base):
resource = 'subnetpool'
cmd = subnetpool.UpdateSubnetPool(test_cli20.MyApp(sys.stdout), None)
self._test_update_resource(resource, cmd, 'myid',
['myid', '--name', 'myname'],
{'name': 'myname'}
)
['myid', '--name', 'myname',
'--description', ':)'],
{'name': 'myname', 'description': ':)'})
def test_update_subnetpool_with_address_scope(self):
# Update subnetpool: myid --address-scope newscope.