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()
Beispiel #2
0
 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()