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
Xiaowu Zhang
slapos.core
Commits
cea99f88
Commit
cea99f88
authored
Sep 20, 2012
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed: Update information for slave in slave list
parent
fbb680f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
slapos/proxy/views.py
slapos/proxy/views.py
+22
-6
No files found.
slapos/proxy/views.py
View file @
cea99f88
...
...
@@ -354,13 +354,21 @@ def request_not_shared():
def
request_slave
():
"""
Function to organise link between slave and master
Function to organise link between slave and master.
Slave information are stored in places:
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 dictionnary 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.
"""
software_release
=
request
.
form
[
'software_release'
].
encode
()
# some supported parameters
software_type
=
request
.
form
.
get
(
'software_type'
).
encode
()
partition_reference
=
request
.
form
.
get
(
'partition_reference'
,
''
).
encode
()
partition_id
=
request
.
form
.
get
(
'computer_partition_id'
,
''
).
encode
()
# Contain slave parameters to be given to slave master
partition_parameter_kw
=
request
.
form
.
get
(
'partition_parameter_xml'
,
None
)
if
partition_parameter_kw
:
partition_parameter_kw
=
xml_marshaller
.
xml_marshaller
.
loads
(
...
...
@@ -368,6 +376,7 @@ def request_slave():
else
:
partition_parameter_kw
=
{}
instance_xml
=
dict2xml
(
partition_parameter_kw
)
# We will search for a master corresponding to request
args
=
[]
a
=
args
.
append
q
=
'SELECT * FROM %s WHERE software_release=?'
...
...
@@ -379,24 +388,31 @@ def request_slave():
if
partition
is
None
:
app
.
logger
.
warning
(
'No partition corresponding to slave request'
)
abort
(
408
)
# Define Slave
# We set slave dictionnary as described in docstring
new_slave
=
{}
slave_reference
=
partition_id
+
'_'
+
partition_reference
new_slave
[
'slave_title'
]
=
slave_reference
new_slave
[
'slap_software_type'
]
=
software_type
new_slave
[
'slave_reference'
]
=
slave_reference
for
key
in
partition_parameter_kw
:
new_slave
[
key
]
=
partition_parameter_kw
[
key
]
if
partition_parameter_kw
[
key
]
is
not
None
:
new_slave
[
key
]
=
partition_parameter_kw
[
key
]
# Add slave to partition slave_list if not present
# Add slave to partition slave_list if not present
else replace information
slave_instance_list
=
partition
[
'slave_instance_list'
]
if
slave_instance_list
==
None
:
slave_instance_list
=
[]
else
:
slave_instance_list
=
xml_marshaller
.
xml_marshaller
.
loads
(
slave_instance_list
)
if
not
slave_reference
in
(
x
[
'slave_reference'
]
for
x
in
slave_instance_list
):
slave_instance_list
.
append
(
new_slave
)
for
x
in
slave_instance_list
:
if
x
[
'slave_reference'
]
==
slave_reference
:
slave_instance_list
.
remove
(
x
)
slave_instance_list
.
append
(
new_slave
)
# Update slave_instance_list in database
args
=
[]
a
=
args
.
append
q
=
'UPDATE %s SET slave_instance_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