def editDevice(info): Zenoss = {'deviceName': '', 'devicePath': '', 'tag': '', 'serialNumber': '', 'zSnmpCommunity': 'monitor', 'zSnmpPort': '161', 'zSnmpVer': 'v1', 'rackSlot': '0', 'productionState': '1000', 'comments': '', 'hwManufacturer': '', 'hwProductName': '', 'osManufacturer': '', 'osProductName': '', 'locationPath': '', 'groupPaths': '', 'systemPaths': '', 'statusMonitors': '', 'performanceMonitor': '', 'discoverProto': 'snmp', 'priority': '3'} x = 0 for a in info: Zenoss['deviceName'] = info[x][0] url = http(Zenoss['deviceName']) valid = re.search("http", url) if valid: snmp_out = http(url+snmpurl) Zenoss['zSnmpCommunity'] = snmp_out[0] Zenoss['zSnmpVer'] = snmp_out[1] Zenoss['comments'] = "Switch %s\n Hardware %s\n Console %s\n Power %s\n Build Profile %s" % (info[x][2],info[x][3],info[x][4],info[x][5],info[x][6]) sys_match = re.search("\w+", "info[x][8]") if sys_match: Zenoss['systemPaths'] = "/%s" % (info[x][8]) groups_return = http(groupsUrl) Zenoss['groupPaths'] = group_final(groups_return, Zenoss['systemPaths']) serv = ServerProxy (url,allow_none=1) serv.manage_editDevice(Zenoss['tag'], Zenoss['serialNumber'], Zenoss['zSnmpCommunity'], Zenoss['zSnmpPort'], Zenoss['zSnmpVer'], Zenoss['rackSlot'], Zenoss['productionState'], Zenoss['comments'], Zenoss['hwManufacturer'], Zenoss['hwProductName'], Zenoss['osManufacturer'], Zenoss['osProductName'], Zenoss['locationPath'] , Zenoss['groupPaths'], Zenoss['systemPaths']) if verbose: print "%s\n%s\n%s\n%s\n%s\n%s\n" % (url,Zenoss['zSnmpCommunity'],Zenoss['zSnmpVer'],Zenoss['comments'], Zenoss['systemPaths'],Zenoss['groupPaths']) x = x +1
def editDevice(cluster, host): Zenoss = {'deviceName': '', 'devicePath': '', 'tag': '', 'serialNumber': '', 'zSnmpCommunity': 'cci-ro', 'zSnmpPort': '161', 'zSnmpVer': 'v2c', 'rackSlot': '0', 'productionState': '1000', 'comments': '', 'hwManufacturer': '', 'hwProductName': '', 'osManufacturer': '', 'osProductName': '', 'locationPath': '', 'groupPaths': '', 'systemPaths': '', 'statusMonitors': '', 'performanceMonitor': '', 'discoverProto': 'snmp', 'priority': '3'} Zenoss['deviceName'] = host Zenoss['systemPaths'] = cluster url = http(Zenoss['deviceName']) valid = re.search("http", url) if valid: snmp_out = http(url+snmpurl) Zenoss['zSnmpCommunity'] = snmp_out[0] Zenoss['zSnmpVer'] = snmp_out[1] sys_match = re.search("\w+", "cluster") if sys_match: Zenoss['systemPaths'] = "/%s" % (cluster) # groups_return = http(groupsUrl) # Zenoss['groupPaths'] = group_final(groups_return, Zenoss['systemPaths']) serv = ServerProxy (url,allow_none=1) serv.manage_editDevice(Zenoss['tag'], Zenoss['serialNumber'], Zenoss['zSnmpCommunity'], Zenoss['zSnmpPort'], Zenoss['zSnmpVer'], Zenoss['rackSlot'], Zenoss['productionState'], Zenoss['comments'], Zenoss['hwManufacturer'], Zenoss['hwProductName'], Zenoss['osManufacturer'], Zenoss['osProductName'], Zenoss['locationPath'] , Zenoss['groupPaths'], Zenoss['systemPaths']) if verbose: print "%s\n%s\n%s\n%s\n%s\n%s\n" % (url,Zenoss['zSnmpCommunity'],Zenoss['zSnmpVer'],Zenoss['comments'], Zenoss['systemPaths'],Zenoss['groupPaths'])