def getBasicAuth(self, endPointName): # Get EndPoint data - username, password, and hostname handler = Router.getHandler(endPointName) endPointInfo = EndPointCache.getInstance().getEndPointInfo(endPointName) iemPassword = endPointInfo.getProperty("PASSWORD").getValue() iemUserName = handler.getUserName() iemServer = handler.getUrl() #Parse the url from the TEMServer if (iemServer != None): urlarray = iemServer.split(":") hostName = str(urlarray[1]) portStr = urlarray[2] # if the url ends with / remove it if (portStr.endswith('/')): port = int(portStr[:-1]) else: port = int(portStr) hostName = hostName.replace("/","") print "hostName: port = ", hostName, port if (iemServer == '' or iemUserName == '' or iemPassword == '' or hostName == None or port == None): self.addToSRWorkLog("iem_missing_endpoint_info_sum", "iem_missing_endpoint_info_desc") print self.scriptName + "Endpoint Information missing for the IEM Server" return None, None, None auth = 'Basic ' + string.strip(base64.encodestring(iemUserName + ':' + iemPassword)) return auth, hostName, port
worklogDesc = worklogDesc + "The incident ID is: " + incident + "\n" worklogDesc = worklogDesc + "CI operated on: " + ipaddress + ":" + port + "\n" # get WAS Handler. If not specified - use the default RBA_WAS endpoint name if credentials is None: credential_to_use = "RBA_WAS" else: credential_to_use = credentials handler = Router.getHandler( credential_to_use) print "using end point: ", credential_to_use # format Get Applications Running on WebSphere Application Server command username = handler.getUserId(); print "username", username endPointInfo = EndPointCache.getInstance().getEndPointInfo(credential_to_use) password = endPointInfo.getProperty("PASSWORD").getValue() print "hostname = ", hostname props = Properties(); props.setProperty( AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP ); props.setProperty( AdminClient.CONNECTOR_HOST, hostname ); props.setProperty( AdminClient.CONNECTOR_PORT, port ); props.setProperty( AdminClient.USERNAME, username ); props.setProperty( AdminClient.PASSWORD, password ); client = AdminClientFactory.createAdminClient(props); query = "*:type=J2EEApplication,*"; queryName = ObjectName(query); print "query name", queryName
import base64 import string # get the SR Worklog mboset originatingTicket = None workorderSet = mbo.getMboSet("PARENTPROCESS") workorder = workorderSet.getMbo(0) originatingTicketSet = workorder.getMboSet("ORIGTICKET") originatingTicket = originatingTicketSet.getMbo(0) if (originatingTicket != None): srWorklogSet = originatingTicket.getMboSet("MODIFYWORKLOG") # Get TEM EndPoint data - username, password, and hostname handler = Router.getHandler(temendpoint) endPointInfo = EndPointCache.getInstance().getEndPointInfo(temendpoint) tempassword = endPointInfo.getProperty("PASSWORD").getValue() temusername = handler.getUserName() temserver = handler.getUrl() urlarray = temserver.split(":") hostname = str(urlarray[1]) port = int(urlarray[2]) hostname = hostname.replace("/", "") print "In SCCDGETTEMACTIONSTATUS script: hostname : port = ", hostname + " , ", port auth = 'Basic ' + string.strip( base64.encodestring(temusername + ':' + tempassword)) webservice = httplib.HTTPSConnection(hostname, port)
print "CI in Work Order: [Host] ", hostname print "CI in Work Order: [Port] ", port print "CI in Work Order: [App] ", appname # format the start of the worklog entry worklogDesc = worklogDesc + "RBAWASSTP script run for Work Order: " + workorder + "\n" worklogDesc = worklogDesc + "CI operated on: " + hostname + ":" + port + "\n" # get SSHWO Handler handler = Router.getHandler("SSHWO") # format Stop application running on a WebSphere Application Server command username = handler.getUserId() print "username", username endPointInfo = EndPointCache.getInstance().getEndPointInfo("SSHWO") password = endPointInfo.getProperty("PASSWORD").getValue() props = Properties() props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP) props.setProperty(AdminClient.CONNECTOR_HOST, hostname) props.setProperty(AdminClient.CONNECTOR_PORT, port) props.setProperty(AdminClient.USERNAME, username) props.setProperty(AdminClient.PASSWORD, password) client = AdminClientFactory.createAdminClient(props) query = "*:type=J2EEApplication,name=" + appname + ",*" queryName = ObjectName(query) print "query name", queryName apps = client.queryNames(queryName, None)