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
Guillaume Hervier
slapos.core
Commits
ab1884ee
Commit
ab1884ee
authored
Sep 21, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all partition logic in dedicated method, to be more readable.
parent
77bc6c75
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
109 deletions
+119
-109
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+119
-109
No files found.
slapos/grid/slapgrid.py
View file @
ab1884ee
...
@@ -554,6 +554,7 @@ class Slapgrid(object):
...
@@ -554,6 +554,7 @@ class Slapgrid(object):
logger
.
info
(
"Finished software releases..."
)
logger
.
info
(
"Finished software releases..."
)
return
clean_run
return
clean_run
def
_launchSupervisord
(
self
):
def
_launchSupervisord
(
self
):
launchSupervisord
(
self
.
supervisord_socket
,
launchSupervisord
(
self
.
supervisord_socket
,
self
.
supervisord_configuration_path
)
self
.
supervisord_configuration_path
)
...
@@ -610,33 +611,12 @@ class Slapgrid(object):
...
@@ -610,33 +611,12 @@ class Slapgrid(object):
if
not
promise_present
:
if
not
promise_present
:
self
.
logger
.
info
(
"No promise."
)
self
.
logger
.
info
(
"No promise."
)
def
processComputerPartition
List
(
self
):
def
processComputerPartition
(
self
,
computer_partition
):
"""
"""
Will start supervisord and process each Computer Partition.
Process a Computer Partition, depending on its state
"""
"""
logger
=
logging
.
getLogger
(
'ComputerPartitionProcessing'
)
logger
=
logging
.
getLogger
(
'ComputerPartitionProcessing'
)
logger
.
info
(
'Processing computer partitions...'
)
# Prepares environment
self
.
checkEnvironmentAndCreateStructure
()
self
.
_launchSupervisord
()
# Process Computer Partitions
clean_run
=
True
for
computer_partition
in
self
.
getComputerPartitionList
():
# Nothing should raise outside of the current loop iteration, so that
# even if something is terribly wrong while processing an instance, it
# won't prevent processing other ones.
try
:
# If id or URL is not defined, then it is an empty partition.
try
:
computer_partition
.
getId
()
computer_partition
.
getSoftwareRelease
().
getURI
()
# XXX should test status as well. But getState() returns default
# value.
except
NotFoundError
:
# No Software Release information: skip.
continue
# Process the partition itself
computer_partition_id
=
computer_partition
.
getId
()
computer_partition_id
=
computer_partition
.
getId
()
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
...
@@ -653,7 +633,7 @@ class Slapgrid(object):
...
@@ -653,7 +633,7 @@ class Slapgrid(object):
# If so, if current partition not in this list, skip.
# If so, if current partition not in this list, skip.
if
len
(
self
.
computer_partition_filter_list
)
>
0
and
\
if
len
(
self
.
computer_partition_filter_list
)
>
0
and
\
(
computer_partition_id
not
in
self
.
computer_partition_filter_list
):
(
computer_partition_id
not
in
self
.
computer_partition_filter_list
):
continue
return
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition_id
)
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition_id
)
...
@@ -691,7 +671,7 @@ class Slapgrid(object):
...
@@ -691,7 +671,7 @@ class Slapgrid(object):
if
int
(
timestamp
)
<=
int
(
old_timestamp
):
if
int
(
timestamp
)
<=
int
(
old_timestamp
):
if
int
(
time
.
time
())
<=
(
if
int
(
time
.
time
())
<=
(
last_runtime
+
self
.
maximum_periodicity
)
:
last_runtime
+
self
.
maximum_periodicity
)
:
continue
return
except
ValueError
:
except
ValueError
:
os
.
remove
(
timestamp_path
)
os
.
remove
(
timestamp_path
)
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
...
@@ -699,6 +679,7 @@ class Slapgrid(object):
...
@@ -699,6 +679,7 @@ class Slapgrid(object):
software_path
=
os
.
path
.
join
(
self
.
software_root
,
software_path
=
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
software_url
))
getSoftwareUrlHash
(
software_url
))
local_partition
=
Partition
(
local_partition
=
Partition
(
software_path
=
software_path
,
software_path
=
software_path
,
instance_path
=
instance_path
,
instance_path
=
instance_path
,
...
@@ -741,11 +722,40 @@ class Slapgrid(object):
...
@@ -741,11 +722,40 @@ class Slapgrid(object):
(
computer_partition_id
,
computer_partition_state
)
(
computer_partition_id
,
computer_partition_state
)
computer_partition
.
error
(
error_string
)
computer_partition
.
error
(
error_string
)
raise
NotImplementedError
(
error_string
)
raise
NotImplementedError
(
error_string
)
# If partition has been successfully processed, write timestamp
# If partition has been successfully processed, write timestamp
if
timestamp
:
if
timestamp
:
timestamp_path
=
os
.
path
.
join
(
instance_path
,
'.timestamp'
)
timestamp_path
=
os
.
path
.
join
(
instance_path
,
'.timestamp'
)
open
(
timestamp_path
,
'w'
).
write
(
timestamp
)
open
(
timestamp_path
,
'w'
).
write
(
timestamp
)
def
processComputerPartitionList
(
self
):
"""
Will start supervisord and process each Computer Partition.
"""
logger
=
logging
.
getLogger
(
'ComputerPartitionProcessing'
)
logger
.
info
(
'Processing computer partitions...'
)
# Prepares environment
self
.
checkEnvironmentAndCreateStructure
()
self
.
_launchSupervisord
()
# Process Computer Partitions
clean_run
=
True
for
computer_partition
in
self
.
getComputerPartitionList
():
# Nothing should raise outside of the current loop iteration, so that
# even if something is terribly wrong while processing an instance, it
# won't prevent processing other ones.
try
:
# If id or URL is not defined, then it is an empty partition.
try
:
computer_partition
.
getId
()
computer_partition
.
getSoftwareRelease
().
getURI
()
# XXX should test status as well. But getState() returns default
# value.
except
NotFoundError
:
# No Software Release information: skip.
continue
# Process the partition itself
self
.
processComputerPartition
(
computer_partition
)
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
...
...
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