Created
November 26, 2015 08:33
-
-
Save bmoussaud/c9c5e057456cafa37a1f to your computer and use it in GitHub Desktop.
check required deployed application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deployedApplication(): | |
return specification.deployedOrPreviousApplication | |
version = deployedApplication().version | |
environment_id = deployedApplication().environment.id | |
applicationRequirements = version.applicationRequirements | |
print "Checking Application Requirements: %s " % applicationRequirements | |
missingRequirements = [] | |
for application in applicationRequirements.keys(): | |
required_application_id = "%s/%s" % (application, applicationRequirements[application]) | |
print "Application %s" % required_application_id | |
deployedApplication_id = "%s/%s" % (environment_id, application) | |
if not repositoryService.exists(deployedApplication_id): | |
missingRequirements.append(required_application_id) | |
continue | |
deployedApplication = repositoryService.read(deployedApplication_id) | |
deployedApplication_version_name = deployedApplication.version.name | |
if deployedApplication_version_name == applicationRequirements[application]: | |
print "The application %s is deployed on %s" % (required_application_id, environment_id) | |
context.addStep(steps.jython( | |
description = "Check '%s' is still deployed in '%s'" % (required_application_id, environment_id), | |
order = 80, | |
script_path = "requirement/step/check.py", | |
jython_context = {"environment_id": environment_id, | |
"required_application_id": required_application_id, | |
"deployed_application_id": deployedApplication_id, | |
"version_name": applicationRequirements[application]} | |
)) | |
else: | |
missingRequirements.append(required_application_id) | |
if len(missingRequirements) > 0: | |
raise Exception("required applications %s are not deployed in %s" % (missingRequirements, environment_id)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "environment_id %s" % environment_id | |
print "required_application_id %s" % required_application_id | |
print "deployed_application_id %s" % deployed_application_id | |
print "version_name %s" % version_name | |
deployedApplication = repositoryService.read(deployed_application_id) | |
deployedApplication_version_name = deployedApplication.version.name | |
if deployedApplication_version_name == version_name: | |
print "Application %s is still deployed in %s" %(required_application_id, environment_id) | |
else: | |
raise Exception("Application %s is not deployed in %s" %(required_application_id, environment_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rule name="check.application.requirements.in.the.current.environment" scope="pre-plan"> | |
<planning-script-path>requirements/planning/check-application-requirements.py</planning-script-path> | |
</rule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment