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
Léo-Paul Géneau
slapos
Commits
27a49425
Commit
27a49425
authored
Oct 27, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm recipe fixup: disk creation and image download
parent
65f69645
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+9
-4
No files found.
slapos/recipe/kvm/template/kvm_run.in
View file @
27a49425
...
@@ -13,6 +13,10 @@ from random import shuffle
...
@@ -13,6 +13,10 @@ from random import shuffle
import glob
import glob
import re
import re
import ssl
opener = urllib.FancyURLopener(context=ssl._create_unverified_context())
# XXX: give all of this through parameter, don't use this as template, but as module
# XXX: give all of this through parameter, don't use this as template, but as module
qemu_img_path = '%(qemu-img-path)s'
qemu_img_path = '%(qemu-img-path)s'
qemu_path = '%(qemu-path)s'
qemu_path = '%(qemu-path)s'
...
@@ -127,8 +131,9 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
...
@@ -127,8 +131,9 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
downloaded_disk = disk_path
downloaded_disk = disk_path
if virtual_hard_drive_gzipped == 'true':
if virtual_hard_drive_gzipped == 'true':
downloaded_disk = '%%s.gz' %% disk_path
downloaded_disk = '%%s.gz' %% disk_path
urllib.url
retrieve(virtual_hard_drive_url, downloaded_disk)
opener.
retrieve(virtual_hard_drive_url, downloaded_disk)
except:
except:
if os.path.exists(downloaded_disk):
os.remove(downloaded_disk)
os.remove(downloaded_disk)
raise
raise
md5sum = virtual_hard_drive_md5sum.strip()
md5sum = virtual_hard_drive_md5sum.strip()
...
@@ -157,7 +162,7 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
...
@@ -157,7 +162,7 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
# XXX: move to Buildout profile
# XXX: move to Buildout profile
if not os.path.exists(disk_path):
if not os.path.exists(disk_path):
print('Creating virtual hard drive...')
print('Creating virtual hard drive...')
subprocess.
Popen
([qemu_img_path, 'create' ,'-f', 'qcow2',
subprocess.
check_call
([qemu_img_path, 'create' ,'-f', 'qcow2',
disk_path, '%%sG' %% disk_size])
disk_path, '%%sG' %% disk_size])
print('Done.')
print('Done.')
...
@@ -186,7 +191,7 @@ if disk_storage_dict:
...
@@ -186,7 +191,7 @@ if disk_storage_dict:
disk_list = glob.glob('%%s.*' %% os.path.join(path, 'kvm_virtual_disk'))
disk_list = glob.glob('%%s.*' %% os.path.join(path, 'kvm_virtual_disk'))
if disk_list == []:
if disk_list == []:
print('Creating one additional virtual hard drive...')
print('Creating one additional virtual hard drive...')
subprocess.Popen
([qemu_img_path, 'create' ,'-f', '%%s' %% external_disk_format,
process = subprocess.check_call
([qemu_img_path, 'create' ,'-f', '%%s' %% external_disk_format,
disk_filepath, '%%sG' %% external_disk_size])
disk_filepath, '%%sG' %% external_disk_size])
else:
else:
# Cannot change or recreate if disk is exists
# Cannot change or recreate if disk is exists
...
...
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