summaryrefslogtreecommitdiff
path: root/devstack/lib/ironic
diff options
context:
space:
mode:
Diffstat (limited to 'devstack/lib/ironic')
-rw-r--r--devstack/lib/ironic80
1 files changed, 77 insertions, 3 deletions
diff --git a/devstack/lib/ironic b/devstack/lib/ironic
index 9128e9ceb..50d8a57ce 100644
--- a/devstack/lib/ironic
+++ b/devstack/lib/ironic
@@ -250,6 +250,30 @@ IRONIC_ENABLED_NETWORK_INTERFACES=${IRONIC_ENABLED_NETWORK_INTERFACES:-}
# This is the network interface to use for a node
IRONIC_NETWORK_INTERFACE=${IRONIC_NETWORK_INTERFACE:-}
+# Ironic provision network name
+IRONIC_PROVISION_NETWORK_NAME=${IRONIC_PROVISION_NETWORK_NAME:-}
+
+# Provision network provider type. Can be flat or vlan.
+IRONIC_PROVISION_PROVIDER_NETWORK_TYPE=${IRONIC_PROVISION_PROVIDER_NETWORK_TYPE:-'vlan'}
+
+# If IRONIC_PROVISION_PROVIDER_NETWORK_TYPE is vlan. VLAN_ID may be specified. If it is not set,
+# vlan will be allocated dynamically.
+IRONIC_PROVISION_SEGMENTATION_ID=${IRONIC_PROVISION_SEGMENTATION_ID:-}
+
+# Allocation network pool for provision network
+# Example: IRONIC_PROVISION_ALLOCATION_POOL=start=10.0.5.10,end=10.0.5.100
+IRONIC_PROVISION_ALLOCATION_POOL=${IRONIC_PROVISION_ALLOCATION_POOL:-}
+
+# Ironic provision subnet name.
+IRONIC_PROVISION_PROVIDER_SUBNET_NAME=${IRONIC_PROVISION_PROVIDER_SUBNET_NAME:-${IRONIC_PROVISION_NETWORK_NAME}-subnet}
+
+# Ironic provision subnet gateway.
+IRONIC_PROVISION_SUBNET_GATEWAY=${IRONIC_PROVISION_SUBNET_GATEWAY:-}
+
+# Ironic provision subnet prefix
+# Example: IRONIC_PROVISION_SUBNET_PREFIX=10.0.5.0/24
+IRONIC_PROVISION_SUBNET_PREFIX=${IRONIC_PROVISION_SUBNET_PREFIX:-}
+
# get_pxe_boot_file() - Get the PXE/iPXE boot file path
function get_pxe_boot_file {
local relpath=syslinux/pxelinux.0
@@ -452,6 +476,59 @@ function configure_ironic_dirs {
fi
}
+function configure_ironic_provision_network {
+
+ die_if_not_set $LINENO IRONIC_PROVISION_SUBNET_PREFIX "You must specify the IRONIC_PROVISION_SUBNET_PREFIX"
+ die_if_not_set $LINENO PHYSICAL_NETWORK "You must specify the PHYSICAL_NETWORK"
+ die_if_not_set $LINENO IRONIC_PROVISION_SUBNET_GATEWAY "You must specify the IRONIC_PROVISION_SUBNET_GATEWAY"
+
+ local net_id
+ net_id=$(neutron net-create --provider:network_type $IRONIC_PROVISION_PROVIDER_NETWORK_TYPE \
+ --provider:physical_network "$PHYSICAL_NETWORK" \
+ ${IRONIC_PROVISION_SEGMENTATION_ID:+--provider:segmentation_id $IRONIC_PROVISION_SEGMENTATION_ID} \
+ ${IRONIC_PROVISION_NETWORK_NAME} | grep ' id ' | get_field 2)
+
+ die_if_not_set $LINENO net_id "Failure creating net_id for $IRONIC_PROVISION_NETWORK_NAME"
+ local subnet_id
+ subnet_id="$(neutron subnet-create --ip_version 4 \
+ ${IRONIC_PROVISION_ALLOCATION_POOL:+--allocation-pool $IRONIC_PROVISION_ALLOCATION_POOL} \
+ --name $IRONIC_PROVISION_PROVIDER_SUBNET_NAME \
+ --gateway $IRONIC_PROVISION_SUBNET_GATEWAY $net_id \
+ $IRONIC_PROVISION_SUBNET_PREFIX | grep ' id ' | get_field 2)"
+
+ die_if_not_set $LINENO subnet_id "Failure creating SUBNET_ID for $IRONIC_PROVISION_NETWORK_NAME"
+
+ iniset $IRONIC_CONF_FILE neutron provisioning_network_uuid $net_id
+
+ IRONIC_PROVISION_SEGMENTATION_ID=${IRONIC_PROVISION_SEGMENTATION_ID:-`neutron net-show ${net_id} | grep -w 'provider:segmentation_id'| get_field 2`}
+ provision_net_prefix=${IRONIC_PROVISION_SUBNET_PREFIX##*/}
+
+ # Set provision network GW on physical interface
+ # Add vlan on br interface in case of IRONIC_PROVISION_PROVIDER_NETWORK_TYPE==vlan
+ # othervise assign ip to br interface directly.
+ if [[ "$IRONIC_PROVISION_PROVIDER_NETWORK_TYPE" == "vlan" ]]; then
+ sudo vconfig add $OVS_PHYSICAL_BRIDGE $IRONIC_PROVISION_SEGMENTATION_ID
+ sudo ip link set dev $OVS_PHYSICAL_BRIDGE.$IRONIC_PROVISION_SEGMENTATION_ID up
+ sudo ip addr add dev $OVS_PHYSICAL_BRIDGE.$IRONIC_PROVISION_SEGMENTATION_ID $IRONIC_PROVISION_SUBNET_GATEWAY/$provision_net_prefix
+ else
+ sudo ip link set dev $OVS_PHYSICAL_BRIDGE up
+ sudo ip addr add dev $OVS_PHYSICAL_BRIDGE $IRONIC_PROVISION_SUBNET_GATEWAY/$provision_net_prefix
+ fi
+}
+
+function cleanup_ironic_provision_network {
+ if [[ -z "${IRONIC_PROVISION_NETWORK_NAME}" ]]; then
+ return 0
+ fi
+ # Cleanup OVS_PHYSICAL_BRIDGE subinterfaces
+ local bridge_subint
+ bridge_subint=$(cat /proc/net/dev | sed -n "s/^\(${OVS_PHYSICAL_BRIDGE}\.[0-9]*\).*/\1/p")
+ for sub_int in $bridge_subint; do
+ sudo ip link set dev $sub_int down
+ sudo ip link del dev $sub_int
+ done
+}
+
# configure_ironic() - Set config files, create data dirs, etc
function configure_ironic {
configure_ironic_dirs
@@ -1281,9 +1358,6 @@ function prepare_baremetal_basic_ops {
configure_ironic_auxiliary
fi
upload_baremetal_ironic_deploy
- if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
- create_bridge_and_vms
- fi
enroll_nodes
configure_tftpd
configure_iptables