blob: 149402b7a9656212b1eae52b49e51db9bb827aed [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
Vasyl Saienko64792aa2017-08-18 14:45:57 +030014{%- if baremetal_simulator.get('tor', {}).get('enabled', False) %}
15
16openvswitch-vtep-pkg:
17 pkg.installed:
18 - name: openvswitch-vtep
19
20openvswitch-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
27openvswitch-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
34openvswitch-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
43br_simulator_ps_present:
44 cmd.run:
45 - name: vtep-ctl add-ps br-simulator
46 - unless: vtep-ctl ps-exists br-simulator
47
48br_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
55br_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
62br_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
Your Namebea2f082017-12-04 12:13:28 +000070brphyv_in_ovs:
71 openvswitch_port.present:
72 - name: brphyv
73 - bridge: br-simulator
74
Vasyl Saienko64792aa2017-08-18 14:45:57 +030075{%- endif %}
76
Your Name8324a3a2017-05-12 10:47:21 +000077libvirt-bin:
78 service.running:
79 - watch:
80 - file: /etc/libvirt/qemu.conf
81
82cgroup:
83 file.append:
84 - name: /etc/libvirt/qemu.conf
Your Name8ba54822017-05-12 12:17:39 +000085 - source: salt://baremetal_simulator/files/qemu-cgroup.conf
Your Name8324a3a2017-05-12 10:47:21 +000086
Your Name8324a3a2017-05-12 10:47:21 +000087default_pool:
88 cmd.run:
89 - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default
90 - unless: virsh pool-info default
91
92/var/log/ironic-bm-logs/:
93 file.directory:
94 - makedirs: true
95
Your Name902fb6b2017-06-21 15:34:36 +000096{%- for identity_name, nodes in bs_nodes.iteritems() %}
Your Name8324a3a2017-05-12 10:47:21 +000097 {%- for node in nodes %}
98
99disk_create_node{{ loop.index }}:
100 cmd.run:
101 - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2
102 - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2
103
104vm_{{ node.name }}_present:
105 cmd.run:
106 - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml
107 - onchanges:
108 - file: /tmp/{{ node.name }}.xml
109
110/tmp/{{ node.name }}.xml:
111 file.managed:
112 - source: salt://baremetal_simulator/files/vm.xml
113 - template: jinja
114 - defaults:
115 node: {{ node }}
116
117vbcm_add_{{ node.name }}:
118 cmd.run:
119 - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }}
120 - unless: vbmc show {{ node.name }}
121
122vbmc_start_{{ node.name }}:
123 cmd.run:
124 - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1
125 - unless: vbmc show {{ node.name }} | grep status |grep -q running
126
Your Name8324a3a2017-05-12 10:47:21 +0000127{%- for port in node.ports %}
128
129{{ node.name }}_tap_device_{{ loop.index }}:
130 cmd.run:
131 - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up
132 - unless: ip link show tap-{{ node.name }}i{{ loop.index }}
133
134{{ node.name }}_tap{{ loop.index }}_in_ovs:
135 openvswitch_port.present:
136 - name: tap-{{ node.name }}i{{ loop.index }}
Your Name8c482f22017-06-21 09:45:57 +0000137 - bridge: br-simulator
Your Name8324a3a2017-05-12 10:47:21 +0000138
Your Name8324a3a2017-05-12 10:47:21 +0000139{%- endfor %}
140
141{%- endfor %}
142{%- endfor %}
143{%- endif %}