File: guest_environments.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (59 lines) | stat: -rw-r--r-- 1,619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Guest environments bodies

body environment_resources kvm(name, arch, cpu_count, mem_kb, disk_file)
# @brief An `environment_resources` body for a KVM virtual machine.
#
# The `env_spec` attribute is set to a KVM XML specification.
#
# @param name The name of the virtual machine
# @param arch The architecture
# @param cpu_count The number of CPUs the virtual machine should have
# @param mem_kb The amount of RAM in kilobyte
# @param disk_file The file on the host system for the virtual machine's harddrive
#
# **Example:**
#
# ```cf3
# bundle agent manage_vm
# {
# guest_environments:
#   am_vm_host::
#     "db_server"
#       environment_host      => atlas,
#       environment_type      => "kvm",
#       environment_state     => "create",
#       environment_resources => kvm("PSQL1, "x86_64", "4", "4096", "/var/lib/libvirt/images/psql1.iso")
# }
# ```
{
      env_spec =>
      "<domain type='kvm'>
  <name>$(name)</name>
  <memory>$(mem_kb)</memory>
  <currentMemory>$(mem_kb)</currentMemory>
  <vcpu>$(cpu_count)</vcpu>
  <os>
    <type arch='$(arch)'>hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <source file='$(disk_file)'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
  </devices>
</domain>";
}