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
a9956d0a
Commit
a9956d0a
authored
Nov 26, 2021
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: include "machine" in compatibility check
parent
d00851cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
slapos/cli/cache.py
slapos/cli/cache.py
+8
-6
slapos/grid/networkcache.py
slapos/grid/networkcache.py
+5
-4
slapos/tests/test_cli.py
slapos/tests/test_cli.py
+6
-6
No files found.
slapos/cli/cache.py
View file @
a9956d0a
...
@@ -74,6 +74,10 @@ def looks_like_md5(s):
...
@@ -74,6 +74,10 @@ def looks_like_md5(s):
return
re
.
match
(
'[0-9a-f]{32}'
,
s
)
return
re
.
match
(
'[0-9a-f]{32}'
,
s
)
def
ostuple
(
jsondict
):
srdict
=
json
.
loads
(
jsondict
)
return
(
srdict
[
'machine'
],)
+
ast
.
literal_eval
(
srdict
[
'os'
])
def
do_lookup
(
logger
,
cache_dir
,
software_url
):
def
do_lookup
(
logger
,
cache_dir
,
software_url
):
if
looks_like_md5
(
software_url
):
if
looks_like_md5
(
software_url
):
md5
=
software_url
md5
=
software_url
...
@@ -100,15 +104,13 @@ def do_lookup(logger, cache_dir, software_url):
...
@@ -100,15 +104,13 @@ def do_lookup(logger, cache_dir, software_url):
logger
.
info
(
'Object found in cache, but has no binary entries.'
)
logger
.
info
(
'Object found in cache, but has no binary entries.'
)
return
0
return
0
ostable
=
sorted
(
ast
.
literal_eval
(
json
.
loads
(
entry
[
0
])[
'os'
])
for
entry
in
entries
)
ostable
=
sorted
(
ostuple
(
entry
[
0
])
for
entry
in
entries
)
pt
=
prettytable
.
PrettyTable
([
'distribution'
,
'version'
,
'id'
,
'compatible?'
])
linux_distribution
=
distribution_tuple
(
)
pt
=
prettytable
.
PrettyTable
([
'machine'
,
'distribution'
,
'version'
,
'id'
,
'compatible?'
]
)
for
os
in
ostable
:
for
os
in
ostable
:
compatible
=
'yes'
if
networkcache
.
os_matches
(
os
,
linux_distribution
)
else
'no'
compatible
=
'yes'
if
networkcache
.
is_compatible
(
os
[
0
],
os
[
1
:]
)
else
'no'
pt
.
add_row
([
os
[
0
],
os
[
1
],
os
[
2
],
compatible
])
pt
.
add_row
([
os
[
0
],
os
[
1
],
os
[
2
],
os
[
3
],
compatible
])
meta
=
json
.
loads
(
entries
[
0
][
0
])
meta
=
json
.
loads
(
entries
[
0
][
0
])
logger
.
info
(
'Software URL: %s'
,
meta
[
'software_url'
])
logger
.
info
(
'Software URL: %s'
,
meta
[
'software_url'
])
...
...
slapos/grid/networkcache.py
View file @
a9956d0a
...
@@ -53,6 +53,10 @@ def fallback_call(function):
...
@@ -53,6 +53,10 @@ def fallback_call(function):
return
wrapper
return
wrapper
def
is_compatible
(
machine
,
os
):
return
machine
==
platform
.
machine
()
and
os_matches
(
os
,
distribution_tuple
())
@
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
,
...
@@ -86,10 +90,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
...
@@ -86,10 +90,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
json_information
,
_
=
entry
json_information
,
_
=
entry
try
:
try
:
tags
=
json
.
loads
(
json_information
)
tags
=
json
.
loads
(
json_information
)
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
if
not
is_compatible
(
tags
.
get
(
'machine'
),
ast
.
literal_eval
(
tags
.
get
(
'os'
))):
continue
if
not
os_matches
(
ast
.
literal_eval
(
tags
.
get
(
'os'
)),
distribution_tuple
()):
continue
continue
if
tags
.
get
(
'software_url'
)
!=
software_url
:
if
tags
.
get
(
'software_url'
)
!=
software_url
:
continue
continue
...
...
slapos/tests/test_cli.py
View file @
a9956d0a
...
@@ -85,13 +85,13 @@ class TestCliCache(CliMixin):
...
@@ -85,13 +85,13 @@ class TestCliCache(CliMixin):
self
.
logger
.
info
.
assert_any_call
(
'Software URL: %s'
,
self
.
logger
.
info
.
assert_any_call
(
'Software URL: %s'
,
u'https://lab.nexedi.com/nexedi/slapos/raw/1.0.102/software/slaprunner/software.cfg'
)
u'https://lab.nexedi.com/nexedi/slapos/raw/1.0.102/software/slaprunner/software.cfg'
)
self
.
logger
.
info
.
assert_any_call
(
'MD5: %s'
,
'cccdc51a07e8c575c880f2d70dd4d458'
)
self
.
logger
.
info
.
assert_any_call
(
'MD5: %s'
,
'cccdc51a07e8c575c880f2d70dd4d458'
)
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------'
)
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------
--------
'
)
self
.
logger
.
info
.
assert_any_call
(
u' distribution version id compatible? '
)
self
.
logger
.
info
.
assert_any_call
(
u'
machine
distribution version id compatible? '
)
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------'
)
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------
--------
'
)
self
.
logger
.
info
.
assert_any_call
(
u' CentOS Linux 7.5.1804 Core no '
)
self
.
logger
.
info
.
assert_any_call
(
u'
x86_64
CentOS Linux 7.5.1804 Core no '
)
self
.
logger
.
info
.
assert_any_call
(
u' Ubuntu 18.04 bionic no '
)
self
.
logger
.
info
.
assert_any_call
(
u'
x86_64
Ubuntu 18.04 bionic no '
)
# Omit some lines as it may fail depending of the OS
# Omit some lines as it may fail depending of the OS
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------'
)
self
.
logger
.
info
.
assert_any_call
(
u'------------------------------------------
--------
'
)
def
test_uncached_binary
(
self
):
def
test_uncached_binary
(
self
):
self
.
assertEqual
(
10
,
cache_do_lookup
(
self
.
assertEqual
(
10
,
cache_do_lookup
(
...
...
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