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