Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.package
Commits
c19d4b77
Commit
c19d4b77
authored
Mar 28, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typo and spacing
parent
ecefc35a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
slapprepare/slapprepare/slapprepare.py
slapprepare/slapprepare/slapprepare.py
+9
-11
No files found.
slapprepare/slapprepare/slapprepare.py
View file @
c19d4b77
...
@@ -105,13 +105,14 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False):
...
@@ -105,13 +105,14 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False):
raise
ExecError
(
'Process respond:"%s" when calling "%s"'
%
\
raise
ExecError
(
'Process respond:"%s" when calling "%s"'
%
\
(
str
(
e
),
' '
.
join
(
cmd_args
)))
(
str
(
e
),
' '
.
join
(
cmd_args
)))
# Utility fonction to get yes/no answers
# Utility fonction to get yes/no answers
def
get_yes_no
(
prompt
,
default
=
None
):
def
get_yes_no
(
prompt
,
default
=
None
):
if
default
:
if
default
:
def_value
=
'/ Default yes'
def_value
=
'/ Default yes'
elif
default
==
False
:
elif
default
==
False
:
def_value
=
'/ Default no'
def_value
=
'/ Default no'
else
:
else
:
def_value
=
''
def_value
=
''
while
True
:
while
True
:
answer
=
raw_input
(
prompt
+
" [y,n] %s: "
%
def_value
)
answer
=
raw_input
(
prompt
+
" [y,n] %s: "
%
def_value
)
...
@@ -120,6 +121,7 @@ def get_yes_no (prompt,default=None):
...
@@ -120,6 +121,7 @@ def get_yes_no (prompt,default=None):
if
not
default
==
None
:
if
not
default
==
None
:
if
answer
==
''
:
return
default
if
answer
==
''
:
return
default
def
getSlaposConfiguration
(
slapos_configuration_file_path
=
None
):
def
getSlaposConfiguration
(
slapos_configuration_file_path
=
None
):
config
=
ConfigParser
.
RawConfigParser
()
config
=
ConfigParser
.
RawConfigParser
()
# Search slapos.cfg
# Search slapos.cfg
...
@@ -137,6 +139,7 @@ def getSlaposConfiguration(slapos_configuration_file_path=None):
...
@@ -137,6 +139,7 @@ def getSlaposConfiguration(slapos_configuration_file_path=None):
config
.
read
(
slapos_configuration_file_path
)
config
.
read
(
slapos_configuration_file_path
)
return
config
return
config
# Return OpenSUSE version if it is SuSE
# Return OpenSUSE version if it is SuSE
def
suse_version
():
def
suse_version
():
if
os
.
path
.
exists
(
'/etc/SuSE-release'
)
:
if
os
.
path
.
exists
(
'/etc/SuSE-release'
)
:
...
@@ -145,7 +148,7 @@ def suse_version():
...
@@ -145,7 +148,7 @@ def suse_version():
if
"VERSION"
in
line
:
if
"VERSION"
in
line
:
dist
=
line
.
split
()
dist
=
line
.
split
()
return
float
(
dist
[
2
])
return
float
(
dist
[
2
])
else
:
else
:
return
0
return
0
...
@@ -273,7 +276,6 @@ def slapserver(config):
...
@@ -273,7 +276,6 @@ def slapserver(config):
pkg_resources
.
resource_stream
(
__name__
,
pkg_resources
.
resource_stream
(
__name__
,
'template/limits.conf.in'
).
read
())
'template/limits.conf.in'
).
read
())
# Writing ssh key
# Writing ssh key
if
config
.
need_ssh
:
if
config
.
need_ssh
:
user_path
=
os
.
path
.
normpath
(
'/'
.
join
([
mount_dir_path
,
'root'
]))
user_path
=
os
.
path
.
normpath
(
'/'
.
join
([
mount_dir_path
,
'root'
]))
...
@@ -390,8 +392,6 @@ def prepare_scripts (config):
...
@@ -390,8 +392,6 @@ def prepare_scripts (config):
remove_former_scripts
(
slapos_configuration
)
remove_former_scripts
(
slapos_configuration
)
def
configureNtp
():
def
configureNtp
():
"""Configures NTP daemon"""
"""Configures NTP daemon"""
server
=
"server pool.ntp.org"
server
=
"server pool.ntp.org"
...
@@ -457,7 +457,7 @@ class Config:
...
@@ -457,7 +457,7 @@ class Config:
self
.
force_slapcontainer
=
get_yes_no
(
"Do you want to force the use lxc on this computer?"
,
False
)
self
.
force_slapcontainer
=
get_yes_no
(
"Do you want to force the use lxc on this computer?"
,
False
)
if
self
.
force_vpn
:
if
self
.
force_vpn
:
self
.
ipv6_interface
=
"tapVPN"
self
.
ipv6_interface
=
"tapVPN"
else
:
else
:
self
.
ipv6_interface
=
""
self
.
ipv6_interface
=
""
self
.
need_ssh
=
get_yes_no
(
"Do you want a remote ssh access?"
,
True
)
self
.
need_ssh
=
get_yes_no
(
"Do you want a remote ssh access?"
,
True
)
...
@@ -475,17 +475,16 @@ class Config:
...
@@ -475,17 +475,16 @@ class Config:
print
"Use a second disk: %s"
%
(
not
self
.
one_disk
)
print
"Use a second disk: %s"
%
(
not
self
.
one_disk
)
def
prepare_from_scratch
(
config
):
def
prepare_from_scratch
(
config
):
try
:
try
:
temp_directory
=
os
.
path
.
join
(
'/tmp/slaptemp/'
)
temp_directory
=
os
.
path
.
join
(
'/tmp/slaptemp/'
)
if
not
os
.
path
.
exists
(
temp_directory
):
if
not
os
.
path
.
exists
(
temp_directory
):
print
"Creating directory: %s"
%
temp_directory
print
"Creating directory: %s"
%
temp_directory
os
.
mkdir
(
temp_directory
,
0711
)
os
.
mkdir
(
temp_directory
,
0711
)
while
True
:
while
True
:
config
.
userConfig
()
config
.
userConfig
()
print
"
\
n
This your configuration:
\
n
"
print
"
\
n
This
is
your configuration:
\
n
"
config
.
displayUserConfig
()
config
.
displayUserConfig
()
if
get_yes_no
(
"
\
n
Do you confirm?"
):
if
get_yes_no
(
"
\
n
Do you confirm?"
):
break
break
...
@@ -559,6 +558,7 @@ def prepare_from_scratch(config):
...
@@ -559,6 +558,7 @@ def prepare_from_scratch(config):
return
return_code
return
return_code
def
chownSlaposDirectory
():
def
chownSlaposDirectory
():
config
=
getSlaposConfiguration
()
config
=
getSlaposConfiguration
()
...
@@ -585,7 +585,6 @@ def chownSlaposDirectory():
...
@@ -585,7 +585,6 @@ def chownSlaposDirectory():
if
not
os
.
path
.
islink
(
item
):
if
not
os
.
path
.
islink
(
item
):
os
.
chown
(
os
.
path
.
join
(
root
,
item
),
getpwnam
(
'%s%s'
%
(
slapformat_user_base_name
,
i
)
)[
2
],
getpwnam
(
'%s%s'
%
(
slapformat_user_base_name
,
i
)
)[
3
])
os
.
chown
(
os
.
path
.
join
(
root
,
item
),
getpwnam
(
'%s%s'
%
(
slapformat_user_base_name
,
i
)
)[
2
],
getpwnam
(
'%s%s'
%
(
slapformat_user_base_name
,
i
)
)[
3
])
# chown of software root (/opt/slapgrid)
# chown of software root (/opt/slapgrid)
for
root
,
dirs
,
files
in
os
.
walk
(
slapos_slapgrid_software
):
for
root
,
dirs
,
files
in
os
.
walk
(
slapos_slapgrid_software
):
for
items
in
dirs
,
files
:
for
items
in
dirs
,
files
:
...
@@ -632,7 +631,6 @@ def slapprepare():
...
@@ -632,7 +631,6 @@ def slapprepare():
_call
([
'systemctl'
,
'enable'
,
'slapos-boot-dedicated.service'
])
_call
([
'systemctl'
,
'enable'
,
'slapos-boot-dedicated.service'
])
_call
([
'systemctl'
,
'start'
,
'slapos-boot-dedicated.service'
])
_call
([
'systemctl'
,
'start'
,
'slapos-boot-dedicated.service'
])
return_code
=
0
return_code
=
0
except
UsageError
,
err
:
except
UsageError
,
err
:
print
>>
sys
.
stderr
,
err
.
msg
print
>>
sys
.
stderr
,
err
.
msg
...
...
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