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
6b4ca7a3
Commit
6b4ca7a3
authored
Mar 06, 2017
by
Oceans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
control agent
parent
00a13b34
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
2 deletions
+82
-2
vcs.xml
.idea/vcs.xml
+6
-0
control_agent.py
drip-deployer/control_agent.py
+58
-0
control_agent.sh
drip-deployer/control_agent.sh
+11
-0
docker_engine.sh
drip-deployer/docker_engine.sh
+2
-1
rpc_server.py
drip-deployer/rpc_server.py
+5
-1
No files found.
.idea/vcs.xml
0 → 100644
View file @
6b4ca7a3
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
drip-deployer/control_agent.py
0 → 100644
View file @
6b4ca7a3
#! /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
def
install_agent
(
vm
,
vm_list
):
try
:
print
"
%
s: ====== Start Control Agent Installation ======"
%
(
vm
.
ip
)
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/'
)
vm_cnt
=
0
file_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
fo
=
open
(
file_path
+
"/cluster_file"
,
"w"
)
for
i
in
vm_list
:
vm_cnt
+=
1
sftp
.
put
(
i
.
key
,
"
%
d"
%
(
vm_cnt
))
fo
.
write
(
"
%
s
%
s /tmp/
%
d
%
s
\n
"
%
(
i
.
ip
,
i
.
user
,
vm_cnt
,
i
.
role
))
fo
.
close
()
sftp
.
put
(
file_path
+
"/cluster_file"
,
"cluster_file"
)
sftp
.
put
(
file_path
+
"/control_agent.sh"
,
"control_agent.sh"
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo sh /tmp/control_agent.sh"
)
stdout
.
read
()
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"nohup python /root/Swarm-Agent/run.py>/dev/null 2>&1 &"
)
stdout
.
read
()
print
"
%
s: ========= Control Agent Installed ========="
%
(
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
):
for
i
in
vm_list
:
if
i
.
role
==
"master"
:
ret
=
install_agent
(
i
,
vm_list
)
if
"ERROR"
in
ret
:
return
ret
return
"SUCCESS"
\ No newline at end of file
drip-deployer/control_agent.sh
0 → 100644
View file @
6b4ca7a3
#! /bin/bash
sudo
apt-get update
sudo
apt-get
-y
install
git
sudo
apt-get
-y
install
wget
sudo
apt-get
-y
install
build-essential libssl-dev libffi-dev python-dev
cd
/root/
sudo
wget https://bootstrap.pypa.io/get-pip.py
sudo
python get-pip.py
sudo
pip
install
flask
sudo
pip
install
paramiko
sudo
git clone https://github.com/oceanshy/Swarm-Agent.git
drip-deployer/docker_engine.sh
View file @
6b4ca7a3
#! /bin/bash
#! /bin/bash
sudo
apt-get remove docker docker-engine
sudo
apt-get update
sudo
apt-get update
sudo
apt-get
-y
install
linux-image-extra-
$(
uname
-r
)
linux-image-extra-virtual
sudo
apt-get
-y
install
linux-image-extra-
$(
uname
-r
)
linux-image-extra-virtual
sudo
apt-get
-y
install
apt-transport-https ca-certificates curl software-properties-common
sudo
apt-get
-y
install
apt-transport-https ca-certificates curl software-properties-common
...
@@ -8,3 +7,5 @@ sudo apt-key fingerprint 0EBFCD88
...
@@ -8,3 +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
add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(
lsb_release
-cs
)
stable"
sudo
apt-get update
sudo
apt-get update
sudo
apt-get
-y
install
docker-ce
sudo
apt-get
-y
install
docker-ce
sudo echo
"DOCKER_OPTS="
--insecure-registry
=
145.100.133.241:5000
""
>>
/etc/default/docker
sudo
service docker restart
drip-deployer/rpc_server.py
View file @
6b4ca7a3
...
@@ -8,6 +8,8 @@ from vm_info import VmInfo
...
@@ -8,6 +8,8 @@ from vm_info import VmInfo
import
docker_kubernetes
import
docker_kubernetes
import
docker_engine
import
docker_engine
import
docker_swarm
import
docker_swarm
import
control_agent
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'172.17.0.3'
))
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'172.17.0.3'
))
channel
=
connection
.
channel
()
channel
=
connection
.
channel
()
...
@@ -44,10 +46,12 @@ def handleDelivery(message):
...
@@ -44,10 +46,12 @@ def handleDelivery(message):
ret
=
docker_engine
.
run
(
vm_list
)
ret
=
docker_engine
.
run
(
vm_list
)
if
"ERROR"
in
ret
:
return
ret
if
"ERROR"
in
ret
:
return
ret
ret
=
docker_swarm
.
run
(
vm_list
)
ret
=
docker_swarm
.
run
(
vm_list
)
if
"ERROR"
in
ret
:
return
ret
ret1
=
control_agent
.
run
(
vm_list
)
if
"ERROR"
in
ret1
:
ret
=
ret1
return
ret
return
ret
else
:
else
:
return
"ERROR: invalid cluster"
return
"ERROR: invalid cluster"
def
on_request
(
ch
,
method
,
props
,
body
):
def
on_request
(
ch
,
method
,
props
,
body
):
...
...
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