add delete subnet
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
5a263464e3
commit
1f28301a94
3 changed files with 46 additions and 10 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
. ./lib/db.sh
|
||||
. ./lib/colors.sh
|
||||
. ./lib/vpc.sh
|
||||
|
||||
function check_subnet_exist {
|
||||
local vpc_name="${1}"
|
||||
|
|
@ -81,4 +82,28 @@ function create_subnet {
|
|||
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function delete_subnet {
|
||||
local subnet_name="${1}"
|
||||
local subnet_id="$(echo "${subnet_name}" | cut -d\- -f2)"
|
||||
|
||||
subnet_def=$(get_from_db "subnet" "${subnet_name}")
|
||||
local vpc_name="$(echo "${subnet_def}" | cut -d\; -f 2)"
|
||||
local vxlan_id="$(echo "${subnet_def}" | cut -d\; -f 3)"
|
||||
local gateway_ip="$(echo "${subnet_def}" | cut -d\; -f 5)"
|
||||
local subnet="$(echo "${subnet_def}" | cut -d\; -f 6)"
|
||||
|
||||
print_in_color "${COLOR_RED}" "Delete ${subnet_name}"
|
||||
delete_in_db "subnet" "${subnet_name}"
|
||||
ip -n "${vpc_name}" route del "${subnet}" dev "br-${subnet_id}"
|
||||
ip link del dev "vxlan-${vxlan_id}"
|
||||
ebtables -D FORWARD -p arp --arp-op Request --arp-ip-dst "${gateway_ip}" --out-interface "br-${subnet_id}" -j DROP
|
||||
ip link del dev "br-${subnet_id}"
|
||||
ip -n "${vpc_name}" link del dev "br-${subnet_id}"
|
||||
ip link del dev "veth-${subnet_id}-ext"
|
||||
|
||||
print_in_color "${COLOR_GREY}" "Try to delete ${vpc_name}"
|
||||
count_in_db "subnet" "${vpc_name}"
|
||||
[ "$?" -eq "0" ] && delete_vpc "${vpc_name}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue