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
0c872925
Commit
0c872925
authored
Jul 11, 2017
by
Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add service scale
parent
21622555
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
docker_service.py
drip-deployer/docker_service.py
+52
-0
rpc_server.py
drip-deployer/rpc_server.py
+6
-0
No files found.
drip-deployer/docker_service.py
0 → 100644
View file @
0c872925
#! /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
scale_service
(
vm
,
application_name
,
service_name
,
service_num
):
try
:
print
"
%
s: ====== Start Docker Service Scaling ======"
%
(
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 service scale
%
s_
%
s=
%
s"
%
(
application_name
,
service_name
,
service_num
))
stdout
.
read
()
print
"
%
s: ======= Service Scaling 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
,
application_name
,
service_name
,
service_num
):
for
i
in
vm_list
:
if
i
.
role
==
"master"
:
ret
=
scale_service
(
i
,
application_name
,
service_name
,
service_num
)
if
"ERROR"
in
ret
:
return
ret
break
return
ret
\ No newline at end of file
drip-deployer/rpc_server.py
View file @
0c872925
...
...
@@ -9,6 +9,7 @@ import docker_kubernetes
import
docker_engine
import
docker_swarm
import
docker_compose
import
docker_service
import
control_agent
import
ansible_playbook
import
sys
,
argparse
...
...
@@ -104,6 +105,9 @@ def handleDelivery(message):
elif
manager_type
==
"ansible"
:
ret
=
ansible_playbook
.
run
(
vm_list
,
playbook
)
return
ret
elif
manager_type
==
"scale"
:
ret
=
docker_service
.
run
(
vm_list
,
name_of_deployment
,
name_of_service
,
number_of_containers
)
return
ret
else
:
return
"ERROR: invalid cluster"
...
...
@@ -125,6 +129,8 @@ def on_request(ch, method, props, body):
res_name
=
"error"
elif
manager_type
==
"ansible"
:
res_name
=
"ansible_output"
elif
manager_type
==
"scale"
:
res_name
=
"status"
else
:
res_name
=
"credential"
...
...
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