Skip to content

Commit 4c59fca

Browse files
author
Benoit Moussaud
committed
add createDeploymentPlan task
1 parent 598cba5 commit 4c59fca

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#
2+
# Copyright 2019 XEBIALABS
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
#
6+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
#
8+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
#
10+
11+
#
12+
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
13+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
14+
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
15+
#
16+
17+
import sys, string, time
18+
import datetime
19+
import json
20+
21+
if nolioServer is None:
22+
print "No server provided."
23+
sys.exit(1)
24+
25+
nolioUrl = nolioServer['url']
26+
27+
deploymentPlan = "{project}_{uniqueid}".format(project=project,
28+
uniqueid=datetime.datetime.fromtimestamp(time.time()).strftime(
29+
'%Y-%m-%d_%H:%M:%S'))
30+
31+
content = {
32+
"application": application,
33+
"build": build,
34+
"deploymentPlan": deploymentPlan,
35+
"deploymentTemplate": deploymentTemplate,
36+
"project": project,
37+
"templateCategory": templateCategory,
38+
"manifest": manifest
39+
}
40+
41+
print "* Sending content {0}".format(json.dumps(content))
42+
43+
context = '/datamanagement/a/api/{0}/create-deployment-plan'.format(nolioServer['version'])
44+
print "* Context is {0}".format(context)
45+
46+
request = HttpRequest(nolioServer, username, password)
47+
response = request.post(context, json.dumps(content), contentType='application/json')
48+
49+
if response.isSuccessful():
50+
print "* status {0}".format(response.status)
51+
print "* response {0}".format(response.response)
52+
53+
json_response = json.loads(response.response)
54+
data = json_response
55+
result = data.get('result')
56+
if result == "false":
57+
description = data.get('description')
58+
print description
59+
print "Failed to create release in Nolio at %s." % nolioUrl
60+
response.errorDump()
61+
sys.exit(1)
62+
else:
63+
deploymentPlan = data.get('deploymentPlan')
64+
print "successfully create the deployment plan " + deploymentPlan
65+
deploymentPlanId = data.get('deploymentPlanId')
66+
else:
67+
print "Failed to create release in Nolio at %s." % nolioUrl
68+
response.errorDump()
69+
sys.exit(1)

src/main/resources/nolio/runDeployment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
print "* status {0}".format(response.status)
4747
print "* response {0}".format(response.response)
4848

49-
data = json.loads(response.response)[0]
49+
json_response = json.loads(response.response)
50+
data = json_response[0]
5051

5152
deploymentId = data.get('id')
5253
deploymentDescription = data.get('description')

src/main/resources/synthetic.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,25 @@
132132
<property name="deploymentStateText" category="output"/>
133133
</type>
134134

135+
<type type="nolio.createDeploymentPlan" extends="xlrelease.PythonScript">
136+
<property name="scriptLocation" default="nolio/createDeploymentPlan.py" hidden="true"/>
137+
<property name="iconLocation" default="nolio/nolio.png" hidden="true"/>
138+
139+
<property name="nolioServer" category="input" label="Server" referenced-type="nolio.Server" kind="ci"/>
140+
141+
<property name="username" category="input" label="username" required="false"/>
142+
<property name="password" password="true" category="input" required="false"/>
143+
144+
<property name="application" category="input" required="true"/>
145+
<property name="project" category="input" required="true"/>
146+
<property name="build" category="input" required="true"/>
147+
<property name="deploymentTemplate" category="input" required="true"/>
148+
<property name="templateCategory" category="input" required="true"/>
149+
<property name="manifest" category="input" required="false" size="large"/>
150+
151+
<property name="deploymentPlan" category="output" />
152+
<property name="deploymentPlanId" category="output"/>
153+
</type>
154+
135155

136156
</synthetic>

0 commit comments

Comments
 (0)