@Pedro, @Shaogang:
change from Long -> String cause update issue, So I change the type from
Long -> BigInteger
swen@ubserver:~/contrail/java-api/generateds$ git diff
diff --git a/ifmap_global.py b/ifmap_global.py
index 7ea3526..90c398e 100644
--- a/ifmap_global.py
+++ b/ifmap_global.py
@@ -19,7 +19,7 @@ JavaTypeMap = {
'xsd:integer': 'Integer',
'xsd:unsignedInt': 'Integer',
'xsd:boolean': 'boolean',
- 'xsd:unsignedLong' : 'Long',
+ 'xsd:unsignedLong' : 'java.math.BigInteger',
'xsd:dateTime': 'java.util.Date',
'xsd:time': 'Long'
}
following is the contrail-api log caused by String mslong:
04/19/2015 04:47:18 AM [ubuntus1:contrail-api:Config:0]: __default__
[SYS_ERR]: VncApiError: <type 'exceptions.TypeError'>
Python 2.7.6: /usr/bin/python
Sun Apr 19 04:47:18 2015
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py in
handler_trap_exception(*args=(), **kwargs={'id': '7
7e329f1-5a81-4db9-b190-520be23514fb'})
474 trace = self._generate_rest_api_request_trace()
475 try:
476 response = handler(*args, **kwargs)
477 self._generate_rest_api_response_trace(trace,
response)
478 return response
response undefined
handler = <bound method
VncApiServer.virtual_machine_http_...i_server.vnc_cfg_api_server.VncApiServer
object>>
args = ()
kwargs = {'id': '77e329f1-5a81-4db9-b190-520be23514fb'}
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/vnc_api_server_gen.py in
virtual_machine_http_put(self=<vnc_cfg_api_serv
er.vnc_cfg_api_server.VncApiServer object>,
id='77e329f1-5a81-4db9-b190-520be23514fb')
12793 buf = cStringIO.StringIO()
12794 xx_id_perms = IdPermsType(**prop_dict)
12795 xx_id_perms.export(buf)
12796 node = etree.fromstring(buf.getvalue())
12797 xx_id_perms = IdPermsType()
xx_id_perms = <vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>
xx_id_perms.export = <bound method IdPermsType.export of
<vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>>
buf = <cStringIO.StringO object>
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py in
export(self=<vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>,
outfile=<cStringIO.StringO object>, level=1, namespace_='', name_='IdPermsType',
namespacedef_='', pretty_print=True)
True)
4944 if self.hasContent_():
4945 outfile.write('>%s' % (eol_, ))
4946 self.exportChildren(outfile, level + 1, namespace_,
name_, pretty_print=pretty_print)
4947 showIndent(outfile, level, pretty_print)
4948 outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
self = <vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>
self.exportChildren = <bound method IdPermsType.exportChildren of
<vnc..._api_server.gen.resource_xsd.IdPermsType object>>
outfile = <cStringIO.StringO object>
level = 1
namespace_ = ''
name_ = 'IdPermsType'
pretty_print = True
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py in
exportChildren(self=<vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>,
outfile=<cStringIO.StringO object>, level=2, namespace_='', name_='IdPermsType',
fromsubclass_=False, pretty_print=True)
4959 self.permissions.export(outfile, level, namespace_,
name_='permissions', pretty_print=pretty_print)
4960 if self.uuid is not None:
4961 self.uuid.export(outfile, level, namespace_,
name_='uuid', pretty_print=pretty_print)
4962 if self.enable is not None:
4963 showIndent(outfile, level, pretty_print)
self = <vnc_cfg_api_server.gen.resource_xsd.IdPermsType object>
self.uuid = <vnc_cfg_api_server.gen.resource_xsd.UuidType object>
self.uuid.export = <bound method UuidType.export of
<vnc_cfg_api_server.gen.resource_xsd.UuidType object>>
outfile = <cStringIO.StringO object>
level = 2
namespace_ = ''
name_ = 'IdPermsType'
pretty_print = True
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py in
export(self=<vnc_cfg_api_server.gen.resource_xsd.UuidType object>,
outfile=<cStringIO.StringO object>, level=2, namespace_='', name_='uuid',
namespacedef_='', pretty_print=True)
741 if self.hasContent_():
742 outfile.write('>%s' % (eol_, ))
743 self.exportChildren(outfile, level + 1, namespace_,
name_, pretty_print=pretty_print)
744 showIndent(outfile, level, pretty_print)
745 outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
self = <vnc_cfg_api_server.gen.resource_xsd.UuidType object>
self.exportChildren = <bound method UuidType.exportChildren of
<vnc_cfg_api_server.gen.resource_xsd.UuidType object>>
outfile = <cStringIO.StringO object>
level = 2
namespace_ = ''
name_ = 'uuid'
pretty_print = True
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py in
exportChildren(self=<vnc_cfg_api_server.gen.resource_xsd.UuidType object>,
outfile=<cStringIO.StringO object>, level=3, namespace_='', name_='uuid',
fromsubclass_=False, pretty_print=True)
755 if self.uuid_mslong is not None:
756 showIndent(outfile, level, pretty_print)
757 outfile.write('<%suuid-mslong>%s</%suuid-mslong>%s' %
(namespace_, self.gds_format_integer(self.uuid_mslong,
input_name='uuid-mslong'), namespace_, eol_))
758 if self.uuid_lslong is not None:
759 showIndent(outfile, level, pretty_print)
outfile = <cStringIO.StringO object>
outfile.write = <built-in method write of cStringIO.StringO object>
namespace_ = ''
self = <vnc_cfg_api_server.gen.resource_xsd.UuidType object>
self.gds_format_integer = <bound method UuidType.gds_format_integer of
<vnc_cfg_api_server.gen.resource_xsd.UuidType object>>
self.uuid_mslong = '8638794626809023929'
input_name undefined
eol_ = '\n'
/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/generatedssuper.py in
gds_format_integer(self=<vnc_cfg_api_server.gen.resource_xsd.UuidType object>,
input_data='8638794626809023929', input_name='uuid-mslong')
68
69 def gds_format_integer(self, input_data, input_name=''):
70 return '%d' % input_data
71
72 def gds_validate_integer(self, input_data, node, input_name=''):
input_data = '8638794626809023929'
<type 'exceptions.TypeError'>: %d format: a number is required, not str
__class__ = <type 'exceptions.TypeError'>
__delattr__ = <method-wrapper '__delattr__' of exceptions.TypeError
object>
__dict__ = {}
__doc__ = 'Inappropriate argument type.'
__format__ = <built-in method __format__ of exceptions.TypeError
object>
__getattribute__ = <method-wrapper '__getattribute__' of
exceptions.TypeError object>
__getitem__ = <method-wrapper '__getitem__' of exceptions.TypeError
object>
__getslice__ = <method-wrapper '__getslice__' of
exceptions.TypeError object>
__hash__ = <method-wrapper '__hash__' of exceptions.TypeError object>
__init__ = <method-wrapper '__init__' of exceptions.TypeError object>
__new__ = <built-in method __new__ of type object>
__reduce__ = <built-in method __reduce__ of exceptions.TypeError
object>
__reduce_ex__ = <built-in method __reduce_ex__ of
exceptions.TypeError object>
__repr__ = <method-wrapper '__repr__' of exceptions.TypeError object>
__setattr__ = <method-wrapper '__setattr__' of exceptions.TypeError
object>
__setstate__ = <built-in method __setstate__ of
exceptions.TypeError object>
__sizeof__ = <built-in method __sizeof__ of exceptions.TypeError
object>
__str__ = <method-wrapper '__str__' of exceptions.TypeError object>
__subclasshook__ = <built-in method __subclasshook__ of type object>
__unicode__ = <built-in method __unicode__ of exceptions.TypeError
object>
args = ('%d format: a number is required, not str',)
message = '%d format: a number is required, not str'
The above is a description of an error in a Python program. Here is
the original traceback:
Traceback (most recent call last):
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py",
line 476, in handler_trap_exception
response = handler(*args, **kwargs)
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/vnc_api_server_gen.py",
line 12795, in virtual_machine_http_put
xx_id_perms.export(buf)
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py",
line 4946, in export
self.exportChildren(outfile, level + 1, namespace_, name_,
pretty_print=pretty_print)
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py",
line 4961, in exportChildren
self.uuid.export(outfile, level, namespace_, name_='uuid',
pretty_print=pretty_print)
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py",
line 743, in export
self.exportChildren(outfile, level + 1, namespace_, name_,
pretty_print=pretty_print)
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/resource_xsd.py",
line 757, in exportChildren
outfile.write('<%suuid-mslong>%s</%suuid-mslong>%s' % (namespace_,
self.gds_format_integer(self.uuid_mslong, input_name='uuid-mslong'),
namespace_, eol_))
File
"/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/gen/generatedssuper.py",
line 70, in gds_format_integer
return '%d' % input_data
TypeError: %d format: a number is required, not str
在 2015年04月18日 10:18, 温曙光 写道:
When java api try to read some object from api server, the gson
library can't de-serialize the object since these two unsigned long
number can't fit in Java Long type:
{"uuid_mslong": 5976865681521722305, "uuid_lslong": 10854624204062833991},
generateDS.sh map xsd:unsignedLong to java Long is not enough, It need
more precise.
在 2015年04月18日 00:05, Pedro Marques 写道:
The UuidType stores UUIDs as 2 longs. While this is how uuids get
propagated to the control-node/vrouter, you shouldn’t use this field
when using the java API. There are members to access/set the Uuid
property as a Java uuid type.
On Jan 22, 2015, at 11:03 AM, Shaogang Chen <[email protected]
<mailto:[email protected]>> wrote:
Pedro
Thank you for ur reply. We have started to use
Juniper/contrail-java-api. There is one issue we found on Java API.
We use generateDS.sh to generate the Java types. One of the types is
IdPermsType.java, in which we have the following
Public class IdPermsType extends ApiPropertyBase {
Public static class UuidType {
Long uuid_mslong;
Long uid_lslong;
However, we have found out that the uuid from DB is too large to fit
into a Java Long. How to solve this issue? We modify the type from
Long to String locally, then it works.
Thanks
Shaogang
From: Pedro Marques <[email protected] <mailto:[email protected]>>
Date: Thursday, January 15, 2015 at 5:18 PM
To: Shaogang Chen <[email protected] <mailto:[email protected]>>
Cc: "[email protected] <mailto:[email protected]>"
<[email protected] <mailto:[email protected]>>,
Sachchidanand Vaidya <[email protected]
<mailto:[email protected]>>
Subject: Re: [opencontrail-dev] about Java API
Shaogang,
github.com/Juniper/contrail-java-api
<http://github.com/Juniper/contrail-java-api> is the most up-to date
version.
We should delete the previous version in the controller repository.
Pedro.
On Jan 15, 2015, at 5:10 PM, Shaogang Chen <[email protected]
<mailto:[email protected]>> wrote:
Contrail has Java API under the following two places.
Juniper <https://github.com/Juniper>/*contrail-java-api
<https://github.com/Juniper/contrail-java-api>*
Juniper/contrail-controller
<https://github.com/Juniper/contrail-controller>/src
<https://github.com/Juniper/contrail-controller/tree/master/src>/api-lib
<https://github.com/Juniper/contrail-controller/tree/master/src/api-lib>/*java*/
I would like to know which one we should use. Do your team intend
to maintain both repository
Thanks
Shaogang
_______________________________________________
Dev mailing list
[email protected] <mailto:[email protected]>
http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org
_______________________________________________
Dev mailing list
[email protected]
http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org
_______________________________________________
Dev mailing list
[email protected]
http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org
_______________________________________________
Dev mailing list
[email protected]
http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org