Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Nirina Malard
slapos
Commits
4b83a276
Commit
4b83a276
authored
Sep 03, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/kvm: Always provide default image
parent
e562bca8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
35 deletions
+51
-35
software/kvm/buildout.hash.cfg
software/kvm/buildout.hash.cfg
+1
-1
software/kvm/template/template-kvm-run.in
software/kvm/template/template-kvm-run.in
+4
-7
software/kvm/test/test.py
software/kvm/test/test.py
+46
-27
No files found.
software/kvm/buildout.hash.cfg
View file @
4b83a276
...
@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257
...
@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257
[template-kvm-run]
[template-kvm-run]
filename = template/template-kvm-run.in
filename = template/template-kvm-run.in
md5sum =
da4947e6d67849f14b7b1ece2b945f04
md5sum =
536c3b208fec9fa29ba6223432cd3509
[template-kvm-controller]
[template-kvm-controller]
filename = template/kvm-controller-run.in
filename = template/kvm-controller-run.in
...
...
software/kvm/template/template-kvm-run.in
View file @
4b83a276
...
@@ -370,7 +370,6 @@ for nbd_ip, nbd_port in nbd_list:
...
@@ -370,7 +370,6 @@ for nbd_ip, nbd_port in nbd_list:
'-drive',
'-drive',
'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)])
'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)])
else:
else:
boot_image_url_list_used = False
if boot_image_url_list_json_config:
if boot_image_url_list_json_config:
# Support boot-image-url-list
# Support boot-image-url-list
with open(boot_image_url_list_json_config) as fh:
with open(boot_image_url_list_json_config) as fh:
...
@@ -379,13 +378,11 @@ else:
...
@@ -379,13 +378,11 @@ else:
for image in sorted(image_config['image-list'], key=lambda k: k['link']):
for image in sorted(image_config['image-list'], key=lambda k: k['link']):
link = os.path.join(image_config['destination-directory'], image['link'])
link = os.path.join(image_config['destination-directory'], image['link'])
if os.path.exists(link) and os.path.islink(link):
if os.path.exists(link) and os.path.islink(link):
boot_image_url_list_used = True
kvm_argument_list.extend([
kvm_argument_list.extend([
'-drive',
'-drive',
'file=%s,media=cdrom' % (link,)
'file=%s,media=cdrom' % (link,)
])
])
if not boot_image_url_list_used:
# Always add by default the default image
# If no NBD is specified/available not downloadable image: use internal disk image
kvm_argument_list.extend([
kvm_argument_list.extend([
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso
])
])
...
...
software/kvm/test/test.py
View file @
4b83a276
...
@@ -563,19 +563,28 @@ class TestBootImageUrlList(InstanceTestCase):
...
@@ -563,19 +563,28 @@ class TestBootImageUrlList(InstanceTestCase):
self
.
assertTrue
(
os
.
path
.
islink
(
image2_link
))
self
.
assertTrue
(
os
.
path
.
islink
(
image2_link
))
self
.
assertEqual
(
os
.
readlink
(
image2_link
),
image2
)
self
.
assertEqual
(
os
.
readlink
(
image2_link
),
image2
)
# check that the image is NOT YET available in kvm
def
getRunningImageList
():
running_image_list
=
[]
with
self
.
slap
.
instance_supervisor_rpc
as
instance_supervisor
:
with
self
.
slap
.
instance_supervisor_rpc
as
instance_supervisor
:
kvm_pid
=
[
q
for
q
in
instance_supervisor
.
getAllProcessInfo
()
kvm_pid
=
[
q
for
q
in
instance_supervisor
.
getAllProcessInfo
()
if
'kvm-'
in
q
[
'name'
]][
0
][
'pid'
]
if
'kvm-'
in
q
[
'name'
]][
0
][
'pid'
]
kvm_process
=
psutil
.
Process
(
kvm_pid
)
kvm_process
=
psutil
.
Process
(
kvm_pid
)
cmd_line
=
''
.
join
(
kvm_process
.
cmdline
())
software_root
=
'/'
.
join
([
self
.
assertNotIn
(
self
.
slap
.
software_directory
,
'srv/boot-image-url-list-repository/image_001,media=cdrom'
,
hashlib
.
md5
(
self
.
getSoftwareURL
()).
hexdigest
()])
cmd_line
for
entry
in
kvm_process
.
cmdline
():
)
if
entry
.
startswith
(
'file'
)
and
'media=cdrom'
in
entry
:
self
.
assertNotIn
(
# do cleanups
'srv/boot-image-url-list-repository/image_002,media=cdrom'
,
entry
=
entry
.
replace
(
software_root
,
''
)
cmd_line
entry
=
entry
.
replace
(
self
.
computer_partition_root_path
,
''
)
running_image_list
.
append
(
entry
)
return
running_image_list
# check that the image is NOT YET available in kvm
self
.
assertEqual
(
[
'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'
],
getRunningImageList
()
)
)
# mimic the requirement: restart the instance by requesting it stopped and
# mimic the requirement: restart the instance by requesting it stopped and
...
@@ -585,19 +594,15 @@ class TestBootImageUrlList(InstanceTestCase):
...
@@ -585,19 +594,15 @@ class TestBootImageUrlList(InstanceTestCase):
self
.
rerequestInstance
(
partition_parameter_kw
,
state
=
'started'
)
self
.
rerequestInstance
(
partition_parameter_kw
,
state
=
'started'
)
self
.
slap
.
waitForInstance
(
max_retry
=
1
)
self
.
slap
.
waitForInstance
(
max_retry
=
1
)
# now the image is available in the kvm
# now the image is available in the kvm, and its above default image
with
self
.
slap
.
instance_supervisor_rpc
as
instance_supervisor
:
self
.
assertEqual
(
kvm_pid
=
[
q
for
q
in
instance_supervisor
.
getAllProcessInfo
()
[
if
'kvm-'
in
q
[
'name'
]][
0
][
'pid'
]
'file=/srv/boot-image-url-list-repository/image_001,media=cdrom'
,
kvm_process
=
psutil
.
Process
(
kvm_pid
)
'file=/srv/boot-image-url-list-repository/image_002,media=cdrom'
,
cmd_line
=
''
.
join
(
kvm_process
.
cmdline
())
'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
self
.
assertIn
(
'media=cdrom'
'srv/boot-image-url-list-repository/image_001,media=cdrom'
,
],
cmd_line
getRunningImageList
()
)
self
.
assertIn
(
'srv/boot-image-url-list-repository/image_002,media=cdrom'
,
cmd_line
)
)
# cleanup of images works, also asserts that configuration changes are
# cleanup of images works, also asserts that configuration changes are
...
@@ -609,6 +614,20 @@ class TestBootImageUrlList(InstanceTestCase):
...
@@ -609,6 +614,20 @@ class TestBootImageUrlList(InstanceTestCase):
[]
[]
)
)
# mimic the requirement: restart the instance by requesting it stopped and
# then started started, like user have to do it
self
.
rerequestInstance
(
partition_parameter_kw
,
state
=
'stopped'
)
self
.
slap
.
waitForInstance
(
max_retry
=
1
)
self
.
rerequestInstance
(
partition_parameter_kw
,
state
=
'started'
)
self
.
slap
.
waitForInstance
(
max_retry
=
1
)
# again only default image is available in the running process
self
.
assertEqual
(
[
'file=/parts/debian-amd64-netinst.iso/debian-amd64-netinst.iso,'
'media=cdrom'
],
getRunningImageList
()
)
def
assertPromiseFails
(
self
,
promise
):
def
assertPromiseFails
(
self
,
promise
):
monitor_run_promise
=
os
.
path
.
join
(
monitor_run_promise
=
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'software_release'
,
'bin'
,
self
.
computer_partition_root_path
,
'software_release'
,
'bin'
,
...
...
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