Last active
June 18, 2021 21:35
-
-
Save cyrenity/9a51a1621195da6dd0ebb7dbe20bf8d2 to your computer and use it in GitHub Desktop.
Create openstack port and bind it with one of management/storage/network node of your openstack cluster
This file contains hidden or 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
# A Small Script for creating a port in an internal network and binding it with one of control/neutron node | |
#### !!!! CAUTION !!!! ##### | |
# DO NOT RUN THIS SCRIPT UNLESS YOU KNOW HOW EACH LINE IS GOING TO DO WITH YOUR OPENSTACK INSTALL | |
# YOU ARE ADVISED TO FIRST UNDERSTAND AND THAN RUN EACH LINE OF THIS SCRIPT INTERACTIVELY | |
############################ | |
NETWORK_NAME=demo1 | |
SUBNET_NAME=demo1-net | |
MGMT_PORT_IP=172.16.2.10 | |
BIND_HOST=control0 | |
SUBNET_ID=$(openstack subnet show ${SUBNET_NAME} -f value -c id) | |
MGMT_PORT_ID=$(openstack port create --device-owner user:mustafa \ | |
--host=$BIND_HOST -c id -f value --network ${NETWORK_NAME} \ | |
--fixed-ip subnet=$SUBNET_ID,ip-address=$MGMT_PORT_IP mgmt-port) | |
MGMT_PORT_MAC=$(openstack port show -c mac_address -f value $MGMT_PORT_ID) | |
echo " | |
# Run following commands on control/management host | |
docker exec -it openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int o-hm1 -- set Interface o-hm1 type=internal -- set Interface o-hm1 external-ids:iface-status=active -- set Interface o-hm1 external-ids:attached-mac=$MGMT_PORT_MAC -- set Interface o-hm1 external-ids:iface-id=$MGMT_PORT_ID | |
echo ip link set dev o-hm1 address $MGMT_PORT_MAC | |
echo ip link set dev o-hm1 up | |
echo dhclient -v o-hm1 -cf dhclient.conf | |
" | |
# Destroy | |
# docker exec -it openvswitch_vswitchd ovs-vsctl del-port br-int o-hm1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment