Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
slapos
Commits
e2387787
Commit
e2387787
authored
Jul 10, 2015
by
Kristopher Ruzic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds support for packer image creation, sets cpu type in kvm to host
parent
bf6545aa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
146 additions
and
33 deletions
+146
-33
component/packer/buildout.cfg
component/packer/buildout.cfg
+24
-18
component/packer/debian77.json.jinja2
component/packer/debian77.json.jinja2
+48
-0
component/packer/instance.cfg.in
component/packer/instance.cfg.in
+62
-0
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+12
-9
software/packer/instance.cfg.in
software/packer/instance.cfg.in
+0
-6
No files found.
component/packer/buildout.cfg
View file @
e2387787
[buildout]
parts =
slap-configuration
extends =
../../stack/slapos.cfg
../../component/dash/buildout.cfg
parts +=
dash
dash-output
slapos-cookbook
packer
instance-profile
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
[packer]
...
...
@@ -37,12 +38,17 @@ script =
extract_dir = self.extract(self.download(url, md5sum))
shutil.move(extract_dir, location)
[template-wrapper]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/templates/wrapper.in
output = ${buildout:directory}/template-wrapper.cfg
mode = 0644
[instance-profile]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in
output = ${buildout:directory}/instance.cfg
#md5sum = 968bea0fc81dc604a874c53648b7d13f
mode = 0644
[packer-json-template]
recipe = hexagonit.recipe.download
url = ${instance-parameter:configuration.packer_json}
destination = ${buildout:parts-directory}
filename = packer-template.json
#md5sum = 47d492dafe5cb314bdc49bf013d21ead
download-only = true
on-update = true
\ No newline at end of file
component/packer/debian77.json.jinja2
0 → 100644
View file @
e2387787
{
"variables": {
"user": "nexedi",
"password": "test",
"disk_size": ${disk-size},
"domain": ""
},
"builders":
[
{
"name": "blah",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}",
"iso_url": "http://cdimage.debian.org/debian-cd/8.1.0/amd64/iso-cd/debian-8.1.0-amd64-netinst.iso",
"iso_checksum": "0b31bccccb048d20b551f70830bb7ad0",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",
"boot_wait": "2s",
"boot_command": [
"<esc><wait><wait>",
"install auto ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
"debian-installer=en_US locale=en_US keymap=us ",
"netcfg/get_hostname={{ .Name }} ",
"netcfg/get_domain={{ user `domain`}} ",
"fb=false debconf/frontend=noninteractive ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/username={{user `user`}} ",
"<enter>"
]
}
]
}
\ No newline at end of file
component/packer/instance.cfg.in
0 → 100644
View file @
e2387787
[buildout]
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
extends =
../../software/kvm/instance-kvm.cfg.jinja2
parts +=
packer-json-template
packer-build-template
kvm-instance
[directory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
etc-run = $${:etc}/run
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/$${:filename}
extra-context =
context =
import json_module json
key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory
$${:extra-context}
[instance-parameter]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
configuration.packer_json = ${:_profile_base_location_}/debian77.json.cfg
[packer-json-template]
recipe = slapos.recipe.template
url = $${instance-parameter:configuration.packer_json}
output = ${buildout:parts-directory}/packer-template.json
context =
key disk_size slap-parameter:disk-size
#destination = ${buildout:parts-directory}
#md5sum = 47d492dafe5cb314bdc49bf013d21ead
[packer-build-template]
< = jinja2-template-base
template = ${template-wrapper:output}
rendered = $${directory:etc-run}/packer-build
mode = 0700
extra-context =
key env packer-configuration:packer-environment
key content packer-configuration:packer-build-command
[packer-configuration]
packer-environment = ${buildout:parts-directory}/qemu/bin/
packer-build-command =
${buildout:parts-directory}/packer/packer build -debug -color=false $${packer-json-template:output} > testing.log
[kvm-instance]
disk-path = ${directory:srv}/virtual.qcow2
\ No newline at end of file
slapos/recipe/kvm/template/kvm_run.in
View file @
e2387787
...
...
@@ -2,6 +2,7 @@
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
import ast
import hashlib
import os
import socket
...
...
@@ -14,6 +15,7 @@ import glob
import re
# XXX: give all of this through parameter, don't use this as template, but as module
# use_tap and use_nat set as Bool as per http://stackoverflow.com/a/922374
qemu_img_path = '%(qemu-img-path)s'
qemu_path = '%(qemu-path)s'
disk_size = '%(disk-size)s'
...
...
@@ -26,8 +28,8 @@ virtual_hard_drive_url = '%(virtual-hard-drive-url)s'.strip()
virtual_hard_drive_md5sum = '%(virtual-hard-drive-md5sum)s'.strip()
virtual_hard_drive_gzipped = '%(virtual-hard-drive-gzipped)s'.strip()
nat_rules = '%(nat-rules)s'.strip()
use_tap =
'%(use-tap)s'
use_nat =
'%(use-nat)s'
use_tap =
literal_eval('%(use-tap)s')
use_nat =
literal_eval('%(use-nat)s')
tap_interface = '%(tap-interface)s'
listen_ip = '%(ipv4)s'
mac_address = '%(mac-address)s'
...
...
@@ -49,6 +51,7 @@ netcat_bin = '%(netcat-binary)s'.strip()
cluster_doc_host = '%(cluster-doc-host)s'
cluster_doc_port = %(cluster-doc-port)s
def md5Checksum(file_path):
with open(file_path, 'rb') as fh:
m = hashlib.md5()
...
...
@@ -115,7 +118,7 @@ def getMapStorageList(disk_storage_dict, external_disk_number):
return id_list, external_disk_number
# Download existing hard drive if needed at first boot
if not
os.path.exists(disk_path
) and virtual_hard_drive_url != '':
if not
(os.path.exists(disk_path) or os.path.exists(packer_path)
) and virtual_hard_drive_url != '':
print('Downloading virtual hard drive...')
try:
downloaded_disk = disk_path
...
...
@@ -192,12 +195,11 @@ if disk_storage_dict:
# Generate network parameters
# XXX: use_tap should be a boolean
tap_network_parameter = []
nat_network_parameter = []
numa_parameter = []
number = -1
if use_nat
== 'True'
:
if use_nat:
number += 1
rules = 'user,id=lan%%s,' %% number + ','.join('hostfwd=tcp:%%s:%%s-:%%s' %% (listen_ip,
int(port) + 10000, port) for port in nat_rules.split())
...
...
@@ -209,7 +211,7 @@ if use_nat == 'True':
cluster_doc_host, cluster_doc_port)
nat_network_parameter = ['-netdev', rules,
'-device', 'e1000,netdev=lan%%s,mac=%%s' %% (number, mac_address)]
if use_tap
== 'True'
:
if use_tap:
number += 1
tap_network_parameter = ['-netdev',
'tap,id=lan%%s,ifname=%%s,script=no,downscript=no' %% (number,
...
...
@@ -222,13 +224,14 @@ if smp_options:
key, val = option.split('=')
if key in ('cores', 'threads', 'sockets', 'maxcpus') and val.isdigit():
smp += ',%%s=%%s' %% (key, val)
kvm_argument_list = [qemu_path,
'-enable-kvm', '-smp', smp
,
'-
m', ram_size, '-vga', 'std',
kvm_argument_list += [ qemu_path
,
'-
enable-kvm', '-smp', smp, '-m', ram_size,
'-drive', 'file=%%s,if=%%s' %% (disk_path, disk_type),
'-vnc', '%%s:1,ipv4,password' %% listen_ip,
'-boot', 'order=cd,menu=on',
'-qmp', 'unix:%%s,server' %% socket_path,
'-vga', 'std', '-cpu', 'host',
'-pidfile', pid_file_path,
]
...
...
software/packer/instance.cfg.in
deleted
100644 → 0
View file @
bf6545aa
[packer-build]
recipe = slapos.cookbook:wrapper
command-line =
packer build
${buildout:parts-directory}/${packer-json-template:filename}
\ No newline at end of file
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