Beispiel #1
0
def exportAll(exportConfigFile, generalConfigFile):
    try:
        print "Loading export config from :", exportConfigFile
        exportConfigProp = loadProps(exportConfigFile,generalConfigFile)
        adminUrl = exportConfigProp.get("adminUrl")
        user = exportConfigProp.get("user")
        passwd = exportConfigProp.get("password")

        jarFileName = exportConfigProp.get("jarFileName")
        customFile = exportConfigProp.get("customizationFile")

        passphrase = exportConfigProp.get("passphrase")
        project = exportConfigProp.get("project")

        connectToServer(user, passwd, adminUrl)
        print 'connected'

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == None :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)
        print 'fileName',jarFileName
        aFile = File(jarFileName)
        print 'file',aFile
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ jarFileName + " has been exported"

        if customFile != None:
            print collection
            query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
            customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

#        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
Beispiel #2
0
def deleteProject(alsbConfigurationMBean, projectName):
    try:
        projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, projectName)
        if alsbConfigurationMBean.exists(projectRef):
            print 'INFO: Removing OSB project: ' + projectName
            alsbConfigurationMBean.delete(Collections.singleton(projectRef))
            print 'INFO: Removed OSB project: ' + projectName
        else:
            raise ValueError('No OSB project exists with name ' + projectName)
    except:
        raise
Beispiel #3
0
def exportAll():
    try:

        ALSBConfigurationMBean = findService(
            "ALSBConfiguration",
            "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None":
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None:
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, None)
            else:
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, passphrase)
        else:
            ref = Ref.makeProjectRef(project)
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(
                collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: " + exportJar + " has been exported"

        if customFile != "None":
            print collection
            query = EnvValueQuery(
                None, Collections.singleton(EnvValueTypes.WORK_MANAGER),
                collection, false, None, false)
            customEnv = FindAndReplaceCustomization(
                'Set the right Work Manager', query,
                'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: " + customFile + " has been created"
    except:
        raise
Beispiel #4
0
def undeployProject():
    SessionMBean = None

    print 'Attempting to undeploy', project, ' from ALSB Admin Server listening on ', adminUrl

    # domainRuntime()
    sessionName = "TransientWLSTSession_" + str(System.currentTimeMillis())
    sessMgmtMBean = findService(SessionManagementMBean.NAME,
                                SessionManagementMBean.TYPE)
    sessMgmtMBean.createSession(sessionName)

    print 'Created session [', sessionName, '] ... ', ALSBConfigurationMBean.NAME, "." + sessionName, ALSBConfigurationMBean.TYPE

    alsbConfigMBean = findService(
        ALSBConfigurationMBean.NAME + "." + sessionName,
        ALSBConfigurationMBean.TYPE)

    projectRefs = alsbConfigMBean.getRefs(Ref.DOMAIN)
    projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, project)

    if alsbConfigMBean.exists(projectRef):
        print "#### removing OSB project: " + projectRef.getProjectName()
        if projectRef.getProjectName() == "System":
            print "Omitting System project, it must not be deleted ..."
        else:
            alsbConfigMBean.delete(Collections.singleton(projectRef))
        print
    else:
        failed = "OSB project <" + projectRef.getProjectName(
        ) + "> does not exist"
        print failed
    print

    print "Activating session ... "
    sessMgmtMBean.activateSession(
        sessionName, "Complete project removal with customization using wlst")
    print "Session activated."
    cleanupSession(sessMgmtMBean, sessionName)
    print "done!"
Beispiel #5
0
def deleteOSBProject(alsbConfigurationMBean, projectName):
    '''Delete a OSB project'''
    try:
        msg("Trying to remove " + projectName, _LOG_LEVEL.INFO)
        projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, projectName)
        if alsbConfigurationMBean.exists(projectRef):
            msg("#### removing OSB project: " + projectName, _LOG_LEVEL.INFO)
            alsbConfigurationMBean.delete(Collections.singleton(projectRef))
            msg("#### removed project: " + projectName, _LOG_LEVEL.INFO)
        else:
            msg("OSB project <" + projectName + "> does not exist",
                _LOG_LEVEL.WARNING)
    except:
        msg("Error whilst removing project:" + sys.exc_info()[0],
            _LOG_LEVEL.ERROR)
        raise
Beispiel #6
0
def exportAll():
    try:

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None" :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ exportJar + " has been exported"

        if customFile != "None":
            print collection
            query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
            customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
def setProxyStatus(proxyNames, status):
    try:
        sleepTime = 2
        sessionName = "SetProxyStateSession_" + str(System.currentTimeMillis())
        sessionMBean = findService(SessionManagementMBean.NAME,
                                   SessionManagementMBean.TYPE)
        sessionMBean.createSession(sessionName)
        pxyConf = 'ProxyServiceConfiguration.' + sessionName
        mbean = findService(
            pxyConf,
            'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean'
        )
        prxNames = proxyNames.split(',')
        for aName in prxNames:
            prxName = aName.strip()
            proxyPath = prxName.split('/')
            serviceRef = Ref.makeRef(Refs.PROXY_SERVICE_TYPE, proxyPath)
            if status == 'disable':
                mbean.disableService(serviceRef)
                print "[" + (pytime.strftime("%d/%m/%Y %H:%M:%S")
                             ) + "] " + "Disabled proxy " + prxName
            else:
                mbean.enableService(serviceRef)
                print "[" + (pytime.strftime("%d/%m/%Y %H:%M:%S")
                             ) + "] " + "Enabled proxy " + prxName
                print "[" + (pytime.strftime(
                    "%d/%m/%Y %H:%M:%S")) + "] " + "Waiting " + str(
                        sleepTime) + " seconds before enabling next service."
                pytime.sleep(sleepTime)

        sessionMBean.activateSession(sessionName, status + 'd ' + proxyNames)
    except:
        print "[" + (
            pytime.strftime("%d/%m/%Y %H:%M:%S")
        ) + "] " + "Got Error while changing status of proxy serivce"
        apply(traceback.print_exception, sys.exc_info())
        dumpStack()
Beispiel #8
0
                        sessionMBean = findService(SessionManagementMBean.NAME,
                                                   SessionManagementMBean.TYPE)
                        sessionMBean.createSession(sessionName)
                        mbean = findService(
                            String("ProxyServiceConfiguration.").concat(
                                sessionName),
                            'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean'
                        )
                        projectName = Refs.makeParentRef(project)
                        proxyRef = Refs.makeProxyRef(projectName, service)
                        #print "Disabling... " + service
                        serviceStatus = str(mbean.isEnabled(proxyRef))
                        if mbean.isEnabled(proxyRef) == 1:
                            mbean.disableService(proxyRef)
                            refArray = []
                            refArray.append(Ref(typeID, projectName, service))
                            cmo.resetStatistics(refArray)
                            #print " === Resetting statistics for this service."
                            action = "Disable/reset Data"
                        else:
                            #print "Service already disabled."
                            action = "Already disabled"
                        sessionMBean.activateSession(sessionName,
                                                     "Auto Disabled BS ")

                    strTable = []
                    strTable.append(ref.getProjectName())
                    strTable.append(service)
                    strTable.append(e.getName())
                    strTable.append(str(e.getMin()))
                    strTable.append(str(e.getMax()))
Beispiel #9
0
def exportAll():
    try:

        ALSBConfigurationMBean = findService(
            "ALSBConfiguration",
            "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None":
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None:
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, None)
            else:
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, passphrase)
        else:
            ref = Ref.makeProjectRef(project)
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(
                collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: " + exportJar + " has been exported"

        if customFile != "None":
            print collection
            # see com.bea.wli.sb.util.EnvValueTypes in sb-kernel-api.jar for the values

            #EnvValueQuery evquery =
            #     new EnvValueQuery(
            #         null,        // search across all resource types
            #         Collections.singleton(EnvValueTypes.URI_ENV_VALUE_TYPE), // search only the URIs
            #         null,        // search across all projects and folders.
            #         true,        // only search across resources that are
            #                      // actually modified/imported in this session
            #         "localhost", // the string we want to replace
            #         false        // not a complete match of URI. any URI
            #                      // that has "localhost" as substring will match
            #         );

            refTypes = HashSet()
            refTypes.add(EnvValueTypes.SERVICE_URI_TABLE)
            refTypes.add(EnvValueTypes.SERVICE_URI)
            query = EnvValueQuery(
                Collections.singleton(Refs.BUSINESS_SERVICE_TYPE), refTypes,
                collection, false, "search string", false)
            #           query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.SERVICE_URI_TABLE), collection, false, "search string", false)
            customEnv = FindAndReplaceCustomization('new endpoint url', query,
                                                    'replace string')

            #            object = QualifiedEnvValue(Refs.makeBusinessSvcRef(ref,'file'), Refs.BUSINESS_SERVICE_TYPE, "XSDvalidation/file", "aaa")
            #            objects = ArrayList()
            #            objects.add(object)
            #            customEnv2 = EnvValueCustomization('Set the right endpoints', objects)

            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            #            customList.add(customEnv2)

            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: " + customFile + " has been created"
    except:
        raise
Beispiel #10
0
def exportAll():
    try:

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None" :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ exportJar + " has been exported"

        if customFile != "None":
            print collection
# see com.bea.wli.sb.util.EnvValueTypes in sb-kernel-api.jar for the values

#EnvValueQuery evquery =
#     new EnvValueQuery(
#         null,        // search across all resource types
#         Collections.singleton(EnvValueTypes.URI_ENV_VALUE_TYPE), // search only the URIs
#         null,        // search across all projects and folders.
#         true,        // only search across resources that are
#                      // actually modified/imported in this session
#         "localhost", // the string we want to replace
#         false        // not a complete match of URI. any URI
#                      // that has "localhost" as substring will match
#         );

            refTypes = HashSet()
            refTypes.add(EnvValueTypes.SERVICE_URI_TABLE)
            refTypes.add(EnvValueTypes.SERVICE_URI)
            query = EnvValueQuery(Collections.singleton(Refs.BUSINESS_SERVICE_TYPE), refTypes, collection, false, "search string", false)
#           query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.SERVICE_URI_TABLE), collection, false, "search string", false)
            customEnv = FindAndReplaceCustomization('new endpoint url', query, 'replace string')

#            object = QualifiedEnvValue(Refs.makeBusinessSvcRef(ref,'file'), Refs.BUSINESS_SERVICE_TYPE, "XSDvalidation/file", "aaa")
#            objects = ArrayList()
#            objects.add(object)
#            customEnv2 = EnvValueCustomization('Set the right endpoints', objects)

            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
#            customList.add(customEnv2)

            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
Beispiel #11
0
    if sessionMBean.sessionExists(sessionName):
        discardSession(sessionMBean, sessionName)

    sessionMBean.createSession(sessionName)

    # obtain the ALSBConfigurationMBean instance that operates
    # on the session that has just been created. Notice that
    # the name of the mbean contains the session name.
    alsbSession = findService(ALSBConfigurationMBean.NAME + "." + sessionName,
                              ALSBConfigurationMBean.TYPE)

    refs = ArrayList()

    for project in undeployProjList:
        projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, project.strip())
        if alsbSession.exists(projectRef):
            print "#### adding OSB project to the delete list: " + project.strip(
            )
            refs.add(projectRef)

        else:
            print "OSB project <" + project.strip() + "> does not exist"

    alsbSession.delete(refs)

    # activate changes performed in the session
    sessionMBean.activateSession(
        sessionName, "Complete project removal with customization using wlst")

    print "#### removed project: " + configProps.get('undeployProjects')
Beispiel #12
0
def exportAll(exportConfigFile):
    try:
        print "Loading export config from :", exportConfigFile
        exportConfigProp = loadProps(exportConfigFile)
        adminUrl = exportConfigProp.get("adminUrl")
        exportUser = exportConfigProp.get("exportUser")
        exportPasswd = exportConfigProp.get("exportPassword")

        exportJar = exportConfigProp.get("exportJar")
        customFile = exportConfigProp.get("customizationFile")

        passphrase = exportConfigProp.get("passphrase")
        project = exportConfigProp.get("project")

        connectToServer(exportUser, exportPasswd, adminUrl)

        ALSBConfigurationMBean = findService(
            "ALSBConfiguration",
            "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == None:
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None:
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, None)
            else:
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(
                    collection, true, passphrase)
        else:
            ref = Ref.makeProjectRef(project)
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(
                collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: " + exportJar + " has been exported"

        if customFile != None:
            print collection
            customList = ArrayList()
            query = EnvValueQuery(
                None, Collections.singleton(EnvValueTypes.WORK_MANAGER),
                collection, false, None, false)
            customEnv = FindAndReplaceCustomization(
                'Set the right Work Manager', query,
                'Production System Work Manager')
            customList.add(customEnv)

            # Uncomment the next three lines to update the server and port to the
            # alsb30_prod environment correctly
            #query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.SERVICE_URI), collection, false, 'localhost:7001', false)
            #customEnv = FindAndReplaceCustomization('Update to the correct server and port number', query, 'localhost:7101')
            #customList.add(customEnv)

            print 'EnvValueCustomization created'
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Customization file: " + customFile + " has been created"
    except:
        raise