Created
September 20, 2019 11:47
-
-
Save andrewdmcleod/00af75eb191e7738faedd812ecae3ad5 to your computer and use it in GitHub Desktop.
add dataport to previously deployed openstack interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo Adding data-port interface to netplan | |
OS_PORT_LIST=$(openstack port list -c "MAC Address" -c "Fixed IP Addresses") | |
OS_SERVER_LIST=$(openstack server list) | |
for IP in $(juju status neutron-gateway|grep "Machine State" -A2|tail -n2|awk '{print $3}') | |
do | |
IFS='' | |
dataport_IP=$(echo $OS_SERVER_LIST | grep ${IP} | awk '{print $9}') | |
mac_addr=$(echo $OS_PORT_LIST | grep $dataport_IP |awk '{print $2}') | |
interface=$(juju ssh ${IP} "ip addr|grep ${mac_addr} -B1|head -n1") | |
interface=$(echo $interface | awk '{print $2}' | tr -d ':') | |
cat << EOF > temp_${IP} | |
network: | |
ethernets: | |
${interface}: | |
dhcp4: false | |
dhcp6: true | |
optional: true | |
match: | |
macaddress: ${mac_addr} | |
set-name: ${interface} | |
version: 2 | |
EOF | |
cat temp_${IP} | |
juju scp temp_${IP} ${IP}:/home/ubuntu/ | |
juju ssh ${IP} "sudo mv /home/ubuntu/temp_${IP} /etc/netplan/60-dataport.yaml ; sudo netplan apply" | |
rm temp_${IP} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment