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
Carlos Ramos Carreño
slapos.core
Commits
56098812
Commit
56098812
authored
Jan 08, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typos + cleanup
parent
f4e4808b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+19
-18
No files found.
slapos/grid/SlapObject.py
View file @
56098812
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
...
@@ -52,6 +53,7 @@ REQUIRED_COMPUTER_PARTITION_PERMISSION = '0750'
...
@@ -52,6 +53,7 @@ REQUIRED_COMPUTER_PARTITION_PERMISSION = '0750'
class
Software
(
object
):
class
Software
(
object
):
"""This class is responsible for installing a software release"""
"""This class is responsible for installing a software release"""
def
__init__
(
self
,
url
,
software_root
,
buildout
,
def
__init__
(
self
,
url
,
software_root
,
buildout
,
signature_private_key_file
=
None
,
signature_certificate_list
=
None
,
signature_private_key_file
=
None
,
signature_certificate_list
=
None
,
upload_cache_url
=
None
,
upload_dir_url
=
None
,
shacache_cert_file
=
None
,
upload_cache_url
=
None
,
upload_dir_url
=
None
,
shacache_cert_file
=
None
,
...
@@ -222,8 +224,9 @@ class Software(object):
...
@@ -222,8 +224,9 @@ class Software(object):
class
Partition
(
object
):
class
Partition
(
object
):
"""This class is responsible of the installation of a instance
"""This class is responsible of the installation of a
n
instance
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
software_path
,
software_path
,
instance_path
,
instance_path
,
...
@@ -389,19 +392,20 @@ class Partition(object):
...
@@ -389,19 +392,20 @@ class Partition(object):
bootstrap_file
=
os
.
path
.
abspath
(
os
.
path
.
join
(
bootstrap_candidate_dir
,
bootstrap_file
=
os
.
path
.
abspath
(
os
.
path
.
join
(
bootstrap_candidate_dir
,
bootstrap_candidate_list
[
0
]))
bootstrap_candidate_list
[
0
]))
file
=
open
(
bootstrap_file
,
'r'
)
first_line
=
open
(
bootstrap_file
,
'r'
).
readline
()
line
=
file
.
readline
()
file
.
close
()
invocation_list
=
[]
invocation_list
=
[]
if
line
.
startswith
(
'#!'
):
if
first_
line
.
startswith
(
'#!'
):
invocation_list
=
line
[
2
:].
split
()
invocation_list
=
first_
line
[
2
:].
split
()
invocation_list
.
append
(
bootstrap_file
)
invocation_list
.
append
(
bootstrap_file
)
self
.
logger
.
debug
(
'Invoking %r in %r'
%
(
' '
.
join
(
invocation_list
),
self
.
logger
.
debug
(
'Invoking %r in %r'
%
(
' '
.
join
(
invocation_list
),
self
.
instance_path
))
self
.
instance_path
))
kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
utils
.
SlapPopen
(
invocation_list
,
process_handler
=
utils
.
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
cwd
=
self
.
instance_path
,
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
cwd
=
self
.
instance_path
,
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to bootstrap buildout in %r.'
%
(
self
.
instance_path
)
message
=
'Failed to bootstrap buildout in %r.'
%
(
self
.
instance_path
)
self
.
logger
.
error
(
message
)
self
.
logger
.
error
(
message
)
...
@@ -487,17 +491,14 @@ class Partition(object):
...
@@ -487,17 +491,14 @@ class Partition(object):
destroy_executable_location
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
destroy_executable_location
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'destroy'
)
'destroy'
)
if
os
.
path
.
exists
(
destroy_executable_location
):
if
os
.
path
.
exists
(
destroy_executable_location
):
# XXX: we should factorize this code
uid
,
gid
=
self
.
getUserGroupId
()
uid
,
gid
=
None
,
None
stat_info
=
os
.
stat
(
self
.
instance_path
)
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
self
.
logger
.
debug
(
'Invoking %r'
%
destroy_executable_location
)
self
.
logger
.
debug
(
'Invoking %r'
%
destroy_executable_location
)
kw
=
dict
()
kw
.
update
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
utils
.
SlapPopen
([
destroy_executable_location
],
process_handler
=
utils
.
SlapPopen
([
destroy_executable_location
],
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
cwd
=
self
.
instance_path
,
preexec_fn
=
lambda
:
utils
.
dropPrivileges
(
uid
,
gid
),
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
cwd
=
self
.
instance_path
,
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to destroy Computer Partition in %r.'
%
\
message
=
'Failed to destroy Computer Partition in %r.'
%
\
self
.
instance_path
self
.
instance_path
...
...
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