Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
26b7efd8
Commit
26b7efd8
authored
Apr 10, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deployer works with playbooks. Missing the k8s dashboard
parent
6ce96ef2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
43 deletions
+121
-43
requirements.txt
deployer/requirements.txt
+2
-2
ansible_service.py
deployer/service/ansible_service.py
+23
-13
test_deployer.py
deployer/test/test_deployer.py
+9
-6
docker-compose.yml
docker-compose.yml
+20
-20
ExoGENI.yml
provisioner/etc/UD/ExoGENI.yml
+60
-0
semaphore_helper.py
...hon-client-generated/semaphore_client/semaphore_helper.py
+7
-2
No files found.
deployer/requirements.txt
View file @
26b7efd8
...
...
@@ -6,9 +6,9 @@ wheel==0.34.2
pyyaml==5.3.1
matplotlib==3.2.1
# ansible==2.9.6
certifi==20
19.11.28
certifi==20
20.4.5.1
six==1.14.0
python_dateutil==2.8.1
setuptools==46.
0.0
setuptools==46.
1.3
urllib3==1.25.8
deployer/service/ansible_service.py
View file @
26b7efd8
...
...
@@ -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
)
self
.
repository_id
=
self
.
semaphore_helper
.
create_repository
(
name
,
project_id
,
key_id
,
git_url
)
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
deployer/test/test_deployer.py
View file @
26b7efd8
...
...
@@ -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']
...
...
docker-compose.yml
View file @
26b7efd8
...
...
@@ -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:
...
...
provisioner/etc/UD/ExoGENI.yml
View file @
26b7efd8
...
...
@@ -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
...
...
semaphore-python-client-generated/semaphore_client/semaphore_helper.py
View file @
26b7efd8
...
...
@@ -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
)
...
...
@@ -117,4 +117,9 @@ class SemaphoreHelper:
return
latest_project
def
find_latest_task
(
self
,
tasks
):
return
tasks
[
0
]
\ No newline at end of file
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment