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
Łukasz Nowak
slapos.core
Commits
4da82657
Commit
4da82657
authored
Sep 05, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slap.py: send all POST data as form-encoded parameters
as part of the migration to 'requests'
parent
368486da
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
slapos/slap/slap.py
slapos/slap/slap.py
+21
-23
No files found.
slapos/slap/slap.py
View file @
4da82657
...
@@ -83,7 +83,7 @@ class SlapRequester(SlapDocument):
...
@@ -83,7 +83,7 @@ class SlapRequester(SlapDocument):
"""
"""
def
_requestComputerPartition
(
self
,
request_dict
):
def
_requestComputerPartition
(
self
,
request_dict
):
try
:
try
:
xml
=
self
.
_connection_helper
.
POST
(
'requestComputerPartition'
,
request_dict
)
xml
=
self
.
_connection_helper
.
POST
(
'requestComputerPartition'
,
data
=
request_dict
)
except
ResourceNotReady
:
except
ResourceNotReady
:
return
ComputerPartition
(
return
ComputerPartition
(
request_dict
=
request_dict
,
request_dict
=
request_dict
,
...
@@ -145,7 +145,7 @@ class SoftwareRelease(SlapDocument):
...
@@ -145,7 +145,7 @@ class SoftwareRelease(SlapDocument):
def
error
(
self
,
error_log
,
logger
=
None
):
def
error
(
self
,
error_log
,
logger
=
None
):
try
:
try
:
# Does not follow interface
# Does not follow interface
self
.
_connection_helper
.
POST
(
'softwareReleaseError'
,
{
self
.
_connection_helper
.
POST
(
'softwareReleaseError'
,
data
=
{
'url'
:
self
.
getURI
(),
'url'
:
self
.
getURI
(),
'computer_id'
:
self
.
getComputerId
(),
'computer_id'
:
self
.
getComputerId
(),
'error_log'
:
error_log
})
'error_log'
:
error_log
})
...
@@ -153,17 +153,17 @@ class SoftwareRelease(SlapDocument):
...
@@ -153,17 +153,17 @@ class SoftwareRelease(SlapDocument):
(
logger
or
fallback_logger
).
exception
(
''
)
(
logger
or
fallback_logger
).
exception
(
''
)
def
available
(
self
):
def
available
(
self
):
self
.
_connection_helper
.
POST
(
'availableSoftwareRelease'
,
{
self
.
_connection_helper
.
POST
(
'availableSoftwareRelease'
,
data
=
{
'url'
:
self
.
getURI
(),
'url'
:
self
.
getURI
(),
'computer_id'
:
self
.
getComputerId
()})
'computer_id'
:
self
.
getComputerId
()})
def
building
(
self
):
def
building
(
self
):
self
.
_connection_helper
.
POST
(
'buildingSoftwareRelease'
,
{
self
.
_connection_helper
.
POST
(
'buildingSoftwareRelease'
,
data
=
{
'url'
:
self
.
getURI
(),
'url'
:
self
.
getURI
(),
'computer_id'
:
self
.
getComputerId
()})
'computer_id'
:
self
.
getComputerId
()})
def
destroyed
(
self
):
def
destroyed
(
self
):
self
.
_connection_helper
.
POST
(
'destroyedSoftwareRelease'
,
{
self
.
_connection_helper
.
POST
(
'destroyedSoftwareRelease'
,
data
=
{
'url'
:
self
.
getURI
(),
'url'
:
self
.
getURI
(),
'computer_id'
:
self
.
getComputerId
()})
'computer_id'
:
self
.
getComputerId
()})
...
@@ -227,7 +227,7 @@ class Supply(SlapDocument):
...
@@ -227,7 +227,7 @@ class Supply(SlapDocument):
def
supply
(
self
,
software_release
,
computer_guid
=
None
,
state
=
'available'
):
def
supply
(
self
,
software_release
,
computer_guid
=
None
,
state
=
'available'
):
try
:
try
:
self
.
_connection_helper
.
POST
(
'supplySupply'
,
{
self
.
_connection_helper
.
POST
(
'supplySupply'
,
data
=
{
'url'
:
software_release
,
'url'
:
software_release
,
'computer_id'
:
computer_guid
,
'computer_id'
:
computer_guid
,
'state'
:
state
})
'state'
:
state
})
...
@@ -267,8 +267,7 @@ class OpenOrder(SlapRequester):
...
@@ -267,8 +267,7 @@ class OpenOrder(SlapRequester):
"""
"""
Requests a computer.
Requests a computer.
"""
"""
xml
=
self
.
_connection_helper
.
POST
(
'requestComputer'
,
xml
=
self
.
_connection_helper
.
POST
(
'requestComputer'
,
data
=
{
'computer_title'
:
computer_reference
})
{
'computer_title'
:
computer_reference
})
computer
=
xml_marshaller
.
loads
(
xml
)
computer
=
xml_marshaller
.
loads
(
xml
)
computer
.
_connection_helper
=
self
.
_connection_helper
computer
.
_connection_helper
=
self
.
_connection_helper
return
computer
return
computer
...
@@ -326,16 +325,15 @@ class Computer(SlapDocument):
...
@@ -326,16 +325,15 @@ class Computer(SlapDocument):
def
reportUsage
(
self
,
computer_usage
):
def
reportUsage
(
self
,
computer_usage
):
if
computer_usage
==
""
:
if
computer_usage
==
""
:
return
return
self
.
_connection_helper
.
POST
(
'useComputer'
,
{
self
.
_connection_helper
.
POST
(
'useComputer'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'use_string'
:
computer_usage
})
'use_string'
:
computer_usage
})
def
updateConfiguration
(
self
,
xml
):
def
updateConfiguration
(
self
,
xml
):
return
self
.
_connection_helper
.
POST
(
return
self
.
_connection_helper
.
POST
(
'loadComputerConfigurationFromXML'
,
data
=
{
'xml'
:
xml
})
'loadComputerConfigurationFromXML'
,
data
=
{
'xml'
:
xml
})
def
bang
(
self
,
message
):
def
bang
(
self
,
message
):
self
.
_connection_helper
.
POST
(
'computerBang'
,
{
self
.
_connection_helper
.
POST
(
'computerBang'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'message'
:
message
})
'message'
:
message
})
...
@@ -344,11 +342,11 @@ class Computer(SlapDocument):
...
@@ -344,11 +342,11 @@ class Computer(SlapDocument):
return
xml_marshaller
.
loads
(
xml
)
return
xml_marshaller
.
loads
(
xml
)
def
revokeCertificate
(
self
):
def
revokeCertificate
(
self
):
self
.
_connection_helper
.
POST
(
'revokeComputerCertificate'
,
{
self
.
_connection_helper
.
POST
(
'revokeComputerCertificate'
,
data
=
{
'computer_id'
:
self
.
_computer_id
})
'computer_id'
:
self
.
_computer_id
})
def
generateCertificate
(
self
):
def
generateCertificate
(
self
):
xml
=
self
.
_connection_helper
.
POST
(
'generateComputerCertificate'
,
{
xml
=
self
.
_connection_helper
.
POST
(
'generateComputerCertificate'
,
data
=
{
'computer_id'
:
self
.
_computer_id
})
'computer_id'
:
self
.
_computer_id
})
return
xml_marshaller
.
loads
(
xml
)
return
xml_marshaller
.
loads
(
xml
)
...
@@ -420,36 +418,36 @@ class ComputerPartition(SlapRequester):
...
@@ -420,36 +418,36 @@ class ComputerPartition(SlapRequester):
return
self
.
_requestComputerPartition
(
request_dict
)
return
self
.
_requestComputerPartition
(
request_dict
)
def
building
(
self
):
def
building
(
self
):
self
.
_connection_helper
.
POST
(
'buildingComputerPartition'
,
{
self
.
_connection_helper
.
POST
(
'buildingComputerPartition'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
()})
'computer_partition_id'
:
self
.
getId
()})
def
available
(
self
):
def
available
(
self
):
self
.
_connection_helper
.
POST
(
'availableComputerPartition'
,
{
self
.
_connection_helper
.
POST
(
'availableComputerPartition'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
()})
'computer_partition_id'
:
self
.
getId
()})
def
destroyed
(
self
):
def
destroyed
(
self
):
self
.
_connection_helper
.
POST
(
'destroyedComputerPartition'
,
{
self
.
_connection_helper
.
POST
(
'destroyedComputerPartition'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
})
})
def
started
(
self
):
def
started
(
self
):
self
.
_connection_helper
.
POST
(
'startedComputerPartition'
,
{
self
.
_connection_helper
.
POST
(
'startedComputerPartition'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
})
})
def
stopped
(
self
):
def
stopped
(
self
):
self
.
_connection_helper
.
POST
(
'stoppedComputerPartition'
,
{
self
.
_connection_helper
.
POST
(
'stoppedComputerPartition'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
})
})
def
error
(
self
,
error_log
,
logger
=
None
):
def
error
(
self
,
error_log
,
logger
=
None
):
try
:
try
:
self
.
_connection_helper
.
POST
(
'softwareInstanceError'
,
{
self
.
_connection_helper
.
POST
(
'softwareInstanceError'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
'error_log'
:
error_log
})
'error_log'
:
error_log
})
...
@@ -457,7 +455,7 @@ class ComputerPartition(SlapRequester):
...
@@ -457,7 +455,7 @@ class ComputerPartition(SlapRequester):
(
logger
or
fallback_logger
).
exception
(
''
)
(
logger
or
fallback_logger
).
exception
(
''
)
def
bang
(
self
,
message
):
def
bang
(
self
,
message
):
self
.
_connection_helper
.
POST
(
'softwareInstanceBang'
,
{
self
.
_connection_helper
.
POST
(
'softwareInstanceBang'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
'message'
:
message
})
'message'
:
message
})
...
@@ -470,7 +468,7 @@ class ComputerPartition(SlapRequester):
...
@@ -470,7 +468,7 @@ class ComputerPartition(SlapRequester):
}
}
if
slave_reference
:
if
slave_reference
:
post_dict
[
'slave_reference'
]
=
slave_reference
post_dict
[
'slave_reference'
]
=
slave_reference
self
.
_connection_helper
.
POST
(
'softwareInstanceRename'
,
post_dict
)
self
.
_connection_helper
.
POST
(
'softwareInstanceRename'
,
data
=
post_dict
)
def
getId
(
self
):
def
getId
(
self
):
if
not
getattr
(
self
,
'_partition_id'
,
None
):
if
not
getattr
(
self
,
'_partition_id'
,
None
):
...
@@ -524,7 +522,7 @@ class ComputerPartition(SlapRequester):
...
@@ -524,7 +522,7 @@ class ComputerPartition(SlapRequester):
def
setConnectionDict
(
self
,
connection_dict
,
slave_reference
=
None
):
def
setConnectionDict
(
self
,
connection_dict
,
slave_reference
=
None
):
if
self
.
getConnectionParameterDict
()
!=
connection_dict
:
if
self
.
getConnectionParameterDict
()
!=
connection_dict
:
self
.
_connection_helper
.
POST
(
'setComputerPartitionConnectionXml'
,
{
self
.
_connection_helper
.
POST
(
'setComputerPartitionConnectionXml'
,
data
=
{
'computer_id'
:
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
'computer_partition_id'
:
self
.
_partition_id
,
'computer_partition_id'
:
self
.
_partition_id
,
'connection_xml'
:
xml_marshaller
.
dumps
(
connection_dict
),
'connection_xml'
:
xml_marshaller
.
dumps
(
connection_dict
),
...
...
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