Last active
May 14, 2025 21:37
-
-
Save THEBATTEUR/6672f5d3f12ef430fadc9c32db08fff2 to your computer and use it in GitHub Desktop.
Script to change floating IP address on Infomaniak's Public Cloud. Name/ID of the instance has to be provided as the first argument of this.
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
#!bin/bash | |
export OS_AUTH_URL=https://api.pub1.infomaniak.cloud/identity/v3 | |
export OS_PROJECT_NAME= | |
export OS_PROJECT_DOMAIN_NAME=default | |
export OS_USERNAME= | |
export OS_USER_DOMAIN_NAME=default | |
export OS_PROJECT_ID= | |
export OS_IDENTITY_API_VERSION=3 | |
export OS_INTERFACE=public | |
export OS_REGION_NAME=dc4-a | |
export OS_PASSWORD= | |
instance_port_id=$(openstack port list --server $1 -c ID -f value) | |
echo "Instance port ID : $instance_port_id" | |
network_id=$(openstack port show $instance_port_id -c network_id -f value) | |
echo "Network ID : $network_id" | |
old_ip_id=$(openstack floating ip list --port $instance_port_id -c ID -f value) | |
echo "Old IP ID : $old_ip_id" | |
new_ip_id=$(openstack floating ip create $(openstack network list --name ext-floating1 -c ID -f value) -c id -f value) | |
echo "New IP ID : $new_ip_id" | |
echo "Changing IPs..." | |
openstack floating ip unset $old_ip_id --port | |
openstack floating ip set $new_ip_id --port $instance_port_id | |
openstack floating ip delete $old_ip_id | |
echo "New IP : $(openstack floating ip show $new_ip_id -f value -c floating_ip_address)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment