blob: 9efdd0fa8a2d496bc698ed51eb80ae275234375e [file] [log] [blame]
Your Name8324a3a2017-05-12 10:47:21 +00001{%- from "baremetal_simulator/map.jinja" import baremetal_simulator with context %}
2{%- 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:
12 - pkg: python-pip
13
14libvirt-bin:
15 service.running:
16 - watch:
17 - file: /etc/libvirt/qemu.conf
18
19cgroup:
20 file.append:
21 - name: /etc/libvirt/qemu.conf
22 - source: salt://ironic/files/qemu-cgroup.conf
23
24brbm:
25 openvswitch_bridge.present
26
27brbm-phy:
28 cmd.run:
29 - names:
30 - ip addr add {{ baremetal_simulator.brbm_net.ip }}/{{ baremetal_simulator.brbm_net.prefix }} dev brbm-phy
31 - ip link set dev brbm-phy up || true
32 - ip link set dev ovs-brbm up || true
33 - ip link add ovs-brbm type veth peer name brbm-phy || true
34 - unless: ip addr show dev brbm-phy |grep -q {{ baremetal_simulator.brbm_net.ip }}
35
36ovs-brbm_in_ovs:
37 openvswitch_port.present:
38 - name: ovs-brbm
39 - bridge: brbm
40 - require:
41 - brbm-phy
42
43brbm-to-ovs:
44 cmd.run:
45 - names:
46 - ovs-vsctl --may-exist add-port br-int brint-brbm -- set Interface brint-brbm type=patch options:peer=brbm-brint
47 - ovs-vsctl --may-exist add-port brbm brbm-brint -- set Interface brbm-brint type=patch options:peer=brint-brbm
48 - unless: (ovs-vsctl show |grep -q "Port brint-brbm") && (ovs-vsctl show |grep -q "Port brbm-brint")
49
50default_pool:
51 cmd.run:
52 - name: virsh pool-define-as --name default dir --target /var/lib/libvirt/images && virsh pool-autostart default && virsh pool-start default
53 - unless: virsh pool-info default
54
55/var/log/ironic-bm-logs/:
56 file.directory:
57 - makedirs: true
58
59deploy_ramdisk:
60 file.managed:
61 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_ramdisk_file }}
62 - source: {{ baremetal_simulator.deploy_ramdisk_ref }}
63 - skip_verify: true
64
65deploy_kernel:
66 file.managed:
67 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_kernel_file }}
68 - source: {{ baremetal_simulator.deploy_kernel_ref }}
69 - skip_verify: true
70
71{%- if baremetal_simulator.cirros_image_ref is defined %}
72
73{{ baremetal_simulator.cirros_image_name }}_file:
74 file.managed:
75 - name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.cirros_image_name }}
76 - source: {{ baremetal_simulator.cirros_image_ref }}
77 - skip_verify: true
78
79{%- endif %}
80
81{%- for identity_name, nodes in baremetal_simulator.nodes.iteritems() %}
82 {%- for node in nodes %}
83
84disk_create_node{{ loop.index }}:
85 cmd.run:
86 - name: virsh vol-create-as default {{ node.name }}.qcow2 --capacity {{ node.properties.local_gb }}G --format qcow2
87 - unless: test -f /var/lib/libvirt/images/{{ node.name }}.qcow2
88
89vm_{{ node.name }}_present:
90 cmd.run:
91 - name: virsh undefine {{ node.name }} && sleep 1; virsh define /tmp/{{ node.name }}.xml
92 - onchanges:
93 - file: /tmp/{{ node.name }}.xml
94
95/tmp/{{ node.name }}.xml:
96 file.managed:
97 - source: salt://baremetal_simulator/files/vm.xml
98 - template: jinja
99 - defaults:
100 node: {{ node }}
101
102vbcm_add_{{ node.name }}:
103 cmd.run:
104 - name: vbmc add {{ node.name }} --port {{ node.driver_info.ipmi_port }}
105 - unless: vbmc show {{ node.name }}
106
107vbmc_start_{{ node.name }}:
108 cmd.run:
109 - name: vbmc start {{ node.name }} > /dev/null 2>&1 && sleep 1
110 - unless: vbmc show {{ node.name }} | grep status |grep -q running
111
112node_{{ node.name }}_present:
113 ironicng.node_present:
114 - name: {{ node.name }}
115 - driver: {{ node.driver }}
116 - properties: {{ node.properties }}
117 - profile: {{ identity_name }}
118 - driver_info: {{ node.driver_info }}
119
120{%- for port in node.ports %}
121
122{{ node.name }}_tap_device_{{ loop.index }}:
123 cmd.run:
124 - name: ip tuntap add dev tap-{{ node.name }}i{{ loop.index }} mode tap; ip link set dev tap-{{ node.name }}i{{ loop.index }} up
125 - unless: ip link show tap-{{ node.name }}i{{ loop.index }}
126
127{{ node.name }}_tap{{ loop.index }}_in_ovs:
128 openvswitch_port.present:
129 - name: tap-{{ node.name }}i{{ loop.index }}
130 - bridge: brbm
131
132{{ node.name }}_port{{ loop.index }}_present:
133 ironicng.port_present:
134 - address: {{ port.address }}
135 - node_name: {{ node.name }}
136 - profile: {{ identity_name }}
137{%- endfor %}
138
139{%- endfor %}
140{%- endfor %}
141{%- endif %}