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
Ophélie Gagnard
slapos.core
Commits
845652db
Commit
845652db
authored
Aug 06, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable security for local cache, allows to develop quickly
parent
726cda79
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+1
-6
slapos/slap/slap.py
slapos/slap/slap.py
+13
-8
No files found.
slapos/grid/slapgrid.py
View file @
845652db
...
@@ -231,12 +231,7 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -231,12 +231,7 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
).
split
(
'
\
n
'
)
if
url
]
).
split
(
'
\
n
'
)
if
url
]
# Set local cache option, use default one if not defined
# Set local cache option, use default one if not defined
# XXX-Cedric: put one cache per cp/sr/ur
local_cache
=
option_dict
.
get
(
'local-cache'
,
'/opt/slapos/cache'
)
# XXX-Cedric: clean after run
local_cache
=
option_dict
.
get
(
'local-cache'
,
# We put by default on instance_root, because we know this path
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'cache'
))
# XXX-Cedric should be shutil.mkdtemp())
# Clean old rubbish cache
# Clean old rubbish cache
if
os
.
path
.
exists
(
local_cache
):
if
os
.
path
.
exists
(
local_cache
):
shutil
.
rmtree
(
local_cache
)
shutil
.
rmtree
(
local_cache
)
...
...
slapos/slap/slap.py
View file @
845652db
...
@@ -572,6 +572,7 @@ class ConnectionHelper:
...
@@ -572,6 +572,7 @@ class ConnectionHelper:
if
self
.
cache_location
and
not
os
.
path
.
exists
(
computer_cache_location
):
if
self
.
cache_location
and
not
os
.
path
.
exists
(
computer_cache_location
):
cache
=
self
.
response
.
read
()
cache
=
self
.
response
.
read
()
open
(
computer_cache_location
,
"w"
).
write
(
cache
)
open
(
computer_cache_location
,
"w"
).
write
(
cache
)
os
.
chmod
(
computer_cache_location
,
0777
)
return
xml_marshaller
.
loads
(
cache
)
return
xml_marshaller
.
loads
(
cache
)
return
xml_marshaller
.
loads
(
self
.
response
.
read
())
return
xml_marshaller
.
loads
(
self
.
response
.
read
())
...
@@ -654,6 +655,8 @@ class slap:
...
@@ -654,6 +655,8 @@ class slap:
zope
.
interface
.
implements
(
interface
.
slap
)
zope
.
interface
.
implements
(
interface
.
slap
)
def
__init__
(
self
,
cache_location
=
None
):
def
__init__
(
self
,
cache_location
=
None
):
self
.
cache_location
=
cache_location
self
.
cache_location
=
cache_location
if
cache_location
is
None
:
self
.
cache_location
=
'/opt/slapos/cache'
def
initializeConnection
(
self
,
slapgrid_uri
,
key_file
=
None
,
cert_file
=
None
,
def
initializeConnection
(
self
,
slapgrid_uri
,
key_file
=
None
,
cert_file
=
None
,
master_ca_file
=
None
,
timeout
=
60
):
master_ca_file
=
None
,
timeout
=
60
):
...
@@ -700,20 +703,22 @@ class slap:
...
@@ -700,20 +703,22 @@ class slap:
"""
"""
# If local cache directory location is defined: we'll use a file inside it
# If local cache directory location is defined: we'll use a file inside it
if
self
.
cache_location
:
if
self
.
cache_location
:
partition
_cache_location
=
os
.
path
.
join
(
self
.
cache_location
,
computer
_cache_location
=
os
.
path
.
join
(
self
.
cache_location
,
'
partition%s%s.xml'
%
(
computer_guid
,
partition_id
)
)
'
computer.xml'
)
# If cache for this partition exists: use it
# If cache for this partition exists: use it
if
self
.
cache_location
and
os
.
path
.
exists
(
partition_cache_location
):
if
self
.
cache_location
and
os
.
path
.
exists
(
computer_cache_location
):
xml_result
=
open
(
partition_cache_location
,
"r"
).
read
()
xml_result
=
open
(
computer_cache_location
,
"r"
).
read
()
computer
=
xml_marshaller
.
loads
(
xml_result
)
computer
.
_connection_helper
=
self
.
_connection_helper
for
instance
in
computer
.
getComputerPartitionList
():
if
instance
.
getId
()
==
partition_id
:
result
=
instance
# Otherwise: go to server
# Otherwise: go to server
else
:
else
:
self
.
_connection_helper
.
GET
(
'/registerComputerPartition?'
\
self
.
_connection_helper
.
GET
(
'/registerComputerPartition?'
\
'computer_reference=%s&computer_partition_reference=%s'
%
(
'computer_reference=%s&computer_partition_reference=%s'
%
(
computer_guid
,
partition_id
))
computer_guid
,
partition_id
))
xml_result
=
self
.
_connection_helper
.
response
.
read
()
xml_result
=
self
.
_connection_helper
.
response
.
read
()
# If cache is defined, let's write it.
if
self
.
cache_location
and
not
os
.
path
.
exists
(
partition_cache_location
):
open
(
partition_cache_location
,
"w"
).
write
(
xml_result
)
result
=
xml_marshaller
.
loads
(
xml_result
)
result
=
xml_marshaller
.
loads
(
xml_result
)
# XXX: dirty hack to make computer partition usable. xml_marshaller is too
# XXX: dirty hack to make computer partition usable. xml_marshaller is too
# low-level for our needs here.
# low-level for our needs here.
...
...
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