Skip to content

Commit e88b13b

Browse files
committed
CFY-5334 add SSL support
1 parent 0d921bf commit e88b13b

File tree

5 files changed

+168
-125
lines changed

5 files changed

+168
-125
lines changed

components/manager/scripts/creation_validation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import utils # NOQA
1111

1212
IMMUTABLE_PROPERTIES = [
13-
'security',
1413
'ssh_user'
1514
]
1615

components/manager/scripts/sanity/sanity.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _upload_app_blueprint(app_tar):
4444
app_data = f.read()
4545
length = os.path.getsize(app_tar)
4646

47-
headers = utils.create_maintenance_headers()
47+
headers = {}
4848
headers['Content-Length'] = length
4949
headers['Content-Type'] = 'application/octet-stream'
5050
params = urllib.urlencode(
@@ -53,7 +53,7 @@ def _upload_app_blueprint(app_tar):
5353

5454
endpoint = '{0}/blueprints/{1}'.format(_get_url_prefix(), BLUEPRINT_ID)
5555
url = endpoint + '?' + params
56-
utils.http_request(url,
56+
utils.rest_request(url,
5757
data=app_data,
5858
headers=headers)
5959

@@ -69,10 +69,9 @@ def _deploy_app():
6969
'blueprint_id': BLUEPRINT_ID,
7070
'inputs': dep_inputs
7171
}
72-
headers = utils.create_maintenance_headers()
73-
headers.update({'content-type': 'application/json'})
72+
headers = {'content-type': 'application/json'}
7473

75-
utils.http_request(
74+
utils.rest_request(
7675
'{0}/deployments/{1}'.format(_get_url_prefix(), DEPLOYMENT_ID),
7776
data=json.dumps(data),
7877
headers=headers)
@@ -92,10 +91,9 @@ def _install_sanity_app():
9291
'deployment_id': DEPLOYMENT_ID,
9392
'workflow_id': 'install'
9493
}
95-
headers = utils.create_maintenance_headers()
96-
headers.update({'content-type': 'application/json'})
94+
headers = {'content-type': 'application/json'}
9795

98-
resp = utils.http_request(
96+
resp = utils.rest_request(
9997
'{0}/executions'.format(_get_url_prefix()),
10098
method='POST',
10199
data=json.dumps(data),
@@ -112,27 +110,26 @@ def _install_sanity_app():
112110
timeout_msg='Timed out while waiting for '
113111
'deployment {0} to install'.format(DEPLOYMENT_ID))
114112

115-
resp_content = resp.readlines()
116-
json_resp = json.loads(resp_content[0])
113+
json_resp = json.loads(resp.content)
117114
return json_resp['id']
118115

119116

120117
def _assert_logs_and_events(execution_id):
121-
headers = utils.create_maintenance_headers()
122118
params = urllib.urlencode(
123119
dict(execution_id=execution_id,
124120
type='cloudify_log'))
125121

126122
endpoint = '{0}/events'.format(_get_url_prefix())
127123
url = endpoint + '?' + params
128-
resp = utils.http_request(url, method='GET', headers=headers, timeout=30)
124+
resp = utils.rest_request(url,
125+
method='GET',
126+
timeout=30)
129127
if not resp:
130128
ctx.abort_operation("Can't connect to elasticsearch")
131129
if resp.code != 200:
132130
ctx.abort_operation('Failed to retrieve logs/events')
133131

134-
resp_content = resp.readlines()
135-
json_resp = json.loads(resp_content[0])
132+
json_resp = json.loads(resp.content)
136133

137134
if 'items' not in json_resp or not json_resp['items']:
138135
ctx.abort_operation('No logs/events received')
@@ -165,10 +162,9 @@ def _uninstall_sanity_app():
165162
'deployment_id': DEPLOYMENT_ID,
166163
'workflow_id': 'uninstall'
167164
}
168-
headers = utils.create_maintenance_headers()
169-
headers.update({'content-type': 'application/json'})
165+
headers = {'content-type': 'application/json'}
170166

171-
utils.http_request(
167+
utils.rest_request(
172168
'{0}/executions'.format(_get_url_prefix()),
173169
method='POST',
174170
data=json.dumps(data),
@@ -189,12 +185,10 @@ def _uninstall_sanity_app():
189185
def _delete_sanity_deployment():
190186
if not _is_sanity_dep_exist():
191187
return
192-
headers = utils.create_maintenance_headers()
193188

194-
resp = utils.http_request(
189+
resp = utils.rest_request(
195190
'{0}/deployments/{1}'.format(_get_url_prefix(), DEPLOYMENT_ID),
196-
method='DELETE',
197-
headers=headers)
191+
method='DELETE')
198192

199193
if resp.code != 200:
200194
ctx.abort_operation('Failed deleting '
@@ -205,11 +199,9 @@ def _delete_sanity_deployment():
205199
def _delete_sanity_blueprint():
206200
if not _is_sanity_blueprint_exist():
207201
return
208-
headers = utils.create_maintenance_headers()
209-
resp = utils.http_request(
202+
resp = utils.rest_request(
210203
'{0}/blueprints/{1}'.format(_get_url_prefix(), BLUEPRINT_ID),
211-
method='DELETE',
212-
headers=headers)
204+
method='DELETE')
213205

214206
if resp.code != 200:
215207
ctx.abort_operation('Failed deleting '
@@ -223,23 +215,19 @@ def _delete_key_file():
223215

224216

225217
def _is_sanity_dep_exist(should_fail=False):
226-
headers = utils.create_maintenance_headers()
227-
res = utils.http_request(
218+
res = utils.rest_request(
228219
'{0}/deployments/{1}'.format(_get_url_prefix(), DEPLOYMENT_ID),
229220
method='GET',
230-
headers=headers,
231221
should_fail=should_fail)
232222
if not res:
233223
return False
234224
return res.code == 200
235225

236226

237227
def _is_sanity_blueprint_exist(should_fail=False):
238-
headers = utils.create_maintenance_headers()
239-
res = utils.http_request(
228+
res = utils.rest_request(
240229
'{0}/blueprints/{1}'.format(_get_url_prefix(), BLUEPRINT_ID),
241230
method='GET',
242-
headers=headers,
243231
should_fail=should_fail)
244232
if not res:
245233
return False
@@ -276,7 +264,15 @@ def perform_sanity():
276264
perform_sanity()
277265

278266
if utils.is_upgrade or utils.is_rollback:
267+
# Restore the snapshot at the end of the workflow.
279268
utils.restore_upgrade_snapshot()
280269

281270
if utils.is_upgrade:
271+
# To keep the upgrade workflow idempotent, this flag is used to figure
272+
# out if the next upgrade should dispose of old rollback data.
282273
utils.set_upgrade_success_in_upgrade_meta()
274+
275+
if utils.is_rollback:
276+
# remove data created by the upgrade process.
277+
utils.remove(utils.UPGRADE_METADATA_FILE)
278+
utils.remove(utils.ES_UPGRADE_DUMP_PATH)

components/nginx/scripts/start.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ def check_response(response):
2525
utils.start_service(NGINX_SERVICE_NAME, append_prefix=False)
2626
utils.systemd.verify_alive(NGINX_SERVICE_NAME, append_prefix=False)
2727

28-
nginx_url = 'http://127.0.0.1/api/v2.1/blueprints'
28+
nginx_url = '127.0.0.1/api/v2.1/blueprints'
2929

30-
if utils.is_upgrade or utils.is_rollback:
31-
headers = utils.create_maintenance_headers()
32-
else:
33-
headers = utils.get_auth_headers(True)
34-
35-
utils.verify_service_http(NGINX_SERVICE_NAME, nginx_url, check_response,
36-
headers=headers)
30+
utils.verify_service_http(NGINX_SERVICE_NAME, nginx_url, check_response)

components/restservice/scripts/start.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22

33
import json
4+
import httplib
45
import urllib2
5-
import urlparse
66
from os.path import join, dirname
77

88
from cloudify import ctx
@@ -23,22 +23,10 @@ def verify_restservice(url):
2323
that also requires the storage backend to be up, so if it works, there's
2424
a good chance everything is configured correctly.
2525
"""
26-
blueprints_url = urlparse.urljoin(url, 'api/v2.1/blueprints')
27-
28-
headers = utils.get_auth_headers(True)
29-
30-
if utils.is_upgrade or utils.is_rollback:
31-
# if we're doing an upgrade, we're in maintenance mode - this request
32-
# is safe to perform in maintenance mode, so let's bypass the check
33-
headers = utils.create_maintenance_headers()
34-
else:
35-
headers = utils.get_auth_headers(True)
36-
37-
req = urllib2.Request(blueprints_url, headers=headers)
38-
26+
blueprints_url = '{0}/{1}'.format(url, 'api/v2.1/blueprints')
3927
try:
40-
response = urllib2.urlopen(req)
41-
except urllib2.URLError as e:
28+
response = utils.rest_request(blueprints_url)
29+
except (urllib2.URLError, httplib.HTTPException) as e:
4230
ctx.abort_operation('REST service returned an invalid response: {0}'
4331
.format(e))
4432
if response.code == 401:
@@ -50,7 +38,7 @@ def verify_restservice(url):
5038
.format(response.code))
5139

5240
try:
53-
json.load(response)
41+
json.loads(response.content)
5442
except ValueError as e:
5543
ctx.abort_operation('REST service returned malformed JSON: {0}'
5644
.format(e))
@@ -61,6 +49,6 @@ def verify_restservice(url):
6149

6250
utils.systemd.verify_alive(REST_SERVICE_NAME)
6351

64-
restservice_url = 'http://{0}:{1}'.format('127.0.0.1', 8100)
52+
restservice_url = '127.0.0.1'
6553
utils.verify_service_http(REST_SERVICE_NAME, restservice_url)
6654
verify_restservice(restservice_url)

0 commit comments

Comments
 (0)