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
Gabriel Monnerat
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
Show 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):
...
@@ -608,7 +608,7 @@ class Partition(object):
def
updateSupervisor
(
self
):
def
updateSupervisor
(
self
):
"""Forces supervisord to reload its configuration"""
"""Forces supervisord to reload its configuration"""
# Note: This method shall wait for results from supervisord
# 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.
# is going to be implemented on server side.
self
.
logger
.
debug
(
'Updating supervisord'
)
self
.
logger
.
debug
(
'Updating supervisord'
)
supervisor
=
self
.
getSupervisorRPC
()
supervisor
=
self
.
getSupervisorRPC
()
...
...
slapos/grid/utils.py
View file @
2530f76d
...
@@ -130,7 +130,7 @@ def getCleanEnvironment(logger, home_path='/tmp'):
...
@@ -130,7 +130,7 @@ def getCleanEnvironment(logger, home_path='/tmp'):
removed_env
.
append
(
k
)
removed_env
.
append
(
k
)
changed_env
[
'HOME'
]
=
env
[
'HOME'
]
=
home_path
changed_env
[
'HOME'
]
=
env
[
'HOME'
]
=
home_path
for
k
in
sorted
(
changed_env
.
iterkeys
()):
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
)))
logger
.
debug
(
'Removed from environment: %s'
%
', '
.
join
(
sorted
(
removed_env
)))
return
env
return
env
...
@@ -175,7 +175,7 @@ def dropPrivileges(uid, gid, logger):
...
@@ -175,7 +175,7 @@ def dropPrivileges(uid, gid, logger):
Do tests to check if dropping was successful and that no system call is able
Do tests to check if dropping was successful and that no system call is able
to re-raise dropped privileges
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
# XXX-Cedric: remove format / just do a print, otherwise formatting is done
# twice
# twice
...
@@ -327,7 +327,7 @@ def launchBuildout(path, buildout_binary, logger,
...
@@ -327,7 +327,7 @@ def launchBuildout(path, buildout_binary, logger,
def
updateFile
(
file_path
,
content
,
mode
=
0o600
):
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
altered
=
False
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
if
not
(
os
.
path
.
isfile
(
file_path
))
or
\
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
not
(
hashlib
.
md5
(
open
(
file_path
).
read
()).
digest
()
==
...
@@ -343,12 +343,12 @@ def updateFile(file_path, content, mode=0o600):
...
@@ -343,12 +343,12 @@ def updateFile(file_path, content, mode=0o600):
def
updateExecutable
(
executable_path
,
content
):
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
)
return
updateFile
(
executable_path
,
content
,
0o700
)
def
createPrivateDirectory
(
path
):
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
):
if
not
os
.
path
.
isdir
(
path
):
os
.
mkdir
(
path
)
os
.
mkdir
(
path
)
os
.
chmod
(
path
,
stat
.
S_IREAD
|
stat
.
S_IWRITE
|
stat
.
S_IEXEC
)
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):
...
@@ -59,15 +59,17 @@ def xml2dict(xml):
return
result_dict
return
result_dict
def
dict2xml
(
diction
n
ary
):
def
dict2xml
(
dictionary
):
instance
=
etree
.
Element
(
'instance'
)
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
# cast everything to string
parameter_value
=
str
(
parameter_value
)
parameter_value
=
str
(
parameter_value
)
etree
.
SubElement
(
instance
,
"parameter"
,
etree
.
SubElement
(
instance
,
"parameter"
,
attrib
=
{
'id'
:
parameter_id
}).
text
=
parameter_value
attrib
=
{
'id'
:
parameter_id
}).
text
=
parameter_value
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
return
etree
.
tostring
(
instance
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
def
partitiondict2partition
(
partition
):
def
partitiondict2partition
(
partition
):
...
@@ -90,7 +92,7 @@ def partitiondict2partition(partition):
...
@@ -90,7 +92,7 @@ def partitiondict2partition(partition):
slap_partition
.
_parameter_dict
[
'ip_list'
]
=
address_list
slap_partition
.
_parameter_dict
[
'ip_list'
]
=
address_list
slap_partition
.
_parameter_dict
[
'slap_software_type'
]
=
\
slap_partition
.
_parameter_dict
[
'slap_software_type'
]
=
\
partition
[
'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'
]
=
\
slap_partition
.
_parameter_dict
[
'slave_instance_list'
]
=
\
xml_marshaller
.
xml_marshaller
.
loads
(
partition
[
'slave_instance_list'
])
xml_marshaller
.
xml_marshaller
.
loads
(
partition
[
'slave_instance_list'
])
slap_partition
.
_connection_dict
=
xml2dict
(
partition
[
'connection_xml'
])
slap_partition
.
_connection_dict
=
xml2dict
(
partition
[
'connection_xml'
])
...
@@ -124,6 +126,7 @@ def before_request():
...
@@ -124,6 +126,7 @@ def before_request():
g
.
db
.
cursor
().
executescript
(
schema
)
g
.
db
.
cursor
().
executescript
(
schema
)
g
.
db
.
commit
()
g
.
db
.
commit
()
@
app
.
after_request
@
app
.
after_request
def
after_request
(
response
):
def
after_request
(
response
):
g
.
db
.
commit
()
g
.
db
.
commit
()
...
@@ -379,7 +382,7 @@ def request_slave():
...
@@ -379,7 +382,7 @@ def request_slave():
1. slave table having information such as slave reference,
1. slave table having information such as slave reference,
connection information to slave (given by slave master),
connection information to slave (given by slave master),
hosted_by and asked_by reference.
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
in which are stored slave_reference, software_type, slave_title and
partition_parameter_kw stored as individual keys.
partition_parameter_kw stored as individual keys.
"""
"""
...
@@ -413,8 +416,7 @@ def request_slave():
...
@@ -413,8 +416,7 @@ def request_slave():
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
if
partition
is
None
:
if
partition
is
None
:
app
.
logger
.
warning
(
'No partition corresponding to slave request: %s'
%
\
app
.
logger
.
warning
(
'No partition corresponding to slave request: %s'
%
args
)
args
)
abort
(
404
)
abort
(
404
)
# We set slave dictionary as described in docstring
# We set slave dictionary as described in docstring
...
@@ -424,13 +426,13 @@ def request_slave():
...
@@ -424,13 +426,13 @@ def request_slave():
new_slave
[
'slap_software_type'
]
=
software_type
new_slave
[
'slap_software_type'
]
=
software_type
new_slave
[
'slave_reference'
]
=
slave_reference
new_slave
[
'slave_reference'
]
=
slave_reference
for
key
in
partition_parameter_kw
:
for
key
in
partition_parameter_kw
:
if
partition_parameter_kw
[
key
]
is
not
None
:
if
partition_parameter_kw
[
key
]
is
not
None
:
new_slave
[
key
]
=
partition_parameter_kw
[
key
]
new_slave
[
key
]
=
partition_parameter_kw
[
key
]
# Add slave to partition slave_list if not present else replace information
# Add slave to partition slave_list if not present else replace information
slave_instance_list
=
partition
[
'slave_instance_list'
]
slave_instance_list
=
partition
[
'slave_instance_list'
]
if
slave_instance_list
==
None
:
if
slave_instance_list
is
None
:
slave_instance_list
=
[]
slave_instance_list
=
[]
else
:
else
:
slave_instance_list
=
xml_marshaller
.
xml_marshaller
.
loads
(
slave_instance_list
)
slave_instance_list
=
xml_marshaller
.
xml_marshaller
.
loads
(
slave_instance_list
)
...
@@ -455,12 +457,12 @@ def request_slave():
...
@@ -455,12 +457,12 @@ def request_slave():
# Add slave to slave table if not there
# Add slave to slave table if not there
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
[
slave_reference
],
one
=
True
)
[
slave_reference
],
one
=
True
)
if
slave
is
None
:
if
slave
is
None
:
execute_db
(
'slave'
,
execute_db
(
'slave'
,
'INSERT OR IGNORE INTO %s (reference,asked_by,hosted_by) values(:reference,:asked_by,:hosted_by)'
,
'INSERT OR IGNORE INTO %s (reference,asked_by,hosted_by) values(:reference,:asked_by,:hosted_by)'
,
[
slave_reference
,
partition_id
,
partition
[
'reference'
]])
[
slave_reference
,
partition_id
,
partition
[
'reference'
]])
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
slave
=
execute_db
(
'slave'
,
'SELECT * FROM %s WHERE reference=?'
,
[
slave_reference
],
one
=
True
)
[
slave_reference
],
one
=
True
)
address_list
=
[]
address_list
=
[]
for
address
in
execute_db
(
'partition_network'
,
for
address
in
execute_db
(
'partition_network'
,
...
@@ -471,7 +473,7 @@ def request_slave():
...
@@ -471,7 +473,7 @@ def request_slave():
# XXX it should be ComputerPartition, not a SoftwareInstance
# XXX it should be ComputerPartition, not a SoftwareInstance
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
_connection_dict
=
xml2dict
(
slave
[
'connection_xml'
]),
_connection_dict
=
xml2dict
(
slave
[
'connection_xml'
]),
xml
=
instance_xml
,
xml
=
instance_xml
,
slap_computer_id
=
app
.
config
[
'computer_id'
],
slap_computer_id
=
app
.
config
[
'computer_id'
],
slap_computer_partition_id
=
slave
[
'hosted_by'
],
slap_computer_partition_id
=
slave
[
'hosted_by'
],
slap_software_release_url
=
partition
[
'software_release'
],
slap_software_release_url
=
partition
[
'software_release'
],
...
@@ -479,4 +481,3 @@ def request_slave():
...
@@ -479,4 +481,3 @@ def request_slave():
slap_software_type
=
partition
[
'software_type'
],
slap_software_type
=
partition
[
'software_type'
],
ip_list
=
address_list
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