Exemplo n.º 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
Exemplo n.º 2
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
Exemplo n.º 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
Exemplo n.º 4
0
def customizeALSBDomain(importConfigFile, customFile):
    try:
        SessionMBean = None
        print 'Loading config from :', importConfigFile
        configProp = loadProps(importConfigFile)
        adminUrl = configProp.get("adminUrl")
        user = configProp.get("user")
        password = configProp.get("password")

        passphrase = configProp.get("passphrase")
        project = configProp.get("project")
	
        connectToServer(user, password, adminUrl)
        print 'connected to yer server'

        sessionName = createSessionName()
        print 'Created session', sessionName
        SessionMBean = getSessionMBean(sessionName)
        print 'SessionMBean started session'
        ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found", ALSBConfigurationMBean
        
        if project == None:
            print 'No project specified, additive deployment performed'
            importResult = ALSBConfigurationMBean.importUploaded(None, false, true, passphrase)
            SessionMBean.commitSession(sessionName)
        else:
            #customize if a customization file is specified
            #affects only the created resources
            if customFile != None :
                print 'Loading customization File', customFile
                
                iStream = FileInputStream(customFile)
                customizationList = Customization.fromXML(iStream)
                
                for customization in customizationList:
                	print '\n customization', customization.getDescription()
                
                print customizationList.size()
                ALSBConfigurationMBean.customize(customizationList)
                print 'Customization applied'
            	SessionMBean.commitSession(sessionName)
            	print 'session committed'
    except:
        print "Unexpected error:", sys.exc_info()[0]
        if SessionMBean != None:
            SessionMBean.discardSession(sessionName)
        raise
Exemplo n.º 5
0
def importToALSBDomain(importConfigFile):
    try:
        SessionMBean = None
        print 'Loading Deployment config from :', importConfigFile
        exportConfigProp = loadProps(importConfigFile)
        adminUrl = exportConfigProp.get("adminUrl")
        importUser = exportConfigProp.get("importUser")
        importPassword = exportConfigProp.get("importPassword")

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

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

        connectToServer(importUser, importPassword, adminUrl)

        print 'Attempting to import :', importJar, "on ALSB Admin Server listening on :", adminUrl

        theBytes = readBinaryFile(importJar)
        print 'Read file', importJar
        sessionName = createSessionName()
        print 'Created session', sessionName
        SessionMBean = getSessionManagementMBean(sessionName)
        print 'SessionMBean started session'
        ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found", ALSBConfigurationMBean
        ALSBConfigurationMBean.uploadJarFile(theBytes)
        print 'Jar Uploaded'

        if project == None:
            print 'No project specified, additive deployment performed'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            alsbImportPlan.setPreserveExistingEnvValues(true)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
            SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")
        else:
            print 'ALSB project', project, 'will get overlaid'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            operationMap=HashMap()
            operationMap = alsbImportPlan.getOperations()
            print
            print 'Default importPlan'
            printOpMap(operationMap)
            set = operationMap.entrySet()

            alsbImportPlan.setPreserveExistingEnvValues(true)

            #boolean
            abort = false
            #list of created ref
            createdRef = ArrayList()

            for entry in set:
                ref = entry.getKey()
                op = entry.getValue()
                #set different logic based on the resource type
                type = ref.getTypeId
                if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
                    if op.getOperation() == ALSBImportOperation.Operation.Create:
                        print 'Unable to import a service account or a service provider on a target system', ref
                        abort = true
                elif op.getOperation() == ALSBImportOperation.Operation.Create:
                    #keep the list of created resources
                    createdRef.add(ref)

            if abort == true :
                print 'This jar must be imported manually to resolve the service account and service provider dependencies'
                SessionMBean.discardSession(sessionName)
                raise

            print
            print 'Modified importPlan'
            printOpMap(operationMap)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)

            printDiagMap(importResult.getImportDiagnostics())

            if importResult.getFailed().isEmpty() == false:
                print 'One or more resources could not be imported properly'
                raise

            #customize if a customization file is specified
            #affects only the created resources
            if customFile != None :
                print 'Loading customization File', customFile
                print 'Customization applied to the created resources only', createdRef
                iStream = FileInputStream(customFile)
                customizationList = Customization.fromXML(iStream)
                filteredCustomizationList = ArrayList()
                setRef = HashSet(createdRef)

                # apply a filter to all the customizations to narrow the target to the created resources
                for customization in customizationList:
                    print customization
                    newcustomization = customization.clone(setRef)
                    filteredCustomizationList.add(newcustomization)

                ALSBConfigurationMBean.customize(filteredCustomizationList)

            SessionMBean.activateSession(sessionName, "Complete test import with customization using wlst")

        print "Deployment of : " + importJar + " successful"
    except:
        print "Unexpected error:", sys.exc_info()[0]
        if SessionMBean != None:
            SessionMBean.discardSession(sessionName)
        raise
        alsbConfigurationMBean = \
            findService(ALSBConfigurationMBean.NAME + '.'
                        + sessionName, ALSBConfigurationMBean.TYPE)

        if alsbConfigurationMBean is None:
            raise ValueError('No session exists with name '
                             + sessionName)

        # customizing

        print 'Executing customization '

        print 'Loading customization File', customFile
        iStream = FileInputStream(customFile)
        customizationList = Customization.fromXML(iStream)
        alsbConfigurationMBean.customize(customizationList)
        print 'Execution of customization done successfully'
        exitFlag = 0
    except:

        print 'ERROR : Unable to execute customization. Possible error:', \
            sys.exc_info()[1]
        print 'Please check the input parameters'
finally:

    if connFlag:
        disconnect('true')
    exit('y', exitFlag)

Exemplo n.º 7
0
def importToALSBDomain():
	try:
		# Declare Variables
		sessionMBean = None
		alsbConfigurationMBean = None
		
		
		# Connect to Server
		print 'Connecting to server: ', adminUrl
		connectToServer(connectMethod)

		print 'Starting import of:', importJar, "on ALSB Admin Server:", adminUrl

		# Read import jar file
		print 'Read import jar file'
		theBytes = readBinaryFile(importJar)
		print 'Import file read successfully', importJar

		# Create unique session name	
		print 'Creating unique session name'
		sessionName = createSessionName()
		print 'Created session name :', sessionName

		# Create and start session
		print 'Creating SessionMBean'
		sessionMBean = getSessionMBean(sessionName)
		print 'SessionMBean started new session'

		# 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.
		print 'Create ALSBConfiguration'
		alsbConfigurationMBean = findService(String(ALSBConfigurationMBean.NAME + ".").concat(sessionName), ALSBConfigurationMBean.TYPE)
		print "ALSBConfiguration MBean found", alsbConfigurationMBean

		# Perform updates or read operations in the session using alsbSession

		# Upload Jar File
		print 'Uploading Jar file'
		alsbConfigurationMBean.uploadJarFile(theBytes)
		print 'Jar Uploaded'

		print 'ALSB Project will now get imported'
		alsbJarInfo = alsbConfigurationMBean.getImportJarInfo()

		alsbImportPlan = alsbJarInfo.getDefaultImportPlan()

		#alsbImportPlan.setPassphrase(passphrase)

		operationMap=HashMap()

		operationMap = alsbImportPlan.getOperations()

		print 'Default importPlan'
		printOpMap(operationMap)

		alsbImportPlan.setPreserveExistingEnvValues(preserveExistingEnvValues)
		alsbImportPlan.setPreserveExistingOperationalValues(preserveExistingOperationalValues)

		print 'Modified importPlan'
		printOpMap(operationMap)
		importResult = alsbConfigurationMBean.importUploaded(alsbImportPlan)

		printDiagMap(importResult.getImportDiagnostics())

		if importResult.getFailed().isEmpty() == false:
			print 'One or more resources could not be imported properly'
			raise

		

		#customize if a customization file is specified
		#affects only the created resources
		if customFile != None :
			print 'Loading customization File', customFile
			iStream = FileInputStream(customFile)
			customizationList = Customization.fromXML(iStream)
			alsbConfigurationMBean.customize(customizationList)

		sessionMBean.activateSession(sessionName, "ALSBImport Operation Completed Successfully")

		print "Deployment of : " + importJar + " successful"
	except:
		print "Unexpected error:", sys.exc_info()[0]
		if sessionMBean != None:
			sessionMBean.discardSession(sessionName)
		raise
def deployToTarget(envConfigProp, mavenGroupId, mavenArtifactId, mavenVersionId, serviceGroupName, serviceType, serviceName, interfaceVersion, jarFileLocation, environmentName, domainName, pwd):
    print 'Deploying ' + mavenGroupId + ':' + mavenArtifactId + ' ' + interfaceVersion + ' (' + mavenVersionId + ') to ' + domainName + ' in ' + environmentName
    auditAction('Attempting deployment of ' + mavenGroupId + '::' + mavenArtifactId + ' version ' + mavenVersionId + "(" + interfaceVersion + ") to domain " + domainName + " in " + environmentName + " environment")

    try:
        SessionMBean = None
        targetName = environmentName + "." + domainName
        admin_host = envConfigProp.get("env." + targetName + ".admin_host")
        admin_port = envConfigProp.get("env." + targetName + ".admin_port")
        adminUrl = "t3://" + admin_host + ":" + admin_port
        importUser = envConfigProp.get("env." + targetName + ".username")
        importPassword = envConfigProp.get("env." + targetName + ".password")
        if pwd != None:
            importPassword = pwd

        print 'Target url: ', adminUrl
        print 'Importing :', jarFileLocation

        if importUser == None:
            print 'Connecting with config files'
            connectToServerWithConfig(configFile, keyFile, adminUrl)
        else:
            print 'Connecting with username/pwd'
            connectToServer(importUser, importPassword, adminUrl)

        print 'Attempting to import :', jarFileLocation, " on OSB Admin Server listening on :", adminUrl

        theBytes = readBinaryFile(jarFileLocation)
        print 'Read file', jarFileLocation
        sessionName = createSessionName()
        print 'Created session', sessionName
        SessionMBean = getSessionManagementMBean(sessionName)
        print 'SessionMBean started session'
        ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")

        listOfAutoBackupEnabledEnvironments = envConfigProp.get("autobackupOnDeployment")
        if (listOfAutoBackupEnabledEnvironments != None):
            if (environmentName in listOfAutoBackupEnabledEnvironments):
                #take backup from domain
                print "Backing up artifact resources including the common bits"
                allRefs = None
                if (serviceGroupName == 'Common'):
                    #step 1: find version specific resources e.g. Common_CanonicalDataModel/v1
                    projectResourcesQuery = ResourceQuery(None)
                    projectResourcesQuery.setPath(serviceGroupName + '_' + serviceName + '/' + interfaceVersion + '/*')
                    artifactRefs = ALSBConfigurationMBean.getRefs(projectResourcesQuery)
                    allRefs = artifactRefs
                else:
                    #take backup from domain
                    print "Backing up artifact resources including the common bits"
                    #step 1: find project's own resources e.g. QueryServices/data/Parcel/v1
                    projectResourcesQuery = ResourceQuery(None)
                    projectResourcesQuery.setPath(serviceGroupName + '/' + serviceType + '/' + serviceName + "/" + interfaceVersion + "/*")
                    artifactRefs = ALSBConfigurationMBean.getRefs(projectResourcesQuery)
                    #step 2: find common group project resources e.g. QueryServices/common/v1
                    commonGroupResourcesQuery = ResourceQuery(None)
                    commonGroupResourcesQuery.setPath(serviceGroupName + '/common/' + interfaceVersion + "/*")
                    commonGroupRefs = ALSBConfigurationMBean.getRefs(commonGroupResourcesQuery)
                    #combine all the refs

                    allRefs = commonGroupRefs
                    allRefs.addAll(artifactRefs)

                exportJarBytes = ALSBConfigurationMBean.export(allRefs, false, None)
                todaysFormattedDate = java.text.SimpleDateFormat("yyyyMMdd").format(java.util.Date())
                exportFolder = os.environ["HOME"] + "/backups/" + environmentName
                File(exportFolder).mkdirs()
                if System.getenv('BUILD_TAG') is not None:
                    exportFileName = todaysFormattedDate + "_" + System.getenv('BUILD_TAG') + "_" + domainName + ".jar"
                else:
                    exportFileName = todaysFormattedDate + "_" + domainName + ".jar"
                exportFile = File(exportFolder, exportFileName)
                out = FileOutputStream(exportFile)
                out.write(exportJarBytes)
                out.close()
                print "Automatic backup taken to: "+ exportFileName

        print 'Uploading jar file'
        ALSBConfigurationMBean.uploadJarFile(theBytes)
        print 'Jar file uploaded'

        print 'Performing deployment'
        alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
        #23/05/2016 Commenting this out as it is causing a deployment issue
#        alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
#        alsbImportPlan.setPassphrase(passphrase)
#        alsbImportPlan.setPreserveExistingEnvValues(true)
        importResult = ALSBConfigurationMBean.importUploaded(None) #alsbImportPlan)
        if importResult.getFailed().isEmpty() == false:
            print 'One or more resources could not be imported properly:'
            printDiagMap(importResult.getImportDiagnostics())
            raise

        customizationFile = getCustomizationFilePath(environmentName, serviceGroupName, serviceName, interfaceVersion, domainName)
        print 'Applying customization file: ', customizationFile
        ALSBConfigurationMBean.customize(Customization.fromXML(FileInputStream(customizationFile)))

        groupCustomizationFile = getGroupCustomizationFilePath(environmentName, serviceGroupName, interfaceVersion, domainName)
        if (os.path.isfile(groupCustomizationFile)):
            print 'Applying group level customization file: ', groupCustomizationFile
            ALSBConfigurationMBean.customize(Customization.fromXML(FileInputStream(groupCustomizationFile)))

        print 'Activating change session'
        buildTag = System.getenv('BUILD_TAG')
        if buildTag == None:
            buildTag = ""
        else:
            buildTag = ". Jenkins build tag: " + buildTag
        SessionMBean.activateSession(sessionName, "Scripted import of " + serviceGroupName + ' : ' + serviceName + ' ' + interfaceVersion + ' version ' + mavenVersionId + buildTag)
        print "Deployment of : " + serviceGroupName + ' : ' + serviceName + ' ' + interfaceVersion + ' version ' + mavenVersionId + " successful"
        auditAction("Service " + serviceGroupName + ' : ' + serviceName + ' ' + interfaceVersion + ' version ' + mavenVersionId + " deployed to domain " + domainName + " in " + environmentName + " environment")
        SessionMBean = None
    except:
        auditAction("Failed to deploy service " + serviceGroupName + ' : ' + serviceName + ' ' + interfaceVersion + ' version ' + mavenVersionId + " to domain " + domainName + " in " + environmentName + " environment")
        print "Unexpected error:", sys.exc_info()[0]
        dumpStack()
        if SessionMBean != None:
            SessionMBean.discardSession(sessionName)
        raise
def customiseImport(configurationBean, customisationFilename):
    customisationFile = File(customisationFilename)
    inputstream = FileInputStream(customisationFile)
    configurationBean.customize(Customization.fromXML(inputstream))
Exemplo n.º 10
0
def customiseImport(configurationBean, customisationFilename):
	customisationFile = File(customisationFilename)
	inputstream = FileInputStream(customisationFile)
	configurationBean.customize(Customization.fromXML(inputstream))
Exemplo n.º 11
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
Exemplo n.º 12
0
def importToALSBDomain():
    try:
        # Declare Variables
        sessionMBean = None
        alsbConfigurationMBean = None

        # Connect to Server
        print 'Connecting to server: ', adminUrl
        connectToServer(connectMethod)

        print 'Starting import of:', importJar, "on ALSB Admin Server:", adminUrl

        # Read import jar file
        print 'Read import jar file'
        theBytes = readBinaryFile(importJar)
        print 'Import file read successfully', importJar

        # Create unique session name
        print 'Creating unique session name'
        sessionName = createSessionName()
        print 'Created session name :', sessionName

        # Create and start session
        print 'Creating SessionMBean'
        sessionMBean = getSessionMBean(sessionName)
        print 'SessionMBean started new session'

        # 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.
        print 'Create ALSBConfiguration'
        alsbConfigurationMBean = findService(
            String(ALSBConfigurationMBean.NAME + ".").concat(sessionName),
            ALSBConfigurationMBean.TYPE)
        print "ALSBConfiguration MBean found", alsbConfigurationMBean

        # Perform updates or read operations in the session using alsbSession

        # Upload Jar File
        print 'Uploading Jar file'
        alsbConfigurationMBean.uploadJarFile(theBytes)
        print 'Jar Uploaded'

        print 'ALSB Project will now get imported'
        alsbJarInfo = alsbConfigurationMBean.getImportJarInfo()

        alsbImportPlan = alsbJarInfo.getDefaultImportPlan()

        #alsbImportPlan.setPassphrase(passphrase)

        operationMap = HashMap()

        operationMap = alsbImportPlan.getOperations()

        print 'Default importPlan'
        printOpMap(operationMap)

        alsbImportPlan.setPreserveExistingEnvValues(preserveExistingEnvValues)
        alsbImportPlan.setPreserveExistingOperationalValues(
            preserveExistingOperationalValues)

        print 'Modified importPlan'
        printOpMap(operationMap)
        importResult = alsbConfigurationMBean.importUploaded(alsbImportPlan)

        printDiagMap(importResult.getImportDiagnostics())

        if importResult.getFailed().isEmpty() == false:
            print 'One or more resources could not be imported properly'
            raise

        #customize if a customization file is specified
        #affects only the created resources
        if customFile != None:
            print 'Loading customization File', customFile
            iStream = FileInputStream(customFile)
            customizationList = Customization.fromXML(iStream)
            alsbConfigurationMBean.customize(customizationList)

        sessionMBean.activateSession(
            sessionName, "ALSBImport Operation Completed Successfully")

        print "Deployment of : " + importJar + " successful"
    except:
        print "Unexpected error:", sys.exc_info()[0]
        if sessionMBean != None:
            sessionMBean.discardSession(sessionName)
        raise
Exemplo n.º 13
0
def importToALSBDomain(importConfigFile):
	try:
		print 'Loading Deployment config from :', importConfigFile
		exportConfigProp = loadProps(importConfigFile)

		host = exportConfigProp.get("host")
		port = exportConfigProp.get("port")
		intPort = int(port)
		print "Connecting to: " + host + ":" + port
		importUser = exportConfigProp.get("importUser")
		importPassword = exportConfigProp.get("importPassword")

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

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

		print "Initiate Connection"
		conn = initConnection(host, intPort, importUser, importPassword)
		print "Connection successful"

		mbconn = conn.getMBeanServerConnection()
		obname = DomainRuntimeServiceMBean.OBJECT_NAME
		domainService = MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(obname))
		name = SessionManagementMBean.NAME
		type = SessionManagementMBean.TYPE
		sm = domainService.findService(name, type, None)
		bytes = readBinaryFile(importJar)
		sessionName = "ScriptImport"
		print "sessionName: ", sessionName

		sm.createSession(sessionName)
		alsbSession = domainService.findService(ALSBConfigurationMBean.NAME + "." + sessionName, ALSBConfigurationMBean.TYPE, None)


		alsbSession.uploadJarFile(bytes)
		
		jarInfo = alsbSession.getImportJarInfo()
		importPlan = jarInfo.getDefaultImportPlan()	
		operationMap = importPlan.getOperations()
		
		set = operationMap.entrySet()
		
		importPlan.setPreserveExistingEnvValues(true)


	        #boolean
	        abort = false
		# list of created references
		createdRef = ArrayList()
		
		for entry in set:
                    ref = entry.getKey()
                    op = entry.getValue()
                    #set different logic based on the resource type
                    type = ref.getTypeId
                    if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
                        if op.getOperation() == ALSBImportOperation.Operation.Create:
                            print 'Unable to import a service account or a service provider on a target system', ref
                            abort = true
                    elif op.getOperation() == ALSBImportOperation.Operation.Create:
                        #keep the list of created resources
                        createdRef.add(ref)

                if abort == true :
                    print 'This jar must be imported manually to resolve the service account and service provider dependencies'
                    sm.discardSession(sessionName)
                    raise
		
		result = alsbSession.importUploaded(importPlan);
		
		# Print out status and build a list of created references. Will be used for customization
		if result.getImported().size() > 0:
			print "The following resources have been imported: "
			for successEntry in result.getImported():
				print successEntry.toString()
		
		# Check for error and discard session in any resource fails
			failCount = result.getFailed().size()
			if failCount > 0:
				print ""
				print "Failed for: " + failCount + " resources"

#	 print "The following resources failed to import"
#	 for entry in result.getFailed().entrySet():
#	 ref = entry.getKey()
#	 diagnostics = entry.getValue().toString()
#	 print ref + " Reason: " + diagnostics
#	 abort = true
#	 raise

#=================================================
# Apply Customizations
#=================================================
#customize if a customization file is specified
#affects only the created resources
		if customFile != None :
			print "Loading customization File: " + customFile
			print "Customization applied to the created resources only " + createdRef.toString()
			iStream = FileInputStream(customFile)
			customizationList = Customization.fromXML(iStream)
			filteredCustomizationList = ArrayList()
			setRef = HashSet(createdRef)

# apply a filter to all the customizations to narrow the target to the created resources
			for customization in customizationList:
				newcustomization = customization.clone(setRef)
				filteredCustomizationList.add(newcustomization)

			alsbSession.customize(filteredCustomizationList)
			
#=========================
# Activate Session
#=========================
		sm.activateSession(sessionName, "Imported Configuration")
		print "Project imported"
		conn.close()
	except:
		print "Unexpected error:", sys.exc_info()[0]
		print "Discarding the session."
		sm.discardSession(sessionName)
		conn.close()
		raise
Exemplo n.º 14
0
def applyCustomizationFile(config_mbean):
    print "[INFO] Loading customization file '%s'" % sbconfig_customization_file
    iStream = FileInputStream(sbconfig_customization_file)
    customizationList = Customization.fromXML(iStream)
    config_mbean.customize(customizationList)
Exemplo n.º 15
0
def importIntoDomain():
	try:
		# Declare Variables
		sessionMBean = None
		alsbConfigurationMBean = None
		xpf = XmlProperties("tmp/ant-properties.xml")
		xpf.transformProperties("tmp/ant-properties.properties")
		pf = PropertiesFile("tmp/ant-properties.properties")
		packageHome = pf.get("package.home")
		
		# Connect to Server
		print 'Connecting to server: ', pf.get("osbadm.adminUrl")
	#		connectToServer()
		connect(pf.get("osbadm.admin_user"), pf.get("osbadm.admin_password"), pf.get("osbadm.adminUrl"))
		domainRuntime()


		# Create unique session name	
		print 'Creating unique session name'
		sessionName = createSessionName()
		print 'Created session name :', sessionName

		# Create and start session
		print 'Creating SessionMBean'
		sessionMBean = getSessionMBean(sessionName)
		print 'SessionMBean started new session'

		# 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.
		print 'Create ALSBConfiguration'
		alsbConfigurationMBean = findService(String(ALSBConfigurationMBean.NAME + ".").concat(sessionName), ALSBConfigurationMBean.TYPE)
		print "ALSBConfiguration MBean found", alsbConfigurationMBean
		
		
		# Perform updates or read operations in the session using alsbSession
		# sys.arg[4] is the root of the package
		print 'INFO package root is ' + packageHome
		psc_list=[]
		pscProps = PropertiesFile(packageHome + "/" + 'psc_details.properties')
		print 'INFO loaded properties from ' + packageHome + "/" + 'psc_details.properties'
		pscNames = pscProps.getPartialKey("*.pscname")
		serviceProps = []
		for k, v in pscNames:
			if pscProps.get(v + ".technology") == "osb":
				serviceProps.append((k, v))
		
		for k, pscName in serviceProps:
			print 'INFO processing serviceslist entry ' + pscName
			# sys.arg[4] is the root of the package
			if len(pscName) != 0:
				service_file= packageHome + "/" + pscProps.get(pscName + ".deployable")
				print 'INFO deployable resolved to ' , service_file
				psc_list.append(pscName + ":" + pscProps.get(pscName + ".version.label"))

				print 'Starting import of:', service_file, "on to OSB Admin Server:", pf.get("osbimp.adminUrl")

				# Read import jar file
				print 'INFO Read import jar file'
				theBytes = BinaryFile(service_file).getBytes()
				print 'INFO Import file read successfully', service_file


				# Upload Jar File
				print 'INFO Uploading Jar file'
				alsbConfigurationMBean.uploadJarFile(theBytes)
				print 'INFO Jar Uploaded'

				print 'INFO ALSB Project will now get imported'
				alsbJarInfo = alsbConfigurationMBean.getImportJarInfo()

				alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
				# we are currently running all WLST with the same keystore
				# if this changes we will have to get more clever here
				alsbImportPlan.setPassphrase(pf.get("oradm.keystore.passphrase"))
				operationMap=HashMap()
				operationMap = alsbImportPlan.getOperations()
				print 'INFO Default importPlan'
				printOpMap(operationMap)
				alsbImportPlan.setPreserveExistingEnvValues(false)
				alsbImportPlan.setPreserveExistingOperationalValues(false)
				print 'INFO Modified importPlan'
				printOpMap(operationMap)
				importResult = alsbConfigurationMBean.importUploaded(alsbImportPlan)
				printDiagMap(importResult.getImportDiagnostics())

				if importResult.getFailed().isEmpty() == false:
					print 'ERROR One or more resources could not be imported properly'
					raise
				
				#customize if a customization file is specified
				#affects only the created resources
				customisationFile = service_file + ".xml"
				if(os.path.exists(customisationFile)):
					print 'INFO Loading customization File', customisationFile
					iStream = FileInputStream(customisationFile)
					customizationList = Customization.fromXML(iStream)
					alsbConfigurationMBean.customize(customizationList)

		print "INFO The MBean session has been configured for the following deployments:"		
		for psc in psc_list:
			print "\t" + psc
		deployMessage = "Deployed PSC's " + "\t" + "\n\t".join(psc_list)
		try:
			sessionMBean.activateSession(sessionName, deployMessage)
		except:
			print "ERROR problem encountered activating the session"
			print "INFO this can happen if one or more of the managed servers are not running"
			raise
			
		print "INFO Deployment of : \n\t" + "\n\t".join(psc_list) + "\nsuccessful"
	except Exception, e:
		print "ERROR Unexpected error:", sys.exc_info()[0]
		print e
		if sessionMBean:
			sessionMBean.discardSession(sessionName)
		raise
Exemplo n.º 16
0
def importIntoDomain():
	try:
		# Declare Variables
		sessionMBean = None
		alsbConfigurationMBean = None
		packageHome = sys.argv[4]
		
		# Connect to Server
		print 'Connecting to server: ', sys.argv[3]
		connectToServer()

		


		# Create unique session name	
		print 'Creating unique session name'
		sessionName = createSessionName()
		print 'Created session name :', sessionName

		# Create and start session
		print 'Creating SessionMBean'
		sessionMBean = getSessionMBean(sessionName)
		print 'SessionMBean started new session'

		# 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.
		print 'Create ALSBConfiguration'
		alsbConfigurationMBean = findService(String(ALSBConfigurationMBean.NAME + ".").concat(sessionName), ALSBConfigurationMBean.TYPE)
		print "ALSBConfiguration MBean found", alsbConfigurationMBean

		# Perform updates or read operations in the session using alsbSession
		# sys.arg[4] is the root of the package
		print 'INFO package root is ' + packageHome
		psc_list=[]
		pscProps = loadPropertiesFromFile(packageHome + "/" + 'psc_details.properties')
		print 'INFO loaded properties from ' + packageHome + "/" + 'psc_details.properties'
		try:
			file = open(packageHome + "/" + "serviceslist.properties","rb")
		except:
			print 'ERROR failed to open serviceslist.properties'
			raise
		for line in file.readlines():
			print 'INFO processing serviceslist entry ' + line.rstrip()
			# sys.arg[4] is the root of the package
			pscName = line.rstrip()
			if len(pscName) != 0:
				service_file= packageHome + "/" + pscProps.getProperty(line.rstrip() + ".deployable")
				print 'INFO deployable resolved to ' , service_file
				psc_list.append(line.rstrip() + ":" + pscProps.getProperty(line.rstrip() + ".version.label"))

				print 'Starting import of:', service_file, "on to OSB Admin Server:", sys.argv[3]
				# Read import jar file
				print 'INFO Read import jar file'
				theBytes = readBinaryFile(service_file)
				print 'INFO Import file read successfully', service_file


				# Upload Jar File
				print 'INFO Uploading Jar file'
				alsbConfigurationMBean.uploadJarFile(theBytes)
				print 'INFO Jar Uploaded'

				print 'INFO ALSB Project will now get imported'
				alsbJarInfo = alsbConfigurationMBean.getImportJarInfo()

				alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
				alsbImportPlan.setPassphrase(sys.argv[5])
				operationMap=HashMap()
				operationMap = alsbImportPlan.getOperations()
				print 'INFO Default importPlan'
				printOpMap(operationMap)
				alsbImportPlan.setPreserveExistingEnvValues(false)
				alsbImportPlan.setPreserveExistingOperationalValues(false)
				print 'INFO Modified importPlan'
				printOpMap(operationMap)
				importResult = alsbConfigurationMBean.importUploaded(alsbImportPlan)
				printDiagMap(importResult.getImportDiagnostics())

				if importResult.getFailed().isEmpty() == false:
					print 'ERROR One or more resources could not be imported properly'
					raise
				
				#customize if a customization file is specified
				#affects only the created resources
				customisationFile = service_file + ".xml"
				if(os.path.exists(customisationFile)):
					print 'INFO Loading customization File', customisationFile
					iStream = FileInputStream(customisationFile)
					customizationList = Customization.fromXML(iStream)
					alsbConfigurationMBean.customize(customizationList)


		print "INFO The MBean session has been configured for the following deployments:"		
		for psc in psc_list:
			print "\t" + psc

		try:
			sessionMBean.activateSession(sessionName, "Deployed PSC's " + "\t" + "\n\t".join(psc_list))
		except:
			print "ERROR problem encountered activating the session"
			print "INFO this can happen if one or more of the managed servers are not running"
			raise
			
		print "INFO Deployment of : \n\t" + "\n\t".join(psc_list) + "\nsuccessful"
	except:
		print "ERROR Unexpected error:", sys.exc_info()[0]
		if sessionMBean != None:
			sessionMBean.discardSession(sessionName)
			file.close()
			raise
Exemplo n.º 17
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
Exemplo n.º 18
0
def applyCustomizationFile(config_mbean):
    print "[INFO] Loading customization file '%s'" % sbconfig_customization_file
    iStream = FileInputStream(sbconfig_customization_file)
    customizationList = Customization.fromXML(iStream)
    config_mbean.customize(customizationList)
Exemplo n.º 19
0
def importToALSBDomain():
    try:
        SessionMBean = None

        print 'Attempting to import :', importJar, "on ALSB Admin Server listening on :", adminUrl

        theBytes = readBinaryFile(importJar)
        print 'Read file', importJar
        sessionName = createSessionName()
        print 'Created session', sessionName
        SessionMBean = getSessionManagementMBean(sessionName)
        print 'SessionMBean started session'
        ALSBConfigurationMBean = findService(String("ALSBConfiguration.").concat(sessionName), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found", ALSBConfigurationMBean
        ALSBConfigurationMBean.uploadJarFile(theBytes)
        print 'Jar Uploaded'

        if project == "None":
            print 'No project specified, additive deployment performed'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            alsbImportPlan.setPreserveExistingEnvValues(true)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)
            SessionMBean.activateSession(sessionName, "Complete import without customization using wlst")
        else:
            print 'ALSB project', project, 'will get overlaid'
            alsbJarInfo = ALSBConfigurationMBean.getImportJarInfo()
            alsbImportPlan = alsbJarInfo.getDefaultImportPlan()
            alsbImportPlan.setPassphrase(passphrase)
            operationMap=HashMap()
            operationMap = alsbImportPlan.getOperations()
            print
            print 'Default importPlan'
            printOpMap(operationMap)
            set = operationMap.entrySet()

            alsbImportPlan.setPreserveExistingEnvValues(true)

            #boolean
            abort = false
            #list of created ref
            createdRef = ArrayList()

            for entry in set:
                ref = entry.getKey()
                op = entry.getValue()
                #set different logic based on the resource type
                type = ref.getTypeId
                if type == Refs.SERVICE_ACCOUNT_TYPE or type == Refs.SERVICE_PROVIDER_TYPE:
                    if op.getOperation() == ALSBImportOperation.Operation.Create:
                        print 'Unable to import a service account or a service provider on a target system', ref
                        abort = true
#                elif op.getOperation() == ALSBImportOperation.Operation.Create:
                else:
                    #keep the list of created resources
                    print 'ref: ',ref
                    createdRef.add(ref)

            if abort == true :
                print 'This jar must be imported manually to resolve the service account and service provider dependencies'
                SessionMBean.discardSession(sessionName)
                raise

            print
            print 'Modified importPlan'
            printOpMap(operationMap)
            importResult = ALSBConfigurationMBean.importUploaded(alsbImportPlan)

            printDiagMap(importResult.getImportDiagnostics())

            if importResult.getFailed().isEmpty() == false:
                print 'One or more resources could not be imported properly'
                raise

            #customize if a customization file is specified
            #affects only the created resources
            if customFile != "None" :
                print 'Loading customization File', customFile
                print 'Customization applied to the created resources only', createdRef
                iStream = FileInputStream(customFile)
                customizationList = Customization.fromXML(iStream)
                filteredCustomizationList = ArrayList()
                setRef = HashSet(createdRef)

                # apply a filter to all the customizations to narrow the target to the created resources
                for customization in customizationList:
                    print customization
                    newcustomization = customization.clone(setRef)
                    filteredCustomizationList.add(newcustomization)

                ALSBConfigurationMBean.customize(filteredCustomizationList)

            SessionMBean.activateSession(sessionName, "Complete import with customization using wlst")

        print "Deployment of : " + importJar + " successful"
    except:
        print "Unexpected error:", sys.exc_info()[0]
        if SessionMBean != None:
            SessionMBean.discardSession(sessionName)
        raise
Exemplo n.º 20
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