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
c2d5a1eb
Commit
c2d5a1eb
authored
Jun 01, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass connection helper as a constructor parameter, not as class property.
Gets rid of the last class property in this file.
parent
5629ac03
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
13 deletions
+32
-13
slapos/slap/slap.py
slapos/slap/slap.py
+32
-13
No files found.
slapos/slap/slap.py
View file @
c2d5a1eb
...
@@ -64,7 +64,11 @@ class HTTPSConnectionCA(httplib.HTTPSConnection):
...
@@ -64,7 +64,11 @@ class HTTPSConnectionCA(httplib.HTTPSConnection):
class
SlapDocument
:
class
SlapDocument
:
pass
def
__init__
(
self
,
connection_helper
=
None
):
if
connection_helper
is
not
None
:
# Do not require connection_helper to be provided, but when it's not,
# cause failures when accessing _connection_helper property.
self
.
_connection_helper
=
connection_helper
class
SoftwareRelease
(
SlapDocument
):
class
SoftwareRelease
(
SlapDocument
):
"""
"""
...
@@ -79,6 +83,7 @@ class SoftwareRelease(SlapDocument):
...
@@ -79,6 +83,7 @@ class SoftwareRelease(SlapDocument):
XXX **kw args only kept for compatibility
XXX **kw args only kept for compatibility
"""
"""
SlapDocument
.
__init__
(
self
,
kw
.
pop
(
'connection_helper'
,
None
))
self
.
_software_instance_list
=
[]
self
.
_software_instance_list
=
[]
if
software_release
is
not
None
:
if
software_release
is
not
None
:
software_release
=
software_release
.
encode
(
'UTF-8'
)
software_release
=
software_release
.
encode
(
'UTF-8'
)
...
@@ -179,13 +184,18 @@ class OpenOrder(SlapDocument):
...
@@ -179,13 +184,18 @@ class OpenOrder(SlapDocument):
try
:
try
:
self
.
_connection_helper
.
POST
(
'/requestComputerPartition'
,
request_dict
)
self
.
_connection_helper
.
POST
(
'/requestComputerPartition'
,
request_dict
)
except
ResourceNotReady
:
except
ResourceNotReady
:
return
ComputerPartition
(
request_dict
=
request_dict
)
return
ComputerPartition
(
request_dict
=
request_dict
,
connection_helper
=
self
.
_connection_helper
,
)
else
:
else
:
xml
=
self
.
_connection_helper
.
response
.
read
()
xml
=
self
.
_connection_helper
.
response
.
read
()
software_instance
=
xml_marshaller
.
loads
(
xml
)
software_instance
=
xml_marshaller
.
loads
(
xml
)
computer_partition
=
ComputerPartition
(
computer_partition
=
ComputerPartition
(
software_instance
.
slap_computer_id
.
encode
(
'UTF-8'
),
software_instance
.
slap_computer_id
.
encode
(
'UTF-8'
),
software_instance
.
slap_computer_partition_id
.
encode
(
'UTF-8'
))
software_instance
.
slap_computer_partition_id
.
encode
(
'UTF-8'
),
connection_helper
=
self
.
_connection_helper
,
)
if
shared
:
if
shared
:
computer_partition
.
_synced
=
True
computer_partition
.
_synced
=
True
computer_partition
.
_connection_dict
=
software_instance
.
_connection_dict
computer_partition
.
_connection_dict
=
software_instance
.
_connection_dict
...
@@ -211,7 +221,8 @@ class Computer(SlapDocument):
...
@@ -211,7 +221,8 @@ class Computer(SlapDocument):
zope
.
interface
.
implements
(
interface
.
IComputer
)
zope
.
interface
.
implements
(
interface
.
IComputer
)
def
__init__
(
self
,
computer_id
):
def
__init__
(
self
,
computer_id
,
connection_helper
=
None
):
SlapDocument
.
__init__
(
self
,
connection_helper
)
self
.
_computer_id
=
computer_id
self
.
_computer_id
=
computer_id
def
__getinitargs__
(
self
):
def
__getinitargs__
(
self
):
...
@@ -298,7 +309,9 @@ class ComputerPartition(SlapDocument):
...
@@ -298,7 +309,9 @@ class ComputerPartition(SlapDocument):
zope
.
interface
.
implements
(
interface
.
IComputerPartition
)
zope
.
interface
.
implements
(
interface
.
IComputerPartition
)
def
__init__
(
self
,
computer_id
=
None
,
partition_id
=
None
,
request_dict
=
None
):
def
__init__
(
self
,
computer_id
=
None
,
partition_id
=
None
,
request_dict
=
None
,
connection_helper
=
None
):
SlapDocument
.
__init__
(
self
,
connection_helper
)
if
request_dict
is
not
None
and
(
computer_id
is
not
None
or
if
request_dict
is
not
None
and
(
computer_id
is
not
None
or
partition_id
is
not
None
):
partition_id
is
not
None
):
raise
TypeError
(
'request_dict conflicts with computer_id and '
raise
TypeError
(
'request_dict conflicts with computer_id and '
...
@@ -348,13 +361,18 @@ class ComputerPartition(SlapDocument):
...
@@ -348,13 +361,18 @@ class ComputerPartition(SlapDocument):
try
:
try
:
self
.
_connection_helper
.
POST
(
'/requestComputerPartition'
,
request_dict
)
self
.
_connection_helper
.
POST
(
'/requestComputerPartition'
,
request_dict
)
except
ResourceNotReady
:
except
ResourceNotReady
:
return
ComputerPartition
(
request_dict
=
request_dict
)
return
ComputerPartition
(
request_dict
=
request_dict
,
connection_helper
=
self
.
_connection_helper
,
)
else
:
else
:
xml
=
self
.
_connection_helper
.
response
.
read
()
xml
=
self
.
_connection_helper
.
response
.
read
()
software_instance
=
xml_marshaller
.
loads
(
xml
)
software_instance
=
xml_marshaller
.
loads
(
xml
)
computer_partition
=
ComputerPartition
(
computer_partition
=
ComputerPartition
(
software_instance
.
slap_computer_id
.
encode
(
'UTF-8'
),
software_instance
.
slap_computer_id
.
encode
(
'UTF-8'
),
software_instance
.
slap_computer_partition_id
.
encode
(
'UTF-8'
))
software_instance
.
slap_computer_partition_id
.
encode
(
'UTF-8'
),
connection_helper
=
self
.
_connection_helper
,
)
if
shared
:
if
shared
:
computer_partition
.
_synced
=
True
computer_partition
.
_synced
=
True
computer_partition
.
_connection_dict
=
getattr
(
software_instance
,
computer_partition
.
_connection_dict
=
getattr
(
software_instance
,
...
@@ -596,8 +614,7 @@ class slap:
...
@@ -596,8 +614,7 @@ class slap:
else
:
else
:
raise
AttributeError
(
'Passed URL %r issue: there is no support for %r p'
raise
AttributeError
(
'Passed URL %r issue: there is no support for %r p'
'rotocol'
%
(
slapgrid_uri
,
scheme
))
'rotocol'
%
(
slapgrid_uri
,
scheme
))
slap
.
_connection_helper
=
\
self
.
_connection_helper
=
ConnectionHelper
(
connection_wrapper
,
SlapDocument
.
_connection_helper
=
ConnectionHelper
(
connection_wrapper
,
netloc
,
path
,
key_file
,
cert_file
,
master_ca_file
,
timeout
)
netloc
,
path
,
key_file
,
cert_file
,
master_ca_file
,
timeout
)
def
registerSoftwareRelease
(
self
,
software_release
):
def
registerSoftwareRelease
(
self
,
software_release
):
...
@@ -605,14 +622,16 @@ class slap:
...
@@ -605,14 +622,16 @@ class slap:
Registers connected representation of software release and
Registers connected representation of software release and
returns SoftwareRelease class object
returns SoftwareRelease class object
"""
"""
return
SoftwareRelease
(
software_release
=
software_release
)
return
SoftwareRelease
(
software_release
=
software_release
,
connection_helper
=
self
.
_connection_helper
,
)
def
registerComputer
(
self
,
computer_guid
):
def
registerComputer
(
self
,
computer_guid
):
"""
"""
Registers connected representation of computer and
Registers connected representation of computer and
returns Computer class object
returns Computer class object
"""
"""
return
Computer
(
computer_guid
)
return
Computer
(
computer_guid
,
connection_helper
=
self
.
_connection_helper
)
def
registerComputerPartition
(
self
,
computer_guid
,
partition_id
):
def
registerComputerPartition
(
self
,
computer_guid
,
partition_id
):
"""
"""
...
@@ -625,7 +644,7 @@ class slap:
...
@@ -625,7 +644,7 @@ class slap:
return
xml_marshaller
.
loads
(
self
.
_connection_helper
.
response
.
read
())
return
xml_marshaller
.
loads
(
self
.
_connection_helper
.
response
.
read
())
def
registerOpenOrder
(
self
):
def
registerOpenOrder
(
self
):
return
OpenOrder
()
return
OpenOrder
(
connection_helper
=
self
.
_connection_helper
)
def
registerSupply
(
self
):
def
registerSupply
(
self
):
return
Supply
()
return
Supply
(
connection_helper
=
self
.
_connection_helper
)
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