Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
e04c7358
Commit
e04c7358
authored
Aug 02, 2013
by
Dionysis Grigoropoulos
Committed by
Christos Stavrakakis
Aug 20, 2013
Browse files
snf-deploy: Add option (--disable-colors) to disable color printing in terminal
parent
ec5cfab4
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-deploy/fabfile.py
View file @
e04c7358
...
...
@@ -22,6 +22,7 @@ def setup_env(confdir="conf", packages="packages",
print
(
" * Using %s and %s for packages and templates accordingly..."
%
(
packages
,
templates
))
autoconf
=
ast
.
literal_eval
(
autoconf
)
disable_colors
=
ast
.
literal_eval
(
disable_colors
)
conf
=
Conf
.
configure
(
confdir
=
confdir
,
cluster_name
=
cluster_name
,
autoconf
=
autoconf
)
env
.
env
=
Env
(
conf
)
...
...
@@ -30,6 +31,9 @@ def setup_env(confdir="conf", packages="packages",
env
.
user
=
env
.
env
.
user
env
.
shell
=
"/bin/bash -c"
if
disable_colors
:
disable_color
()
if
env
.
env
.
cms
.
hostname
in
[
env
.
env
.
accounts
.
hostname
,
env
.
env
.
cyclades
.
hostname
,
env
.
env
.
pithos
.
hostname
]:
env
.
cms_pass
=
True
else
:
...
...
snf-deploy/snfdeploy/__init__.py
View file @
e04c7358
...
...
@@ -254,8 +254,10 @@ def fabcommand(args, env, actions, nodes=[]):
fabcmd
=
"fab "
fabcmd
+=
" --fabfile {4}/fabfile.py
\
setup_env:confdir={0},packages={1},templates={2},cluster_name={3},autoconf={5}
\
"
.
format
(
args
.
confdir
,
env
.
packages
,
env
.
templates
,
args
.
cluster_name
,
env
.
lib
,
args
.
autoconf
)
setup_env:confdir={0},packages={1},templates={2},cluster_name={3},
\
autoconf={5}, disable_colors={6}
\
"
.
format
(
args
.
confdir
,
env
.
packages
,
env
.
templates
,
args
.
cluster_name
,
env
.
lib
,
args
.
autoconf
,
args
.
disable_colors
)
if
nodes
:
hosts
=
[
env
.
nodes_info
[
n
].
hostname
for
n
in
nodes
]
...
...
@@ -400,8 +402,13 @@ def parse_options():
parser
.
add_argument
(
"actions"
,
type
=
str
,
nargs
=
"*"
,
help
=
"Run one or more of the supported subcommands"
)
# disable colors in terminal
parser
.
add_argument
(
"--disable-colors"
,
dest
=
"disable_colors"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Disable colors in terminal"
)
return
parser
.
parse_args
()
def
get_actions
(
*
args
):
actions
=
{
# prepare actions
...
...
snf-deploy/snfdeploy/lib.py
View file @
e04c7358
...
...
@@ -16,6 +16,25 @@ import tempfile
from
snfdeploy
import
massedit
HEADER
=
'
\033
[95m'
OKBLUE
=
'
\033
[94m'
OKGREEN
=
'
\033
[92m'
WARNING
=
'
\033
[93m'
FAIL
=
'
\033
[91m'
ENDC
=
'
\033
[0m'
def
disable_color
():
HEADER
=
''
OKBLUE
=
''
OKGREEN
=
''
WARNING
=
''
FAIL
=
''
ENDC
=
''
if
not
sys
.
stdout
.
isatty
():
disable_color
()
class
Host
(
object
):
def
__init__
(
self
,
hostname
,
ip
,
mac
,
domain
):
...
...
@@ -164,27 +183,10 @@ class Conf(object):
self
.
nodes
.
set
(
"info"
,
"public_iface"
,
get_default_route
()[
1
])
class
bcolors
:
HEADER
=
'
\033
[95m'
OKBLUE
=
'
\033
[94m'
OKGREEN
=
'
\033
[92m'
WARNING
=
'
\033
[93m'
FAIL
=
'
\033
[91m'
ENDC
=
'
\033
[0m'
def
disable
(
self
):
self
.
HEADER
=
''
self
.
OKBLUE
=
''
self
.
OKGREEN
=
''
self
.
WARNING
=
''
self
.
FAIL
=
''
self
.
ENDC
=
''
def
debug
(
host
,
msg
):
print
bcolors
.
HEADER
+
host
+
\
bcolors
.
OKBLUE
+
": "
+
msg
+
bcolors
.
ENDC
print
HEADER
+
host
+
\
OKBLUE
+
": "
+
msg
+
ENDC
def
check_pidfile
(
pidfile
):
...
...
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