blob: 0f79f659c3afc1b35af1ca17fa5432f23d6f40d1 [file] [log] [blame]
{%- from "baremetal_simulator/map.jinja" import baremetal_simulator 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:
- pkg: python-pip
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
brbm:
openvswitch_bridge.present
brbm-phy_veth_present:
cmd.run:
- name: ip link add ovs-brbm type veth peer name brbm-phy && ip link set dev ovs-brbm up && ip link set dev brbm-phy up
- unless: ip link show brbm-phy
brbm-phy_phy_ip:
cmd.run:
- name: ip addr add {{ baremetal_simulator.brbm_net.ip }}/{{ baremetal_simulator.brbm_net.prefix }} dev brbm-phy
- unless: ip addr show dev brbm-phy |grep -q {{ baremetal_simulator.brbm_net.ip }}
- require:
- brbm-phy_veth_present
ovs-brbm_in_ovs:
openvswitch_port.present:
- name: ovs-brbm
- bridge: brbm
- require:
- brbm-phy_veth_present
brbm-to-ovs:
cmd.run:
- names:
- ovs-vsctl --may-exist add-port br-floating brfl-brbm -- set Interface brfl-brbm type=patch options:peer=brbm-brfl
- ovs-vsctl --may-exist add-port brbm brbm-brfl -- set Interface brbm-brfl type=patch options:peer=brfl-brbm
- unless: (ovs-vsctl show |grep -q "Port brfl-brbm") && (ovs-vsctl show |grep -q "Port brbm-brfl")
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
deploy_ramdisk:
file.managed:
- name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_ramdisk_file }}
- source: {{ baremetal_simulator.deploy_ramdisk_ref }}
- skip_verify: true
deploy_kernel:
file.managed:
- name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.deploy_kernel_file }}
- source: {{ baremetal_simulator.deploy_kernel_ref }}
- skip_verify: true
{%- if baremetal_simulator.cirros_image_ref is defined %}
{{ baremetal_simulator.cirros_image_name }}_file:
file.managed:
- name: {{ baremetal_simulator.http_root }}/{{ baremetal_simulator.cirros_image_name }}
- source: {{ baremetal_simulator.cirros_image_ref }}
- skip_verify: true
{%- endif %}
{%- for identity_name, nodes in baremetal_simulator.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
node_{{ node.name }}_present:
ironicng.node_present:
- name: {{ node.name }}
- driver: {{ node.driver }}
- properties: {{ node.properties }}
- profile: {{ identity_name }}
- driver_info: {{ node.driver_info }}
{%- 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: brbm
{{ node.name }}_port{{ loop.index }}_present:
ironicng.port_present:
- address: {{ port.address }}
- node_name: {{ node.name }}
- profile: {{ identity_name }}
{%- endfor %}
{%- endfor %}
{%- endfor %}
{%- endif %}