Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Created June 17, 2022 14:25
Show Gist options
  • Save gilangvperdana/81f754924bfbb3dda6fa9f8a41450586 to your computer and use it in GitHub Desktop.
Save gilangvperdana/81f754924bfbb3dda6fa9f8a41450586 to your computer and use it in GitHub Desktop.
Octavia 'o-hm0' port Auto DHClient when Reboot

Auto DHClient Octavia Openstack Port

Make a Script

nano /usr/lib/octavia-interface.sh
#!/bin/bash

set -ex

MGMT_PORT_MAC=fa:16:3e:c8:a7:74
MGMT_PORT_ID=8b66f1d7-70e4-484f-bc01-e94f146a6398

if [ "$1" == "start" ]; then
  docker exec -i openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int o-hm0 -- set Interface o-hm0 type=internal -- set Interface o-hm0 external-ids:iface-status=active -- set Interface o-hm0 external-ids:attached-mac=$MGMT_PORT_MAC -- set Interface o-hm0 external-ids:iface-id=$MGMT_PORT_ID
  ip link set dev o-hm0 address $MGMT_PORT_MAC
  ip link set o-hm0 up
  dhclient -v o-hm0 -cf /etc/dhcp/octavia/dhclient.conf
elif [ "$1" == "stop" ]; then
  docker exec -i openvswitch_vswitchd ovs-vsctl del-port o-hm0
else
  docker exec -i openvswitch_vswitchd ovs-vsctl show
  ip a s dev o-hm0
fi

Make a SystemD Service

nano /etc/systemd/system/octavia-interface.service
[Unit]
Description=Octavia Interface Creator

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/lib/octavia-interface.sh start
ExecStop=/usr/lib/octavia-interface.sh stop

[Install]
WantedBy=multi-user.target

Make Auto Up on Boot

systemctl enable octavia-interface
systemctl start octavia-interface
systemctl status octavia-interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment