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
Thomas Leymonerie
slapos.core
Commits
0ad51d3d
Commit
0ad51d3d
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import cleanup
parent
ead116af
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
42 deletions
+39
-42
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+29
-28
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+10
-14
No files found.
slapos/grid/SlapObject.py
View file @
0ad51d3d
...
...
@@ -30,24 +30,25 @@
import
logging
import
os
import
shutil
import
subprocess
import
pkg_resources
import
pwd
import
shutil
import
stat
import
subprocess
import
tarfile
import
tempfile
import
textwrap
import
utils
import
xmlrpclib
from
supervisor
import
xmlrpc
from
slapos.grid.utils
import
(
getSoftwareUrlHash
,
getCleanEnvironment
,
bootstrapBuildout
,
launchBuildout
,
SlapPopen
,
dropPrivileges
,
updateFile
)
from
slapos.slap.slap
import
NotFoundError
from
svcbackend
import
getSupervisorRPC
from
exception
import
BuildoutFailedError
,
WrongPermissionError
,
\
PathDoesNotExistError
from
networkcache
import
download_network_cached
,
upload_network_cached
from
watchdog
import
getWatchdogID
from
s
lapos.grid.s
vcbackend
import
getSupervisorRPC
from
slapos.grid.exception
import
(
BuildoutFailedError
,
WrongPermissionError
,
PathDoesNotExistError
)
from
slapos.grid.
networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.grid.
watchdog
import
getWatchdogID
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
'0750'
...
...
@@ -67,7 +68,7 @@ class Software(object):
"""
self
.
url
=
url
self
.
software_root
=
software_root
self
.
software_url_hash
=
utils
.
getSoftwareUrlHash
(
self
.
url
)
self
.
software_url_hash
=
getSoftwareUrlHash
(
self
.
url
)
self
.
software_path
=
os
.
path
.
join
(
self
.
software_root
,
self
.
software_url_hash
)
self
.
buildout
=
buildout
...
...
@@ -136,7 +137,7 @@ class Software(object):
it. If it fails, we notify the server.
"""
root_stat_info
=
os
.
stat
(
self
.
software_root
)
os
.
environ
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
root_stat_info
.
st_uid
os
.
environ
=
getCleanEnvironment
(
pwd
.
getpwuid
(
root_stat_info
.
st_uid
).
pw_dir
)
if
not
os
.
path
.
isdir
(
self
.
software_path
):
os
.
mkdir
(
self
.
software_path
)
...
...
@@ -175,9 +176,9 @@ class Software(object):
self
.
createProfileIfMissing
(
buildout_cfg
,
self
.
url
)
buildout_parameter_list
.
extend
([
'-c'
,
buildout_cfg
])
utils
.
bootstrapBuildout
(
self
.
software_path
,
self
.
buildout
,
bootstrapBuildout
(
self
.
software_path
,
self
.
buildout
,
additional_buildout_parametr_list
=
buildout_parameter_list
)
utils
.
launchBuildout
(
self
.
software_path
,
launchBuildout
(
self
.
software_path
,
os
.
path
.
join
(
self
.
software_path
,
'bin'
,
'buildout'
),
additional_buildout_parametr_list
=
buildout_parameter_list
)
finally
:
...
...
@@ -358,7 +359,7 @@ class Partition(object):
'are %s'
%
(
self
.
instance_path
,
permission
,
REQUIRED_COMPUTER_PARTITION_PERMISSION
))
os
.
environ
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
os
.
environ
=
getCleanEnvironment
(
pwd
.
getpwuid
(
instance_stat_info
.
st_uid
).
pw_dir
)
# Generates buildout part from template
template_location
=
os
.
path
.
join
(
self
.
software_path
,
'instance.cfg'
)
...
...
@@ -418,10 +419,10 @@ class Partition(object):
self
.
logger
.
debug
(
'Invoking %r in %r'
%
(
' '
.
join
(
invocation_list
),
self
.
instance_path
))
process_handler
=
utils
.
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
self
.
instance_path
,
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
...
...
@@ -432,12 +433,12 @@ class Partition(object):
if
not
os
.
path
.
exists
(
buildout_binary
):
# use own buildout generation
utils
.
bootstrapBuildout
(
self
.
instance_path
,
self
.
buildout
,
bootstrapBuildout
(
self
.
instance_path
,
self
.
buildout
,
[
'buildout:bin-directory=%s'
%
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
)])
buildout_binary
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'buildout'
)
# Launches buildout
utils
.
launchBuildout
(
self
.
instance_path
,
buildout_binary
)
launchBuildout
(
self
.
instance_path
,
buildout_binary
)
# Generates supervisord configuration file from template
self
.
logger
.
info
(
"Generating supervisord config file from template..."
)
# check if CP/etc/run exists and it is a directory
...
...
@@ -469,7 +470,7 @@ class Partition(object):
self
.
addServiceToGroup
(
partition_id
,
runner_list
,
self
.
run_path
)
self
.
addServiceToGroup
(
partition_id
,
service_list
,
self
.
service_path
,
extension
=
getWatchdogID
())
u
tils
.
u
pdateFile
(
self
.
supervisord_partition_configuration_path
,
updateFile
(
self
.
supervisord_partition_configuration_path
,
self
.
partition_supervisor_configuration
)
self
.
updateSupervisor
()
...
...
@@ -511,10 +512,10 @@ class Partition(object):
if
os
.
path
.
exists
(
destroy_executable_location
):
uid
,
gid
=
self
.
getUserGroupId
()
self
.
logger
.
debug
(
'Invoking %r'
%
destroy_executable_location
)
process_handler
=
utils
.
SlapPopen
([
destroy_executable_location
],
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
process_handler
=
SlapPopen
([
destroy_executable_location
],
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
self
.
instance_path
,
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
...
...
slapos/grid/slapgrid.py
View file @
0ad51d3d
...
...
@@ -30,9 +30,7 @@
import
argparse
import
ConfigParser
from
exception
import
BuildoutFailedError
from
hashlib
import
md5
from
lxml
import
etree
import
logging
import
os
import
pkg_resources
...
...
@@ -49,19 +47,17 @@ if sys.version_info < (2, 6):
warnings
.
warn
(
'Used python version (%s) is old and have problems with'
' IPv6 connections'
%
sys
.
version
.
split
(
'
\
n
'
)[
0
])
from
lxml
import
etree
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
ServerError
from
SlapObject
import
Software
,
Partition
,
WrongPermissionError
,
\
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.SlapObject
import
Software
,
Partition
,
WrongPermissionError
,
\
PathDoesNotExistError
from
svcbackend
import
launchSupervisord
from
utils
import
createPrivateDirectory
from
utils
import
dropPrivileges
from
utils
import
getSoftwareUrlHash
from
utils
import
setRunning
from
utils
import
setFinished
from
utils
import
SlapPopen
from
utils
import
updateFile
from
slapos
import
slap
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.utils
import
(
getSoftwareUrlHash
,
createPrivateDirectory
,
dropPrivileges
,
setRunning
,
setFinished
,
SlapPopen
,
updateFile
)
import
slapos.slap
MANDATORY_PARAMETER_LIST
=
[
'computer_id'
,
...
...
@@ -468,7 +464,7 @@ class Slapgrid(object):
# Configures logger
self
.
logger
=
logging
.
getLogger
(
'Slapgrid'
)
# Creates objects from slap module
self
.
slap
=
slap
.
slap
()
self
.
slap
=
slap
os
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
master_url
,
key_file
=
self
.
key_file
,
cert_file
=
self
.
cert_file
,
master_ca_file
=
self
.
master_ca_file
)
self
.
computer
=
self
.
slap
.
registerComputer
(
self
.
computer_id
)
...
...
@@ -1290,7 +1286,7 @@ class Slapgrid(object):
logger
.
error
(
exception
)
try
:
computer_partition
.
destroyed
()
except
slap
.
NotFoundError
:
except
NotFoundError
:
logger
.
debug
(
'Ignored slap error while trying to inform about '
'destroying not fully configured Computer Partition %r'
%
computer_partition
.
getId
())
...
...
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