Commit 26b7efd8 authored by Spiros Koulouzis's avatar Spiros Koulouzis

deployer works with playbooks. Missing the k8s dashboard

parent 6ce96ef2
......@@ -6,9 +6,9 @@ wheel==0.34.2
pyyaml==5.3.1
matplotlib==3.2.1
# ansible==2.9.6
certifi==2019.11.28
certifi==2020.4.5.1
six==1.14.0
python_dateutil==2.8.1
setuptools==46.0.0
setuptools==46.1.3
urllib3==1.25.8
......@@ -54,6 +54,9 @@ class AnsibleService:
playbook_names = inputs['playbooks']
for playbook_name in playbook_names:
task_id = self.run_task(name, project_id, key_id, git_url, inventory_id, playbook_name)
if self.semaphore_helper.get_task(project_id, task_id).status != 'success':
break
if self.semaphore_helper.get_task(project_id,task_id).status == 'success':
configure = standard['configure']
inputs = configure['inputs']
......@@ -61,6 +64,8 @@ class AnsibleService:
playbook_names = inputs['playbooks']
for playbook_name in playbook_names:
task_id = self.run_task(name, project_id, key_id, git_url, inventory_id, playbook_name)
if self.semaphore_helper.get_task(project_id, task_id).status != 'success':
break
def build_yml_inventory(self, vms):
# loader = DataLoader()
......@@ -94,19 +99,24 @@ class AnsibleService:
return base64.b64decode(private_key).decode('utf-8').replace(r'\n', '\n')
def run_task(self, name, project_id, key_id, git_url, inventory_id, playbook_name):
logger.info('task name: ' + str(name)+ ' git url: '+git_url+' playbook: '+playbook_name)
logger.info('project_id: '+str(project_id)+ ' task name: ' + str(name)+ ' git url: '+git_url+' playbook: '+playbook_name)
if not self.repository_id:
self.repository_id = self.semaphore_helper.create_repository(name, project_id, key_id, git_url)
template_id = self.semaphore_helper.create_template(project_id, key_id, inventory_id, self.repository_id,
playbook_name)
#
# task_id = self.semaphore_helper.execute_task(project_id, template_id, playbook_name)
# task = self.semaphore_helper.get_task(project_id, task_id)
# while task.status == 'waiting' or task.status == 'running':
# task = self.semaphore_helper.get_task(project_id, task_id)
# logger.info('task status: ' + str(task.status))
# task_outputs = self.semaphore_helper.get_task_outputs(project_id, task_id)
# sleep(1.5)
# task_outputs = self.semaphore_helper.get_task_outputs(project_id, task_id)
# # logger.info('task_output: ' + str(task_outputs))
return None #task_id
task_id = self.semaphore_helper.execute_task(project_id, template_id, playbook_name)
task = self.semaphore_helper.get_task(project_id, task_id)
last_output = ''
while task.status == 'waiting' or task.status == 'running':
task = self.semaphore_helper.get_task(project_id, task_id)
logger.info('task name: '+name+ ' task status: ' + str(task.status))
task_outputs = self.semaphore_helper.get_task_outputs(project_id, task_id)
this_output = task_outputs[len(task_outputs)-1].output.replace(r'\n', '\n').replace(r'\r', '\r')
if last_output != this_output:
logger.info('task output: ' + str(this_output))
last_output = this_output
# logger.info('task output: ' + str(latask name:st_output))
sleep(3)
return task_id
......@@ -8,6 +8,7 @@ import time
import yaml
import re # noqa: F401
from pathlib import Path
import unittest
import sure_tosca_client
......@@ -33,13 +34,15 @@ class TestDeployer(unittest.TestCase):
def test(self):
logger = logging.getLogger(__name__)
tosca_path = "../../example_messages/"
input_tosca_file_path = tosca_path + '/message_deploy_request.json'
if not os.path.exists(input_tosca_file_path):
tosca_path = "../example_messages/"
input_tosca_file_path = tosca_path + '/message_deploy_request.json'
message_file_path = str(Path.home()) + '/Downloads/message_deploy_request.json'
# example_messages_path = "../../example_messages/"
# message_file_path = example_messages_path + '/message_deploy_request.json'
# if not os.path.exists(message_file_path):
# example_messages_path = "../example_messages/"
# message_file_path = example_messages_path + '/message_deploy_request.json'
with open(input_tosca_file_path, 'r') as stream:
with open(message_file_path, 'r') as stream:
parsed_json_message = json.load(stream)
# owner = parsed_json_message['owner']
......
......@@ -56,18 +56,18 @@ services:
- "27017:27017"
#manager:
#depends_on:
#- rabbit
#- mongo
#- sure-tosca
#image: manager:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
#MONGO_HOST: mongo
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#ports:
#- "30000:8080"
manager:
depends_on:
- rabbit
- mongo
- sure-tosca
image: manager:3.0.0
environment:
RABBITMQ_HOST: rabbit
MONGO_HOST: mongo
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
ports:
- "30000:8080"
sure-tosca:
image: sure-tosca:3.0.0
......@@ -82,14 +82,14 @@ services:
environment:
RABBITMQ_HOST: rabbit
#provisioner:
#depends_on:
#- rabbit
#- sure-tosca
#image: provisioner:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
provisioner:
depends_on:
- rabbit
- sure-tosca
image: provisioner:3.0.0
environment:
RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#deployer:
#depends_on:
......
......@@ -235,6 +235,26 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 4
MEM: 12
VMType: "XOXLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 2
MEM: 6
VMType: "XOLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 50
- domain: "RENCI (Chapel Hill, NC USA) XO Rack"
endpoint: "rcivmsite.rdf#rcivmsite"
country: USA
......@@ -284,6 +304,26 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 4
MEM: 12
VMType: "XOXLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 2
MEM: 6
VMType: "XOLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 50
- domain: "FIU (Miami, FL USA) XO Rack"
endpoint: "fiuvmsite.rdf#fiuvmsite"
country: USA
......@@ -333,6 +373,26 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 4
MEM: 12
VMType: "XOXLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75
- OS: "Ubuntu 18.04"
CPU: 2
MEM: 6
VMType: "XOLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 50
- domain: "UH (Houston, TX USA) XO Rack"
endpoint: "uhvmsite.rdf#uhvmsite"
country: USA
......
......@@ -78,7 +78,7 @@ class SemaphoreHelper:
repository_id=repository_id, alias=playbook_name, playbook=playbook_name)
self.project_api.project_project_id_templates_post(template_request , project_id )
templates = self.project_api.project_project_id_templates_get(project_id, playbook_name, 'asc')
return templates[0].id
return self.find_template(templates,playbook_name).id
def execute_task(self, project_id, template_id, playbook_name):
task = Task(template_id=template_id, playbook=playbook_name)
......@@ -118,3 +118,8 @@ class SemaphoreHelper:
def find_latest_task(self, tasks):
return tasks[0]
def find_template(self, templates,playbook_name):
for template in templates:
if template.playbook == playbook_name:
return template
\ No newline at end of file
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