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
Łukasz Nowak
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 = [
...
@@ -71,6 +71,12 @@ MANDATORY_PARAMETER_LIST = [
COMPUTER_PARTITION_DESTROYED_STATE
=
'destroyed'
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
# XXX hardcoded watchdog_path
WATCHDOG_PATH
=
'/opt/slapos/bin/slapos-watchdog'
WATCHDOG_PATH
=
'/opt/slapos/bin/slapos-watchdog'
...
@@ -316,23 +322,29 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -316,23 +322,29 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
def
realRun
(
argument_tuple
,
method_list
):
def
realRun
(
argument_tuple
,
method_list
):
clean_run
=
True
slapgrid_object
,
option_dict
=
\
slapgrid_object
,
option_dict
=
\
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
pidfile
=
option_dict
.
get
(
'pidfile'
)
pidfile
=
option_dict
.
get
(
'pidfile'
)
if
pidfile
:
if
pidfile
:
setRunning
(
pidfile
)
setRunning
(
pidfile
)
try
:
try
:
failed
=
False
failed_promise
=
False
for
method
in
method_list
:
for
method
in
method_list
:
if
not
getattr
(
slapgrid_object
,
method
)():
# Quite complicated way to figure out if everything went fine
clean_run
=
False
return_value
=
getattr
(
slapgrid_object
,
method
)()
if
return_value
==
SLAPGRID_FAIL
:
failed
=
True
if
return_value
==
SLAPGRID_PROMISE_FAIL
:
failed_promise
=
True
finally
:
finally
:
if
pidfile
:
if
pidfile
:
setFinished
(
pidfile
)
setFinished
(
pidfile
)
if
clean_run
:
if
failed
:
sys
.
exit
(
0
)
sys
.
exit
(
SLAPGRID_FAIL
)
else
:
if
failed_promise
:
sys
.
exit
(
1
)
sys
.
exit
(
SLAPGRID_PROMISE_FAIL
)
sys
.
exit
(
SLAPGRID_SUCCESS
)
def
run
(
*
argument_tuple
):
def
run
(
*
argument_tuple
):
...
@@ -520,6 +532,7 @@ class Slapgrid(object):
...
@@ -520,6 +532,7 @@ class Slapgrid(object):
self
.
checkEnvironmentAndCreateStructure
()
self
.
checkEnvironmentAndCreateStructure
()
logger
=
logging
.
getLogger
(
'SoftwareReleases'
)
logger
=
logging
.
getLogger
(
'SoftwareReleases'
)
logger
.
info
(
"Processing software releases..."
)
logger
.
info
(
"Processing software releases..."
)
# Boolean to know if every instance has correctly been deployed
clean_run
=
True
clean_run
=
True
for
software_release
in
self
.
computer
.
getSoftwareReleaseList
():
for
software_release
in
self
.
computer
.
getSoftwareReleaseList
():
state
=
software_release
.
getState
()
state
=
software_release
.
getState
()
...
@@ -600,7 +613,11 @@ class Slapgrid(object):
...
@@ -600,7 +613,11 @@ class Slapgrid(object):
except
NotFoundError
:
except
NotFoundError
:
pass
pass
logger
.
info
(
"Finished software releases..."
)
logger
.
info
(
"Finished software releases..."
)
return
clean_run
# Return success value
if
not
clean_run
:
return
SLAPGRID_FAIL
return
SLAPGRID_SUCCESS
def
_launchSupervisord
(
self
):
def
_launchSupervisord
(
self
):
...
@@ -812,9 +829,8 @@ class Slapgrid(object):
...
@@ -812,9 +829,8 @@ class Slapgrid(object):
# If partition has no SR: skip it.
# If partition has no SR: skip it.
try
:
try
:
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
software_path
=
os
.
path
.
join
(
self
.
software_root
,
computer_partition
.
getSoftwareRelease
().
getURI
()))
getSoftwareUrlHash
(
software_url
))
except
(
NotFoundError
,
TypeError
):
except
(
NotFoundError
,
TypeError
):
# This is surely free partition. Check it...
# This is surely free partition. Check it...
if
os
.
listdir
(
computer_partition_path
)
==
[]:
if
os
.
listdir
(
computer_partition_path
)
==
[]:
...
@@ -833,7 +849,6 @@ class Slapgrid(object):
...
@@ -833,7 +849,6 @@ class Slapgrid(object):
# Buildout failed: send log but don't print it to output (already done)
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
except
BuildoutFailedError
,
exception
:
clean_run
=
False
try
:
try
:
computer_partition
.
error
(
exception
)
computer_partition
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
...
@@ -845,7 +860,6 @@ class Slapgrid(object):
...
@@ -845,7 +860,6 @@ class Slapgrid(object):
# For everything else: log it, send it, continue.
# For everything else: log it, send it, continue.
except
Exception
as
exception
:
except
Exception
as
exception
:
clean_run
=
False
logger
.
error
(
traceback
.
format_exc
())
logger
.
error
(
traceback
.
format_exc
())
try
:
try
:
computer_partition
.
error
(
exception
)
computer_partition
.
error
(
exception
)
...
@@ -867,8 +881,11 @@ class Slapgrid(object):
...
@@ -867,8 +881,11 @@ class Slapgrid(object):
# Prepares environment
# Prepares environment
self
.
checkEnvironmentAndCreateStructure
()
self
.
checkEnvironmentAndCreateStructure
()
self
.
_launchSupervisord
()
self
.
_launchSupervisord
()
# Process Computer Partitions
# Boolean to know if every instance has correctly been deployed
clean_run
=
True
clean_run
=
True
# Boolean to know if every promises correctly passed
clean_run_promise
=
True
# Filter all dummy / empty partitions
# Filter all dummy / empty partitions
computer_partition_list
=
self
.
FilterComputerPartitionList
(
computer_partition_list
=
self
.
FilterComputerPartitionList
(
...
@@ -888,6 +905,18 @@ class Slapgrid(object):
...
@@ -888,6 +905,18 @@ class Slapgrid(object):
computer_partition
.
error
(
exception
)
computer_partition
.
error
(
exception
)
raise
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)
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
except
BuildoutFailedError
,
exception
:
clean_run
=
False
clean_run
=
False
...
@@ -914,7 +943,13 @@ class Slapgrid(object):
...
@@ -914,7 +943,13 @@ class Slapgrid(object):
exception
)
exception
)
logger
.
info
(
"Finished computer partitions..."
)
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
):
def
validateXML
(
self
,
to_be_validated
,
xsd_model
):
...
@@ -1239,4 +1274,8 @@ class Slapgrid(object):
...
@@ -1239,4 +1274,8 @@ class Slapgrid(object):
(
computer_partition
.
getId
(),
server_error
.
args
[
0
]))
(
computer_partition
.
getId
(),
server_error
.
args
[
0
]))
logger
.
info
(
"Finished usage reports..."
)
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