-create_networks() {
- # create required networks
- for net in pxe mgmt internal public; do
- if virsh net-info $net >/dev/null 2>&1; then
- virsh net-destroy ${net}
- virsh net-undefine ${net}
+function create_networks {
+ local vnode_networks=("$@")
+ # create required networks, including constant "mcpcontrol"
+ # FIXME(alav): since we renamed "pxe" to "mcpcontrol", we need to make sure
+ # we delete the old "pxe" virtual network, or it would cause IP conflicts.
+ # FIXME(alav): The same applies for "fuel1" virsh network.
+ for net in "fuel1" "pxe" "mcpcontrol" "${vnode_networks[@]}"; do
+ if virsh net-info "${net}" >/dev/null 2>&1; then
+ virsh net-destroy "${net}" || true
+ virsh net-undefine "${net}"
+ fi
+ # in case of custom network, host should already have the bridge in place
+ if [ -f "net_${net}.xml" ] && [ ! -d "/sys/class/net/${net}/bridge" ]; then
+ virsh net-define "net_${net}.xml"
+ virsh net-autostart "${net}"
+ virsh net-start "${net}"