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
snf-ganeti
Commits
40a97d80
Commit
40a97d80
authored
Dec 19, 2008
by
Michael Hanselmann
Browse files
ganeti.bootstrap: Move SSL certificate generation into separate function
Reviewed-by: amishchenko
parent
b5b67ef9
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/bootstrap.py
View file @
40a97d80
...
...
@@ -67,23 +67,34 @@ def _InitSSHSetup():
f
.
close
()
def
_
InitGanetiServerSetup
(
):
"""
Setup the necessary configuration for the initial node daemon
.
def
_
GenerateSelfSignedSslCert
(
file_name
,
validity
=
(
365
*
5
)
):
"""
Generates a self-signed SSL certificate
.
This creates the nodepass file containing the shared password for
the cluster and also generates the SSL certificate.
@type file_name: str
@param file_name: Path to output file
@type validity: int
@param validity: Validity for certificate in days
"""
result
=
utils
.
RunCmd
([
"openssl"
,
"req"
,
"-new"
,
"-newkey"
,
"rsa:1024"
,
"-days"
,
str
(
365
*
5
),
"-nodes"
,
"-x509"
,
"-keyout"
,
constants
.
SSL_CERT_FILE
,
"-out"
,
constants
.
SSL_CERT_FILE
,
"-batch"
])
"-days"
,
str
(
validity
),
"-nodes"
,
"-x509"
,
"-keyout"
,
file_name
,
"-out"
,
file_name
,
"-batch"
])
if
result
.
failed
:
raise
errors
.
OpExecError
(
"
c
ould not generate
server ssl cert
, command"
raise
errors
.
OpExecError
(
"
C
ould not generate
SSL certificate
, command"
" %s had exitcode %s and error message %s"
%
(
result
.
cmd
,
result
.
exit_code
,
result
.
output
))
os
.
chmod
(
constants
.
SSL_CERT_FILE
,
0400
)
os
.
chmod
(
file_name
,
0400
)
def
_InitGanetiServerSetup
():
"""Setup the necessary configuration for the initial node daemon.
This creates the nodepass file containing the shared password for
the cluster and also generates the SSL certificate.
"""
_GenerateSelfSignedSslCert
(
constants
.
SSL_CERT_FILE
)
result
=
utils
.
RunCmd
([
constants
.
NODE_INITD_SCRIPT
,
"restart"
])
...
...
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