Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
75ff941e
authored
Jul 22, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update fabfile
parent
8cdbd55d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
circle/fabfile.py
+27
-13
No files found.
circle/fabfile.py
View file @
75ff941e
import
contextlib
import
contextlib
import
datetime
import
datetime
from
fabric.api
import
env
,
run
,
settings
,
sudo
,
prefix
,
cd
from
fabric.api
import
env
,
run
,
settings
,
sudo
,
prefix
,
cd
,
execute
from
fabric.decorators
import
roles
from
fabric.decorators
import
roles
,
parallel
from
vm.models
import
Node
from
vm.models
import
Node
from
storage.models
import
DataStore
from
storage.models
import
DataStore
def
get_hosts
():
env
.
roledefs
[
'portal'
]
=
[
'localhost'
]
env
.
roledefs
[
'portal'
]
=
[
'localhost'
]
env
.
roledefs
[
'node'
]
=
[
unicode
(
n
.
host
.
ipv4
)
env
.
roledefs
[
'nodes'
]
=
[
unicode
(
n
.
host
.
ipv4
)
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)]
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)]
env
.
roledefs
[
'storage'
]
=
[
DataStore
.
objects
.
get
()
.
hostname
]
env
.
roledefs
[
'storage'
]
=
[
DataStore
.
objects
.
get
()
.
hostname
]
print
env
.
roledefs
def
update_all
():
def
update_all
():
update_node
()
execute
(
stop_portal
)
update_portal
()
execute
(
update_node
)
execute
(
update_portal
)
@roles
(
'portal'
)
@roles
(
'portal'
)
...
@@ -94,12 +92,28 @@ def update_portal(test=False):
...
@@ -94,12 +92,28 @@ def update_portal(test=False):
test
()
test
()
@roles
(
'portal'
)
def
stop_portal
(
test
=
False
):
_stop_services
(
"portal"
,
"mancelery"
)
@parallel
@roles
(
'node'
)
@roles
(
'node'
)
def
update_node
():
def
update_node
():
"Update and restart nodes"
"Update and restart nodes"
with
_stopped
(
"node"
,
"agent"
):
with
_stopped
(
"node"
,
"agent"
):
pull
(
"~/circle/vmdriver"
)
pull
(
"~/vmdriver"
)
pull
(
"~/circle/agentdriver"
)
pull
(
"~/agentdriver"
)
@parallel
@roles
(
'node'
)
def
checkout
(
vmdriver
=
"master"
,
agent
=
"master"
):
"""Checkout specific branch on nodes"""
with
settings
(
warn_only
=
True
),
cd
(
"~/vmdriver"
):
run
(
"git checkout
%
s"
%
vmdriver
)
with
settings
(
warn_only
=
True
),
cd
(
"~/agentdriver"
):
run
(
"git checkout
%
s"
%
agent
)
def
_stop_services
(
*
services
):
def
_stop_services
(
*
services
):
...
@@ -122,7 +136,7 @@ def _restart_service(*services):
...
@@ -122,7 +136,7 @@ def _restart_service(*services):
@contextlib.contextmanager
@contextlib.contextmanager
def
_stopped
(
*
services
):
def
_stopped
(
*
services
):
_stop_services
(
True
,
*
services
)
_stop_services
(
*
services
)
yield
yield
_start_services
(
*
services
)
_start_services
(
*
services
)
...
...
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