-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker_deployment.py
More file actions
31 lines (23 loc) · 1.32 KB
/
docker_deployment.py
File metadata and controls
31 lines (23 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import cloudshell.helpers.scripts.cloudshell_scripts_helpers as helpers
from cloudshell.api.cloudshell_api import *
import os
import json
reservation_id = helpers.get_reservation_context_details().id
service_details = helpers.get_resource_context_details()
dict = helpers.get_resource_context_details_dict()
docker_host = service_details.attributes['Docker Host']
image = service_details.attributes['Docker Image']
environment = service_details.attributes['Container Env']
ports = service_details.attributes['Container Ports']
api = helpers.get_api_session()
api.WriteMessageToReservationOutput(reservation_id,"Deploying App..." )
result = api.ExecuteCommand(reservationId=reservation_id, targetName=docker_host, targetType="Resource",
commandName="deploy_image",
commandInputs=[InputNameValue("app_name",dict["appData"]["name"]),
InputNameValue("image", image),InputNameValue("env", environment),
InputNameValue("port_config", ports)])
api.WriteMessageToReservationOutput(reservation_id,"Deploy done:" + result.Output)
if hasattr(result, "Output"):
print 'command_json_result=%s=command_json_result_end' % result.Output
else:
print 'command_json_result=%s=command_json_result_end' % result