Ejemplo n.º 1
0
def processCMDBManifest(pf):
	""" create the autodeploy file system from a released repository
	supposes a structure as in svn BuildDeliverables
	"""
	repoPath = pf.get("manifest.repository.root")
	manifest = CMDBManifest(pf.get("manifest.file"))
	releaseId = manifest.getReleaseId()
	pscs = manifest.getPSCs()
	deployables = []
	# cater for different transport protocols - right now only file
	antFile = AntCopyProject("antBuildtmpFS.xml", pf.get("manifest.repository.protocol"))
	antFile.setName("createtmpfs")
	antFile.deleteDir("tmp/" + releaseId)
	# cater for getting metadata in different ways - right now only config registry
	metadata = DeploymentMetadata(pf.get("manifest.metadata.source"), pf.get("manifest.metadata.file"))
	for psc in pscs:
		deployable = metadata.getMetadataForPSC(psc)
		if deployable:
			deployables.append(deployable)
			source = repoPath + "/" + deployable["repo-path"]
			pattern = "**/**"
			target = "tmp/" + releaseId + "/" + deployable["name"] + "_" + deployable["version"]
			antFile.copyDir(source, pattern, target)
			# generic name for config folder DC-SR-ORAPP-XX_ROOT hard-coded
			antFile.copyDir(target + "/config", "**", "tmp/" + releaseId + "/DC-SR-ORAPP-XX_ROOT/PSCConfig")
	createAutodeployProperties(antFile, releaseId, deployables)
Ejemplo n.º 2
0
def processCIManifest(pf):
	""" create a file system for autodeploy from some file system - probably build-system output
	the CIManifest allows the inclusion of a pattern match so that we can get the latest build
	of a particular artefact
	"""
	manifest = CIManifest(pf.get("manifest.file"))
	releaseId = manifest.getReleaseId()
	deployPackageHome = "tmp/" + releaseId
	pscs = manifest.getPSCs()
	deployables = []
	# cater for different repository types - file/ftp
	# TODO implement file for CI
	antFile = AntCopyProject("antBuildtmpFS.xml", pf.get("manifest.repository.protocol"))
	antFile.setName("createtmpfs")
	antFile.deleteDir(deployPackageHome)
	metadata = DeploymentMetadata(pf.get("manifest.metadata.source"), pf.get("manifest.metadata.file"))
	for psc in pscs:
		deployable = metadata.getMetadataForPSC(psc)
		if deployable:
			deployables.append(deployable)
			if pf.get("manifest.repository.protocol").lower() == "ftp":
				repoHome = "ftp://" + pf.get("manifest.repository.root")
			elif pf.get("manifest.repository.protocol").lower() == "file":
				repoHome = pf.get("manifest.repository.root")
			if deployable["artefact"].find("*") > 0 and pf.get("manifest.repository.protocol").lower() == "ftp":
				ftpSite = FTPSiteNav(pf.get("manifest.repository.root"))
				latest = ftpSite.getLatestFromPattern(deployable["repo-path"], deployable["artefact"])[0]
				deployable["artefact"] = latest
			artefact = deployable["artefact"]
			sourceDir = repoHome + "/" + deployable["repo-path"]
			target = deployPackageHome + "/" + deployable["name"]
			antFile.copyFile(sourceDir, artefact, target)
	createAutodeployProperties(antFile, releaseId, deployables)
Ejemplo n.º 3
0
	def testWriteBuildfileFTP(self):
		print "TestAntCopyProject : testWriteBuildfileFTP"
		project = AntCopyProject("sample_properties/testAntFTPProject.xml", "ftp")
		project.setName("ftp-project")
		project.copyFile("ftp://build.gateway.michaelpage.local/TempBookingParentPOM/trunk"
						, "TempBookingApplicationEar-tempbookingbuild-3.0.0-SNAPSHOT-build.279.ear"
						, "tmp/package-root/TempBookingApplication")
		project.writeBuildfile()
Ejemplo n.º 4
0
	def testDisplayProject(self):
		""" kinda difficult to do strict unit testing here - just displat the results for now
		"""
		print "TestAntCopyProject : displayProject"
		project = AntCopyProject("sample_properties/testCopyProject.xml", "file")
		project.setName("display-project")
		self.assertEqual(len(self.deployables), 2)
		processed = 0
		for deployable in self.deployables:
			processed += 1
			project.copyDir("d:/repo/" + deployable["repo-path"], "/**/*.*",
							"temp/deployment-root/" + deployable["name"] + "_" + deployable["version"])
		self.assertEqual(processed, 2)
		project.copyDir(".", "psc_details.properties", "tmp/package.home")
		project.property(name="package.home", value="tmp/package-home")
		print "--- project xml ---"
		for line in project.project:
			print line
Ejemplo n.º 5
0
	def testOpenProject(self):
		print "TestAntCopyProject : testOpenProject"
		project = AntCopyProject("sample_properties/testCopyProject.xml", "file")
		self.assertEqual(project.project[0], """<?xml version="1.0" encoding="UTF-8"?>""")
		project.setName("test-ant-copy")
		self.assertEqual(project.project[1], """<project name="test-ant-copy" default="build">""")
Ejemplo n.º 6
0
	def testWriteBuildfile(self):
		print "TestAntCopyProject : writeBuildfile"
		project = AntCopyProject("sample_properties/testAntCopyProject.xml", "file")
		project.setName("written-project")
		self.assertEqual(len(self.deployables), 2)
		processed = 0
		project.deleteDir("tmp/package-home")
		for deployable in self.deployables:
			processed += 1
			project.copyDir("d:/repo/" + deployable["repo-path"], "/**/*.*",
							"temp/deployment-root/" + deployable["name"] + "_" + deployable["version"])
		self.assertEqual(processed, 2)
		project.property(name="package.home", value="tmp/package-home")
		project.updateConfigProps("config.properties", "package.home", "tmp/package-home")
		project.createSetEnvFile("PACKAGE_HOME", "/tmp/package-home")
		project.writeBuildfile()