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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kwabena Antwi-Boasiako
slapos
Commits
32d29b57
Commit
32d29b57
authored
Mar 23, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid getting wrong storage path when creating kvm external disk
parent
242e94db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+25
-5
software/kvm/common.cfg
software/kvm/common.cfg
+1
-1
software/kvm/instance-kvm.cfg.jinja2
software/kvm/instance-kvm.cfg.jinja2
+1
-0
No files found.
slapos/recipe/kvm/template/kvm_run.in
View file @
32d29b57
...
...
@@ -36,11 +36,8 @@ external_disk_number = %(external-disk-number)s
external_disk_size = '%(external-disk-size)s'
disk_storage_dict = {}
disk_storage_list = """%(disk-storage-list)s""".split('\n')
for storage in disk_storage_list:
if storage:
key, val = storage.split(' ')
disk_storage_dict[key.strip()] = val.strip()
map_storage_list = ['data%%r' %% (i + 1) for i in range(0, len(disk_storage_dict))]
map_storage_list = []
etc_directory = '%(etc-directory)s'.strip()
def md5Checksum(file_path):
with open(file_path, 'rb') as fh:
...
...
@@ -71,6 +68,22 @@ def getSocketStatus(host, port):
break
return s
def getMapStorageList(disk_storage_dict):
map_disk_file = os.path.join(etc_directory, '.data-disk-ids')
id_list = []
if os.path.exists(map_disk_file):
with open(map_disk_file, 'r') as mf:
# ID are writen in one line: data1 data3 data2 ...
content = mf.readline()
if content:
id_list = [id for id in content.split(' ') if disk_storage_dict.has_key(id)]
for key in disk_storage_dict:
if not key in id_list:
id_list.append(key)
with open(map_disk_file, 'w') as mf:
mf.write(' '.join(id_list))
return id_list
# Download existing hard drive if needed at first boot
if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
print('Downloading virtual hard drive...')
...
...
@@ -109,6 +122,13 @@ if not os.path.exists(disk_path):
# Check and create external disk
additional_disk_list = []
for storage in sorted(disk_storage_list):
if storage:
key, val = storage.split(' ')
disk_storage_dict[key.strip()] = val.strip()
map_storage_list = getMapStorageList(disk_storage_dict)
if disk_storage_dict:
if int(external_disk_number) > 0:
index = 0
...
...
software/kvm/common.cfg
View file @
32d29b57
...
...
@@ -93,7 +93,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644
md5sum =
10af5beb60655add4de26f7ae60e32aa
md5sum =
5506e1df6ba32c6ead647636ebece79e
download-only = true
on-update = true
...
...
software/kvm/instance-kvm.cfg.jinja2
View file @
32d29b57
...
...
@@ -103,6 +103,7 @@ qemu-path = {{ qemu_executable_location }}
qemu-img-path = {{ qemu_img_executable_location }}
6tunnel-path = {{ sixtunnel_executable_location }}
etc-directory = ${directory:etc}
disk-storage-list =
{% for key, path in storage_dict.items() -%}
{{ ' ' ~ key ~ ' ' ~ path }}
...
...
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