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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos
Commits
80b99e40
Commit
80b99e40
authored
Jul 16, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: fix kvm_run script, add qed in external disk format and improve http server
parent
a55d0291
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
28 deletions
+57
-28
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+7
-7
software/kvm/common.cfg
software/kvm/common.cfg
+2
-2
software/kvm/instance-kvm-cluster-input-schema.json
software/kvm/instance-kvm-cluster-input-schema.json
+1
-1
software/kvm/instance-kvm-cluster.cfg.jinja2.in
software/kvm/instance-kvm-cluster.cfg.jinja2.in
+16
-6
software/kvm/instance-kvm-input-schema.json
software/kvm/instance-kvm-input-schema.json
+1
-1
software/kvm/instance-kvm.cfg.jinja2
software/kvm/instance-kvm.cfg.jinja2
+30
-11
No files found.
slapos/recipe/kvm/template/kvm_run.in
View file @
80b99e40
...
@@ -24,10 +24,10 @@ default_disk_image = '%(default-disk-image)s'
...
@@ -24,10 +24,10 @@ default_disk_image = '%(default-disk-image)s'
disk_path = '%(disk-path)s'
disk_path = '%(disk-path)s'
virtual_hard_drive_url = '%(virtual-hard-drive-url)s'.strip()
virtual_hard_drive_url = '%(virtual-hard-drive-url)s'.strip()
virtual_hard_drive_md5sum = '%(virtual-hard-drive-md5sum)s'.strip()
virtual_hard_drive_md5sum = '%(virtual-hard-drive-md5sum)s'.strip()
virtual_hard_drive_gzipped = '%(virtual-hard-drive-gzipped)s'.strip()
virtual_hard_drive_gzipped = '%(virtual-hard-drive-gzipped)s'.strip()
.lower()
nat_rules = '%(nat-rules)s'.strip()
nat_rules = '%(nat-rules)s'.strip()
use_tap = '%(use-tap)s'
use_tap = '%(use-tap)s'
.lower()
use_nat = '%(use-nat)s'
use_nat = '%(use-nat)s'
.lower()
tap_interface = '%(tap-interface)s'
tap_interface = '%(tap-interface)s'
listen_ip = '%(ipv4)s'
listen_ip = '%(ipv4)s'
mac_address = '%(mac-address)s'
mac_address = '%(mac-address)s'
...
@@ -119,7 +119,7 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
...
@@ -119,7 +119,7 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
print('Downloading virtual hard drive...')
print('Downloading virtual hard drive...')
try:
try:
downloaded_disk = disk_path
downloaded_disk = disk_path
if virtual_hard_drive_gzipped == '
T
rue':
if virtual_hard_drive_gzipped == '
t
rue':
downloaded_disk = '%%s.gz' %% disk_path
downloaded_disk = '%%s.gz' %% disk_path
urllib.urlretrieve(virtual_hard_drive_url, downloaded_disk)
urllib.urlretrieve(virtual_hard_drive_url, downloaded_disk)
except:
except:
...
@@ -162,7 +162,7 @@ for storage in disk_storage_list:
...
@@ -162,7 +162,7 @@ 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']:
if not external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop'
, 'qed'
]:
external_disk_format = 'qcow2'
external_disk_format = 'qcow2'
map_storage_list, external_disk_number = getMapStorageList(disk_storage_dict,
map_storage_list, external_disk_number = getMapStorageList(disk_storage_dict,
...
@@ -197,7 +197,7 @@ tap_network_parameter = []
...
@@ -197,7 +197,7 @@ tap_network_parameter = []
nat_network_parameter = []
nat_network_parameter = []
numa_parameter = []
numa_parameter = []
number = -1
number = -1
if use_nat == '
T
rue':
if use_nat == '
t
rue':
number += 1
number += 1
rules = 'user,id=lan%%s,' %% number + ','.join('hostfwd=tcp:%%s:%%s-:%%s' %% (listen_ip,
rules = 'user,id=lan%%s,' %% number + ','.join('hostfwd=tcp:%%s:%%s-:%%s' %% (listen_ip,
int(port) + 10000, port) for port in nat_rules.split())
int(port) + 10000, port) for port in nat_rules.split())
...
@@ -209,7 +209,7 @@ if use_nat == 'True':
...
@@ -209,7 +209,7 @@ if use_nat == 'True':
cluster_doc_host, cluster_doc_port)
cluster_doc_host, cluster_doc_port)
nat_network_parameter = ['-netdev', rules,
nat_network_parameter = ['-netdev', rules,
'-device', 'e1000,netdev=lan%%s,mac=%%s' %% (number, mac_address)]
'-device', 'e1000,netdev=lan%%s,mac=%%s' %% (number, mac_address)]
if use_tap == '
T
rue':
if use_tap == '
t
rue':
number += 1
number += 1
tap_network_parameter = ['-netdev',
tap_network_parameter = ['-netdev',
'tap,id=lan%%s,ifname=%%s,script=no,downscript=no' %% (number,
'tap,id=lan%%s,ifname=%%s,script=no,downscript=no' %% (number,
...
...
software/kvm/common.cfg
View file @
80b99e40
...
@@ -95,7 +95,7 @@ mode = 0644
...
@@ -95,7 +95,7 @@ mode = 0644
recipe = hexagonit.recipe.download
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644
mode = 644
md5sum =
fb2dcca424fa0bf4d6ec445965a8bc81
md5sum =
55eb9cb0d85dedbda0f03986cef261db
download-only = true
download-only = true
on-update = true
on-update = true
...
@@ -103,7 +103,7 @@ on-update = true
...
@@ -103,7 +103,7 @@ on-update = true
recipe = hexagonit.recipe.download
recipe = hexagonit.recipe.download
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 =
36d9ea062c13f88eadd6f635eed36b7e
md5sum =
1e4d8eade6d291480e5112ef9f31f031
download-only = true
download-only = true
on-update = true
on-update = true
...
...
software/kvm/instance-kvm-cluster-input-schema.json
View file @
80b99e40
...
@@ -266,7 +266,7 @@
...
@@ -266,7 +266,7 @@
"description"
:
"Type of QEMU disk drive, to create."
,
"description"
:
"Type of QEMU disk drive, to create."
,
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"qcow2"
,
"default"
:
"qcow2"
,
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
]
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
,
"qed"
]
},
},
"use-tap"
:
{
"use-tap"
:
{
"title"
:
"Use QEMU TAP network interface"
,
"title"
:
"Use QEMU TAP network interface"
,
...
...
software/kvm/instance-kvm-cluster.cfg.jinja2.in
View file @
80b99e40
...
@@ -22,7 +22,7 @@ config-use-ipv6 = {{ dumps(slapparameter_dict.get('use-ipv6', False)) }}
...
@@ -22,7 +22,7 @@ config-use-ipv6 = {{ dumps(slapparameter_dict.get('use-ipv6', False)) }}
# Request kvm instances
# Request kvm instances
{% for instance_name, kvm_parameter_dict in slapparameter_dict.get('kvm-partition-dict', {'kvm-default': {}}).items() -%}
{% for instance_name, kvm_parameter_dict in slapparameter_dict.get('kvm-partition-dict', {'kvm-default': {}}).items() -%}
{% set section = 'request-' ~ instance_name -%}
{% set section = 'request-' ~ instance_name -%}
{% set use_nat = kvm_parameter_dict.get('use-nat',
True
) -%}
{% set use_nat = kvm_parameter_dict.get('use-nat',
'True'
) -%}
[{{ section }}]
[{{ section }}]
<= request-common
<= request-common
software-type = kvm
software-type = kvm
...
@@ -73,12 +73,12 @@ config-document-path = ${http-server:path}
...
@@ -73,12 +73,12 @@ config-document-path = ${http-server:path}
return =
return =
backend-url
backend-url
url
url
{% if use_nat -%}
{% if use_nat
.lower()
-%}
{% for port in nat_rules_list -%}
{% for port in nat_rules_list -%}
{{ ' ' }}nat-rule-url-{{ port }}
{{ ' ' }}nat-rule-url-{{ port }}
{% endfor -%}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if kvm_parameter_dict.get('use-tap',
True)
-%}
{% if kvm_parameter_dict.get('use-tap',
'True').lower() == 'true'
-%}
{{ ' ' }}tap-ipv4
{{ ' ' }}tap-ipv4
{% do publish_dict.__setitem__('lan-' ~ instance_name, '${' ~ section ~ ':connection-tap-ipv4}') -%}
{% do publish_dict.__setitem__('lan-' ~ instance_name, '${' ~ section ~ ':connection-tap-ipv4}') -%}
...
@@ -86,7 +86,7 @@ return =
...
@@ -86,7 +86,7 @@ return =
{% endif -%}
{% endif -%}
{% do publish_dict.__setitem__(instance_name ~ '-backend-url', '${' ~ section ~ ':connection-backend-url}') -%}
{% do publish_dict.__setitem__(instance_name ~ '-backend-url', '${' ~ section ~ ':connection-backend-url}') -%}
{% do publish_dict.__setitem__(instance_name ~ '-url', '${' ~ section ~ ':connection-url}') -%}
{% do publish_dict.__setitem__(instance_name ~ '-url', '${' ~ section ~ ':connection-url}') -%}
{% do kvm_instance_dict.__setitem__(instance_name, (
kvm_parameter_dict.get('use-nat', True)
, nat_rules_list)) -%}
{% do kvm_instance_dict.__setitem__(instance_name, (
use_nat
, nat_rules_list)) -%}
{% endfor %}
{% endfor %}
...
@@ -145,6 +145,7 @@ log = ${:var}/log
...
@@ -145,6 +145,7 @@ log = ${:var}/log
scripts = ${:etc}/run
scripts = ${:etc}/run
services = ${:etc}/service
services = ${:etc}/service
document = ${:srv}/document
document = ${:srv}/document
promises = ${:etc}/promise
ssl = ${:etc}/ssl
ssl = ${:etc}/ssl
[http-ssl]
[http-ssl]
...
@@ -164,8 +165,16 @@ wrapper = ${directory:services}/simple-http-server
...
@@ -164,8 +165,16 @@ wrapper = ${directory:services}/simple-http-server
log-file = ${directory:log}/http.log
log-file = ${directory:log}/http.log
cert-file = ${http-ssl:cert}
cert-file = ${http-ssl:cert}
key-file = ${http-ssl:key}
key-file = ${http-ssl:key}
{% do publish_dict.__setitem__('http-file-server', 'https://' ~ '[${http-server:host}]:' ~ '${http-server:port}/' ~ '${http-server:path}') -%}
use-hash-url = true
[http-promise]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promises}/http-server
hostname = ${http-server:host}
port = ${http-server:port}
{% if len(kvm_hostname_list) -%}
{% do part_list.append('write-vm-hostname') -%}
[write-vm-hostname]
[write-vm-hostname]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
template = {{ template_content }}
template = {{ template_content }}
...
@@ -174,6 +183,7 @@ rendered = ${http-server:root-dir}/${:filename}
...
@@ -174,6 +183,7 @@ rendered = ${http-server:root-dir}/${:filename}
context =
context =
raw content_list {{ kvm_hostname_list | join('#') }}
raw content_list {{ kvm_hostname_list | join('#') }}
raw sep #
raw sep #
{% endif -%}
{% macro writefile(section_name, file_path, content, mode='') -%}
{% macro writefile(section_name, file_path, content, mode='') -%}
{% do part_list.append(section_name) -%}
{% do part_list.append(section_name) -%}
...
@@ -199,7 +209,7 @@ recipe = slapos.cookbook:publish
...
@@ -199,7 +209,7 @@ recipe = slapos.cookbook:publish
[buildout]
[buildout]
parts =
parts =
http-server
http-server
write-vm-hostnam
e
http-promis
e
publish
publish
# Complete parts with sections
# Complete parts with sections
{{ part_list | join('\n ') }}
{{ part_list | join('\n ') }}
...
...
software/kvm/instance-kvm-input-schema.json
View file @
80b99e40
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
"description"
:
"Type of QEMU disk drive, to create."
,
"description"
:
"Type of QEMU disk drive, to create."
,
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"qcow2"
,
"default"
:
"qcow2"
,
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
]
"enum"
:
[
"qcow2"
,
"raw"
,
"vdi"
,
"vmdk"
,
"cloop"
,
"qed"
]
},
},
"use-tap"
:
{
"use-tap"
:
{
...
...
software/kvm/instance-kvm.cfg.jinja2
View file @
80b99e40
{% set enable_http = slapparameter_dict.get('enable-http-server', 'False') -%}
{% set enable_http = slapparameter_dict.get('enable-http-server', 'False').lower() -%}
{% set use_tap = slapparameter_dict.get('use-tap', 'False').lower() -%}
{% set use_nat = slapparameter_dict.get('use-nat', 'True').lower() -%}
#############################
#############################
#
#
# Instanciate kvm
# Instanciate kvm
...
@@ -19,7 +21,7 @@ parts =
...
@@ -19,7 +21,7 @@ parts =
{% if slapparameter_dict.get('document-host', '') %}
{% if slapparameter_dict.get('document-host', '') %}
cluster-url-path
cluster-url-path
{% endif -%}
{% endif -%}
{% if
slapparameter_dict.get('enable-http-server', 'False') == 'T
rue' %}
{% if
enable_http == 't
rue' %}
httpd
httpd
httpd-promise
httpd-promise
publish-host-config
publish-host-config
...
@@ -30,8 +32,8 @@ parts =
...
@@ -30,8 +32,8 @@ parts =
get-authorized-key
get-authorized-key
{% endif -%}
{% endif -%}
extends =
#
extends =
{{ template_httpd_cfg }}
#
{{ template_httpd_cfg }}
{% endif -%}
{% endif -%}
eggs-directory = {{ eggs_directory }}
eggs-directory = {{ eggs_directory }}
...
@@ -133,7 +135,7 @@ external-disk-number = ${slap-parameter:external-disk-number}
...
@@ -133,7 +135,7 @@ external-disk-number = ${slap-parameter:external-disk-number}
external-disk-size = ${slap-parameter:external-disk-size}
external-disk-size = ${slap-parameter:external-disk-size}
external-disk-format = ${slap-parameter:external-disk-format}
external-disk-format = ${slap-parameter:external-disk-format}
{% if
slapparameter_dict.get('enable-http-server', 'False') == 'True' or ( slapparameter_dict.get('use-tap', 'False') == 'T
rue' and tap_network_dict.has_key('ipv4') ) -%}
{% if
enable_http == 'tue' or ( use_tap == 't
rue' and tap_network_dict.has_key('ipv4') ) -%}
httpd-port = ${slap-parameter:httpd-port}
httpd-port = ${slap-parameter:httpd-port}
{% else -%}
{% else -%}
httpd-port = 0
httpd-port = 0
...
@@ -270,6 +272,23 @@ dash_path = {{ dash_executable_location }}
...
@@ -270,6 +272,23 @@ dash_path = {{ dash_executable_location }}
curl_path = {{ curl_executable_location }}
curl_path = {{ curl_executable_location }}
{% if enable_http == 'true' %}
[httpd]
recipe = slapos.cookbook:simplehttpserver
host = ${slap-network-information:local-ipv4}
port = ${slap-parameter:httpd-port}
base-path = ${directory:public}
wrapper = ${directory:services}/http-server
log-file = ${directory:log}/httpd.log
use-hash-url = false
[httpd-promise]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promises}/httpd
hostname = ${httpd:host}
port = ${httpd:port}
{% endif %}
[publish-connection-information]
[publish-connection-information]
recipe = slapos.cookbook:publish
recipe = slapos.cookbook:publish
ipv6 = ${slap-network-information:global-ipv6}
ipv6 = ${slap-network-information:global-ipv6}
...
@@ -278,7 +297,7 @@ url = ${request-slave-frontend:connection-url}/vnc_auto.html?host=${request-slav
...
@@ -278,7 +297,7 @@ url = ${request-slave-frontend:connection-url}/vnc_auto.html?host=${request-slav
{% set disk_number = len(storage_dict) -%}
{% set disk_number = len(storage_dict) -%}
maximum-extra-disk-amount = {{ disk_number }}
maximum-extra-disk-amount = {{ disk_number }}
{% set iface = 'eth0' -%}
{% set iface = 'eth0' -%}
{% if
slapparameter_dict.get('use-nat', 'True') == 'T
rue' -%}
{% if
use_nat == 't
rue' -%}
{% set iface = 'eth1' -%}
{% set iface = 'eth1' -%}
# Publish NAT port mapping status
# Publish NAT port mapping status
# XXX: hardcoded value from [slap-parameter]
# XXX: hardcoded value from [slap-parameter]
...
@@ -291,13 +310,13 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:{{external_por
...
@@ -291,13 +310,13 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:{{external_por
{% endif -%}
{% endif -%}
{% endfor -%}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if
slapparameter_dict.get('use-tap', 'False') == 'T
rue' -%}
{% if
use_tap == 't
rue' -%}
tap-ipv4 = ${slap-network-information:tap-ipv4}
tap-ipv4 = ${slap-network-information:tap-ipv4}
{% endif -%}
{% endif -%}
{% set kvm_http = 'http://${slap-network-information:local-ipv4}:' ~ slapparameter_dict.get('httpd-port', 8081) -%}
{% set kvm_http = 'http://${slap-network-information:local-ipv4}:' ~ slapparameter_dict.get('httpd-port', 8081) -%}
{% if enable_http == 'True' %}
{% if enable_http == 'True' %}
{% if
slapparameter_dict.get('use-nat', 'True') == 'T
rue' -%}
{% if
use_nat == 't
rue' -%}
{% set kvm_http = 'http://10.0.2.100' -%}
{% set kvm_http = 'http://10.0.2.100' -%}
{% endif %}
{% endif %}
{% if slapparameter_dict.get('authorized-key', '') -%}
{% if slapparameter_dict.get('authorized-key', '') -%}
...
@@ -305,13 +324,13 @@ tap-ipv4 = ${slap-network-information:tap-ipv4}
...
@@ -305,13 +324,13 @@ tap-ipv4 = ${slap-network-information:tap-ipv4}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if
slapparameter_dict.get('use-tap', 'False') == 'T
rue' and tap_network_dict.has_key('ipv4') -%}
{% if
use_tap == 't
rue' and tap_network_dict.has_key('ipv4') -%}
1_info = Use these configurations below to configure interface {{ iface }} in your VM.
1_info = Use these configurations below to configure interface {{ iface }} in your VM.
2_info = ${network-config:ifconfig}
2_info = ${network-config:ifconfig}
3_info = ${network-config:route-iface}
3_info = ${network-config:route-iface}
4_info = ${network-config:route-network}
4_info = ${network-config:route-network}
5_info = ${network-config:route-default}
5_info = ${network-config:route-default}
{% if enable_http == '
T
rue' %}
{% if enable_http == '
t
rue' %}
6_info = Or run in your VM the command: wget -O- {{ kvm_http }}/netconfig.sh | /bin/sh -
6_info = Or run in your VM the command: wget -O- {{ kvm_http }}/netconfig.sh | /bin/sh -
{% endif %}
{% endif %}
...
@@ -357,7 +376,7 @@ mode = {{ mode }}
...
@@ -357,7 +376,7 @@ mode = {{ mode }}
[publish-host-config]
[publish-host-config]
recipe = plone.recipe.command
recipe = plone.recipe.command
name = {{ slapparameter_dict.get('name', 'localhost') }}
name = {{ slapparameter_dict.get('name', 'localhost') }}
{% if
slapparameter_dict.get('use-tap', 'False') == 'T
rue' and tap_network_dict.has_key('ipv4') -%}
{% if
use_tap == 't
rue' and tap_network_dict.has_key('ipv4') -%}
local-ipv4 = ${slap-network-information:tap-ipv4}
local-ipv4 = ${slap-network-information:tap-ipv4}
{% else -%}
{% else -%}
local-ipv4 = 127.0.0.1
local-ipv4 = 127.0.0.1
...
...
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