Commit b47089fb authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Léo-Paul Géneau

software/kvm: Name field "Boot image list" for readability

parent bc5e10cf
......@@ -19,11 +19,11 @@ md5sum = e6d5c7bb627b4f1d3e7c99721b7c58fe
[template-kvm]
filename = instance-kvm.cfg.jinja2
md5sum = 50e78a2a34efe09afab161ae1c1efd46
md5sum = 2fb085450d33e2674b0c1d4ab2055762
[template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in
md5sum = a4788112008cd0b38a57cd28f7252fbd
md5sum = be228c9e39682be53aaba491f858f848
[template-kvm-resilient]
filename = instance-kvm-resilient.cfg.jinja2
......@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257
[template-kvm-run]
filename = template/template-kvm-run.in
md5sum = dd1f581f34cf5a0b627576771347c710
md5sum = da4947e6d67849f14b7b1ece2b945f04
[template-kvm-controller]
filename = template/kvm-controller-run.in
......
......@@ -43,8 +43,8 @@
"format": "uri",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
},
"image-url-list": {
"title": "List of URLs images to download",
"boot-image-url-list": {
"title": "Boot image list",
"description": "The list shall be list of direct URLs to images, followed by hash (#), then by image MD5SUM. Each image shall appear on newline, like: \"https://example.com/image.iso#06226c7fac5bacfa385872a19bb99684<newline>https://example.com/another-image.iso#31b40d58b18e038498ddb46caea1361c\". They will be provided in KVM image list according to the order on the list. After updating the list, the instance has to be restarted to refresh it. Amount of images is limited to 4, and one image can be maximum 5G. Image will be downloaded and checked against its MD5SUM 4 times, then it will be considered as impossible to download with given MD5SUM. Each image has to be downloaded in time shorter than 4 hours, so in case of very slow images to access, it can take up to 16 hours to download all of them. Note: The instance has to be restarted in order to update the list of available images in the VM.",
"type": "string",
"textarea": "true"
......
......@@ -127,9 +127,9 @@ config-document-host = ${apache-conf:ip}
config-document-port = ${apache-conf:port}
config-document-path = ${hash-code:passwd}
config-keyboard-layout-language = {{ dumps(kvm_parameter_dict.get('keyboard-layout-language', 'fr')) }}
{%- if 'image-url-list' in kvm_parameter_dict %}
{%- if 'boot-image-url-list' in kvm_parameter_dict %}
{#- play nice: if parameter was not constructed by the original request, do not send it at all #}
config-image-url-list = {{ kvm_parameter_dict['image-url-list'] }}
config-boot-image-url-list = {{ kvm_parameter_dict['boot-image-url-list'] }}
{%- endif %}
config-type = cluster
......
......@@ -366,8 +366,8 @@
"format": "uri",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
},
"image-url-list": {
"title": "List of URLs images to download",
"boot-image-url-list": {
"title": "Boot image list",
"description": "The list shall be list of direct URLs to images, followed by hash (#), then by image MD5SUM. Each image shall appear on newline, like: \"https://example.com/image.iso#06226c7fac5bacfa385872a19bb99684<newline>https://example.com/another-image.iso#31b40d58b18e038498ddb46caea1361c\". They will be provided in KVM image list according to the order on the list. After updating the list, the instance has to be restarted to refresh it. Amount of images is limited to 4, and one image can be maximum 5G. Image will be downloaded and checked against its MD5SUM 4 times, then it will be considered as impossible to download with given MD5SUM. Each image has to be downloaded in time shorter than 4 hours, so in case of very slow images to access, it can take up to 16 hours to download all of them. Note: The instance has to be restarted in order to update the list of available images in the VM.",
"type": "string",
"textarea": "true"
......
This diff is collapsed.
......@@ -99,7 +99,7 @@ enable_device_hotplug = '{{ parameter_dict.get("enable-device-hotplug") }}'.lowe
logfile = '{{ parameter_dict.get("log-file") }}'
image_url_list_json_config = '{{ parameter_dict.get("image-url-list-json-config") }}'
boot_image_url_list_json_config = '{{ parameter_dict.get("boot-image-url-list-json-config") }}'
if hasattr(ssl, '_create_unverified_context') and url_check_certificate == 'false':
opener = FancyURLopener(context=ssl._create_unverified_context())
......@@ -370,21 +370,21 @@ for nbd_ip, nbd_port in nbd_list:
'-drive',
'file=nbd:[%s]:%s,media=cdrom' % (nbd_ip, nbd_port)])
else:
image_url_list_used = False
if image_url_list_json_config:
# Support image-url-list
with open(image_url_list_json_config) as fh:
boot_image_url_list_used = False
if boot_image_url_list_json_config:
# Support boot-image-url-list
with open(boot_image_url_list_json_config) as fh:
image_config = json.load(fh)
if image_config['error-amount'] == 0:
for image in sorted(image_config['image-list'], key=lambda k: k['link']):
link = os.path.join(image_config['destination-directory'], image['link'])
if os.path.exists(link) and os.path.islink(link):
image_url_list_used = True
boot_image_url_list_used = True
kvm_argument_list.extend([
'-drive',
'file=%s,media=cdrom' % (link,)
])
if not image_url_list_used:
if not boot_image_url_list_used:
# If no NBD is specified/available not downloadable image: use internal disk image
kvm_argument_list.extend([
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso
......
......@@ -486,8 +486,8 @@ class TestInstanceNbdServer(InstanceTestCase):
@skipUnlessKvm
class TestImageUrlList(InstanceTestCase):
__partition_reference__ = 'iul'
class TestBootImageUrlList(InstanceTestCase):
__partition_reference__ = 'biul'
@classmethod
def getInstanceSoftwareType(cls):
......@@ -501,7 +501,7 @@ class TestImageUrlList(InstanceTestCase):
def tearDown(self):
# clean up the instance for other tests
# 1st remove all images...
self.rerequestInstance({'image-url-list': ''})
self.rerequestInstance({'boot-image-url-list': ''})
self.slap.waitForInstance(max_retry=10)
# 2nd ...move instance to "default" state
self.rerequestInstance({})
......@@ -535,7 +535,7 @@ class TestImageUrlList(InstanceTestCase):
def test(self):
partition_parameter_kw = {
'image-url-list': "%s#%s\n%s#%s" % (
'boot-image-url-list': "%s#%s\n%s#%s" % (
self.fake_image, self.fake_image_md5sum, self.fake_image2,
self.fake_image2_md5sum)
}
......@@ -543,7 +543,8 @@ class TestImageUrlList(InstanceTestCase):
self.slap.waitForInstance(max_retry=10)
# check that image is correctly downloaded and linked
image_repository = os.path.join(
self.computer_partition_root_path, 'srv', 'image-repository')
self.computer_partition_root_path, 'srv',
'boot-image-url-list-repository')
image = os.path.join(image_repository, self.fake_image_md5sum)
image_link = os.path.join(image_repository, 'image_001')
self.assertTrue(os.path.exists(image))
......@@ -569,11 +570,11 @@ class TestImageUrlList(InstanceTestCase):
kvm_process = psutil.Process(kvm_pid)
cmd_line = ''.join(kvm_process.cmdline())
self.assertNotIn(
'srv/image-repository/image_001,media=cdrom',
'srv/boot-image-url-list-repository/image_001,media=cdrom',
cmd_line
)
self.assertNotIn(
'srv/image-repository/image_002,media=cdrom',
'srv/boot-image-url-list-repository/image_002,media=cdrom',
cmd_line
)
......@@ -591,17 +592,17 @@ class TestImageUrlList(InstanceTestCase):
kvm_process = psutil.Process(kvm_pid)
cmd_line = ''.join(kvm_process.cmdline())
self.assertIn(
'srv/image-repository/image_001,media=cdrom',
'srv/boot-image-url-list-repository/image_001,media=cdrom',
cmd_line
)
self.assertIn(
'srv/image-repository/image_002,media=cdrom',
'srv/boot-image-url-list-repository/image_002,media=cdrom',
cmd_line
)
# cleanup of images works, also asserts that configuration changes are
# reflected
self.rerequestInstance({'image-url-list': ''})
self.rerequestInstance({'boot-image-url-list': ''})
self.slap.waitForInstance(max_retry=2)
self.assertEqual(
os.listdir(image_repository),
......@@ -625,43 +626,43 @@ class TestImageUrlList(InstanceTestCase):
def test_bad_parameter(self):
self.rerequestInstance({
'image-url-list': "jsutbad"
'boot-image-url-list': "jsutbad"
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-config-state-promise.py')
self.assertPromiseFails('boot-image-url-list-config-state-promise.py')
def test_incorrect_md5sum(self):
self.rerequestInstance({
'image-url-list': "%s#" % (self.fake_image,)
'boot-image-url-list': "%s#" % (self.fake_image,)
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-config-state-promise.py')
self.assertPromiseFails('boot-image-url-list-config-state-promise.py')
self.rerequestInstance({
'image-url-list': "url#asdasd"
'boot-image-url-list': "url#asdasd"
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-config-state-promise.py')
self.assertPromiseFails('boot-image-url-list-config-state-promise.py')
def test_not_matching_md5sum(self):
self.rerequestInstance({
'image-url-list': "%s#%s" % (
'boot-image-url-list': "%s#%s" % (
self.fake_image, self.fake_image_wrong_md5sum)
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-download-md5sum-promise.py')
self.assertPromiseFails('image-url-list-download-state-promise.py')
self.assertPromiseFails('boot-image-url-list-download-md5sum-promise.py')
self.assertPromiseFails('boot-image-url-list-download-state-promise.py')
def test_unreachable_host(self):
self.rerequestInstance({
'image-url-list': "evennotahost#%s" % (
'boot-image-url-list': "evennotahost#%s" % (
self.fake_image_md5sum,)
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-download-state-promise.py')
self.assertPromiseFails('boot-image-url-list-download-state-promise.py')
def test_too_many_images(self):
self.rerequestInstance({
'image-url-list': """
'boot-image-url-list': """
image1#11111111111111111111111111111111
image2#22222222222222222222222222222222
image3#33333333333333333333333333333333
......@@ -671,12 +672,12 @@ class TestImageUrlList(InstanceTestCase):
"""
})
self.raising_waitForInstance(3)
self.assertPromiseFails('image-url-list-config-state-promise.py')
self.assertPromiseFails('boot-image-url-list-config-state-promise.py')
@skipUnlessKvm
class TestImageUrlListKvmCluster(InstanceTestCase):
__partition_reference__ = 'iulkc'
class TestBootImageUrlListKvmCluster(InstanceTestCase):
__partition_reference__ = 'biulkc'
@classmethod
def getInstanceSoftwareType(cls):
......@@ -699,12 +700,12 @@ class TestImageUrlListKvmCluster(InstanceTestCase):
"kvm-partition-dict": {
"KVM0": {
"disable-ansible-promise": True,
"image-url-list": "%s#%s" % (
"boot-image-url-list": "%s#%s" % (
cls.fake_image, cls.fake_image_md5sum)
},
"KVM1": {
"disable-ansible-promise": True,
"image-url-list": "%s#%s" % (
"boot-image-url-list": "%s#%s" % (
cls.fake_image2, cls.fake_image2_md5sum)
}
}
......@@ -715,10 +716,10 @@ class TestImageUrlListKvmCluster(InstanceTestCase):
# we assume ordering of the cluster requests
KVM0_config = os.path.join(
self.slap.instance_directory, self.__partition_reference__ + '1', 'etc',
'image-url-list.conf')
'boot-image-url-list.conf')
KVM1_config = os.path.join(
self.slap.instance_directory, self.__partition_reference__ + '2', 'etc',
'image-url-list.conf')
'boot-image-url-list.conf')
with open(KVM0_config, 'r') as fh:
self.assertEqual(
"%s#%s" % (self.fake_image, self.fake_image_md5sum),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment