TECHZEN Zenoss User Community ARCHIVE  

Help Needed in creating relationships for a Zenpack

Subject: Help Needed in creating relationships for a Zenpack
Author: [Not Specified]
Posted: 2015-03-05 00:41

H

We at Nutanix are doing a proof of concept by creating a Nutanix Zenpack. We have been following Zenoss developer guide and are stuck in the container modeling section .

http://zenosslabs.readthedocs.org/en/latest/zenpack_development/monitori...

We have created a component subclass but when we try to establish the relationship between the component and device , we have been consistently getting the below error , even after deleting and re-adding the device and rebuilding the relation for the device .

>>> from ZenPacks.community.Nutanix.ControllerVM import ControllerVM
>>> cvm = ControllerVM('cvm_01')
>>> device = find("angola-c2.eng.nutanix.com")
>>> device.buildRelations()
>>> commit()
>>> device.Controller_VM._setObject(cvm.id)
Traceback (most recent call last):
File "", line 1, in
AttributeError: Controller_VM

For your reference , I am putting down the code for the Device Component Subclass (ControllerVM.py) and device class (NutanixDevice.py). Request your help on this

============================================================
Device Component Subclass (ControllerVM.py)
============================================================

# Import Symbols

from Products.ZenModel.DeviceComponent import DeviceComponent
from Products.ZenModel.ManagedEntity import ManagedEntity
from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE
from Products.ZenRelations.RelSchema import ToManyCont, ToOne

class ControllerVM(DeviceComponent, ManagedEntity):
meta_type = portal_type = 'ControllerVM'

ControllerVMMemory= None
ControllerVMNumCpus = None

_properties = ManagedEntity._properties + (
{'id': 'ControllerVMMemory', 'type': 'int'},
{'id': 'ControllerVMNumCpus', 'type': 'int'},
)

_relations = ManagedEntity._relations + (
('Nutanix_Device', ToOne(ToManyCont,
'ZenPacks.community.Nutanix.NutanixDevice',
'Controller_VM',
)
),
)

# factory_type_information = ({
# 'actions': ({
# 'id': 'perfConf',
# 'name': 'Template',
# 'action': 'objTemplates',
# 'permissions': (ZEN_CHANGE_DEVICE,),
# },),
# },)

def device(self):
return self.Nutanix_Device()

# def getRRDTemplateName(self):
# return 'Controller_VM'a

============================================================
Device class (NutanixDevice.py)
============================================================
from Products.ZenModel.Device import Device
from Products.ZenRelations.RelSchema import ToManyCont, ToOne

class NutanixDevice(Device):
total_cvm_count = None

_properties = Device._properties + (
{'id': 'total_cvm_count', 'type': 'int'},
)

_relations = Device._relations + (
('Controller_VM', ToManyCont(ToOne,
'ZenPacks.community.Nutanix.ControllerVM',
'Nutanix_Device',
)
),
)

T



Subject: Did you ever figure this one
Author: [Not Specified]
Posted: 2015-03-23 12:15

Did you ever figure this one out

If you still need a hand let me know. sparctacus@gmail.com



< Previous
Metrics collection not working when we run zenpython in background (ie: zenpytho ...
  Next
Getting attribute error while trying to test component class .
>