예제 #1
0
	def testGetConfig(self):
		print "TestApplicationDeploymentConfig : testGetConfig"
		pf = XmlProperties("tmp/ant-properties.xml").getAntProperties()
		for k, psc in pf.getPartialKey("*.pscname"):
			if pf.get(psc + ".technology") == "webapp":
				appConfig = ApplicationDeploymentConfig(psc, pf).getConfig()
				self.assertEqual(appConfig["domain"], "GWA_Applications")
				self.assertEqual(appConfig["deployable"], os.path.join(pf.get("package.home"), pf.get(psc + ".deployable")))
				self.assertEqual(appConfig["admin.user"], "GWAApplicationsAdmin")
				self.assertEqual(appConfig["target"], pf.get(pf.get(psc + ".target") + ".target.name"))
				self.assertEqual(appConfig["name"], psc)
				if pf.get(psc + ".securitymodel"):
					self.assertEqual(appConfig["security.model"], pf.get(psc + ".securitymodel"))
				else:
					self.assertEqual(appConfig["security.model"], "CustomRoles")
예제 #2
0
""" take a list of properties files and open them
"""
import sys, os
from propertiesutils import PropertiesFile
from propertiesutils import NonEncryptedPropertiesFile
from loggingutils import SimpleReporter
from propertiesutils import XmlProperties
logger = SimpleReporter()
xpf = XmlProperties("tmp/ant-properties.xml")
xpf.transformProperties("tmp/ant-properties.properties")
pf = PropertiesFile("tmp/ant-properties.properties")
fileList = pf.get("property.files").split(",")
for file in fileList:
	logger.report("Processing %s" % (file))
	enc = NonEncryptedPropertiesFile(file)
예제 #3
0
		
		
  	except java.lang.UnsupportedOperationException, usoe:
    		print "Could not create  resource "
    		pass
  	except weblogic.descriptor.BeanAlreadyExistsException,bae:
    		print "Could not create  resource"
    		pass
  	except java.lang.reflect.UndeclaredThrowableException,udt:
    		print "Could not create  resource"
    		pass
			
# IMPORT script init
try:

	xmlp = XmlProperties("tmp/ant-properties.xml")
	pf = xmlp.getAntProperties()

	# get a list of datasource unique ids
	jmsNameProps = pf.getPartialKey("*.module.name")
	jmsIds = []
	for key, value in jmsNameProps:
		jmsIds.append(key.split(".")[0])

	for jmsId in jmsIds:
		jmsConfig = JMSResourceConfig(jmsId, pf).getConfig()
		target = jmsConfig["target"]

		print "[INFO} resolving admin server for " + target		connected = false
		print "[INFO] resolving admin server for target " + target
		connected = false
예제 #4
0
		if (createJmsResources(jmsConfig)) :
			return true
		else :
			print "Unable to create " + modname + "; cancelling configuration of " + modname + " and aborting"
			return false
	elif (action == "drop") :
		destroyJmsResources(jmsConfig)
		return true
	else :
		print "Unrecognised action: '" + action + "'"
		return false


try:
	# return a PropertiesFile object containing the ant namespace properties
	pf = XmlProperties("tmp/ant-properties.xml").getAntProperties()
	debug = pf.get("weblogic.script.debugging")
	if debug == "on":
		debugging = true
	else:
		debugging = false
	action = pf.get("managejmsresources.action")
	modules = pf.getPartialKey("*.jms.system.module.name")
	if debugging:
		print "[DEBUG] len(modules): %i" % len(modules)
		print "[DEBUG] modules[0][1]: " + modules[0][1]
		print "[DEBUG] action: " + action
	for k, modname in modules:
		print "Processing properties for JMS resource ID: %s" % (modname)
		jmsConfig = JMSResourceConfig(modname, pf).getConfig()
예제 #5
0
import os, sys
from propertiesutils import XmlProperties
from propertiesutils import PropertiesFile
xmlProps = XmlProperties("tmp/ant-properties.xml")
antPropertiesFile = "tmp/ant-properties.properties"
xmlProps.transformProperties(antPropertiesFile)
apf = PropertiesFile(antPropertiesFile)
# add some validation of existence of config file
configFilePath = apf.get("config.file.path")
if os.path.isfile(configFilePath):
	epf = PropertiesFile(configFilePath)
else:
	print "[ERROR] configuration properties file " + configFilePath + " does not exist"
	sys.exit("missing environment configuration file")
# add some validation of version
envVersion = apf.get("config.file.version")
if epf.validateVersionProperty(propertyValue=envVersion):
	version = epf.get("property.file.version")
	config_file_name = apf.get("config.file.name")
	tpf = epf.createTokenisedProperties("{@", "@}", "configmaps/" + config_file_name + version + ".properties")
else:
	print "[ERROR] invalid configuration file version"
	sys.exit("invalid configuration file")
				deployable["artefact"] = latest
			artefact = deployable["artefact"]
			sourceDir = repoHome + "/" + deployable["repo-path"]
			target = deployPackageHome + "/" + deployable["name"]
			antFile.copyFile(sourceDir, artefact, target)
	createAutodeployProperties(antFile, releaseId, deployables)
			
				
def createAutodeployProperties(antFile, packageHome, deployables):
	""" do the bits that are common to all ant files like create the properties file and set package.home
	"""
	# force protocol to file for local file copy
	antFile.copyDir(".", "psc_details.properties", "tmp/" + packageHome, protocol="file")
	antFile.property(name="package.home", value="tmp/" + packageHome)
	antFile.updateConfigProps("environment-config.properties", "package.home", "tmp/" + packageHome)
	antFile.createSetEnvFile("PACKAGE_HOME", "tmp/" + packageHome)
	antFile.writeBuildfile()
	detailsFile = PSCDetailsFile(deployables).writeFile(".")
			
	
pf = XmlProperties("tmp/ant-properties.xml").getAntProperties()
manifestSource = pf.get("manifest.source")
# cater for different kinds of manifest - right now only cmdb and ci
if manifestSource == "cmdb":
	processCMDBManifest(pf)
elif manifestSource == "ci":
	processCIManifest(pf)
else:
	raise
	
	
예제 #7
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
예제 #8
0
			return false
	except:
		return false
	return true

def isDeployed(appConfig):
	""" check if application is deployed
	"""
	deployed = false
	if len( re.findall(appConfig["name"], ls('/AppDeployments')) ) > 0:
		deployed = true
	return deployed

try:
	# return a PropertiesFile object containing the ant namespace properties
	pf = XmlProperties("tmp/ant-properties.xml").getAntProperties()
	debug = pf.get("weblogic.script.debugging")
	if debug == "on":
		debugging = true
	else:
		debugging = false
	action = pf.get("deployApplications.action")
	if not (action == "deploy" or action == "undeploy"):
		print "Action must be 'deploy' or 'undeploy'"
		exit(exitcode=2)
	
	
	# Holder for name of domain to which we're currently connected:
	# use it to avoid re-connecting to domain already connected
	currentDomain = None
	pscs = pf.getPartialKey("*.pscname")