Your Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame] | 1 | {%- from "baremetal_simulator/map.jinja" import baremetal_simulator,bs_nodes with context %} |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 2 | {%- if baremetal_simulator.enabled %} |
| 3 | |
| 4 | simulator_pkgs: |
| 5 | pkg.installed: |
| 6 | - names: {{ baremetal_simulator.pkgs }} |
| 7 | |
| 8 | simulator_pip_pkgs: |
| 9 | pip.installed: |
| 10 | - names: {{ baremetal_simulator.pip_pkgs }} |
| 11 | - require: |
Vasyl Saienko | 5a853fd | 2017-07-10 14:40:05 +0300 | [diff] [blame^] | 12 | - simulator_pkgs |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 13 | |
| 14 | libvirt-bin: |
| 15 | service.running: |
| 16 | - watch: |
| 17 | - file: /etc/libvirt/qemu.conf |
| 18 | |
| 19 | cgroup: |
| 20 | file.append: |
| 21 | - name: /etc/libvirt/qemu.conf |
Your Name | 8ba5482 | 2017-05-12 12:17:39 +0000 | [diff] [blame] | 22 | - source: salt://baremetal_simulator/files/qemu-cgroup.conf |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 23 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 24 | default_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 Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame] | 33 | {%- for identity_name, nodes in bs_nodes.iteritems() %} |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 34 | {%- for node in nodes %} |
| 35 | |
| 36 | disk_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 | |
| 41 | vm_{{ 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 | |
| 54 | vbcm_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 | |
| 59 | vbmc_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 Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 64 | {%- 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 Name | 8c482f2 | 2017-06-21 09:45:57 +0000 | [diff] [blame] | 74 | - bridge: br-simulator |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 75 | |
Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 76 | {%- endfor %} |
| 77 | |
| 78 | {%- endfor %} |
| 79 | {%- endfor %} |
| 80 | {%- endif %} |