| {%- from "baremetal_simulator/map.jinja" import baremetal_simulator,bs_nodes with context %} |
| {%- if baremetal_simulator.enabled %} |
| |
| simulator_pkgs: |
| pkg.installed: |
| - names: {{ baremetal_simulator.pkgs }} |
| |
| simulator_pip_pkgs: |
| pip.installed: |
| - names: {{ baremetal_simulator.pip_pkgs }} |
| - require: |
| - simulator_pkgs |
| |
| libvirt-bin: |
| service.running: |
| - watch: |
| - file: /etc/libvirt/qemu.conf |
| |
| cgroup: |
| file.append: |
| - name: /etc/libvirt/qemu.conf |
| - source: salt://baremetal_simulator/files/qemu-cgroup.conf |
| |
| default_pool: |
| cmd.run: |
| - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default |
| - unless: virsh pool-info default |
| |
| /var/log/ironic-bm-logs/: |
| file.directory: |
| - makedirs: true |
| |
| {%- for identity_name, nodes in bs_nodes.iteritems() %} |
| {%- for node in nodes %} |
| |
| disk_create_node{{ loop.index }}: |
| cmd.run: |
| - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2 |
| - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2 |
| |
| vm_{{ node.name }}_present: |
| cmd.run: |
| - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml |
| - onchanges: |
| - file: /tmp/{{ node.name }}.xml |
| |
| /tmp/{{ node.name }}.xml: |
| file.managed: |
| - source: salt://baremetal_simulator/files/vm.xml |
| - template: jinja |
| - defaults: |
| node: {{ node }} |
| |
| vbcm_add_{{ node.name }}: |
| cmd.run: |
| - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }} |
| - unless: vbmc show {{ node.name }} |
| |
| vbmc_start_{{ node.name }}: |
| cmd.run: |
| - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1 |
| - unless: vbmc show {{ node.name }} | grep status |grep -q running |
| |
| {%- for port in node.ports %} |
| |
| {{ node.name }}_tap_device_{{ loop.index }}: |
| cmd.run: |
| - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up |
| - unless: ip link show tap-{{ node.name }}i{{ loop.index }} |
| |
| {{ node.name }}_tap{{ loop.index }}_in_ovs: |
| openvswitch_port.present: |
| - name: tap-{{ node.name }}i{{ loop.index }} |
| - bridge: br-simulator |
| |
| {%- endfor %} |
| |
| {%- endfor %} |
| {%- endfor %} |
| {%- endif %} |