Commit 65aa14d8 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added docker attributes

parent 41a9f95c
......@@ -34,6 +34,11 @@ node_types:
capability: tosca.capabilities.ARTICONF.docker.Orchestrator
node: tosca.nodes.ARTICONF.docker.Orchestrator
relationship: tosca.relationships.HostedOn
attributes:
service_url:
type: string
required: false
description: url of the service
tosca.nodes.ARTICONF.docker.Orchestrator:
derived_from: tosca.nodes.ARTICONF.Root
......
......@@ -97,12 +97,11 @@ def handle_delivery(message):
ansible_playbook_path = k8s_service.write_ansible_k8s_files(tosca_template_dict, tmp_path)
out, err = ansible_service.run(inventory_path, ansible_playbook_path)
dashboard_token = ansible_service.parse_dashboard_tokens(out.decode("utf-8"))
tokens['dashboard_token'] = dashboard_token
tosca_template_dict = tosca.add_tokens(tokens, tosca_template_dict)
tosca_template_dict = tosca.add_dashboard_url(k8s_service.get_dashboard_url(vms), tosca_template_dict)
tosca_template_dict = tosca.add_service_url(k8s_service.get_service_urls(vms,tosca_template_dict), tosca_template_dict)
response = {'toscaTemplate': tosca_template_dict}
output_current_milli_time = int(round(time.time() * 1000))
......
......@@ -222,3 +222,21 @@ def get_dashboard_url(vms):
k8_master = attributes['public_ip']
url = 'https://' + k8_master + ':' + str(dashboard_port)
return url
def get_service_urls(vms, tosca_template_json):
dockers = get_dockers(tosca_template_json)
for vm_name in vms:
attributes = vms[vm_name]['attributes']
role = attributes['role']
if role == 'master':
k8_master = attributes['public_ip']
break
urls = {}
for docker in dockers:
docker_name = next(iter(docker))
docker_ports = docker[docker_name]['properties']['ports'][0].split(':')
node_port = int(docker_ports[0])
url = 'https://' + k8_master + ':' + str(node_port)
urls[docker_name] = url
return urls
......@@ -45,3 +45,14 @@ def add_dashboard_url(dashboard_url, tosca_template_dict):
attributes = node_templates[node_name]['attributes']
attributes['dashboard_url'] = dashboard_url
return tosca_template_dict
def add_service_url(serviceurls_url, tosca_template_dict):
node_templates = tosca_template_dict['topology_template']['node_templates']
for node_name in node_templates:
if node_templates[node_name]['type'] == '"tosca.nodes.ARTICONF.Container.Application.Docker':
if 'attributes' not in node_templates[node_name]:
node_templates[node_name]['attributes'] = {}
attributes = node_templates[node_name]['attributes']
attributes['service_url'] = serviceurls_url[node_name]
return tosca_template_dict
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment