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
Léo-Paul Géneau
slapos.core
Commits
2a081f07
Commit
2a081f07
authored
Jan 20, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'networkcache-debian' into cache-lookup
parents
e2f53cce
75b2d79c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
15 deletions
+73
-15
CHANGES.txt
CHANGES.txt
+2
-1
slapos/grid/distribution.py
slapos/grid/distribution.py
+65
-0
slapos/grid/networkcache.py
slapos/grid/networkcache.py
+6
-14
No files found.
CHANGES.txt
View file @
2a081f07
...
@@ -4,7 +4,8 @@ Changes
...
@@ -4,7 +4,8 @@ Changes
0.33.2 (unreleased)
0.33.2 (unreleased)
-------------------
-------------------
* networkcache: only match major release number in debian [Marco Mariani]
* networkcache: only match major release number in Debian,
fixed platform detection for Ubuntu [Marco Mariani]
* slapproxy: Filter by instance_guid, allow computer partition renames
* slapproxy: Filter by instance_guid, allow computer partition renames
and change of software_type and requested_state [Marco Mariani]
and change of software_type and requested_state [Marco Mariani]
* slapproxy: Stop instance even if buildout/reporting is wrong [Cedric de Saint Martin]
* slapproxy: Stop instance even if buildout/reporting is wrong [Cedric de Saint Martin]
...
...
slapos/grid/distribution.py
0 → 100644
View file @
2a081f07
# -*- coding: utf-8 -*-
"""
Provides helper functions to check if two binary caches are compatible.
os_matches(...):
returns True if the arguments reference compatible platforms.
patched_linux_distribution(...):
a patched version of platform.linux_distribution()
this is the same function provided with the python package in Debian and Ubuntu:
see http://bugs.python.org/issue9514
otherwise, Ubuntu will always be reported as an unstable Debian, regardless of the version.
"""
import
platform
import
re
def
_debianize
(
os
):
"""
keep only the major release number in case of debian, otherwise
minor releases would be seen as not compatible to each other.
"""
distname
,
version
,
id_
=
os
if
distname
==
'debian'
and
'.'
in
version
:
version
=
version
.
split
(
'.'
)[
0
]
return
distname
,
version
,
id_
def
os_matches
(
os1
,
os2
):
return
_debianize
(
os1
)
==
_debianize
(
os2
)
_distributor_id_file_re
=
re
.
compile
(
"(?:DISTRIB_ID
\
s*=)
\
s*(.*)"
,
re
.
I
)
_release_file_re
=
re
.
compile
(
"(?:DISTRIB_RELEASE
\
s*=)
\
s*(.*)"
,
re
.
I
)
_codename_file_re
=
re
.
compile
(
"(?:DISTRIB_CODENAME
\
s*=)
\
s*(.*)"
,
re
.
I
)
def
patched_linux_distribution
(
distname
=
''
,
version
=
''
,
id
=
''
,
supported_dists
=
platform
.
_supported_dists
,
full_distribution_name
=
1
):
# check for the Debian/Ubuntu /etc/lsb-release file first, needed so
# that the distribution doesn't get identified as Debian.
try
:
etclsbrel
=
open
(
"/etc/lsb-release"
,
"rU"
)
for
line
in
etclsbrel
:
m
=
_distributor_id_file_re
.
search
(
line
)
if
m
:
_u_distname
=
m
.
group
(
1
).
strip
()
m
=
_release_file_re
.
search
(
line
)
if
m
:
_u_version
=
m
.
group
(
1
).
strip
()
m
=
_codename_file_re
.
search
(
line
)
if
m
:
_u_id
=
m
.
group
(
1
).
strip
()
if
_u_distname
and
_u_version
:
return
(
_u_distname
,
_u_version
,
_u_id
)
except
(
EnvironmentError
,
UnboundLocalError
):
pass
return
platform
.
linux_distribution
(
distname
,
version
,
id
,
supported_dists
,
full_distribution_name
)
slapos/grid/networkcache.py
View file @
2a081f07
...
@@ -18,6 +18,8 @@ import platform
...
@@ -18,6 +18,8 @@ import platform
import
shutil
import
shutil
import
traceback
import
traceback
from
slapos.grid.distribution
import
os_matches
,
patched_linux_distribution
try
:
try
:
try
:
try
:
from
slapos.libnetworkcache
import
NetworkcacheClient
,
UploadError
,
\
from
slapos.libnetworkcache
import
NetworkcacheClient
,
UploadError
,
\
...
@@ -32,6 +34,8 @@ except:
...
@@ -32,6 +34,8 @@ except:
LIBNETWORKCACHE_ENABLED
=
False
LIBNETWORKCACHE_ENABLED
=
False
print
'Networkcache forced to be disabled.'
print
'Networkcache forced to be disabled.'
def
fallback_call
(
function
):
def
fallback_call
(
function
):
"""Decorator which disallow to have any problem while calling method"""
"""Decorator which disallow to have any problem while calling method"""
def
wrapper
(
self
,
*
args
,
**
kwd
):
def
wrapper
(
self
,
*
args
,
**
kwd
):
...
@@ -48,18 +52,6 @@ def fallback_call(function):
...
@@ -48,18 +52,6 @@ def fallback_call(function):
return
wrapper
return
wrapper
def
debianize
(
os
):
# keep only the major release number in case of debian
distname
,
version
,
id_
=
os
if
distname
==
'debian'
and
'.'
in
version
:
version
=
version
.
split
(
'.'
)[
0
]
return
distname
,
version
,
id_
def
os_matches
(
os1
,
os2
):
return
debianize
(
os1
)
==
debianize
(
os2
)
@
fallback_call
@
fallback_call
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
software_root
,
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
software_root
,
key
,
path
,
logger
,
signature_certificate_list
,
key
,
path
,
logger
,
signature_certificate_list
,
...
@@ -99,7 +91,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
...
@@ -99,7 +91,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
continue
continue
if
not
os_matches
(
ast
.
literal_eval
(
tags
.
get
(
'os'
)),
if
not
os_matches
(
ast
.
literal_eval
(
tags
.
get
(
'os'
)),
p
latform
.
linux_distribution
()):
p
atched_
linux_distribution
()):
continue
continue
if
tags
.
get
(
'software_url'
)
!=
software_url
:
if
tags
.
get
(
'software_url'
)
!=
software_url
:
continue
continue
...
@@ -145,7 +137,7 @@ def upload_network_cached(software_root, software_url, cached_key,
...
@@ -145,7 +137,7 @@ def upload_network_cached(software_root, software_url, cached_key,
software_url
=
software_url
,
software_url
=
software_url
,
software_root
=
software_root
,
software_root
=
software_root
,
machine
=
platform
.
machine
(),
machine
=
platform
.
machine
(),
os
=
str
(
p
latform
.
linux_distribution
())
os
=
str
(
p
atched_
linux_distribution
())
)
)
f
=
open
(
path
,
'r'
)
f
=
open
(
path
,
'r'
)
...
...
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