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
Jérome Perrin
slapos.core
Commits
ebeb22c3
Commit
ebeb22c3
authored
May 02, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide the _instance_guid and _requested_state in request result.
parent
6581791a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
3 deletions
+85
-3
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+78
-0
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+6
-2
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
ebeb22c3
...
...
@@ -2167,6 +2167,84 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
if
os
.
path
.
exists
(
self
.
instance_request_simulator
):
os
.
unlink
(
self
.
instance_request_simulator
)
def
test_request_allocated_instance
(
self
):
self
.
tic
()
self
.
person
.
edit
(
default_email_coordinate_text
=
"%s@example.org"
%
self
.
person
.
getReference
(),
career_role
=
'member'
,
)
self
.
_makeComplexComputer
(
person
=
self
.
person
)
self
.
start_requested_software_instance
.
updateLocalRolesOnSecurityGroups
()
self
.
tic
()
self
.
login
(
self
.
person_reference
)
response
=
self
.
portal_slap
.
requestComputerPartition
(
software_release
=
self
.
start_requested_software_instance
.
getUrlString
(),
software_type
=
self
.
start_requested_software_instance
.
getSourceReference
(),
partition_reference
=
self
.
start_requested_software_instance
.
getTitle
(),
partition_parameter_xml
=
'<marshal><dictionary id="i2"/></marshal>'
,
filter_xml
=
'<marshal><dictionary id="i2"/></marshal>'
,
state
=
'<marshal><string>started</string></marshal>'
,
shared_xml
=
'<marshal><bool>0</bool></marshal>'
,
)
self
.
assertEqual
(
type
(
response
),
str
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<object id='i2' module='slapos.slap.slap' class='SoftwareInstance'>
<tuple/>
<dictionary id='i3'>
<string>_connection_dict</string>
<dictionary id='i4'/>
<string>_instance_guid</string>
<string>%(instance_guid)s</string>
<string>_parameter_dict</string>
<dictionary id='i5'/>
<string>_requested_state</string>
<string>%(state)s</string>
<string>ip_list</string>
<list id='i6'>
<tuple>
<string/>
<string>%(ip)s</string>
</tuple>
</list>
<string>slap_computer_id</string>
<string>%(computer_id)s</string>
<string>slap_computer_partition_id</string>
<string>%(partition_id)s</string>
<string>slap_software_release_url</string>
<string>%(url_string)s</string>
<string>slap_software_type</string>
<string>%(type)s</string>
<string>slave_instance_list</string>
<list id='i7'/>
<string>timestamp</string>
<string>%(timestamp)s</string>
</dictionary>
</object>
</marshal>
"""
%
dict
(
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
state
=
"started"
,
url_string
=
self
.
start_requested_software_instance
.
getUrlString
(),
type
=
self
.
start_requested_software_instance
.
getSourceReference
(),
timestamp
=
int
(
self
.
start_requested_software_instance
.
getModificationDate
()),
computer_id
=
self
.
computer_id
,
partition_id
=
self
.
start_requested_software_instance
.
getAggregateId
(),
ip
=
self
.
start_requested_software_instance
.
getAggregateValue
()
\
.
getDefaultNetworkAddressIpAddress
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
assertSupplySimulator
(
self
,
args
,
kwargs
):
stored
=
eval
(
open
(
self
.
computer_supply_simulator
).
read
())
# do the same translation magic as in workflow
...
...
master/bt5/slapos_slap_tool/bt/revision
View file @
ebeb22c3
24
\ No newline at end of file
25
\ No newline at end of file
master/product/Vifib/Tool/SlapTool.py
View file @
ebeb22c3
...
...
@@ -654,7 +654,6 @@ class SlapTool(BaseTool):
computer_partition_document
.
getRelativeUrl
())
if
software_instance
is
not
None
:
slap_partition
.
_instance_guid
=
software_instance
.
getReference
()
# trick client side, that data has been synchronised already for given
# document
slap_partition
.
_synced
=
True
...
...
@@ -677,6 +676,7 @@ class SlapTool(BaseTool):
parameter_dict
.
pop
(
'xml'
))
slap_partition
.
_connection_dict
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'connection_xml'
))
slap_partition
.
_instance_guid
=
parameter_dict
.
pop
(
'instance_guid'
)
for
slave_instance_dict
in
parameter_dict
.
get
(
"slave_instance_list"
,
[]):
if
slave_instance_dict
.
has_key
(
"connection_xml"
):
slave_instance_dict
.
update
(
self
.
_instanceXmlToDict
(
...
...
@@ -788,7 +788,6 @@ class SlapTool(BaseTool):
computer_partition_document
.
getRelativeUrl
())
if
software_instance
is
not
None
:
slap_partition
.
_instance_guid
=
software_instance
.
getReference
()
state
=
software_instance
.
getSlapState
()
if
state
==
"stop_requested"
:
slap_partition
.
_requested_state
=
'stopped'
...
...
@@ -808,6 +807,7 @@ class SlapTool(BaseTool):
parameter_dict
.
pop
(
'xml'
))
slap_partition
.
_connection_dict
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'connection_xml'
))
slap_partition
.
_instance_guid
=
parameter_dict
.
pop
(
'instance_guid'
)
for
slave_instance_dict
in
parameter_dict
.
get
(
"slave_instance_list"
,
[]):
if
slave_instance_dict
.
has_key
(
"connection_xml"
):
slave_instance_dict
.
update
(
self
.
_instanceXmlToDict
(
...
...
@@ -1176,10 +1176,13 @@ class SlapTool(BaseTool):
parameter_dict
.
pop
(
'xml'
))
connection_xml
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'connection_xml'
))
instance_guid
=
parameter_dict
.
pop
(
'instance_guid'
)
software_instance
=
SoftwareInstance
(
**
parameter_dict
)
software_instance
.
_parameter_dict
=
xml
software_instance
.
_connection_dict
=
connection_xml
software_instance
.
_requested_state
=
state
software_instance
.
_instance_guid
=
instance_guid
return
xml_marshaller
.
xml_marshaller
.
dumps
(
software_instance
)
####################################################
...
...
@@ -1320,6 +1323,7 @@ class SlapTool(BaseTool):
if
(
newtimestamp
>
timestamp
):
timestamp
=
newtimestamp
return
{
'instance_guid'
:
software_instance
.
getReference
(),
'xml'
:
software_instance
.
getTextContent
(),
'connection_xml'
:
software_instance
.
getConnectionXml
(),
'slap_computer_id'
:
computer_partition
.
getParentValue
().
getReference
(),
...
...
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