def stopServer(trustStore, trustStorePassword, hostname, port, username, password, host, usrdir, serverName, options): JMXRESTConnector.trustStore = trustStore JMXRESTConnector.trustStorePassword = trustStorePassword connector = JMXRESTConnector() connector.connect(hostname, port, username, password) mconnection = connector.getMBeanServerConnection() serverCommand = server.serverCommand(mconnection) stopServerResults = serverCommand.stop(host, usrdir, serverName, options) return stopServerResults
def listClusterNames(trustStore, trustStorePassword, hostname, port, username, password): JMXRESTConnector.trustStore = trustStore JMXRESTConnector.trustStorePassword = trustStorePassword connector = JMXRESTConnector() connector.connect(hostname, port, username, password) mconnection = connector.getMBeanServerConnection() clusterManager = cluster.manager(mconnection) clusterNames = clusterManager.listClusterNames() return clusterNames
def stopCluster(trustStore, trustStorePassword, hostname, port, username, password, clusterName): JMXRESTConnector.trustStore = trustStore JMXRESTConnector.trustStorePassword = trustStorePassword connector = JMXRESTConnector() connector.connect(hostname, port, username, password) mconnection = connector.getMBeanServerConnection() clusterManager = cluster.manager(mconnection) stopClusterResults = clusterManager.stop(argParser[CLUSTER_NAME], "") return stopClusterResults
def genClusterPlugin(trustStore, trustStorePassword, hostname, port, username, password, clusterName): JMXRESTConnector.trustStore = trustStore JMXRESTConnector.trustStorePassword = trustStorePassword connector = JMXRESTConnector() connector.connect(hostname, port, username, password) mconnection = connector.getMBeanServerConnection() clusterManager = cluster.manager(mconnection) genPluginFile = clusterManager.genPlugin( clusterName) #invoke generate plugins on the cluster print "Generated plugin-cfg.xml file: " + str(genPluginFile) print "This file will reside in the controller's host filesystem" return genPluginFile
if __name__ == '__main__': argParser = TransferAppToClusterArgs() if (argParser.parse(sys.argv) == True): try: appPath = argParser.getPositional(0) if (os.path.exists(appPath) == False): raise IOError("Cannot transfer specified application, file does not exist: " + str(appPath)) if (os.path.isfile(appPath) == False): raise IOError("Cannot transfer specified application, path is not a file: " + str(appPath)) # Connect to the collective controller JMXRESTConnector.trustStore = argParser[arguments.TRUST_STORE] JMXRESTConnector.trustStorePassword = argParser[arguments.TRUST_STORE_PASSWORD] connector = JMXRESTConnector() connector.connect(argParser[arguments.HOSTNAME], int(argParser[arguments.PORT]), argParser[arguments.USERNAME], argParser[arguments.PASSWORD]) mconnection = connector.getMBeanServerConnection() # Get a list of the cluster members for the specified cluster. clusterManager = cluster.manager(mconnection) memberList = clusterManager.listMembers(argParser[CLUSTER_NAME]) if ((memberList == None) or (len(memberList) == 0)): print "The cluster " + argParser[CLUSTER_NAME] + " did not contain any members" else: print "" # List of servers that had problems
if (os.path.exists(configPath) == False): raise IOError( "Cannot transfer server.xml, file does not exist: " + str(configPath)) if (os.path.isfile(configPath) == False): raise IOError( "Cannot transfer server.xml, path is not a file: " + str(configPath)) # Connect to the collective controller JMXRESTConnector.trustStore = argParser[arguments.TRUST_STORE] JMXRESTConnector.trustStorePassword = argParser[ arguments.TRUST_STORE_PASSWORD] connector = JMXRESTConnector() connector.connect(argParser[arguments.HOSTNAME], int(argParser[arguments.PORT]), argParser[arguments.USERNAME], argParser[arguments.PASSWORD]) mconnection = connector.getMBeanServerConnection() # Get a list of the cluster members for the specified cluster. clusterManager = cluster.manager(mconnection) memberList = clusterManager.listMembers(argParser[CLUSTER_NAME]) if ((memberList == None) or (len(memberList) == 0)): print "The cluster " + argParser[ CLUSTER_NAME] + " did not contain any members" else: print ""
COLLECTIVE_PW = 'adminPassword' TRUSTSTORE = '/path/to/truststore.p12' TRUSTSTORE_PW = 'truststorePassword' HOSTNAME = 'hostnameOfServer' SERVER_NAME = 'serverName' # USR_DIR is the directory with / replaced with %2F # example USR_DIR = '%2Fusr%2FWebSphere%2Fwlp%2Fusr' USR_DIR = '%2Fpath%2Fto%2Fusr' # Setup truststore with collective controller public key JMXRESTConnector.trustStore = TRUSTSTORE JMXRESTConnector.trustStorePassword = TRUSTSTORE_PW # Connect to the Collective connector = JMXRESTConnector() connection = connector.connect(COLLECTIVE_HOST, COLLECTIVE_PORT, COLLECTIVE_USERID, COLLECTIVE_PW) mconnection = connector.getMBeanServerConnection() # Get the CollectiveRepository MBean mbeans = mconnection.queryNames( ObjectName("WebSphere:type=CollectiveRepository,*"), None).toArray() mbean_repo = mbeans[0] # Try to find the App Server, if found then delete it DATA = '/sys.was.collectives/local/hosts/' + HOSTNAME + '/userdirs/' + USR_DIR + '/servers/' + SERVER_NAME try: mconnection.invoke(mbean_repo, 'getDescendantData', [DATA], ['java.lang.String'])
argParser = DeployMembersArgs() if (argParser.parse(sys.argv) == True): print "" JMXRESTConnector.trustStore = argParser[arguments.TRUST_STORE] JMXRESTConnector.trustStorePassword = argParser[arguments.TRUST_STORE_PASSWORD] installHost = argParser[INSTALL_HOST] # Connect to the collective controller # Using a timeout of 20 minutes for the zip file to upload and extract map = HashMap() map.put(ClientProvider.READ_TIMEOUT,20*60*1000) map.put(JMXConnector.CREDENTIALS,jarray.array([argParser[arguments.USERNAME],argParser[arguments.PASSWORD]],java.lang.String)) map.put("jmx.remote.provider.pkgs","com.ibm.ws.jmx.connector.client") map.put(ConnectorSettings.DISABLE_HOSTNAME_VERIFICATION, True) connector = JMXRESTConnector() connector.connect(argParser[arguments.HOSTNAME], int(argParser[arguments.PORT]), map) mconnection = connector.getMBeanServerConnection() # build hostAuthInfo Map installDir = argParser[INSTALL_DIR] localZipPath = argParser[ZIP_FILE] zipFile = os.path.basename(localZipPath) zipName = os.path.splitext(zipFile)[0] wlpDir = installDir if (isWlpZipRootDir(localZipPath)): wlpDir = installDir + os.sep + "wlp"