Commit 46fef392 authored by Kristopher Ruzic's avatar Kristopher Ruzic

add an actual working (as in runnable) packer SR

this still has a long way to go, but it's getting there. Some stuff is not done properly at all
parent 0f1edbf2
...@@ -178,7 +178,7 @@ def getMapStorageList(disk_storage_dict, external_disk_number): ...@@ -178,7 +178,7 @@ def getMapStorageList(disk_storage_dict, external_disk_number):
return id_list, external_disk_number return id_list, external_disk_number
# Download existing hard drive if needed at first boot # Download existing hard drive if needed at first boot
if not (os.path.exists(disk_path) or os.path.exists(packer_path)) and virtual_hard_drive_url != '': if not (os.path.exists(disk_path) or '%(is-packer)s') 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
......
...@@ -20,6 +20,8 @@ extends = ...@@ -20,6 +20,8 @@ extends =
# to avoid versioning issues # to avoid versioning issues
parts = parts =
slapos-cookbook
slapos-cookbook-develop
template template
eggs eggs
...@@ -87,7 +89,7 @@ command = ...@@ -87,7 +89,7 @@ command =
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in url = ${:_profile_base_location_}/instance.cfg.in
md5sum = cf67212d3155767d0d0d8a6d75d2d8ad #md5sum = ac3924b48aa22d70efb5316374acfb39
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
...@@ -194,6 +196,15 @@ md5sum = 47d492dafe5cb314bdc49bf013d21ead ...@@ -194,6 +196,15 @@ md5sum = 47d492dafe5cb314bdc49bf013d21ead
download-only = true download-only = true
on-update = true on-update = true
[template-packer]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/packer-wrapper.in
mode = 644
filename = packer-wrapper.in
md5sum = 718ae65d6410bc30001666e90ed46794
download-only = true
on-update = true
[template-httpd] [template-httpd]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
filename = template-httpd.cfg filename = template-httpd.cfg
......
...@@ -6,16 +6,19 @@ ...@@ -6,16 +6,19 @@
############################# #############################
[buildout] [buildout]
parts = parts =
packer
certificate-authority certificate-authority
publish-connection-information publish-connection-information
# kvm-vnc-promise # kvm-vnc-promise
kvm-disk-image-corruption-promise # kvm-disk-image-corruption-promise
websockify-sighandler websockify-sighandler
novnc-promise novnc-promise
# kvm-monitor # kvm-monitor
cron cron
# cron-entry-monitor # cron-entry-monitor
frontend-promise # frontend-promise
packer-build-template
{% if slapparameter_dict.get('document-host', '') %} {% if slapparameter_dict.get('document-host', '') %}
cluster-url-path cluster-url-path
{% endif -%} {% endif -%}
...@@ -23,7 +26,7 @@ parts = ...@@ -23,7 +26,7 @@ parts =
httpd httpd
httpd-promise httpd-promise
publish-host-config publish-host-config
packer-build-template
extends = extends =
{{ template_httpd_cfg }} {{ template_httpd_cfg }}
...@@ -31,7 +34,6 @@ extends = ...@@ -31,7 +34,6 @@ extends =
eggs-directory = {{ eggs_directory }} eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }} develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -70,7 +72,7 @@ bytes = 8 ...@@ -70,7 +72,7 @@ bytes = 8
# Specific code. It needs Jinja. # Specific code. It needs Jinja.
recipe = slapos.cookbook:kvm recipe = slapos.cookbook:kvm
is-packer = True is-packer = True
vnc-passwd = '' vnc-passwd = 'l'
ipv4 = ${slap-network-information:local-ipv4} ipv4 = ${slap-network-information:local-ipv4}
ipv6 = ${slap-network-information:global-ipv6} ipv6 = ${slap-network-information:global-ipv6}
...@@ -100,6 +102,7 @@ ram-size = ${slap-parameter:ram-size} ...@@ -100,6 +102,7 @@ ram-size = ${slap-parameter:ram-size}
numa = ${slap-parameter:numa} numa = ${slap-parameter:numa}
mac-address = ${create-mac:mac-address} mac-address = ${create-mac:mac-address}
tap-mac-address = ${create-tap-mac:mac-address} tap-mac-address = ${create-tap-mac:mac-address}
kvm-software-type = software-test
# XXX-Cedric: should be named runner-wrapper-path and controller-wrapper-path # XXX-Cedric: should be named runner-wrapper-path and controller-wrapper-path
runner-path = ${directory:services}/kvm runner-path = ${directory:services}/kvm
...@@ -394,26 +397,48 @@ shell-path = {{ dash_executable_location }} ...@@ -394,26 +397,48 @@ shell-path = {{ dash_executable_location }}
6tunnel-path = {{ sixtunnel_executable_location }} 6tunnel-path = {{ sixtunnel_executable_location }}
runner-path = ${directory:services}/6tunnel-cluster runner-path = ${directory:services}/6tunnel-cluster
[packer]
recipe = slapos.recipe.build
# here, two %s are used, first one is for directory name (eg. x86_64), and second one is for filename (eg. x86-64).
url_x86-64 = https://dl.bintray.com/mitchellh/packer/packer_0.7.5_linux_amd64.zip
url_x86 = https://dl.bintray.com/mitchellh/packer/packer_0.7.5_linux_386.zip
# supported architectures md5sums
md5sum_x86 = a545108a0ccfde7c1e74de6c4e6fdded
md5sum_x86-64 = f343d709b84db494e8d6ec38259aa4a6
# script to install.
script =
location = %(location)r
self.failIfPathExists(location)
import sys
ARCH_DIR_MAP = { 'x86': 'x86', 'x86-64': 'x86_64' }
WK_SUFIX_MAP = { 'x86': '386', 'x86-64': 'amd64' }
platform = guessPlatform()
url = self.options['url_' + platform]
md5sum = self.options['md5sum_' + platform]
extract_dir = self.extract(self.download(url, md5sum))
shutil.move(extract_dir, location)
[packer-build-template] [packer-build-template]
< = jinja2-template-base recipe = slapos.recipe.template:jinja2
template = ${packer-template-wrapper:output} template = {{ packer_wrapper }}
rendered = $${directory:scripts}/packer-build rendered = ${directory:scripts}/packer-build
mode = 0700 mode = 0700
extra-context = context =
key env packer-configuration:packer-environment key env packer-configuration:packer-environment
key content packer-configuration:packer-build-command key content packer-configuration:packer-build-command
key dash dash_executable_location key dash other:dash-exe
[packer-configuration] [packer-configuration]
packer-environment = ${buildout:parts-directory}/qemu/bin/ packer-environment = ${buildout:parts-directory}/qemu/bin/
packer-build-command = packer-build-command =
${buildout:parts-directory}/packer/packer build -color=false ${buildout:directory}/packer.json ${buildout:parts-directory}/packer/packer build -color=false ${buildout:directory}/packer.json
[packer-template-wrapper]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/templates/packer-wrapper.in
output = ${buildout:directory}/packer-template-wrapper.cfg
mode = 0644
[slap-parameter] [slap-parameter]
# Default values if not specified # Default values if not specified
...@@ -463,3 +488,6 @@ packer-username = nexedi ...@@ -463,3 +488,6 @@ packer-username = nexedi
#XXX: change to use password gen #XXX: change to use password gen
packer-password = test packer-password = test
[other]
dash-exe = {{ dash_executable_location }}
\ No newline at end of file
...@@ -10,7 +10,7 @@ recipe = slapos.cookbook:softwaretype ...@@ -10,7 +10,7 @@ recipe = slapos.cookbook:softwaretype
default = $${:kvm} default = $${:kvm}
kvm-cluster = $${dynamic-template-kvm-cluster:rendered} kvm-cluster = $${dynamic-template-kvm-cluster:rendered}
kvm = $${dynamic-template-kvm:rendered} kvm = $${dynamic-template-kvm:rendered}
packer = ${dynamic-template-packer:rendered} packer = $${dynamic-template-packer:rendered}
nbd = ${template-nbd:output} nbd = ${template-nbd:output}
frontend = ${template-frontend:output} frontend = ${template-frontend:output}
...@@ -166,6 +166,8 @@ context = ...@@ -166,6 +166,8 @@ context =
raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel
raw template_httpd_cfg ${template-httpd:rendered} raw template_httpd_cfg ${template-httpd:rendered}
raw template_content ${template-content:location}/${template-content:filename} raw template_content ${template-content:location}/${template-content:filename}
raw packer_wrapper ${template-packer:location}/${template-packer:filename}
raw packer_dir ${template-packer:location}
raw websockify_executable_location ${buildout:directory}/bin/websockify raw websockify_executable_location ${buildout:directory}/bin/websockify
template-parts-destination = ${template-parts:destination} template-parts-destination = ${template-parts:destination}
template-replicated-destination = ${template-replicated:destination} template-replicated-destination = ${template-replicated:destination}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment