[Zenoss-dev] Re: lookupSchema

Erik A. Dahl edahl at zenoss.com
Tue Mar 4 22:08:48 EST 2008


If you want to add relationships to one of the zenoss classes you  
really should subclass it and add the relations there.  This is pretty  
easy if you are adding to Device.py because zenoss has a mechanism to  
control what python class is instantiated based on the zenoss device  
class (/Devices/Etc).  To do this set the zProperty zPythonClass to  
the name of your subclass.

Its harder if you need to subclass OperatingSystem.py as you seem to  
want to do.  In Device.__init__ you can see the OperatingSystem class  
being added.  You really need to override the constructor in your  
subclass.  I guess that's not the end of the world if you have already  
gone down the road of using zPythonClass.

-EAD

On Mar 4, 2008, at 12:17 PM, lazabba wrote:

> Hi,
>
> physicaldisks is only a simple example- which will allow me to  
> create something more sophisticated later and I do need a  
> flexibility of zenpacks such as creating relationships without  
> modifing the original zenoss code.
>
>
>
>
>
> edahl wrote:
>> I can dive into the details of making a relationship with you but
>> before we get too far I think you need to take a look at the DeviceHW
>> harddisks relationship.  I think that's what you are looking for.  In
>> the modeler look at the InformantHardDiskMap.py for an example of how
>> to map the object.  Your path should be something like.
>>
>> device.hw.harddisks.sd0
>>
>> -EAD
>>
>> On Mar 4, 2008, at 11:40 AM, lazabba wrote:
>>
>>
>>> Yes I've seen it done this way.
>>> But somehow I do not like it, so I figured out a different way - as
>>> above. Seems to work.
>>>
>>> It also looks like_createRelObject from ApplyDataMap called during
>>> zenmodelling should be able to fix some relations if they do not
>>> exist. But I haven't made attempts to verify how and why.
>>>
>>>
>>> A.
>>>
>>>
>>>
>>> ecn wrote:
>>>
>>>> Ahhh.  Ok.
>>>>
>>>> Here's a basic outline of what you need to do.
>>>>
>>>>
>>>> Add an entry to to the list of _relations in the OperatingSystem
>>>> class variable
>>>>
>>>> Specify both sides of the relation (ToManyCont and ToOne)... lots
>>>> of examples of that all over the ZenModel/*.py files.
>>>>
>>>>
>>>> Code:
>>>> OperatingSystem._relations += ('physicalDisks',
>>>> ToManyCont(ToOne, ...))
>>>>
>>>>
>>>>
>>>> Then rebuild the relations on all the existing objects.  You only
>>>> want to do this once since it means touching every device.
>>>>
>>>>
>>>> Code:
>>>> for d in dmd.getSubDevices():
>>>> d.os.buildRelations()
>>>>
>>>>
>>>>
>>>>
>>>> I hope this helps.
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> zenoss-dev mailing list
>>> zenoss-dev at zenoss.org
>>> http://lists.zenoss.org/mailman/listinfo/zenoss-dev
>>>
>>
>> -EAD
>>
>> Erik A. Dahl
>> Co-Founder and CTO, Zenoss Inc.
>> http://www.zenoss.com
>>
>>
>>
>>
>>
>> _______________________________________________
>> zenoss-dev mailing list
>> zenoss-dev at zenoss.org
>> http://lists.zenoss.org/mailman/listinfo/zenoss-dev
>
>
>
>
>
> -------------------- m2f --------------------
>
> Read this topic online here:
> http://community.zenoss.com/forums/viewtopic.php?p=16922#16922
>
> -------------------- m2f --------------------
>
>
>
> _______________________________________________
> zenoss-dev mailing list
> zenoss-dev at zenoss.org
> http://lists.zenoss.org/mailman/listinfo/zenoss-dev

-EAD

Erik A. Dahl
Co-Founder and CTO, Zenoss Inc.
http://www.zenoss.com







More information about the zenoss-dev mailing list