Skip to content

Commit

Permalink
Issue #38: Fixing undeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewinne committed Jan 17, 2017
1 parent 271f5cc commit 75311c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deploy:
provider: releases
api_key:
secure: aoVXZyLOBmB4Q2lLKLaqEN8zcqN3K3/3agRBA1znM1PLeqXSE3CwQe6sHkX6BrfMoDDtjqeepDMgJ9TsqJFq+lPY+HuVFzOqGlrWlIZHBUKI3hmfjgM/61CkdK2eBO42Ym4tqCQ4L1Tp42fcrB6M/a/0TGI5ENW2bJk8+ofRT8M=
file: build/libs/xlr-xldeploy-plugin-2.8.0.jar
file: build/libs/xlr-xldeploy-plugin-2.8.1.jar
skip_cleanup: true
on:
all_branches: true
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "com.xebialabs.xl.docker" version "1.0.0"
}

version = "2.8.0"
version = "2.8.1"

apply plugin: 'java'
apply plugin: 'idea'
Expand Down
9 changes: 7 additions & 2 deletions src/main/resources/xldeploy/XLDeployClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,15 @@ def deployment_exists(self, deployment_package, environment):
response = deployment_exists_response.getResponse()
return 'true' in response

def deployment_prepare_undeploy(self, deployed_application_id):
def deployment_prepare_undeploy(self, deployed_application_id, orchestrators=None, deployed_application_properties=None):
deployment_prepare_undeploy_url = "/deployit/deployment/prepare/undeploy?deployedApplication=%s" % deployed_application_id
deployment_prepare_undeploy_url_response = self.http_request.get(deployment_prepare_undeploy_url, contentType='application/xml')
return deployment_prepare_undeploy_url_response.getResponse()
if not deployment_prepare_undeploy_url_response.isSuccessful():
raise Exception("Failed to prepare undeploy. Server return [%s], with content [%s]" % (deployment_prepare_undeploy_url_response.status, deployment_prepare_undeploy_url_response.response))
undeployment_xml = deployment_prepare_undeploy_url_response.getResponse()
undeployment_xml = add_orchestrators(undeployment_xml, orchestrators)
undeployment_xml = set_deployed_application_properties(undeployment_xml, deployed_application_properties)
return undeployment_xml

def deployment_prepare_update(self, deployment_package, environment):
deployment_prepare_update_url = "/deployit/deployment/prepare/update?version=%s&deployedApplication=%s" % (deployment_package, "%s/%s" % (environment, deployment_package.rsplit('/', 2)[1]))
Expand Down
11 changes: 2 additions & 9 deletions src/main/resources/xldeploy/undeployTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@
import sys
from xldeploy.XLDeployClientUtil import XLDeployClientUtil

xld_client = XLDeployClientUtil
xld_client = XLDeployClientUtil.create_xldeploy_client(xldeployServer, username, password)

deployment = None
deployment_package = xld_client.get_deployment_package("%s/%s" % (environment, deployedApplication))
if xld_client.deployment_exists(deployment_package, environment):
print "Undeploying [%s] from environment [%s] \n" % (deployment_package, environment)
deployment = xld_client.deployment_prepare_undeploy("%s/%s" % (environment, deployedApplication))
deployment = xld_client.deployment_prepare_undeploy("%s/%s" % (environment, deployedApplication), orchestrators, deployedApplicationProperties)
else:
print "No deployed application found [%s] for environment [%s] \n" % (deployedApplication, environment)
sys.exit(1)

# Mapping deployables to the target environment
print "Set orchestrators \n"
deployment = xld_client.add_orchestrators(deployment, orchestrators)

print "Set Deployed Application Properties \n"
deployment = xld_client.set_deployed_application_properties(deployment, deployedApplicationProperties)

print "Creating a deployment task \n"
task_id = xld_client.get_deployment_task_id(deployment)

Expand Down

0 comments on commit 75311c9

Please sign in to comment.