[openstack-dev] "list=true" issue with the python client.- help
Vasudevan, Swaminathan (PNB Roseville)
swaminathan.vasudevan at hp.com
Mon Jun 17 22:16:41 UTC 2013
Hi Folks,
I need some help to resolve the issue high lighted below.
I have configured for an attribute to accept a "list".
But for some reason, the "list=true" pops up as a value.
Can anyone suggest what might be wrong.
Here is the code. ( Look for the vpnconnection.py)
https://review.openstack.org/#/c/29811/
Here is the command that I issued:
quantum vpn-connection-create --name myconnection --peer_address 10.20.0.30 --peer_id 10.20.0.30 ----psk "abcd" --vpnservice_id myvpn --ikepolicy_id ikepolicy1 --ipsecpolicy_id ipsecpolicy1 --peer_cidrs list=true 10.1.0.0/24 10.2.0.0/24
Used PDB to see what is happening inside.
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(331)get_data()
-> quantum_client = self.get_client()
(Pdb) p parsed_args
Namespace(admin_state_down=True, columns=[], description=None, dpd_action='hold', dpd_interval='30', dpd_timeout='120', formatter='table', ikepolicy_id='ikepolicy1', initiator='bi-directional', ipsecpolicy_id='ipsecpolicy1', mtu='1500', name='myconnection', peer_address='10.20.0.30', peer_cidrs=['list=true'], peer_id='10.20.0.30', prefix='', psk=None, request_format='json', tenant_id=None, variables=[], vpnservice_id='myvpn')
(Pdb) quit
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(332)get_data()
-> quantum_client.format = parsed_args.request_format
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(333)get_data()
-> _extra_values = parse_args_to_dict(self.values_specs)
(Pdb) p quantum_client.format
'json'
(Pdb) n
AttributeError: "'Namespace' object has no attribute ''"
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(333)get_data()
-> _extra_values = parse_args_to_dict(self.values_specs)
(Pdb) p _extra_values
*** NameError: NameError("name '_extra_values' is not defined",)
(Pdb)
NOTE: Extra values does not return a valid value. But in the case of the subnet, when I ran the debugger it was returning a valid list.
But in the case of the subnet, extra values returns the list.
See the debug message below.
guest at swaminathan-virtual-machine-rest:~/devstack$ quantum subnet-create net1 40.0.0.0/24 --dns_nameservers list=true 8.8.8.7 8.8.8.8
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(330)get_data()
-> self.log.debug('get_data(%s)' % parsed_args)
(Pdb) p parsed_args
Namespace(allocation_pools=None, cidr='40.0.0.0/24', columns=[], disable_dhcp=False, dns_nameservers=None, formatter='table', gateway=None, host_routes=None, ip_version=4, name=None, network_id='net1', no_gateway=False, prefix='', request_format='json', tenant_id=None, variables=[])
(Pdb) l
325 self.add_known_arguments(parser)
326 return parser
327
328 def get_data(self, parsed_args):
329 pdb.set_trace()
330 -> self.log.debug('get_data(%s)' % parsed_args)
331 quantum_client = self.get_client()
332 quantum_client.format = parsed_args.request_format
333 _extra_values = parse_args_to_dict(self.values_specs)
334 _merge_args(self, parsed_args, _extra_values,
335 self.values_specs)
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(331)get_data()
-> quantum_client = self.get_client()
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(332)get_data()
-> quantum_client.format = parsed_args.request_format
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(333)get_data()
-> _extra_values = parse_args_to_dict(self.values_specs)
(Pdb) n
> /opt/stack/python-quantumclient/quantumclient/quantum/v2_0/__init__.py(334)get_data()
-> _merge_args(self, parsed_args, _extra_values,
(Pdb) p _extra_values
{'dns_nameservers': ['8.8.8.7', '8.8.8.8']}
(Pdb)
Just for your info.
This is how I have coded in my "vpnconnection".
parser.add_argument(
'--peer_cidrs', metavar='PEER_CIDRS',
action='append', dest='peer_cidrs',
help='set the remote subnet(s) in CIDR format')
def args2body(self, parsed_args):
pdb.set_trace()
_vpnservice_id = quantumv20.find_resourceid_by_name_or_id(
self.get_client(), 'vpnservice',
parsed_args.vpnservice_id)
_ikepolicy_id = quantumv20.find_resourceid_by_name_or_id(
self.get_client(), 'ikepolicy',
parsed_args.ikepolicy_id)
_ipsecpolicy_id = quantumv20.find_resourceid_by_name_or_id(
self.get_client(), 'ipsecpolicy',
parsed_args.ipsecpolicy_id)
body = {
'vpnconnection': {
'vpnservice_id': _vpnservice_id,
'ikepolicy_id': _ikepolicy_id,
'ipsecpolicy_id': _ipsecpolicy_id,
'name': parsed_args.name,
'peer_address': parsed_args.peer_address,
'peer_id': parsed_args.peer_id,
'mtu': parsed_args.mtu,
'description': parsed_args.description,
'dpd_action': parsed_args.dpd_action,
'dpd_interval': parsed_args.dpd_interval,
'dpd_timeout': parsed_args.dpd_timeout,
'psk': parsed_args.psk,
'admin_state_up': parsed_args.admin_state_down,
},
}
pdb.set_trace()
if parsed_args.peer_cidrs:
body['vpnconnection']['peer_cidrs'] = parsed_args.peer_cidrs
pdb.set_trace()
return body
Thanks
Swaminathan Vasudevan
Systems Software Engineer (TC)
HP Networking
Hewlett-Packard
8000 Foothills Blvd
M/S 5541
Roseville, CA - 95747
tel: 916.785.0937
fax: 916.785.1815
email: swaminathan.vasudevan at hp.com
-----Original Message-----
From: Nachi Ueno [mailto:nachi at ntti3.com]
Sent: Wednesday, June 12, 2013 9:08 PM
To: Vasudevan, Swaminathan (PNB Roseville)
Subject: Re: Change in openstack/quantum[master]: blueprint VPNaaS-Python-API VPNaaS DataModel/Plugin
Hi Swami
Dest is destination argument
In this case,
https://github.com/openstack/python-quantumclient/blob/master/quantumclient/quantum/v2_0/subnet.py#L115
parameters go to parsed_args.dns_nameservers
https://github.com/openstack/python-quantumclient/blob/master/quantumclient/quantum/v2_0/subnet.py#L156
so here is some debug tips
1. use --verbose option on cli
quantum -verbose commands
You can see the api request and response.
2. Use pdb to check the value is set or not.
Best
Nachi
2013/6/12 Vasudevan, Swaminathan (PNB Roseville) <swaminathan.vasudevan at hp.com>:
> Hi Nachi,
>
> For some reason "list=true" does not work when I pass a list for the
> vpnconnection.
>
>
>
> parser.add_argument(
>
> '--peer_cidrs', metavar='PEER_CIDR',
>
> action='append', dest='peer_cidrs',
>
> help='set the remote subnet(s) in CIDR format')
>
>
>
> Nachi: What does the "dest=" mean.
>
>
>
> Is there anything else required in the client side to accept the list.
>
>
>
> The "list=true" command works for the example that you provided (for
> subnet).
>
>
>
> Thanks.
>
>
>
> Swaminathan Vasudevan
>
> Systems Software Engineer (TC)
>
>
>
>
>
> HP Networking
>
> Hewlett-Packard
>
> 8000 Foothills Blvd
>
> M/S 5541
>
> Roseville, CA - 95747
>
> tel: 916.785.0937
>
> fax: 916.785.1815
>
> email: swaminathan.vasudevan at hp.com
>
>
>
>
>
> -----Original Message-----
>
> From: Nachi Ueno [mailto:nachi at ntti3.com]
>
> Sent: Wednesday, June 12, 2013 2:52 PM
>
> To: Vasudevan, Swaminathan (PNB Roseville)
>
> Subject: Re: Change in openstack/quantum[master]: blueprint
> VPNaaS-Python-API VPNaaS DataModel/Plugin
>
>
>
> Hi Swami
>
>
>
> It should be as follows
>
>
>
> quantum vpn-connection-create --name myconnection --peer_id 10.20.0.30
>
> --peer_address 10.20.0.30 --peer_cidrs list=true 10.1.0.0/24
>
> 10.2.0.0/24 10.3.0.0/24 --psk abcd myvpn ikepolicy1 ipsecpolicy1
>
>
>
> (see this example)
>
> quantum subnet-create test-net1 40.0.0.0/24 --dns_nameservers
>
> list=true 8.8.8.7 8.8.8.8
>
> https://github.com/openstack/quantum/blob/master/quantum/api/v2/attributes.py#L608
>
>
>
> I said string_list is good, however cidr_list is more better.
>
> so could you implement type:cidr_list ?
>
>
>
> (list version of this validator)
>
> https://github.com/openstack/quantum/blob/master/quantum/api/v2/attributes.py#L246
>
>
>
> Thanks
>
> Nachi
>
>
>
> 2013/6/12 Vasudevan, Swaminathan (PNB Roseville)
> <swaminathan.vasudevan at hp.com>:
>
>> Hi Nachi,
>
>>
>
>>
>
>>
>
>> With the "string_list" type validate both the inputs are valid.
>
>>
>
>>
>
>>
>
>> Which one do you think will be the right way of setting the peer_cidrs.
>
>>
>
>>
>
>>
>
>> guest at swaminathan-virtual-machine-rest:~/devstack$ quantum
>
>> vpn-connection-create --name myconnection --peer_id 10.20.0.30
>
>> --peer_address 10.20.0.30 --peer_cidrs "['10.1.0.0/24', '10.2.0.0/24',
>
>> '10.3.0.0/24']" --psk abcd myvpn ikepolicy1 ipsecpolicy1
>
>>
>
>>
>
>>
>
>> guest at swaminathan-virtual-machine-rest:~/devstack$ quantum
>
>> vpn-connection-create --name myconnection --peer_id 10.20.0.30
>
>> --peer_address 10.20.0.30 --peer_cidrs "[10.1.0.0/24, 10.2.0.0/24,
>
>> 10.3.0.0/24]" --psk abcd myvpn ikepolicy1 ipsecpolicy1
>
>>
>
>>
>
>>
>
>> Thanks.
>
>>
>
>> Swaminathan Vasudevan
>
>>
>
>> Systems Software Engineer (TC)
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> HP Networking
>
>>
>
>> Hewlett-Packard
>
>>
>
>> 8000 Foothills Blvd
>
>>
>
>> M/S 5541
>
>>
>
>> Roseville, CA - 95747
>
>>
>
>> tel: 916.785.0937
>
>>
>
>> fax: 916.785.1815
>
>>
>
>> email: swaminathan.vasudevan at hp.com
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> -----Original Message-----
>
>> From: Nachi Ueno [mailto:nachi at ntti3.com]
>
>> Sent: Wednesday, June 12, 2013 10:09 AM
>
>> To: Vasudevan, Swaminathan (PNB Roseville)
>
>> Subject: Re: Change in openstack/quantum[master]: blueprint
>
>> VPNaaS-Python-API VPNaaS DataModel/Plugin
>
>>
>
>>
>
>>
>
>> Hi Swami
>
>>
>
>>
>
>>
>
>> +1 for new type:string_list
>
>>
>
>>
>
>>
>
>> Ps. Could you reply on gerrit for review comment?
>
>>
>
>>
>
>>
>
>> Thanks
>
>>
>
>> Nachi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130617/a7fbdc17/attachment.html>
More information about the OpenStack-dev
mailing list