def exportZProperties(self, exclusionList=()): """ @param exclusionList: list of zproperties we do not want to export @type exclusionList: collection For this manager will return the following about each zProperty Will return the following about each Zen Property - id - identifier - islocal - if this object has a local definition - value - value for this object - valueAsString - string representation of the property - type - int string lines etc - path - where it is defined - options - acceptable values of this zProperty """ props = [] for zId in self.zenPropertyIds(): if zId in exclusionList: continue prop = dict(id=zId, islocal=self.hasProperty(zId), type=self.getPropertyType(zId), path=self.zenPropertyPath(zId), options=self.zenPropertyOptions(zId), category=getzPropertyCategory(zId), value=None, valueAsString=self.zenPropertyString(zId)) if not self.zenPropIsPassword(zId): prop['value'] = self.getZ(zId) else: prop['value'] = self.zenPropertyString(zId) props.append(prop) return props
def exportZProperties(self, exclusionList=()): """ @param exclusionList: list of zproperties we do not want to export @type exclusionList: collection For this manager will return the following about each zProperty Will return the following about each Zen Property - id - identifier - islocal - if this object has a local definition - value - value for this object - valueAsString - string representation of the property - type - int string lines etc - path - where it is defined - options - acceptable values of this zProperty """ props = [] for zId in self.zenPropertyIds(): if zId in exclusionList: continue prop = dict( id=zId, islocal=self.hasProperty(zId), type=self.getPropertyType(zId), path=self.zenPropertyPath(zId), options=self.zenPropertyOptions(zId), category=getzPropertyCategory(zId), value=None, valueAsString=self.zenPropertyString(zId) ) if not self.zenPropIsPassword(zId): prop['value'] = self.getZ(zId) else: prop['value'] = self.zenPropertyString(zId) props.append(prop) return props
def remote_getSnmpConfig(self, devicePath, snmpCategory='SNMP'): "Get the snmp configuration defaults for scanning a device" devroot = self.dmd.Devices.createOrganizer(devicePath) snmpConfig = {} for name, value in devroot.zenPropertyItems(): if getzPropertyCategory(name) == snmpCategory: snmpConfig[name] = value return snmpConfig
def remote_getDeviceClassSnmpConfig(self, devicePath, category='SNMP'): "Get the snmp configuration defaults for scanning a device" devRoot = self.dmd.Devices.createOrganizer(devicePath) snmpConfig = {} for name, value in devRoot.zenPropertyItems(): if getzPropertyCategory(name) == category: snmpConfig[name] = value return snmpConfig
def test_ZenPack(self): """Assert that ZenPack class has been properly created.""" from ZenPacks.zenoss.ZPLTest1 import ZenPack zenpack = ZenPack('ZenPacks.zenoss.ZPLTest1') self.assert_superclasses(zenpack, ( ZenPack, schema.ZenPack, )) expected_zpropnames = { 'zZPLTest1Port', 'zZPLTest1Username', 'zZPLTest1Password', } zpropnames = {x[0] for x in zenpack.packZProperties} self.assertTrue( expected_zpropnames.issubset(zpropnames), "missing zProperties: {difference!r}" .format( difference=expected_zpropnames.difference(zpropnames))) expected_zproperties = { 'zZPLTest1Port': (443, 'int'), 'zZPLTest1SSL': (True, 'boolean'), 'zZPLTest1Username': ('admin', 'string'), 'zZPLTest1Password': ('', 'password'), 'zZPLTest1HealthInterval': (300, 'int'), } for zpropname, zpdefault, zptype in zenpack.packZProperties: self.assertEquals( getzPropertyCategory(zpropname), 'ZPLTest1', "{zpropname!r} isn't categorized as 'ZPLTest1'" .format( zpropname=zpropname)) expected_zpdefault, expected_zptype = expected_zproperties[zpropname] self.assertEquals( zpdefault, expected_zpdefault, "{zpropname!r} has default of {zpdefault!r} instead of {expected_zpdefault!r}" .format( zpropname=zpropname, zpdefault=zpdefault, expected_zpdefault=expected_zpdefault)) self.assertEquals( zptype, expected_zptype, "{zpropname!r} has type of {zptype!r} instead of {expected_zptype!r}" .format( zpropname=zpropname, zptype=zptype, expected_zptype=expected_zptype))
def exportZProperty(self, zId, root=None): if not root: root = self.getDmdRoot(self.dmdRootName) return dict(id=zId, islocal=self.hasProperty(zId), type=self.getPropertyType(zId), path=self.zenPropertyPath(zId), options=self.zenPropertyOptions(zId), category=getzPropertyCategory(zId), value=None, valueAsString=self.zenPropertyString(zId), label=root.propertyLabel(zId), description=root.propertyDescription(zId))
def exportZProperty(self, zId, root=None): if not root: root = self.getDmdRoot(self.dmdRootName) return dict( id=zId, islocal=self.hasProperty(zId), type=self.getPropertyType(zId), path=self.zenPropertyPath(zId), options=self.zenPropertyOptions(zId), category=getzPropertyCategory(zId), value=None, valueAsString=self.zenPropertyString(zId), label=root.propertyLabel(zId), description= root.propertyDescription(zId) )