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
5a2a0d57
Commit
5a2a0d57
authored
Nov 27, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/proxy_instance_guid'
parents
6a1d6116
472f13f0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
42 deletions
+88
-42
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+12
-5
slapos/proxy/schema.sql
slapos/proxy/schema.sql
+3
-2
slapos/proxy/views.py
slapos/proxy/views.py
+69
-30
slapos/slap/__init__.py
slapos/slap/__init__.py
+1
-1
slapos/slap/interface/slap.py
slapos/slap/interface/slap.py
+1
-1
slapos/slap/slap.py
slapos/slap/slap.py
+2
-3
No files found.
slapos/grid/slapgrid.py
View file @
5a2a0d57
...
...
@@ -70,6 +70,8 @@ MANDATORY_PARAMETER_LIST = [
]
COMPUTER_PARTITION_DESTROYED_STATE
=
'destroyed'
COMPUTER_PARTITION_STARTED_STATE
=
'started'
COMPUTER_PARTITION_STOPPED_STATE
=
'stopped'
# Global variables about return state of slapgrid
SLAPGRID_SUCCESS
=
0
...
...
@@ -773,16 +775,21 @@ class Slapgrid(object):
buildout
=
self
.
buildout
)
computer_partition_state
=
computer_partition
.
getState
()
if
computer_partition_state
==
"started"
:
if
computer_partition_state
==
COMPUTER_PARTITION_STARTED_STATE
:
local_partition
.
install
()
computer_partition
.
available
()
local_partition
.
start
()
self
.
_checkPromises
(
computer_partition
)
computer_partition
.
started
()
elif
computer_partition_state
==
"stopped"
:
local_partition
.
install
()
computer_partition
.
available
()
local_partition
.
stop
()
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
try
:
local_partition
.
install
()
computer_partition
.
available
()
except
Exception
:
raise
finally
:
# Instance has to be stopped even if buildout/reporting is wrong.
local_partition
.
stop
()
computer_partition
.
stopped
()
elif
computer_partition_state
==
COMPUTER_PARTITION_DESTROYED_STATE
:
local_partition
.
stop
()
...
...
slapos/proxy/schema.sql
View file @
5a2a0d57
--version:
9
--version:
10
CREATE
TABLE
IF
NOT
EXISTS
software
%
(
version
)
s
(
url
VARCHAR
(
255
)
UNIQUE
);
CREATE
TABLE
IF
NOT
EXISTS
computer
%
(
version
)
s
(
address
VARCHAR
(
255
),
...
...
@@ -14,7 +14,8 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
slave_instance_list
TEXT
,
software_type
VARCHAR
(
255
),
partition_reference
VARCHAR
(
255
),
requested_by
VARCHAR
(
255
)
requested_by
VARCHAR
(
255
),
requested_state
VARCHAR
(
255
)
NOT
NULL
DEFAULT
'started'
);
CREATE
TABLE
IF
NOT
EXISTS
slave
%
(
version
)
s
(
...
...
slapos/proxy/views.py
View file @
5a2a0d57
...
...
@@ -78,7 +78,7 @@ def partitiondict2partition(partition):
if
partition
[
'software_release'
]:
slap_partition
.
_need_modification
=
1
slap_partition
.
_requested_state
=
'started'
slap_partition
.
_requested_state
=
partition
[
'requested_state'
]
slap_partition
.
_parameter_dict
=
xml2dict
(
partition
[
'xml'
])
address_list
=
[]
for
address
in
execute_db
(
'partition_network'
,
...
...
@@ -272,33 +272,54 @@ def requestComputerPartition():
else
:
return
request_slave
()
@
app
.
route
(
'/softwareInstanceRename'
,
methods
=
[
'POST'
])
def
softwareInstanceRename
():
new_name
=
request
.
form
[
'new_name'
].
encode
()
computer_partition_id
=
request
.
form
[
'computer_partition_id'
].
encode
()
q
=
'UPDATE %s SET partition_reference = ? WHERE reference = ?'
execute_db
(
'partition'
,
q
,
[
new_name
,
computer_partition_id
])
return
'done'
def
request_not_shared
():
software_release
=
request
.
form
[
'software_release'
].
encode
()
# some supported parameters
software_type
=
request
.
form
.
get
(
'software_type'
,
'RootSoftwareInstance'
).
encode
()
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
()
partition_parameter_kw
=
request
.
form
.
get
(
'partition_parameter_xml'
,
None
)
requested_state
=
xml_marshaller
.
xml_marshaller
.
loads
(
request
.
form
.
get
(
'state'
))
if
partition_parameter_kw
:
partition_parameter_kw
=
xml_marshaller
.
xml_marshaller
.
loads
(
partition_parameter_kw
.
encode
())
else
:
partition_parameter_kw
=
{}
instance_xml
=
dict2xml
(
partition_parameter_kw
)
args
=
[]
a
=
args
.
append
q
=
'SELECT * FROM %s WHERE partition_reference=?'
a
(
partition_reference
)
if
partition_id
:
q
+=
' AND requested_by=?'
a
(
partition_id
)
#
# XXX the following filter breaks renaming asked by the bully script
#
# if partition_id:
# q += ' AND requested_by=?'
# a(partition_id)
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
args
=
[]
a
=
args
.
append
q
=
'UPDATE %s SET slap_state="busy"'
if
requested_state
:
q
+=
', requested_state=?'
a
(
requested_state
)
# If partition doesn't exist: create it and insert parameters
if
partition
is
None
:
partition
=
execute_db
(
'partition'
,
...
...
@@ -308,15 +329,21 @@ def request_not_shared():
abort
(
408
)
q
+=
' ,software_release=?'
a
(
software_release
)
if
software_type
:
q
+=
' ,software_type=?'
a
(
software_type
)
if
partition_reference
:
q
+=
' ,partition_reference=?'
a
(
partition_reference
)
if
partition_id
:
q
+=
' ,requested_by=?'
a
(
partition_id
)
if
not
software_type
:
software_type
=
'RootSoftwareInstance'
#
# XXX change software_type when requested
#
if
software_type
:
q
+=
' ,software_type=?'
a
(
software_type
)
# Else: only update partition_parameter_kw
if
instance_xml
:
...
...
@@ -331,17 +358,20 @@ def request_not_shared():
address_list
=
[]
for
address
in
execute_db
(
'partition_network'
,
'SELECT * FROM %s WHERE partition_reference=?'
,
[
partition
[
'reference'
]]):
address_list
.
append
((
address
[
'reference'
],
address
[
'address'
]))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
**
dict
(
xml
=
partition
[
'xml'
],
connection_xml
=
partition
[
'connection_xml'
],
slap_computer_id
=
app
.
config
[
'computer_id'
],
slap_computer_partition_id
=
partition
[
'reference'
],
slap_software_release_url
=
partition
[
'software_release'
],
slap_server_url
=
'slap_server_url'
,
slap_software_type
=
partition
[
'software_type'
],
slave_instance_list
=
partition
[
'slave_instance_list'
],
ip_list
=
address_list
)))
# XXX it should be ComputerPartition, not a SoftwareInstance
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
xml
=
partition
[
'xml'
],
connection_xml
=
partition
[
'connection_xml'
],
slap_computer_id
=
app
.
config
[
'computer_id'
],
slap_computer_partition_id
=
partition
[
'reference'
],
slap_software_release_url
=
partition
[
'software_release'
],
slap_server_url
=
'slap_server_url'
,
slap_software_type
=
partition
[
'software_type'
],
slave_instance_list
=
partition
[
'slave_instance_list'
],
instance_guid
=
partition
[
'reference'
],
ip_list
=
address_list
))
abort
(
408
)
raise
NotImplementedError
...
...
@@ -369,6 +399,9 @@ def request_slave():
partition_parameter_kw
.
encode
())
else
:
partition_parameter_kw
=
{}
filter_kw
=
xml_marshaller
.
xml_marshaller
.
loads
(
request
.
form
.
get
(
'filter_xml'
).
encode
())
instance_xml
=
dict2xml
(
partition_parameter_kw
)
# We will search for a master corresponding to request
args
=
[]
...
...
@@ -378,6 +411,10 @@ def request_slave():
if
software_type
:
q
+=
' AND software_type=?'
a
(
software_type
)
if
'instance_guid'
in
filter_kw
:
q
+=
' AND reference=?'
a
(
filter_kw
[
'instance_guid'
])
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
if
partition
is
None
:
app
.
logger
.
warning
(
'No partition corresponding to slave request: %s'
%
\
...
...
@@ -434,13 +471,15 @@ def request_slave():
'SELECT * FROM %s WHERE partition_reference=?'
,
[
partition
[
'reference'
]]):
address_list
.
append
((
address
[
'reference'
],
address
[
'address'
]))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
**
dict
(
_connection_dict
=
xml2dict
(
slave
[
'connection_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'
],
slap_server_url
=
'slap_server_url'
,
slap_software_type
=
partition
[
'software_type'
],
ip_list
=
address_list
)))
# XXX it should be ComputerPartition, not a SoftwareInstance
return
xml_marshaller
.
xml_marshaller
.
dumps
(
SoftwareInstance
(
_connection_dict
=
xml2dict
(
slave
[
'connection_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'
],
slap_server_url
=
'slap_server_url'
,
slap_software_type
=
partition
[
'software_type'
],
ip_list
=
address_list
))
slapos/slap/__init__.py
View file @
5a2a0d57
...
...
@@ -28,6 +28,6 @@
import
sys
if
sys
.
version_info
<
(
2
,
6
):
import
warnings
warnings
.
warn
(
'Used python version (%s) is old and ha
ve
problems with'
warnings
.
warn
(
'Used python version (%s) is old and ha
s
problems with'
' IPv6 connections'
%
'.'
.
join
([
str
(
q
)
for
q
in
sys
.
version_info
[:
3
]]))
from
slap
import
*
slapos/slap/interface/slap.py
View file @
5a2a0d57
...
...
@@ -68,7 +68,7 @@ class IRequester(Interface):
def
request
(
software_release
,
software_type
,
partition_reference
,
shared
=
False
,
partition_parameter_kw
=
None
,
filter_kw
=
None
):
"""
Request software release instan
c
iation to slapgrid server.
Request software release instan
t
iation to slapgrid server.
Returns a new computer partition document, where this sofware release will
be installed.
...
...
slapos/slap/slap.py
View file @
5a2a0d57
...
...
@@ -115,9 +115,6 @@ class SoftwareRelease(SlapDocument):
'computer_id'
:
self
.
getComputerId
(),
'error_log'
:
error_log
})
def
getURI
(
self
):
return
self
.
_software_release
def
available
(
self
):
self
.
_connection_helper
.
POST
(
'/availableSoftwareRelease'
,
{
'url'
:
self
.
getURI
(),
...
...
@@ -193,6 +190,8 @@ class OpenOrder(SlapDocument):
'partition_reference'
:
partition_reference
,
'partition_parameter_xml'
:
xml_marshaller
.
dumps
(
partition_parameter_kw
),
'filter_xml'
:
xml_marshaller
.
dumps
(
filter_kw
),
# XXX Cedric: Why state and shared are marshalled? First is a string
# And second is a boolean.
'state'
:
xml_marshaller
.
dumps
(
state
),
'shared_xml'
:
xml_marshaller
.
dumps
(
shared
),
}
...
...
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