| 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 |  | 
| Vasyl Saienko | 64792aa | 2017-08-18 14:45:57 +0300 | [diff] [blame^] | 14 | {%- if baremetal_simulator.get('tor', {}).get('enabled', False) %} | 
|  | 15 |  | 
|  | 16 | openvswitch-vtep-pkg: | 
|  | 17 | pkg.installed: | 
|  | 18 | - name: openvswitch-vtep | 
|  | 19 |  | 
|  | 20 | openvswitch-vtep.init: | 
|  | 21 | file.managed: | 
|  | 22 | - name: /etc/init.d/openvswitch-vtep | 
|  | 23 | - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.init | 
|  | 24 | - require: | 
|  | 25 | - openvswitch-vtep-pkg | 
|  | 26 |  | 
|  | 27 | openvswitch-vtep.default: | 
|  | 28 | file.managed: | 
|  | 29 | - name: /etc/default/openvswitch-vtep | 
|  | 30 | - source: salt://baremetal_simulator/files/openvswitch/openvswitch-vtep.default | 
|  | 31 | - require: | 
|  | 32 | - openvswitch-vtep-pkg | 
|  | 33 |  | 
|  | 34 | openvswitch-vtep: | 
|  | 35 | service.running: | 
|  | 36 | - watch: | 
|  | 37 | - file: /etc/init.d/openvswitch-vtep | 
|  | 38 | - file: /etc/default/openvswitch-vtep | 
|  | 39 | - require: | 
|  | 40 | - openvswitch-vtep.init | 
|  | 41 | - openvswitch-vtep.default | 
|  | 42 |  | 
|  | 43 | br_simulator_ps_present: | 
|  | 44 | cmd.run: | 
|  | 45 | - name: vtep-ctl add-ps br-simulator | 
|  | 46 | - unless: vtep-ctl ps-exists br-simulator | 
|  | 47 |  | 
|  | 48 | br_simulator_vtep_tunnel: | 
|  | 49 | cmd.run: | 
|  | 50 | - name: vtep-ctl set Physical_Switch br-simulator tunnel_ips={{ baremetal_simulator.tor.tunnel_ips }} | 
|  | 51 | - unless: vtep-ctl show br-baremetal | grep -q "tunnel_ips.*{{ baremetal_simulator.tor.tunnel_ips }}" | 
|  | 52 | - require: | 
|  | 53 | - br_simulator_ps_present | 
|  | 54 |  | 
|  | 55 | br_simulator_vtep_management: | 
|  | 56 | cmd.run: | 
|  | 57 | - name: vtep-ctl set Physical_Switch br-simulator management_ips={{ baremetal_simulator.tor.tunnel_ips }} | 
|  | 58 | - unless: vtep-ctl show br-baremetal | grep -q "management_ips.*{{ baremetal_simulator.tor.tunnel_ips }}" | 
|  | 59 | - require: | 
|  | 60 | - br_simulator_ps_present | 
|  | 61 |  | 
|  | 62 | br_simulator_vtep: | 
|  | 63 | cmd.run: | 
|  | 64 | - name: /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach br-simulator | 
|  | 65 | - unless: ps xafu |grep -v grep |grep -q "ovs-vtep .* br-simulator" | 
|  | 66 | - require: | 
|  | 67 | - br_simulator_vtep_management | 
|  | 68 | - br_simulator_vtep_tunnel | 
|  | 69 |  | 
|  | 70 | {%- endif %} | 
|  | 71 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 72 | libvirt-bin: | 
|  | 73 | service.running: | 
|  | 74 | - watch: | 
|  | 75 | - file: /etc/libvirt/qemu.conf | 
|  | 76 |  | 
|  | 77 | cgroup: | 
|  | 78 | file.append: | 
|  | 79 | - name: /etc/libvirt/qemu.conf | 
| Your Name | 8ba5482 | 2017-05-12 12:17:39 +0000 | [diff] [blame] | 80 | - source: salt://baremetal_simulator/files/qemu-cgroup.conf | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 81 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 82 | default_pool: | 
|  | 83 | cmd.run: | 
|  | 84 | - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default | 
|  | 85 | - unless: virsh pool-info default | 
|  | 86 |  | 
|  | 87 | /var/log/ironic-bm-logs/: | 
|  | 88 | file.directory: | 
|  | 89 | - makedirs: true | 
|  | 90 |  | 
| Your Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame] | 91 | {%- for identity_name, nodes in bs_nodes.iteritems() %} | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 92 | {%- for node in nodes %} | 
|  | 93 |  | 
|  | 94 | disk_create_node{{ loop.index }}: | 
|  | 95 | cmd.run: | 
|  | 96 | - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2 | 
|  | 97 | - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2 | 
|  | 98 |  | 
|  | 99 | vm_{{ node.name }}_present: | 
|  | 100 | cmd.run: | 
|  | 101 | - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml | 
|  | 102 | - onchanges: | 
|  | 103 | - file: /tmp/{{ node.name }}.xml | 
|  | 104 |  | 
|  | 105 | /tmp/{{ node.name }}.xml: | 
|  | 106 | file.managed: | 
|  | 107 | - source: salt://baremetal_simulator/files/vm.xml | 
|  | 108 | - template: jinja | 
|  | 109 | - defaults: | 
|  | 110 | node: {{ node }} | 
|  | 111 |  | 
|  | 112 | vbcm_add_{{ node.name }}: | 
|  | 113 | cmd.run: | 
|  | 114 | - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }} | 
|  | 115 | - unless: vbmc show {{ node.name }} | 
|  | 116 |  | 
|  | 117 | vbmc_start_{{ node.name }}: | 
|  | 118 | cmd.run: | 
|  | 119 | - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1 | 
|  | 120 | - unless: vbmc show {{ node.name }} | grep status |grep -q running | 
|  | 121 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 122 | {%- for port in node.ports %} | 
|  | 123 |  | 
|  | 124 | {{ node.name }}_tap_device_{{ loop.index }}: | 
|  | 125 | cmd.run: | 
|  | 126 | - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up | 
|  | 127 | - unless: ip link show tap-{{ node.name }}i{{ loop.index }} | 
|  | 128 |  | 
|  | 129 | {{ node.name }}_tap{{ loop.index }}_in_ovs: | 
|  | 130 | openvswitch_port.present: | 
|  | 131 | - name: tap-{{ node.name }}i{{ loop.index }} | 
| Your Name | 8c482f2 | 2017-06-21 09:45:57 +0000 | [diff] [blame] | 132 | - bridge: br-simulator | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 133 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 134 | {%- endfor %} | 
|  | 135 |  | 
|  | 136 | {%- endfor %} | 
|  | 137 | {%- endfor %} | 
|  | 138 | {%- endif %} |