def processServer(self, cmdDict=None, action=None): '''processServer: This method processes a server configuration object. It takes two parameters, a dictionary containing the command and the action (RW)''' self.logger.trace("processServer: cmdDict=%s" % cmdDict) if cmdDict == None: self.logger.error("processServer: No dictionary was passed to the generateCommands method") raise ProcessCommandException("No dictionary was passed to the generateCommands method") #end-if k = cmdDict.keys()[0] v = cmdDict.values()[0] self.logger.trace("processServer: key=%s, value=%s" % (k, v)) if k and v != None: self.validateScope(v, 'processServer') srv = AdminConfig.getid(v['scope']+"%s:%s/" % (k, v['name'])) self.logger.trace("processServer: srv=%s " % srv) if srv == "": self.logger.info("processServer: creating server %s" % v['name']) else: srvObj = AdminConfig.getObjectName(srv) self.logger.trace("processServer: srvObj %s" % srvObj) ptype = AdminControl.getAttribute(srvObj, 'processType') self.logger.trace("processServer: ptype %s" % ptype) if ptype != 'UnManagedProcess': self.logger.info("processServer: This is a Network Deployment Profile so this command will run.") else: self.logger.warn("processServer: This is not a Network Deployment Profile so this command won't be run. Use the manageprofiles too to create servers." ) #raise ProcessCommandException("This is not a Network Deployment Profile so this command won't be run. Use the manageprofiles too to create servers.") #end-if #end-if else: self.logger.error("processServer: key and value parameters were not suppled to the method.") raise ProcessCommandException("key and value parameters were not suppled to the method.")
def __init__(self, topologyfile): self.CellName = AdminControl.getCell() self.timeout = 1200 self.topologyfile = 'file:' + topologyfile
def generateCommands(self, cmdList=None, action=None): '''Method that takes a list of command dictionaries and processes them. Use this method to process a series or sequential commands.''' self.action = action if self.action == None: self.action = 'R' self.cmdList = cmdList self.logger.info("generateCommands: processing command list.") if self.cmdList == None: self.logger.error("generateCommands: No list was passed to the generateCommands method") raise ProcessCommandException("No list was passed to the generateCommands method") self.logger.info("generateCommands: action is %s" % self.action) self.logger.trace("generateCommands: self.cmdList = %s " % self.cmdList) for item in self.cmdList: cmdDict = item self.logger.trace("generateCommands: item = %s" % item) for k, v in cmdDict.items(): self.logger.trace("generateCommands: k = %s" % k ) self.logger.trace("generateCommands: v = %s" % v ) if k == "Cell": self.logger.debug("generateCommands: block = Cell") if AdminControl.getCell() != v['name']: self.logger.error("generateCommands: Cell name %s != %s. You may have connected to the wrong WebSphere environment or the name of the cell in the configuration xml is not correct." % (AdminControl.getCell(),v['name'])) raise ProcessCommandException("Cell name %s != %s. You may have connected to the wrong WebSphere environment or the name of the cell in the configuration xml is not correct." % (AdminControl.getCell(),v['name'])) elif k == "ServerCluster": self.logger.trace("generateCommands: block = ServerCluster") '''IMPLEMENT ME''' elif re.search("ClusterMember", k): self.logger.trace("generateCommands: block = ClusterMember") '''IMPLEMENT ME''' elif k == "Server": self.logger.trace("generateCommands: block = Server") self.processServer(cmdDict=cmdDict, action=self.action) elif k == "DataSource" or k == "MQQueueConnectionFactory" or k == 'MQQueue' or k == "JDBCProvider" or k == 'J2CActivationSpec' or k == 'J2CAdminObject' or k == 'J2CConnectionFactory': self.logger.trace("generateCommands: block = JDBCProvider, DataSource, MQQueueConnectionFactory, MQQueue, J2CActivationSpec, J2CAdminObject, J2CConnectionFactory") self.processConfigItem(cmdDict=cmdDict, action=self.action) elif k == "J2EEResourceProperty": self.logger.trace("generateCommands: block = J2EEResourceProperty") self.processPropertySet(cmdDict=cmdDict, action=self.action) elif k == "JAASAuthData": self.logger.trace("generateCommands: block = JAASAuthData") self.processSecurity(cmdDict=cmdDict, action=self.action) elif k == "ConnectionPool" or k == "connectionPool" or k == "sessionPool" or k == 'EJBCache' or k == 'PMIService' or k == 'PMIRequestMetrics': self.logger.trace("generateCommands: block = ConnectionPool, connectionPool, sessionPool") self.processNestedAttribute(cmdDict=cmdDict, action=self.action) elif k == "JavaVirtualMachine" or k == "ProcessExecution": self.logger.trace("generateCommands: block = JavaVirtualMachine, ProcessExecution") self.processNestedAttribute(cmdDict=cmdDict, action=self.action) elif k == 'SIBus' or k == 'SIBusMember' or k == 'SIBTopicSpace' or k == 'SIBQueue': self.logger.trace("generateCommands: block = SIBus, SIBusMember, SIBTopicSpace, SIBQueue") self.processAdminTask(cmdDict=cmdDict, action=self.action) elif k == "env" or k == "Node" or k == 'dmgr' or k == 'JMSProvider' or k == 'J2CResourceAdapter': self.logger.trace("generateCommands: block = env, Node, dmgr") '''Ignore a tag''' self.logger.debug("generateCommands: ignoring tag %s" % k ) else: '''Throw an exception if the tag is unknown''' self.logger.error("generateCommands: %s is an unknown key. Remove it from the configuration or add code to handle it." % k) raise ProcessCommandException("generateCommands: %s is an unknown key. Remove it from the configuration or add code to handle it." % k) #end-if self.logger.debug("generateCommands: config save status is %s" % AdminConfig.hasChanges()) if AdminConfig.hasChanges() == 1: self.logger.info("generateCommands: saving changes.") AdminConfig.save()