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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
565dab64
Commit
565dab64
authored
Oct 16, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'return_value'
parents
08063548
0a349a97
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
57 deletions
+102
-57
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+55
-16
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+47
-41
No files found.
slapos/grid/slapgrid.py
View file @
565dab64
...
...
@@ -71,6 +71,12 @@ MANDATORY_PARAMETER_LIST = [
COMPUTER_PARTITION_DESTROYED_STATE
=
'destroyed'
# Global variables about return state of slapgrid
SLAPGRID_SUCCESS
=
0
SLAPGRID_FAIL
=
1
SLAPGRID_PROMISE_FAIL
=
2
# XXX hardcoded watchdog_path
WATCHDOG_PATH
=
'/opt/slapos/bin/slapos-watchdog'
...
...
@@ -316,23 +322,29 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
def
realRun
(
argument_tuple
,
method_list
):
clean_run
=
True
slapgrid_object
,
option_dict
=
\
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
pidfile
=
option_dict
.
get
(
'pidfile'
)
if
pidfile
:
setRunning
(
pidfile
)
try
:
failed
=
False
failed_promise
=
False
for
method
in
method_list
:
if
not
getattr
(
slapgrid_object
,
method
)():
clean_run
=
False
# Quite complicated way to figure out if everything went fine
return_value
=
getattr
(
slapgrid_object
,
method
)()
if
return_value
==
SLAPGRID_FAIL
:
failed
=
True
if
return_value
==
SLAPGRID_PROMISE_FAIL
:
failed_promise
=
True
finally
:
if
pidfile
:
setFinished
(
pidfile
)
if
clean_run
:
sys
.
exit
(
0
)
else
:
sys
.
exit
(
1
)
if
failed
:
sys
.
exit
(
SLAPGRID_FAIL
)
if
failed_promise
:
sys
.
exit
(
SLAPGRID_PROMISE_FAIL
)
sys
.
exit
(
SLAPGRID_SUCCESS
)
def
run
(
*
argument_tuple
):
...
...
@@ -520,6 +532,7 @@ class Slapgrid(object):
self
.
checkEnvironmentAndCreateStructure
()
logger
=
logging
.
getLogger
(
'SoftwareReleases'
)
logger
.
info
(
"Processing software releases..."
)
# Boolean to know if every instance has correctly been deployed
clean_run
=
True
for
software_release
in
self
.
computer
.
getSoftwareReleaseList
():
state
=
software_release
.
getState
()
...
...
@@ -600,7 +613,11 @@ class Slapgrid(object):
except
NotFoundError
:
pass
logger
.
info
(
"Finished software releases..."
)
return
clean_run
# Return success value
if
not
clean_run
:
return
SLAPGRID_FAIL
return
SLAPGRID_SUCCESS
def
_launchSupervisord
(
self
):
...
...
@@ -812,9 +829,8 @@ class Slapgrid(object):
# If partition has no SR: skip it.
try
:
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
software_path
=
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
software_url
))
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
computer_partition
.
getSoftwareRelease
().
getURI
()))
except
(
NotFoundError
,
TypeError
):
# This is surely free partition. Check it...
if
os
.
listdir
(
computer_partition_path
)
==
[]:
...
...
@@ -833,7 +849,6 @@ class Slapgrid(object):
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
clean_run
=
False
try
:
computer_partition
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
...
...
@@ -845,7 +860,6 @@ class Slapgrid(object):
# For everything else: log it, send it, continue.
except
Exception
as
exception
:
clean_run
=
False
logger
.
error
(
traceback
.
format_exc
())
try
:
computer_partition
.
error
(
exception
)
...
...
@@ -867,8 +881,11 @@ class Slapgrid(object):
# Prepares environment
self
.
checkEnvironmentAndCreateStructure
()
self
.
_launchSupervisord
()
# Process Computer Partitions
# Boolean to know if every instance has correctly been deployed
clean_run
=
True
# Boolean to know if every promises correctly passed
clean_run_promise
=
True
# Filter all dummy / empty partitions
computer_partition_list
=
self
.
FilterComputerPartitionList
(
...
...
@@ -888,6 +905,18 @@ class Slapgrid(object):
computer_partition
.
error
(
exception
)
raise
except
Slapgrid
.
PromiseError
as
exception
:
clean_run_promise
=
False
try
:
logger
.
error
(
exception
)
computer_partition
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
exception
=
traceback
.
format_exc
()
logger
.
error
(
'Problem during reporting error, continuing:
\
n
'
+
exception
)
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
clean_run
=
False
...
...
@@ -914,7 +943,13 @@ class Slapgrid(object):
exception
)
logger
.
info
(
"Finished computer partitions..."
)
return
clean_run
# Return success value
if
not
clean_run
:
return
SLAPGRID_FAIL
if
not
clean_run_promise
:
return
SLAPGRID_PROMISE_FAIL
return
SLAPGRID_SUCCESS
def
validateXML
(
self
,
to_be_validated
,
xsd_model
):
...
...
@@ -1239,4 +1274,8 @@ class Slapgrid(object):
(
computer_partition
.
getId
(),
server_error
.
args
[
0
]))
logger
.
info
(
"Finished usage reports..."
)
return
clean_run
# Return success value
if
not
clean_run
:
return
SLAPGRID_FAIL
return
SLAPGRID_SUCCESS
slapos/tests/slapgrid.py
View file @
565dab64
This diff is collapsed.
Click to expand it.
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