def appendToAudit(strToAppend): # if (auditFileName == '') : auditFileName = getReportDirectory( ) + 'technical-linux' + '-' + strTechnologyType + '-' + strEnvironment + '-' + datetimeSuffix + '.csv' appendToFile(strToAppend, auditFileName)
def appendToAudit(strToAppend): global auditFileName global strEnvironment global strTechnologyType if (auditFileName == ''): auditFileName = '../reports/technical' + '-' + strTechnologyType + '-' + strEnvironment + '-' + datetimeSuffix + '.csv' appendToFile(strToAppend, auditFileName)
def appendToReport(strToAppend): global reportFileName global strEnvironment global strTechnologyType if (reportFileName == ''): reportFilename = '../reports/managerial' + '-' + strTechnologyType + '-' + strEnvironment + '-' + datetimeSuffix + '.csv' appendToFile(strToAppend, reportFilename)
mkdir_p("./autoGen") auditAtomFile = "./autoGen/CodeGen.AuditAtomsWritable.py" auditPropertyFile = "./autoGen/CodeGen.PropertiesWritable.py" remoteServerConnection = getConnection(host, port) domainList = getDomainList(remoteServerConnection) writeToFile("\n", auditAtomFile) # reset file writeToFile("\n", auditPropertyFile) # reset file for domain in domainList: print "# Code generation. Copy AuditAtoms generated into your code.\n" print '# Domain:' + domain appendToFile("# Code generation. Copy AuditAtoms generated into your code.\n", auditAtomFile) appendToFile('# Domain:' + domain + "\n", auditAtomFile) objectNames = getObjectNames(remoteServerConnection, domain) for objectName in objectNames: sleep(0.1) #print ' Object Name:' + name.toString() mInfo = remoteServerConnection.getMBeanInfo(objectName) mBeanAttrs = mInfo.getAttributes() for attr in mBeanAttrs : if (attr.isWritable()) : #print ' Attribute: ' + attr.getName() + ', type: ' + str(attr.getType()) + ', ' + name.toString() + ': is Writable' strToPrintAndUse = "\t" + "auditObjectAtoms.append(auditObjectAtom(servername, runtimeProperties[\"port\"], runtimeProperties[\"username\"], runtimeProperties[\"password\"], \"" + domain + ". " + attr.getName() + "\", \"" + objectName.toString() + "\", \"" + attr.getName() + "\", runtimeProperties[\"" + objectName.toString() + ". " + attr.getName() + "\"], bApplyRequiredChanges))" print strToPrintAndUse appendToFile(strToPrintAndUse + "\n", auditAtomFile)
def appendToReport(strToAppend): # if (reportFileName == '') : reportFilename = getReportDirectory( ) + 'managerial-linux' + '-' + strTechnologyType + '-' + strEnvironment + '-' + datetimeSuffix + '.csv' appendToFile(strToAppend, reportFilename)
def importSatIntoInventoryMultiEnvironmentExcluding( csvFile, inventoryPythonOutputFile, columnOfHostnames, columnOfServerType, columnOfEnvironments, excludesList): # init file writeToFile("\n", inventoryPythonOutputFile) hostEntries = Set() allHosts = Set() allEnvironments = Set() allServerTypes = Set() with open(csvFile) as csvDataFile: csvReader = csv.reader(csvDataFile) appendToFile("allHosts = [\n", inventoryPythonOutputFile) rowCount = 0 for row in csvReader: if (rowCount > 0): # ignore title row.. excludeThis = False if (excludesList.count > 0): # if we have to consider and excludes list for excludeEntry in excludesList: for columnEntry in row: if (str(excludeEntry).lower() in columnEntry): excludeThis = True break if (str(excludeEntry).upper() in columnEntry): excludeThis = True break if (not excludeThis): # if not excluded if len(row) >= columnOfHostnames and len( row) >= columnOfEnvironments and len( row) >= columnOfServerType: print 'Row:' + str(rowCount) + ', ' + row[ columnOfHostnames] + ', ' + row[ columnOfEnvironments] + ', ' + row[ columnOfServerType] #print row[columnOfHostnames], row[columnOfEnvironments], (row[columnOfServerType]) hostname = str(row[columnOfHostnames]) environment = stripNonChars( str(row[columnOfEnvironments])) serverType = stripNonChars( str(row[columnOfServerType])) aHostEntry = hostEntry(hostname, environment, serverType) hostEntries.add(aHostEntry) allHosts.add(hostname) allServerTypes.add(serverType) if not (environment in allEnvironments): allEnvironments.add(environment) appendToFile('\t"' + hostname + '",\n', inventoryPythonOutputFile) else: if not (environment in allEnvironments): allEnvironments.add(environment) appendToFile('\t"' + hostname + '",\n', inventoryPythonOutputFile) rowCount = rowCount + 1 appendToFile("\n]\n\n", inventoryPythonOutputFile) # all environments appendToFile('allEnvironments = [\n', inventoryPythonOutputFile) for anEnvironment in allEnvironments: print 'environment: ' + anEnvironment appendToFile('\t"' + anEnvironment + '",\n', inventoryPythonOutputFile) appendToFile("\n]\n\n", inventoryPythonOutputFile) # hosts in an environment... for anEnvironment in allEnvironments: print 'Environment: ' + anEnvironment appendToFile('env_' + anEnvironment + ' = [\n', inventoryPythonOutputFile) for aHostEntry in hostEntries: if (anEnvironment in aHostEntry.environment): print 'Environment: ' + anEnvironment + ' host: ' + aHostEntry.hostname appendToFile('\t"' + aHostEntry.hostname + '",\n', inventoryPythonOutputFile) appendToFile("\n]\n\n", inventoryPythonOutputFile) # hosts in their environment by type... for anEnvironment in allEnvironments: for aServerType in allServerTypes: print 'server type: ' + aServerType appendToFile( 'env_' + anEnvironment + '_Type_' + aServerType + ' = [\n', inventoryPythonOutputFile) for aHostEntry in hostEntries: if (aServerType in aHostEntry.type) and (anEnvironment in aHostEntry.environment): print 'Environment: ' + anEnvironment + ' host: ' + aHostEntry.hostname appendToFile('\t"' + aHostEntry.hostname + '",\n', inventoryPythonOutputFile) appendToFile("\n]\n\n", inventoryPythonOutputFile) # hosts by type for aServerType in allServerTypes: print 'server type: ' + aServerType appendToFile('type_' + aServerType + ' = [\n', inventoryPythonOutputFile) for aHostEntry in hostEntries: if (aServerType in aHostEntry.type): print 'Environment: ' + anEnvironment + ' host: ' + aHostEntry.hostname appendToFile('\t"' + aHostEntry.hostname + '",\n', inventoryPythonOutputFile) appendToFile("\n]\n\n", inventoryPythonOutputFile)
"127.0.0.1", } for servername in serverList: cli = connectSilent(servername, username, password) if (cli) : result = issueCliCommand(cli, "/deployment=prpc_j2ee14_jboss61JBM.ear/subdeployment=pradapter.rar/subsystem=resource-adapters/statistics=statistics/connection-definitions=java\:\/eis\/PRAdapterConnectionFactory/:write-attribute(name=statistics-enabled,value=true)") print "cli stats enable complete..." else : print "CLI connection FAILED..." exit() datetimeSuffix = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H.%M.%S') filename = "ConnectionFactoryPool-" + datetimeSuffix + ".csv" # Title for table appendToFile("PRPC PRAdapterConnectionFactory In-Use,", filename) for servername in serverList: appendToFile(servername + ",", filename) appendToFile("\n", filename) while (1 == 1) : appendToFile(datetime.datetime.strftime(datetime.datetime.now(), '%H.%M.%S %Y-%m-%d') + ",", filename) for servername in serverList: maxPoolCountStr = getParameterValue(servername, username, password, "/deployment=prpc_j2ee14_jboss61JBM.ear/subdeployment=pradapter.rar/subsystem=resource-adapters/ironjacamar=ironjacamar/resource-adapter=prpc_j2ee14_jboss61JBM.ear#pradapter/connection-definitions=eis\/PRAdapterConnectionFactory/", "max-pool-size") currentPoolFreeStr = getParameterValue(servername, username, password, "/deployment=prpc_j2ee14_jboss61JBM.ear/subdeployment=pradapter.rar/subsystem=resource-adapters/statistics=statistics/connection-definitions=java\:\/eis\/PRAdapterConnectionFactory/", "AvailableCount") maxPoolCount = int(maxPoolCountStr) currentPoolFree = int(currentPoolFreeStr) inUsePoolCount = maxPoolCount - currentPoolFree
# for servername in serverList: # cli = connectSilent(servername, username, password) # if (cli) : # result = issueCliCommand(cli, "/subsystem=ejb3:write-attribute(name=enable-statistics, value=true)") # # print "cli include defaults complete..." # else : # print "CLI connection FAILED..." # exit() datetimeSuffix = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H.%M.%S') filename = "AviyaConnectedVoipDevices-" + datetimeSuffix + ".csv" # Title for table appendToFile("Aviya Connected VOIP Devices,", filename) for servername in serverList: appendToFile(servername + ",", filename) appendToFile("\n", filename) while (1 == 1): appendToFile( datetime.datetime.strftime(datetime.datetime.now(), '%H.%M.%S %Y-%m-%d') + ",", filename) for servername in serverList: maxPoolCountStr = getParameterValue( servername, username, password, "/deployment=prpc_j2ee14_jboss61JBM.ear/subdeployment=prbeans.jar/subsystem=ejb3/stateless-session-bean=EngineBMT/", "pool-max-size")