blob: 1cfdfa4bf8ba832a6f3fa4315e091a1778e21320 [file] [log] [blame]
Your Name902fb6b2017-06-21 15:34:36 +00001{%- from "baremetal_simulator/map.jinja" import baremetal_simulator,bs_nodes with context %}
Your Name8324a3a2017-05-12 10:47:21 +00002{%- if baremetal_simulator.enabled %}
3
4simulator_pkgs:
5 pkg.installed:
6 - names: {{ baremetal_simulator.pkgs }}
7
8simulator_pip_pkgs:
9 pip.installed:
10 - names: {{ baremetal_simulator.pip_pkgs }}
11 - require:
Vasyl Saienko5a853fd2017-07-10 14:40:05 +030012 - simulator_pkgs
Your Name8324a3a2017-05-12 10:47:21 +000013
14libvirt-bin:
15 service.running:
16 - watch:
17 - file: /etc/libvirt/qemu.conf
18
19cgroup:
20 file.append:
21 - name: /etc/libvirt/qemu.conf
Your Name8ba54822017-05-12 12:17:39 +000022 - source: salt://baremetal_simulator/files/qemu-cgroup.conf
Your Name8324a3a2017-05-12 10:47:21 +000023
Your Name8324a3a2017-05-12 10:47:21 +000024default_pool:
25 cmd.run:
26 - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default
27 - unless: virsh pool-info default
28
29/var/log/ironic-bm-logs/:
30 file.directory:
31 - makedirs: true
32
Your Name902fb6b2017-06-21 15:34:36 +000033{%- for identity_name, nodes in bs_nodes.iteritems() %}
Your Name8324a3a2017-05-12 10:47:21 +000034 {%- for node in nodes %}
35
36disk_create_node{{ loop.index }}:
37 cmd.run:
38 - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2
39 - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2
40
41vm_{{ node.name }}_present:
42 cmd.run:
43 - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml
44 - onchanges:
45 - file: /tmp/{{ node.name }}.xml
46
47/tmp/{{ node.name }}.xml:
48 file.managed:
49 - source: salt://baremetal_simulator/files/vm.xml
50 - template: jinja
51 - defaults:
52 node: {{ node }}
53
54vbcm_add_{{ node.name }}:
55 cmd.run:
56 - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }}
57 - unless: vbmc show {{ node.name }}
58
59vbmc_start_{{ node.name }}:
60 cmd.run:
61 - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1
62 - unless: vbmc show {{ node.name }} | grep status |grep -q running
63
Your Name8324a3a2017-05-12 10:47:21 +000064{%- for port in node.ports %}
65
66{{ node.name }}_tap_device_{{ loop.index }}:
67 cmd.run:
68 - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up
69 - unless: ip link show tap-{{ node.name }}i{{ loop.index }}
70
71{{ node.name }}_tap{{ loop.index }}_in_ovs:
72 openvswitch_port.present:
73 - name: tap-{{ node.name }}i{{ loop.index }}
Your Name8c482f22017-06-21 09:45:57 +000074 - bridge: br-simulator
Your Name8324a3a2017-05-12 10:47:21 +000075
Your Name8324a3a2017-05-12 10:47:21 +000076{%- endfor %}
77
78{%- endfor %}
79{%- endfor %}
80{%- endif %}