[buildout]
# Note that we don't extend instance.cfg.in from ../software/kvm because it
# would bring all the resilient stuff that we don't need. The drawback is we
# can't share all the template parameters.
parts =
  switch_softwaretype

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}

[switch_softwaretype]
recipe = slapos.cookbook:switch-softwaretype
default = dynamic-template-vps:output
vpsbrute-4disks = dynamic-template-vpsbrute-4disks:output
vpsbrute-6disks = dynamic-template-vpsbrute-6disks:output
vpsbrute-10disks = dynamic-template-vpsbrute-10disks:output

[slap-configuration]
# we usejsonschema recipe in order to force some values for VPS (see all the const in the JSON schema)
<= slap-connection
recipe = slapos.cookbook:slapconfiguration.jsonschema
jsonschema = ${software.json:target}
set-default = main
validate-parameters = main

[slap-configuration-vps]
# this section will force all constant values for VPS
recipe  = slapos.recipe.build
depends = $${slap-configuration:configuration}
init =
  conf = self.buildout['slap-configuration']['configuration']
  # we know for sure that there is only the boot-image parameters in conf
  # so only set what is custom compared to default values
  ${slap-configuration-common:common-all}
  conf['ram-size'] = 245760
  conf['ram-max-size'] = 246272
  conf['cpu-count'] = 40
  conf['cpu-max-count'] = 41
  conf['disk-device-path'] = "/dev/sdb"
  options['configuration'] = conf
  # XXX we should make sure this configuration matches KVM json schema...

[slap-configuration-vpsbrute-4disks]
# this section will force all constant values for VPSbrute 4 disks
recipe  = slapos.recipe.build
depends = $${slap-configuration:configuration}
init =
  conf = self.buildout['slap-configuration']['configuration']
  ${slap-configuration-common:common-all}
  ${slap-configuration-common:common-vpsbrute}
  conf['disk-device-path'] = "/dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1"
  options['configuration'] = conf
  # XXX we should make sure this configuration matches KVM json schema...

[slap-configuration-vpsbrute-6disks]
# this section will force all constant values for VPSbrute 4 disks
recipe  = slapos.recipe.build
depends = $${slap-configuration:configuration}
init =
  conf = self.buildout['slap-configuration']['configuration']
  ${slap-configuration-common:common-all}
  ${slap-configuration-common:common-vpsbrute}
  conf['disk-device-path'] = "/dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1 /dev/nvme4n1 /dev/nvme5n1"
  options['configuration'] = conf
  # XXX we should make sure this configuration matches KVM json schema...

[slap-configuration-vpsbrute-10disks]
# this section will force all constant values for VPSbrute 4 disks
recipe  = slapos.recipe.build
depends = $${slap-configuration:configuration}
init =
  conf = self.buildout['slap-configuration']['configuration']
  ${slap-configuration-common:common-all}
  ${slap-configuration-common:common-vpsbrute}
  conf['disk-device-path'] = "/dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1 /dev/nvme4n1 /dev/nvme5n1 /dev/nvme6n1 /dev/nvme7n1 /dev/nvme8n1 /dev/nvme9n1"
  options['configuration'] = conf
  # XXX we should make sure this configuration matches KVM json schema...

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
url = ${template-kvm:location}/instance-kvm.cfg.jinja2
output = $${buildout:directory}/$${:filename}
extensions = jinja2.ext.do
extra-context =
context =
  key develop_eggs_directory buildout:develop-eggs-directory
  key eggs_directory buildout:eggs-directory
  key ipv4 slap-configuration:ipv4
  key ipv6 slap-configuration:ipv6
  key global_ipv4_prefix network-information:global-ipv4-network
  key storage_dict slap-configuration:storage-dict

  key computer_id slap-configuration:computer-id
  raw openssl_executable_location ${openssl:location}/bin/openssl
  section slap_configuration slap-configuration
  raw ansible_promise_tpl ${template-ansible-promise:target}
  raw curl_executable_location ${curl:location}/bin/curl
  raw dash_executable_location ${dash:location}/bin/dash
  raw dnsresolver_executable ${buildout:bin-directory}/dnsresolver
  raw dcron_executable_location ${dcron:location}/sbin/crond
  raw boot_image_select_source_config ${boot-image-select-source-config:target}
  raw whitelist_domains_default ${whitelist-domains-default:target}
  raw whitelist_firewall_download_controller ${whitelist-firewall-download-controller:output}
  raw image_download_controller ${image-download-controller:output}
  raw image_download_config_creator ${image-download-config-creator:output}
  raw logrotate_cfg ${template-logrotate-base:output}
  raw novnc_location ${noVNC:location}
  raw netcat_bin ${netcat:location}/bin/netcat
  raw nginx_executable ${nginx-output:nginx}
  raw nginx_mime ${nginx-output:mime}
  raw python_executable ${buildout:executable}
  raw python_eggs_executable ${buildout:bin-directory}/${python-with-eggs:interpreter}
  raw qemu_executable_location ${qemu:location}/bin/qemu-system-x86_64
  raw qemu_img_executable_location ${qemu:location}/bin/qemu-img
  raw qemu_start_promise_tpl ${template-qemu-ready:target}
  raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel
  raw template_httpd_cfg ${template-httpd:output}
  raw template_content ${template-content:target}
  raw template_kvm_controller_run ${template-kvm-controller:target}
  raw template_kvm_run ${template-kvm-run:target}
  raw template_monitor ${monitor2-template:output}
  raw template_nginx ${template-nginx:target}
  raw websockify_executable_location ${buildout:directory}/bin/websockify
  raw wipe_disk_wrapper ${buildout:directory}/bin/securedelete
  $${:extra-context}

[dynamic-template-vps]
<= jinja2-template-base
filename = template-vps.cfg
extra-context =
  key slapparameter_dict slap-configuration-vps:configuration

[dynamic-template-vpsbrute-4disks]
<= jinja2-template-base
filename = template-vpsbrute-4disks.cfg
extra-context =
  key slapparameter_dict slap-configuration-vpsbrute-4disks:configuration

[dynamic-template-vpsbrute-6disks]
<= jinja2-template-base
filename = template-vpsbrute-6disks.cfg
extra-context =
  key slapparameter_dict slap-configuration-vpsbrute-6disks:configuration

[dynamic-template-vpsbrute-10disks]
<= jinja2-template-base
filename = template-vpsbrute-10disks.cfg
extra-context =
  key slapparameter_dict slap-configuration-vpsbrute-10disks:configuration
