Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
3b1b0cb6
Commit
3b1b0cb6
authored
15 years ago
by
Guido Trotter
Browse files
Options
Downloads
Patches
Plain Diff
Collapse SSL key checking/overriding for daemons
Signed-off-by:
Guido Trotter
<
ultrotter@google.com
>
parent
04ccf5e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
daemons/ganeti-noded
+6
-13
6 additions, 13 deletions
daemons/ganeti-noded
daemons/ganeti-rapi
+0
-19
0 additions, 19 deletions
daemons/ganeti-rapi
lib/constants.py
+6
-0
6 additions, 0 deletions
lib/constants.py
lib/daemon.py
+25
-1
25 additions, 1 deletion
lib/daemon.py
with
37 additions
and
33 deletions
daemons/ganeti-noded
+
6
−
13
View file @
3b1b0cb6
...
@@ -732,16 +732,6 @@ class NodeHttpServer(http.server.HttpServer):
...
@@ -732,16 +732,6 @@ class NodeHttpServer(http.server.HttpServer):
return
backend
.
ValidateHVParams
(
hvname
,
hvparams
)
return
backend
.
ValidateHVParams
(
hvname
,
hvparams
)
def
CheckNODED
(
options
,
args
):
"""
Initial checks whether to run exit with a failure
"""
for
fname
in
(
constants
.
SSL_CERT_FILE
,):
if
not
os
.
path
.
isfile
(
fname
):
print
"
config %s not there, will not run.
"
%
fname
sys
.
exit
(
constants
.
EXIT_NOTCLUSTER
)
def
ExecNODED
(
options
,
args
):
def
ExecNODED
(
options
,
args
):
"""
Main NODED function, executed with the pidfile held.
"""
Main NODED function, executed with the pidfile held.
...
@@ -749,8 +739,11 @@ def ExecNODED(options, args):
...
@@ -749,8 +739,11 @@ def ExecNODED(options, args):
global
queue_lock
global
queue_lock
# Read SSL certificate
# Read SSL certificate
ssl_params
=
http
.
HttpSslParams
(
ssl_key_path
=
constants
.
SSL_CERT_FILE
,
if
options
.
ssl
:
ssl_cert_path
=
constants
.
SSL_CERT_FILE
)
ssl_params
=
http
.
HttpSslParams
(
ssl_key_path
=
options
.
ssl_key
,
ssl_cert_path
=
options
.
ssl_cert
)
else
:
ssl_params
=
None
# Prepare job queue
# Prepare job queue
queue_lock
=
jstore
.
InitAndVerifyQueue
(
must_lock
=
False
)
queue_lock
=
jstore
.
InitAndVerifyQueue
(
must_lock
=
False
)
...
@@ -776,7 +769,7 @@ def main():
...
@@ -776,7 +769,7 @@ def main():
dirs
=
[(
val
,
constants
.
RUN_DIRS_MODE
)
for
val
in
constants
.
SUB_RUN_DIRS
]
dirs
=
[(
val
,
constants
.
RUN_DIRS_MODE
)
for
val
in
constants
.
SUB_RUN_DIRS
]
dirs
.
append
((
constants
.
LOG_OS_DIR
,
0750
))
dirs
.
append
((
constants
.
LOG_OS_DIR
,
0750
))
dirs
.
append
((
constants
.
LOCK_DIR
,
1777
))
dirs
.
append
((
constants
.
LOCK_DIR
,
1777
))
daemon
.
GenericMain
(
constants
.
NODED
,
parser
,
dirs
,
CheckNODED
,
ExecNODED
)
daemon
.
GenericMain
(
constants
.
NODED
,
parser
,
dirs
,
None
,
ExecNODED
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
daemons/ganeti-rapi
+
0
−
19
View file @
3b1b0cb6
...
@@ -186,16 +186,6 @@ def CheckRAPI(options, args):
...
@@ -186,16 +186,6 @@ def CheckRAPI(options, args):
sys
.
argv
[
0
]
sys
.
argv
[
0
]
sys
.
exit
(
constants
.
EXIT_FAILURE
)
sys
.
exit
(
constants
.
EXIT_FAILURE
)
if
options
.
ssl
:
if
not
(
options
.
ssl_cert
and
options
.
ssl_key
):
print
>>
sys
.
stderr
,
(
"
For secure mode please provide
"
"
--ssl-key and --ssl-cert arguments
"
)
sys
.
exit
(
constants
.
EXIT_FAILURE
)
for
fname
in
(
options
.
ssl_cert
,
options
.
ssl_key
):
if
not
os
.
path
.
isfile
(
fname
):
print
>>
sys
.
stderr
,
"
config %s not there, will not run.
"
%
fname
sys
.
exit
(
constants
.
EXIT_FAILURE
)
ssconf
.
CheckMaster
(
options
.
debug
)
ssconf
.
CheckMaster
(
options
.
debug
)
...
@@ -228,15 +218,6 @@ def main():
...
@@ -228,15 +218,6 @@ def main():
parser
=
optparse
.
OptionParser
(
description
=
"
Ganeti Remote API
"
,
parser
=
optparse
.
OptionParser
(
description
=
"
Ganeti Remote API
"
,
usage
=
"
%prog [-f] [-d] [-p port] [-b ADDRESS]
"
,
usage
=
"
%prog [-f] [-d] [-p port] [-b ADDRESS]
"
,
version
=
"
%%prog (ganeti) %s
"
%
constants
.
RAPI_VERSION
)
version
=
"
%%prog (ganeti) %s
"
%
constants
.
RAPI_VERSION
)
parser
.
add_option
(
"
--no-ssl
"
,
dest
=
"
ssl
"
,
help
=
"
Do not secure HTTP protocol with SSL
"
,
default
=
True
,
action
=
"
store_false
"
)
parser
.
add_option
(
"
-K
"
,
"
--ssl-key
"
,
dest
=
"
ssl_key
"
,
help
=
"
SSL key
"
,
default
=
constants
.
RAPI_CERT_FILE
,
type
=
"
string
"
)
parser
.
add_option
(
"
-C
"
,
"
--ssl-cert
"
,
dest
=
"
ssl_cert
"
,
help
=
"
SSL certificate
"
,
default
=
constants
.
RAPI_CERT_FILE
,
type
=
"
string
"
)
dirs
=
[(
val
,
constants
.
RUN_DIRS_MODE
)
for
val
in
constants
.
SUB_RUN_DIRS
]
dirs
=
[(
val
,
constants
.
RUN_DIRS_MODE
)
for
val
in
constants
.
SUB_RUN_DIRS
]
dirs
.
append
((
constants
.
LOG_OS_DIR
,
0750
))
dirs
.
append
((
constants
.
LOG_OS_DIR
,
0750
))
...
...
This diff is collapsed.
Click to expand it.
lib/constants.py
+
6
−
0
View file @
3b1b0cb6
...
@@ -117,6 +117,12 @@ MASTERD = "ganeti-masterd"
...
@@ -117,6 +117,12 @@ MASTERD = "ganeti-masterd"
MULTITHREADED_DAEMONS
=
frozenset
([
MASTERD
])
MULTITHREADED_DAEMONS
=
frozenset
([
MASTERD
])
DAEMONS_SSL
=
{
# daemon-name: (default-cert-path, default-key-path)
NODED
:
(
SSL_CERT_FILE
,
SSL_CERT_FILE
),
RAPI
:
(
RAPI_CERT_FILE
,
RAPI_CERT_FILE
),
}
DAEMONS_PORTS
=
{
DAEMONS_PORTS
=
{
# daemon-name: ("proto", "default-port")
# daemon-name: ("proto", "default-port")
NODED
:
(
"
tcp
"
,
1811
),
NODED
:
(
"
tcp
"
,
1811
),
...
...
This diff is collapsed.
Click to expand it.
lib/daemon.py
+
25
−
1
View file @
3b1b0cb6
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
"""
Module with helper classes and functions for daemons
"""
"""
Module with helper classes and functions for daemons
"""
import
os
import
select
import
select
import
signal
import
signal
import
errno
import
errno
...
@@ -339,11 +340,34 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn):
...
@@ -339,11 +340,34 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn):
help
=
"
Bind address
"
,
help
=
"
Bind address
"
,
default
=
""
,
metavar
=
"
ADDRESS
"
)
default
=
""
,
metavar
=
"
ADDRESS
"
)
if
daemon_name
in
constants
.
DAEMONS_SSL
:
default_cert
,
default_key
=
constants
.
DAEMONS_SSL
[
daemon_name
]
optionparser
.
add_option
(
"
--no-ssl
"
,
dest
=
"
ssl
"
,
help
=
"
Do not secure HTTP protocol with SSL
"
,
default
=
True
,
action
=
"
store_false
"
)
optionparser
.
add_option
(
"
-K
"
,
"
--ssl-key
"
,
dest
=
"
ssl_key
"
,
help
=
"
SSL key
"
,
default
=
default_key
,
type
=
"
string
"
)
optionparser
.
add_option
(
"
-C
"
,
"
--ssl-cert
"
,
dest
=
"
ssl_cert
"
,
help
=
"
SSL certificate
"
,
default
=
default_cert
,
type
=
"
string
"
)
multithread
=
utils
.
no_fork
=
daemon_name
in
constants
.
MULTITHREADED_DAEMONS
multithread
=
utils
.
no_fork
=
daemon_name
in
constants
.
MULTITHREADED_DAEMONS
options
,
args
=
optionparser
.
parse_args
()
options
,
args
=
optionparser
.
parse_args
()
check_fn
(
options
,
args
)
if
hasattr
(
options
,
'
ssl
'
)
and
options
.
ssl
:
if
not
(
options
.
ssl_cert
and
options
.
ssl_key
):
print
>>
sys
.
stderr
,
"
Need key and certificate to use ssl
"
sys
.
exit
(
constants
.
EXIT_FAILURE
)
for
fname
in
(
options
.
ssl_cert
,
options
.
ssl_key
):
if
not
os
.
path
.
isfile
(
fname
):
print
>>
sys
.
stderr
,
"
Need ssl file %s to run
"
%
fname
sys
.
exit
(
constants
.
EXIT_FAILURE
)
if
check_fn
is
not
None
:
check_fn
(
options
,
args
)
utils
.
EnsureDirs
(
dirs
)
utils
.
EnsureDirs
(
dirs
)
if
options
.
fork
:
if
options
.
fork
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment