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
Xavier Thompson
slapos
Commits
f2c83225
Commit
f2c83225
authored
Aug 29, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: allow to set main disk format
it clean up....
parent
cbc24f0e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
11 deletions
+31
-11
software/kvm/instance-kvm-cluster-input-schema.json
software/kvm/instance-kvm-cluster-input-schema.json
+7
-0
software/kvm/instance-kvm-cluster.cfg.jinja2.in
software/kvm/instance-kvm-cluster.cfg.jinja2.in
+1
-0
software/kvm/instance-kvm-input-schema.json
software/kvm/instance-kvm-input-schema.json
+8
-0
software/kvm/instance-kvm.cfg.jinja2
software/kvm/instance-kvm.cfg.jinja2
+2
-2
software/kvm/software.cfg
software/kvm/software.cfg
+3
-3
software/kvm/template/template-kvm-run.in
software/kvm/template/template-kvm-run.in
+10
-6
No files found.
software/kvm/instance-kvm-cluster-input-schema.json
View file @
f2c83225
...
@@ -232,6 +232,13 @@
...
@@ -232,6 +232,13 @@
"default"
:
10
,
"default"
:
10
,
"minimum"
:
1
"minimum"
:
1
},
},
"disk-format"
:
{
"title"
:
"Type of external disk drive to create by QEMU."
,
"description"
:
"Type of QEMU disk drive, to create."
,
"type"
:
"string"
,
"default"
:
"qcow2"
,
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
,
"qed"
]
},
"disk-type"
:
{
"disk-type"
:
{
"title"
:
"Disk type"
,
"title"
:
"Disk type"
,
"description"
:
"Type of QEMU disk drive."
,
"description"
:
"Type of QEMU disk drive."
,
...
...
software/kvm/instance-kvm-cluster.cfg.jinja2.in
View file @
f2c83225
...
@@ -56,6 +56,7 @@ config-enable-device-hotplug = {{ dumps(kvm_parameter_dict.get('enable-device-ho
...
@@ -56,6 +56,7 @@ config-enable-device-hotplug = {{ dumps(kvm_parameter_dict.get('enable-device-ho
config-ram-hotplug-slot-size = {{ dumps(kvm_parameter_dict.get('ram-hotplug-slot-size', 512)) }}
config-ram-hotplug-slot-size = {{ dumps(kvm_parameter_dict.get('ram-hotplug-slot-size', 512)) }}
config-disk-size = {{ dumps(kvm_parameter_dict.get('disk-size', 10)) }}
config-disk-size = {{ dumps(kvm_parameter_dict.get('disk-size', 10)) }}
config-disk-type = {{ dumps(kvm_parameter_dict.get('disk-type', 'virtio')) }}
config-disk-type = {{ dumps(kvm_parameter_dict.get('disk-type', 'virtio')) }}
config-disk-format = {{ dumps(kvm_parameter_dict.get('disk-format', 'qcow2')) }}
config-cpu-count = {{ dumps(kvm_parameter_dict.get('cpu-count', 1)) }}
config-cpu-count = {{ dumps(kvm_parameter_dict.get('cpu-count', 1)) }}
config-cpu-max-count = {{ dumps(kvm_parameter_dict.get('cpu-max-count', 24)) }}
config-cpu-max-count = {{ dumps(kvm_parameter_dict.get('cpu-max-count', 24)) }}
{{ setconfig('numa', kvm_parameter_dict.get('numa', '')) }}
{{ setconfig('numa', kvm_parameter_dict.get('numa', '')) }}
...
...
software/kvm/instance-kvm-input-schema.json
View file @
f2c83225
...
@@ -55,6 +55,14 @@
...
@@ -55,6 +55,14 @@
"default"
:
"virtio"
,
"default"
:
"virtio"
,
"enum"
:
[
"ide"
,
"scsi"
,
"sd"
,
"mtd"
,
"floppy"
,
"pflash"
,
"virtio"
]
"enum"
:
[
"ide"
,
"scsi"
,
"sd"
,
"mtd"
,
"floppy"
,
"pflash"
,
"virtio"
]
},
},
"disk-format"
:
{
"title"
:
"Type of disk drive to create by QEMU."
,
"description"
:
"Type of QEMU disk drive, to create."
,
"type"
:
"string"
,
"default"
:
"qcow2"
,
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
,
"qed"
]
},
"disk-cache"
:
{
"disk-cache"
:
{
"title"
:
"Cache option to use with Disk."
,
"title"
:
"Cache option to use with Disk."
,
"description"
:
"Disk cache controls how the host cache is used to access block data."
,
"description"
:
"Disk cache controls how the host cache is used to access block data."
,
...
...
software/kvm/instance-kvm.cfg.jinja2
View file @
f2c83225
...
@@ -88,10 +88,10 @@ nbd2-port = ${slap-parameter:nbd2-port}
...
@@ -88,10 +88,10 @@ nbd2-port = ${slap-parameter:nbd2-port}
tap-interface = ${slap-network-information:network-interface}
tap-interface = ${slap-network-information:network-interface}
disk-path = ${directory:srv}/virtual.qcow2
disk-size = ${slap-parameter:disk-size}
disk-size = ${slap-parameter:disk-size}
disk-type = ${slap-parameter:disk-type}
disk-type = ${slap-parameter:disk-type}
disk-format = ${slap-parameter:disk-format}
disk-path = ${directory:srv}/virtual.${slap-parameter:disk-format}
pid-file-path = ${kvm-controller-parameter-dict:pid-file}
pid-file-path = ${kvm-controller-parameter-dict:pid-file}
socket-path = ${kvm-controller-parameter-dict:socket-path}
socket-path = ${kvm-controller-parameter-dict:socket-path}
...
...
software/kvm/software.cfg
View file @
f2c83225
...
@@ -99,7 +99,7 @@ recipe = hexagonit.recipe.download
...
@@ -99,7 +99,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true
ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644
mode = 644
md5sum =
e59ea29533d7f989ec676e14b0f29839
md5sum =
92e0723a2b474d9cc686ef7f0a91e36c
download-only = true
download-only = true
on-update = true
on-update = true
...
@@ -108,7 +108,7 @@ recipe = hexagonit.recipe.download
...
@@ -108,7 +108,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true
ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm-cluster.cfg.jinja2.in
url = ${:_profile_base_location_}/instance-kvm-cluster.cfg.jinja2.in
mode = 644
mode = 644
md5sum =
6d165aec7d236ea3944765236d11940f
md5sum =
cccabafc001c6df35da95af6bf2ae28e
download-only = true
download-only = true
on-update = true
on-update = true
...
@@ -186,7 +186,7 @@ ignore-existing = true
...
@@ -186,7 +186,7 @@ ignore-existing = true
url = ${:_profile_base_location_}/template/template-kvm-run.in
url = ${:_profile_base_location_}/template/template-kvm-run.in
mode = 644
mode = 644
filename = template-kvm-run.in
filename = template-kvm-run.in
md5sum =
bc09717dd86063a558b125f43905b4a4
md5sum =
807e03a9ada561499adf447f79e9d2ec
download-only = true
download-only = true
on-update = true
on-update = true
...
...
software/kvm/template/template-kvm-run.in
View file @
f2c83225
...
@@ -20,6 +20,10 @@ qemu_img_path = '{{ parameter_dict.get("qemu-img-path") }}'
...
@@ -20,6 +20,10 @@ qemu_img_path = '{{ parameter_dict.get("qemu-img-path") }}'
qemu_path = '{{ parameter_dict.get("qemu-path") }}'
qemu_path = '{{ parameter_dict.get("qemu-path") }}'
disk_size = '{{ parameter_dict.get("disk-size") }}'
disk_size = '{{ parameter_dict.get("disk-size") }}'
disk_type = '{{ parameter_dict.get("disk-type") }}'
disk_type = '{{ parameter_dict.get("disk-type") }}'
disk_format = '{{ parameter_dict.get("disk-format", "qcow2")}}'
disk_format = disk_format \
if disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
socket_path = '{{ parameter_dict.get("socket-path") }}'
socket_path = '{{ parameter_dict.get("socket-path") }}'
nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
{{ parameter_dict.get("nbd-port") }}),
{{ parameter_dict.get("nbd-port") }}),
...
@@ -46,7 +50,9 @@ init_ram_size = {{ parameter_dict.get("init-ram-size") }}
...
@@ -46,7 +50,9 @@ init_ram_size = {{ parameter_dict.get("init-ram-size") }}
pid_file_path = '{{ parameter_dict.get("pid-file-path") }}'
pid_file_path = '{{ parameter_dict.get("pid-file-path") }}'
external_disk_number = {{ parameter_dict.get("external-disk-number") }}
external_disk_number = {{ parameter_dict.get("external-disk-number") }}
external_disk_size = {{ parameter_dict.get("external-disk-size") }}
external_disk_size = {{ parameter_dict.get("external-disk-size") }}
external_disk_format = '{{ parameter_dict.get("external-disk-format") }}'
external_disk_format = '{{ parameter_dict.get("external-disk-format", "qcow2") }}'
external_disk_format = external_disk_format \
if external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
disk_storage_dict = {}
disk_storage_dict = {}
disk_storage_list = """{{ parameter_dict.get("disk-storage-list") }}""".split('\n')
disk_storage_list = """{{ parameter_dict.get("disk-storage-list") }}""".split('\n')
map_storage_list = []
map_storage_list = []
...
@@ -185,7 +191,7 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
...
@@ -185,7 +191,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.check_call([qemu_img_path, 'create' ,'-f',
'qcow2'
,
subprocess.check_call([qemu_img_path, 'create' ,'-f',
disk_format
,
disk_path, '%sG' % disk_size])
disk_path, '%sG' % disk_size])
print('Done.')
print('Done.')
...
@@ -196,9 +202,6 @@ for storage in disk_storage_list:
...
@@ -196,9 +202,6 @@ for storage in disk_storage_list:
key, val = storage.split(' ')
key, val = storage.split(' ')
disk_storage_dict[key.strip()] = val.strip()
disk_storage_dict[key.strip()] = val.strip()
if not external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed']:
external_disk_format = 'qcow2'
map_storage_list, external_disk_number = getMapStorageList(disk_storage_dict,
map_storage_list, external_disk_number = getMapStorageList(disk_storage_dict,
int(external_disk_number))
int(external_disk_number))
...
@@ -214,7 +217,7 @@ if disk_storage_dict:
...
@@ -214,7 +217,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...')
process = subprocess.check_call([qemu_img_path, 'create' ,'-f',
'%s' %
external_disk_format,
process = subprocess.check_call([qemu_img_path, 'create' ,'-f', 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
...
@@ -264,6 +267,7 @@ if enable_device_hotplug != 'true':
...
@@ -264,6 +267,7 @@ if enable_device_hotplug != 'true':
else:
else:
smp = '1,maxcpus=%s' % smp_max_count
smp = '1,maxcpus=%s' % smp_max_count
ram = '%sM,slots=128,maxmem=%sM' % (init_ram_size, ram_max_size)
ram = '%sM,slots=128,maxmem=%sM' % (init_ram_size, ram_max_size)
kvm_argument_list = [qemu_path,
kvm_argument_list = [qemu_path,
'-enable-kvm', '-smp', smp, '-name', vm_name, '-m', ram, '-vga', 'std',
'-enable-kvm', '-smp', smp, '-name', vm_name, '-m', ram, '-vga', 'std',
'-drive', 'file=%s,if=%s,cache=%s,aio=%s' % (disk_path, disk_type, disk_cache, disk_aio),
'-drive', 'file=%s,if=%s,cache=%s,aio=%s' % (disk_path, disk_type, disk_cache, disk_aio),
...
...
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