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
90c9dc20
Commit
90c9dc20
authored
Sep 26, 2017
by
Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add service check
parent
0dc5d2c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
docker_check.py
drip-deployer/docker_check.py
+56
-0
rpc_server.py
drip-deployer/rpc_server.py
+4
-0
No files found.
drip-deployer/docker_check.py
0 → 100644
View file @
90c9dc20
#! /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
docker_check
(
vm
,
compose_name
):
try
:
print
"
%
s: ====== Start Check Docker Services ======"
%
(
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
)
retstr
=
"
\n
=========== Cluster Node Information ===============
\n
"
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker node ls"
)
ret
=
stdout
.
readlines
()
for
i
in
ret
:
retstr
+=
i
.
encode
()
retstr
+=
"
\n
============ Services Information ================
\n
"
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"sudo docker stack ps
%
s"
%
(
compose_name
))
ret
=
stdout
.
readlines
()
for
i
in
ret
:
retstr
+=
i
.
encode
()
print
"
%
s: =========== Check Finished =============="
%
(
vm
.
ip
)
except
Exception
as
e
:
print
'
%
s:
%
s'
%
(
vm
.
ip
,
e
)
return
"ERROR:"
+
vm
.
ip
+
" "
+
str
(
e
)
ssh
.
close
()
return
retstr
def
run
(
vm_list
,
compose_name
):
for
i
in
vm_list
:
if
i
.
role
==
"master"
:
ret
=
docker_check
(
i
,
compose_name
)
if
"ERROR:"
in
ret
:
return
ret
return
ret
\ No newline at end of file
drip-deployer/rpc_server.py
View file @
90c9dc20
...
...
@@ -10,6 +10,7 @@ import docker_engine
import
docker_swarm
import
docker_compose
import
docker_service
import
docker_check
import
control_agent
import
ansible_playbook
import
sys
,
argparse
...
...
@@ -112,6 +113,9 @@ def handleDelivery(message):
elif
manager_type
==
"scale"
:
ret
=
docker_service
.
run
(
vm_list
,
name_of_deployment
,
name_of_service
,
number_of_containers
)
return
ret
elif
manager_type
==
"service check"
:
ret
=
docker_check
.
run
(
vm_list
,
compose_name
)
return
ret
else
:
return
"ERROR: invalid cluster"
...
...
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