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
70ef3781
Commit
70ef3781
authored
Jul 06, 2017
by
skoulouzis
Committed by
GitHub
Jul 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into drip_1.0
parents
fbef3be4
45479297
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
7 deletions
+84
-7
docker_compose.py
drip-deployer/docker_compose.py
+59
-0
docker_engine.py
drip-deployer/docker_engine.py
+6
-0
docker_engine.sh
drip-deployer/docker_engine.sh
+2
-2
docker_swarm.py
drip-deployer/docker_swarm.py
+12
-0
rpc_server.py
drip-deployer/rpc_server.py
+5
-5
No files found.
drip-deployer/docker_compose.py
0 → 100644
View file @
70ef3781
#! /usr/bin/env python
# Copyright 2017 --Yang Hu--
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__
=
'Yang Hu'
import
paramiko
,
os
from
vm_info
import
VmInfo
def
deploy_compose
(
vm
,
compose_file
,
compose_name
):
try
:
print
"
%
s: ====== Start Docker Compose Deploying ======"
%
(
vm
.
ip
)
paramiko
.
util
.
log_to_file
(
"deployment.log"
)
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
vm
.
ip
,
username
=
vm
.
user
,
key_filename
=
vm
.
key
)
sftp
=
ssh
.
open_sftp
()
sftp
.
chdir
(
'/tmp/'
)
sftp
.
put
(
compose_file
,
"docker-compose.yml"
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker stack deploy --compose-file /tmp/docker-compose.yml
%
s"
%
(
compose_name
))
stdout
.
read
()
print
"
%
s: ======= Deployment of Compose Finished ========="
%
(
vm
.
ip
)
except
Exception
as
e
:
print
'
%
s:
%
s'
%
(
vm
.
ip
,
e
)
return
"ERROR:"
+
vm
.
ip
+
" "
+
str
(
e
)
ssh
.
close
()
return
"SUCCESS"
def
run
(
vm_list
,
compose_file
,
compose_name
):
for
i
in
vm_list
:
if
i
.
role
==
"master"
:
ret
=
deploy_compose
(
i
,
compose_file
,
compose_name
)
if
"ERROR"
in
ret
:
return
ret
else
:
swarm_file
=
open
(
i
.
key
)
ret
=
swarm_file
.
read
()
swarm_file
.
close
()
break
return
ret
\ No newline at end of file
drip-deployer/docker_engine.py
View file @
70ef3781
...
...
@@ -22,9 +22,15 @@ import threading
def
install_engine
(
vm
):
try
:
print
"
%
s: ====== Start Docker Engine Installing ======"
%
(
vm
.
ip
)
paramiko
.
util
.
log_to_file
(
"deployment.log"
)
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
vm
.
ip
,
username
=
vm
.
user
,
key_filename
=
vm
.
key
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo dpkg --get-selections | grep docker"
)
temp_list
=
stdout
.
readlines
()
temp_str
=
""
for
i
in
temp_list
:
temp_str
+=
i
if
temp_str
.
find
(
"docker"
)
!=
-
1
:
return
"SUCCESS"
sftp
=
ssh
.
open_sftp
()
sftp
.
chdir
(
'/tmp/'
)
file_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
...
...
drip-deployer/docker_engine.sh
View file @
70ef3781
...
...
@@ -7,5 +7,5 @@ sudo apt-key fingerprint 0EBFCD88
sudo
add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(
lsb_release
-cs
)
stable"
sudo
apt-get update
sudo
apt-get
-y
install
docker-ce
sudo echo
"{
\"
insecure-registries
\"
:[
\"
129.7.98.3:5000
\"
] }"
>
/etc/docker/daemon.json
sudo
service docker restart
#
sudo echo "{ \"insecure-registries\":[\"129.7.98.3:5000\"] }" > /etc/docker/daemon.json
#
sudo service docker restart
drip-deployer/docker_swarm.py
View file @
70ef3781
...
...
@@ -22,9 +22,15 @@ from vm_info import VmInfo
def
install_manager
(
vm
):
try
:
print
"
%
s: ====== Start Swarm Manager Installing ======"
%
(
vm
.
ip
)
paramiko
.
util
.
log_to_file
(
"deployment.log"
)
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
vm
.
ip
,
username
=
vm
.
user
,
key_filename
=
vm
.
key
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker info | grep Swarm"
)
temp_list
=
stdout
.
readlines
()
temp_str
=
""
for
i
in
temp_list
:
temp_str
+=
i
if
temp_str
.
find
(
"Swarm: active"
)
!=
-
1
:
return
"SUCCESS"
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker swarm leave --force"
)
stdout
.
read
()
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker swarm init --advertise-addr
%
s"
%
(
vm
.
ip
))
...
...
@@ -39,6 +45,7 @@ def install_manager(vm):
def
install_worker
(
join_cmd
,
vm
):
try
:
print
"
%
s: ====== Start Swarm Worker Installing ======"
%
(
vm
.
ip
)
paramiko
.
util
.
log_to_file
(
"deployment.log"
)
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
vm
.
ip
,
username
=
vm
.
user
,
key_filename
=
vm
.
key
)
...
...
@@ -62,6 +69,11 @@ def run(vm_list):
join_cmd
=
install_manager
(
i
)
if
"ERROR"
in
join_cmd
:
return
join_cmd
elif
"SUCCESS"
in
join_cmd
:
swarm_file
=
open
(
i
.
key
)
swarm_string
=
swarm_file
.
read
()
swarm_file
.
close
()
return
swarm_string
else
:
join_cmd
=
join_cmd
.
encode
()
join_cmd
=
join_cmd
.
replace
(
"
\n
"
,
""
)
...
...
drip-deployer/rpc_server.py
View file @
70ef3781
...
...
@@ -8,6 +8,7 @@ from vm_info import VmInfo
import
docker_kubernetes
import
docker_engine
import
docker_swarm
import
docker_compose
import
control_agent
import
ansible_playbook
import
sys
,
argparse
...
...
@@ -69,8 +70,9 @@ def handleDelivery(message):
fo
.
close
()
elif
name
==
"composer"
:
value
=
param
[
"value"
]
docker_composer
=
path
+
"docker-composer.yml"
fo
=
open
(
docker_composer
,
"w"
)
compose_file
=
path
+
"docker-compose.yml"
compose_name
=
param
[
"attributes"
][
"name"
]
fo
=
open
(
compose_file
,
"w"
)
fo
.
write
(
value
)
fo
.
close
()
...
...
@@ -82,9 +84,7 @@ def handleDelivery(message):
if
"ERROR"
in
ret
:
return
ret
ret
=
docker_swarm
.
run
(
vm_list
)
if
"ERROR"
in
ret
:
return
ret
ret1
=
control_agent
.
run
(
vm_list
)
#deploy_composer.run(vm_list,docker_composer)
if
"ERROR"
in
ret1
:
ret
=
ret1
ret
=
docker_compose
.
run
(
vm_list
,
compose_file
,
compose_name
)
return
ret
elif
manager_type
==
"ansible"
:
ret
=
ansible_playbook
.
run
(
vm_list
,
playbook
)
...
...
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