instance-kvm-resilient.cfg.jinja2 1.79 KB
Newer Older
1 2 3
# vim: set ft=cfg:

{% import 'parts' as parts %}
4
{% import 'replicated' as replicated with context %}
5

6
{% set backup_amount = slapparameter_dict.pop('resilient-clone-number', "1")|int + 1 -%}
7

8 9 10 11 12 13 14
[buildout]
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true

# += because we need to take up parts (like instance-custom, slapmonitor etc) from the profile we extended
parts +=
15
  {{ parts.replicate("kvm", backup_amount) }}
16
  publish-connection-informations
17
  kvm-frontend-url-promise
18
  kvm-backend-url-promise
19

20
{{ replicated.replicate("kvm", backup_amount, "kvm-export", "kvm-import", slapparameter_dict=slapparameter_dict) }}
21

22 23
[directory]
recipe = slapos.cookbook:mkdirectory
24 25
etc = ${buildout:directory}/etc
promises = ${:etc}/promise
26

27
# Bubble down the parameters of the requested instance to the user
28
[request-kvm]
29
# Note: += doesn't work.
30 31 32 33
return =
# Resilient related parameters
  url ssh-public-key ssh-url notification-id ip
# KVM related parameters
34
# XXX: return ALL parameters (like nat rules), through jinja
35
  backend-url url ip
36 37 38 39 40

[publish-connection-informations]
recipe = slapos.cookbook:publish
backend-url = ${request-kvm:connection-backend-url}
url = ${request-kvm:connection-url}
41
ipv6 = ${request-kvm:connection-ip}
42 43 44 45 46 47 48 49 50 51 52

[kvm-frontend-url-promise]
# Check that url parameter is complete
recipe = collective.recipe.template
input = inline:#!/bin/sh
  URL="${request-kvm:connection-url}"
  if [[ ! "$URL" == https://* ]]; then
    exit 1
  fi
output = ${resilient-directory:promise}/kvm-frontend-url
mode = 700
53 54 55 56 57

[kvm-backend-url-promise]
# Check that backend url is reachable
recipe = slapos.cookbook:check_url_available
path = ${directory:promises}/frontend_promise
58
url = ${publish-connection-informations:url}
59 60
dash_path = /bin/sh
curl_path = {{ curl_executable_location }}