Skip to content

Instantly share code, notes, and snippets.

View bmoussaud's full-sized avatar
😀

Benoit Moussaud bmoussaud

😀
View GitHub Profile
@bmoussaud
bmoussaud / planning-check.py
Created November 24, 2015 09:13
XLDeploy: Check running tasks running or have scheduled to prevent several deployment on the same environment
def deployedApplication():
return specification.deployedOrPreviousApplication
environment = deployedApplication().environment
candidates = filter(lambda task: task.metadata['environment_id'] == environment.id, taskService.allCurrentTasks)
if len(candidates) == 1:
raise Exception("%d deployment task is running or has been scheduled on '%s'" % (len(candidates), environment.id))
@bmoussaud
bmoussaud / Precondition1.py
Last active November 24, 2015 14:52
XLR preconditions
print getCurrentTask().title
print getCurrentTask().pythonScript.deploymentPackage
result = "hotfix" not in getCurrentTask().pythonScript.deploymentPackage
@bmoussaud
bmoussaud / comment.py
Last active December 3, 2015 13:55
Comment / uncomment java property file entry
from com.xebialabs.overthere.util import OverthereUtils
from java.io import PrintWriter
def comment(line):
if line.startswith(entry):
return "#"+line
else:
return line
def out_line(pw,line,lineSeparator):
@bmoussaud
bmoussaud / check-application-requirements.py
Created November 26, 2015 08:33
check required deployed application
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():
from com.xebialabs.deployit.plugin.api.deployment.specification import Operation
def dump_modified_delta(delta):
print "DUMP %s " % delta
ci_type = delta.deployed.type
print ci_type
ci_descriptor = metadataService.findDescriptor(Type.valueOf(str(ci_type)))
print ci_descriptor
for pd in ci_descriptor.getPropertyDescriptors():
print "-- %s %s %s" % (pd, pd.get(delta.deployed), pd.get(delta.previous))
def gather_steps_from_block(b, tid):
if hasattr(b, "blocks") and len(b.blocks):
for i in b.blocks:
return gather_steps_from_block(i, tid)
else:
step_block_state = task2.steps(tid, b.id)
return step_block_state.steps
def gather_steps_from_task(t):
step_ids = []
cd %windir%\system32\inetsrv
appcmd set config "${deployed.websiteName}/${deployed.name}" /section:system.ftpserver/security/authorization /-[accessType='Allow',permissions='Read',roles='',users='*'] /commit:apphost
appcmd set config "${deployed.websiteName}/${deployed.name}" /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='Read,Write',roles='',users='*'] /commit:apphost
@bmoussaud
bmoussaud / 0_login.rb
Created March 10, 2016 16:19 — forked from yannvery/0_login.rb
Savon Client for SDM webservices - Request examples
require 'savon'
# Get wsdl
client = Savon.client(wsdl: "http://localhost:8080/axis/services/USD_R11_WebService?wsdl")
#login
response = client.call(:login, message: {username: "servicedesk", password: ""})
sid = response.body[:login_response][:login_return]
@bmoussaud
bmoussaud / demo.py
Created April 27, 2016 14:00
XLR Create Task by API
import sys
def add_task(version, env):
print "Create a new task %s -> %s " % (version,env)
phase = getCurrentPhase()
current_task = getCurrentTask()
task = taskApi.newTask("xldeploy.DeployTask")
task.title = "Deploy %s -> %s" % (version, env)
task.pythonScript.xldeployServer = current_task.getPythonScript().getProperty("xldeployServer")
task.pythonScript.deploymentPackage = version
@bmoussaud
bmoussaud / synthetic.xml
Created April 29, 2016 08:28
versioned="false"
<type-modification type="overthere.SshHost" versioned="false">
</type-modification>
<type-modification type="file.File" versioned="false">
</type-modification>