| 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: | 
|  | 12 | - pkg: python-pip | 
|  | 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 |  | 
|  | 33 | deploy_ramdisk: | 
|  | 34 | file.managed: | 
|  | 35 | - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_ramdisk_file }} | 
|  | 36 | - source: {{ baremetal_simulator.deploy_ramdisk_ref }} | 
|  | 37 | - skip_verify: true | 
|  | 38 |  | 
|  | 39 | deploy_kernel: | 
|  | 40 | file.managed: | 
|  | 41 | - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_kernel_file }} | 
|  | 42 | - source: {{ baremetal_simulator.deploy_kernel_ref }} | 
|  | 43 | - skip_verify: true | 
|  | 44 |  | 
|  | 45 | {%- if baremetal_simulator.cirros_image_ref is defined %} | 
|  | 46 |  | 
|  | 47 | {{ baremetal_simulator.cirros_image_name }}_file: | 
|  | 48 | file.managed: | 
|  | 49 | - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.cirros_image_name }} | 
|  | 50 | - source: {{ baremetal_simulator.cirros_image_ref }} | 
|  | 51 | - skip_verify: true | 
|  | 52 |  | 
|  | 53 | {%- endif %} | 
|  | 54 |  | 
| Your Name | 902fb6b | 2017-06-21 15:34:36 +0000 | [diff] [blame^] | 55 | {%- for identity_name, nodes in bs_nodes.iteritems() %} | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 56 | {%- for node in nodes %} | 
|  | 57 |  | 
|  | 58 | disk_create_node{{ loop.index }}: | 
|  | 59 | cmd.run: | 
|  | 60 | - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2 | 
|  | 61 | - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2 | 
|  | 62 |  | 
|  | 63 | vm_{{ node.name }}_present: | 
|  | 64 | cmd.run: | 
|  | 65 | - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml | 
|  | 66 | - onchanges: | 
|  | 67 | - file: /tmp/{{ node.name }}.xml | 
|  | 68 |  | 
|  | 69 | /tmp/{{ node.name }}.xml: | 
|  | 70 | file.managed: | 
|  | 71 | - source: salt://baremetal_simulator/files/vm.xml | 
|  | 72 | - template: jinja | 
|  | 73 | - defaults: | 
|  | 74 | node: {{ node }} | 
|  | 75 |  | 
|  | 76 | vbcm_add_{{ node.name }}: | 
|  | 77 | cmd.run: | 
|  | 78 | - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }} | 
|  | 79 | - unless: vbmc show {{ node.name }} | 
|  | 80 |  | 
|  | 81 | vbmc_start_{{ node.name }}: | 
|  | 82 | cmd.run: | 
|  | 83 | - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1 | 
|  | 84 | - unless: vbmc show {{ node.name }} | grep status |grep -q running | 
|  | 85 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 86 | {%- for port in node.ports %} | 
|  | 87 |  | 
|  | 88 | {{ node.name }}_tap_device_{{ loop.index }}: | 
|  | 89 | cmd.run: | 
|  | 90 | - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up | 
|  | 91 | - unless: ip link show tap-{{ node.name }}i{{ loop.index }} | 
|  | 92 |  | 
|  | 93 | {{ node.name }}_tap{{ loop.index }}_in_ovs: | 
|  | 94 | openvswitch_port.present: | 
|  | 95 | - name: tap-{{ node.name }}i{{ loop.index }} | 
| Your Name | 8c482f2 | 2017-06-21 09:45:57 +0000 | [diff] [blame] | 96 | - bridge: br-simulator | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 97 |  | 
| Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 98 | {%- endfor %} | 
|  | 99 |  | 
|  | 100 | {%- endfor %} | 
|  | 101 | {%- endfor %} | 
|  | 102 | {%- endif %} |