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
Nicolas Wavrant
slapos.core
Commits
2530f76d
Commit
2530f76d
authored
Jun 13, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typos and improved comments, whitespaces
parent
c4d44672
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
23 deletions
+24
-23
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+1
-1
slapos/grid/utils.py
slapos/grid/utils.py
+5
-5
slapos/proxy/views.py
slapos/proxy/views.py
+18
-17
No files found.
slapos/grid/SlapObject.py
View file @
2530f76d
...
...
@@ -608,7 +608,7 @@ class Partition(object):
def
updateSupervisor
(
self
):
"""Forces supervisord to reload its configuration"""
# Note: This method shall wait for results from supervisord
# In future it will
be not
needed, as update command
# In future it will
not be
needed, as update command
# is going to be implemented on server side.
self
.
logger
.
debug
(
'Updating supervisord'
)
supervisor
=
self
.
getSupervisorRPC
()
...
...
slapos/grid/utils.py
View file @
2530f76d
...
...
@@ -130,7 +130,7 @@ def getCleanEnvironment(logger, home_path='/tmp'):
removed_env
.
append
(
k
)
changed_env
[
'HOME'
]
=
env
[
'HOME'
]
=
home_path
for
k
in
sorted
(
changed_env
.
iterkeys
()):
logger
.
debug
(
'Overriden %s = %r'
%
(
k
,
changed_env
[
k
]))
logger
.
debug
(
'Overrid
d
en %s = %r'
%
(
k
,
changed_env
[
k
]))
logger
.
debug
(
'Removed from environment: %s'
%
', '
.
join
(
sorted
(
removed_env
)))
return
env
...
...
@@ -175,7 +175,7 @@ def dropPrivileges(uid, gid, logger):
Do tests to check if dropping was successful and that no system call is able
to re-raise dropped privileges
Does nothing i
n case i
f uid and gid are not 0
Does nothing if uid and gid are not 0
"""
# XXX-Cedric: remove format / just do a print, otherwise formatting is done
# twice
...
...
@@ -327,7 +327,7 @@ def launchBuildout(path, buildout_binary, logger,
def
updateFile
(
file_path
,
content
,
mode
=
0o600
):
"""Creates
an executab
le with "content" as content."""
"""Creates
or updates a fi
le with "content" as content."""
altered
=
False
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
...
...
@@ -343,12 +343,12 @@ def updateFile(file_path, content, mode=0o600):
def
updateExecutable
(
executable_path
,
content
):
"""Creates
an executab
le with "content" as content."""
"""Creates
or updates an executable fi
le with "content" as content."""
return
updateFile
(
executable_path
,
content
,
0o700
)
def
createPrivateDirectory
(
path
):
"""Creates directory belonging to root with umask 077"""
"""Creates
a
directory belonging to root with umask 077"""
if
not
os
.
path
.
isdir
(
path
):
os
.
mkdir
(
path
)
os
.
chmod
(
path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
...
...
slapos/proxy/views.py
View file @
2530f76d
...
...
@@ -59,15 +59,17 @@ def xml2dict(xml):
return
result_dict
def
dict2xml
(
diction
n
ary
):
def
dict2xml
(
dictionary
):
instance
=
etree
.
Element
(
'instance'
)
for
parameter_id
,
parameter_value
in
diction
n
ary
.
iteritems
():
for
parameter_id
,
parameter_value
in
dictionary
.
iteritems
():
# cast everything to string
parameter_value
=
str
(
parameter_value
)
etree
.
SubElement
(
instance
,
"parameter"
,
attrib
=
{
'id'
:
parameter_id
}).
text
=
parameter_value
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
def
partitiondict2partition
(
partition
):
...
...
@@ -90,7 +92,7 @@ def partitiondict2partition(partition):
slap_partition
.
_parameter_dict
[
'ip_list'
]
=
address_list
slap_partition
.
_parameter_dict
[
'slap_software_type'
]
=
\
partition
[
'software_type'
]
if
not
partition
[
'slave_instance_list'
]
==
None
:
if
partition
[
'slave_instance_list'
]
is
not
None
:
slap_partition
.
_parameter_dict
[
'slave_instance_list'
]
=
\
xml_marshaller
.
xml_marshaller
.
loads
(
partition
[
'slave_instance_list'
])
slap_partition
.
_connection_dict
=
xml2dict
(
partition
[
'connection_xml'
])
...
...
@@ -124,6 +126,7 @@ def before_request():
g
.
db
.
cursor
().
executescript
(
schema
)
g
.
db
.
commit
()
@
app
.
after_request
def
after_request
(
response
):
g
.
db
.
commit
()
...
...
@@ -379,7 +382,7 @@ def request_slave():
1. slave table having information such as slave reference,
connection information to slave (given by slave master),
hosted_by and asked_by reference.
2. A diction
n
ary in slave_instance_list of selected slave master
2. A dictionary in slave_instance_list of selected slave master
in which are stored slave_reference, software_type, slave_title and
partition_parameter_kw stored as individual keys.
"""
...
...
@@ -413,8 +416,7 @@ def request_slave():
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
if
partition
is
None
:
app
.
logger
.
warning
(
'No partition corresponding to slave request: %s'
%
\
args
)
app
.
logger
.
warning
(
'No partition corresponding to slave request: %s'
%
args
)
abort
(
404
)
# We set slave dictionary as described in docstring
...
...
@@ -424,13 +426,13 @@ def request_slave():
new_slave
[
'slap_software_type'
]
=
software_type
new_slave
[
'slave_reference'
]
=
slave_reference
for
key
in
partition_parameter_kw
:
if
partition_parameter_kw
[
key
]
is
not
None
:
for
key
in
partition_parameter_kw
:
if
partition_parameter_kw
[
key
]
is
not
None
:
new_slave
[
key
]
=
partition_parameter_kw
[
key
]
# Add slave to partition slave_list if not present else replace information
slave_instance_list
=
partition
[
'slave_instance_list'
]
if
slave_instance_list
==
None
:
if
slave_instance_list
is
None
:
slave_instance_list
=
[]
else
:
slave_instance_list
=
xml_marshaller
.
xml_marshaller
.
loads
(
slave_instance_list
)
...
...
@@ -455,12 +457,12 @@ def request_slave():
# Add slave to slave table if not there
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
[
slave_reference
],
one
=
True
)
if
slave
is
None
:
if
slave
is
None
:
execute_db
(
'slave'
,
'INSERT OR IGNORE INTO %s (reference,asked_by,hosted_by) values(:reference,:asked_by,:hosted_by)'
,
[
slave_reference
,
partition_id
,
partition
[
'reference'
]])
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
[
slave_reference
],
one
=
True
)
[
slave_reference
,
partition_id
,
partition
[
'reference'
]])
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
[
slave_reference
],
one
=
True
)
address_list
=
[]
for
address
in
execute_db
(
'partition_network'
,
...
...
@@ -471,7 +473,7 @@ def request_slave():
# XXX it should be ComputerPartition, not a SoftwareInstance
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
_connection_dict
=
xml2dict
(
slave
[
'connection_xml'
]),
xml
=
instance_xml
,
xml
=
instance_xml
,
slap_computer_id
=
app
.
config
[
'computer_id'
],
slap_computer_partition_id
=
slave
[
'hosted_by'
],
slap_software_release_url
=
partition
[
'software_release'
],
...
...
@@ -479,4 +481,3 @@ def request_slave():
slap_software_type
=
partition
[
'software_type'
],
ip_list
=
address_list
))
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