[Engine-devel] [ovirt-engine-sdk] some questions about the params.py code generated by generateSD

ShaoHe Feng shaohef at linux.vnet.ibm.com
Fri Jun 8 17:30:21 UTC 2012


still a question.

I find  there are reduplicate items in _rootClassMap dictionary  of 
./src/ovirtsdk/xml/params.py file.
such as:
1.
in line 18924
                   "storage"                       : Storage,
in line 18931
                   "storage"                       : Storage,
above items has same key and value.

2.
in line 18905
                   "product_info"                  : ProductInfo,
in line 18934
                   "product_info"                  : ProductInfo,
above items has same key and value.

3.
  in line 18953
                     "vm_pause_details"              : VmPauseDetails,
  in line 18962
                     "vm_pause_detail"               : VmPauseDetails,

above items  has value but different key.

is it OK ? or should I commit  a patch to fix it?


On 06/08/2012 02:04 AM, Juan Hernandez wrote:
> On 06/07/2012 05:14 PM, ShaoHe Feng wrote:
>> Hi all,
>>
>> as we all know the current params.py was not completely by the
>> generateSD.py, there are parts that have to be updated manually.
>>
>> now I have post a primarypatch to improve it.
>> http://gerrit.ovirt.org/#/c/4880/
>>
>> it can generate some codes, but still two parts codes can not be 
>> generated.
>>
>> they aretwo dictionaries: _rootClassMap and _elementToClassMap.
>>
>> However, for I do get any clue to know these two dictionaries  from the
>> params.py.
>
> The reason for these dictionaries is that "generateDS.py" generates 
> classes for the complex types inside the API .xsd, but it doesn't 
> generate anything for the tags that can appear as root tags in the XML 
> documents used by the API. The map helps the parser find the classes 
> that correspond to each of those tags.
>
> It might be possible to generate this map from the list of classes 
> using a rule like this:
>
>   CamelCaseName -> camel_case_names
>
> But there are exceptions like these:
>
>   VLAN -> vlan
>   IPs  -> ips
>   IscsiDetails -> iscsi
>
> You could write code that takes into account the exceptions and 
> generates the map. But I think it is not worth, and error prone. I 
> would rather take that chunk of code out of params.py and move it to 
> an external file or to a constant, like you do for other chunks of 
> code in paramsconf.py.
>
>> there are some questions:
>> 1.
>> And the __all__ list  which include all the classes of _rootClassMap and
>> _elementToClassMap.
>> And there some classes  both in _rootClassMap and _elementToClassMap.
>
> The "__all__" list is just a python mechanism to control the symbols 
> that are imported when you do something like "from whatever import *". 
> In this case "generateDS.py" is making sure that all the generated 
> classes are imported, which is not really relevant for us.
>
>> 2.
>> And  some of class in _rootClassMap inherit GeneratedsSuper class, some
>> inherit BaseResource class, and two classes inherit Link class.
>> And it is the same with _elementToClassMap.
>>
>> so what is the difference between _rootClassMap and _elementToClassMap.
>> What rule to generate these two dictionaries.
>
> I can't find any difference between those two dictionaries, they serve 
> exactly the same purpose. Maybe Michael had a future use in mind.
>
>> 3.
>> And also, how to generate the keys in _rootClassMap and
>> _elementToClassMap.Any rule to generate them?
>>
>> there are some items in these two dictionaries
>>
>>                         "access_control_list"           :
>> AccessControlList,   #  "_" among the word in key
>>                         "api"                                    : API,
>>                         "body"                                 : Body,
>>                          "iscsi"                                 :
>> IscsiDetails,             # key "iscsi" is one part of value 
>> "IscsiDetails"
>>                         "storage_domain"                : StorageDomain,
>>                         "topology"                           : 
>> CpuTopology,
>>                         "creation_status"                  : Status, #
>> key has a more word  "creation"  than the value.
>>                         "parent"                                : 
>> TagParent
>
>
>




More information about the Devel mailing list