Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.core
Commits
d573a5fb
Commit
d573a5fb
authored
Dec 12, 2012
by
Cédric Le Ninivin
Committed by
Cédric de Saint Martin
Dec 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Watchdog uses instance certificate to bang
parent
34dfa390
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
slapos/grid/watchdog.py
slapos/grid/watchdog.py
+19
-12
No files found.
slapos/grid/watchdog.py
View file @
d573a5fb
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
##############################################################################
##############################################################################
import
argparse
import
argparse
import
os.path
import
slapos.slap.slap
import
slapos.slap.slap
import
sys
import
sys
...
@@ -47,11 +48,8 @@ def parseArgumentTuple():
...
@@ -47,11 +48,8 @@ def parseArgumentTuple():
parser
.
add_argument
(
"--computer-id"
,
parser
.
add_argument
(
"--computer-id"
,
help
=
"The computer id defined in the server."
,
help
=
"The computer id defined in the server."
,
required
=
True
)
required
=
True
)
parser
.
add_argument
(
"--key-file"
,
parser
.
add_argument
(
"--certificate-repository-path"
,
help
=
"SSL Authorisation key file."
,
help
=
"Path to partition certificates."
,
default
=
None
)
parser
.
add_argument
(
"--cert-file"
,
help
=
"SSL Authorisation certificate file."
,
default
=
None
)
default
=
None
)
option
=
parser
.
parse_args
()
option
=
parser
.
parse_args
()
...
@@ -75,9 +73,17 @@ class Watchdog():
...
@@ -75,9 +73,17 @@ class Watchdog():
self
.
stdout
=
sys
.
stdout
self
.
stdout
=
sys
.
stdout
self
.
stderr
=
sys
.
stderr
self
.
stderr
=
sys
.
stderr
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
=
slapos
.
slap
.
slap
()
def
initialize_connection
(
self
,
partition_id
):
cert_file
=
None
key_file
=
None
if
self
.
certificate_repository_path
is
not
None
:
cert_file
=
os
.
path
.
join
(
self
.
certificate_repository_path
,
"%s.crt"
%
partition_id
)
key_file
=
os
.
path
.
join
(
self
.
certificate_repository_path
,
"%s.key"
%
partition_id
)
self
.
slap
.
initializeConnection
(
self
.
slap
.
initializeConnection
(
slapgrid_uri
=
self
.
master_url
,
key_file
=
self
.
key_file
,
slapgrid_uri
=
self
.
master_url
,
key_file
=
key_file
,
cert_file
=
cert_file
)
cert_file
=
self
.
cert_file
)
def
write_stdout
(
self
,
s
):
def
write_stdout
(
self
,
s
):
self
.
stdout
.
write
(
s
)
self
.
stdout
.
write
(
s
)
...
@@ -91,23 +97,24 @@ class Watchdog():
...
@@ -91,23 +97,24 @@ class Watchdog():
while
1
:
while
1
:
self
.
write_stdout
(
'READY
\
n
'
)
self
.
write_stdout
(
'READY
\
n
'
)
line
=
self
.
stdin
.
readline
()
# read header line from stdin
line
=
self
.
stdin
.
readline
()
# read header line from stdin
headers
=
dict
([
x
.
split
(
':'
)
for
x
in
line
.
split
()
])
headers
=
dict
([
x
.
split
(
':'
)
for
x
in
line
.
split
()
])
data
=
sys
.
stdin
.
read
(
int
(
headers
[
'len'
]))
# read the event payload
data
=
sys
.
stdin
.
read
(
int
(
headers
[
'len'
]))
# read the event payload
self
.
handle_event
(
headers
,
data
)
self
.
handle_event
(
headers
,
data
)
self
.
write_stdout
(
'RESULT 2
\
n
OK'
)
# transition from READY to ACKNOWLEDGED
self
.
write_stdout
(
'RESULT 2
\
n
OK'
)
# transition from READY to ACKNOWLEDGED
def
handle_event
(
self
,
headers
,
payload
):
def
handle_event
(
self
,
headers
,
payload
):
if
headers
[
'eventname'
]
in
self
.
process_state_events
:
if
headers
[
'eventname'
]
in
self
.
process_state_events
:
payload_dict
=
dict
([
x
.
split
(
':'
)
for
x
in
payload
.
split
()
])
payload_dict
=
dict
([
x
.
split
(
':'
)
for
x
in
payload
.
split
()
])
if
getWatchdogID
()
in
payload_dict
[
'processname'
]:
if
getWatchdogID
()
in
payload_dict
[
'processname'
]:
self
.
handle_process_state_change_event
(
headers
,
payload_dict
)
self
.
handle_process_state_change_event
(
headers
,
payload_dict
)
def
handle_process_state_change_event
(
self
,
headers
,
payload_dict
):
def
handle_process_state_change_event
(
self
,
headers
,
payload_dict
):
partition_id
=
payload_dict
[
'groupname'
]
partition_id
=
payload_dict
[
'groupname'
]
self
.
initialize_connection
(
partition_id
)
partition
=
slapos
.
slap
.
ComputerPartition
(
partition
=
slapos
.
slap
.
ComputerPartition
(
computer_id
=
self
.
computer_id
,
computer_id
=
self
.
computer_id
,
connection_helper
=
self
.
slap
.
_connection_helper
,
connection_helper
=
self
.
slap
.
_connection_helper
,
partition_id
=
partition_id
)
partition_id
=
partition_id
)
partition
.
bang
(
"%s process in partition %s encountered a problem"
partition
.
bang
(
"%s process in partition %s encountered a problem"
%
(
payload_dict
[
'processname'
],
partition_id
))
%
(
payload_dict
[
'processname'
],
partition_id
))
...
...
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