f-28: fix: renomage api param
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
9492de7a2b
commit
848f965883
13 changed files with 53 additions and 53 deletions
|
|
@ -315,7 +315,7 @@ components:
|
|||
|
||||
SubnetCreateRequest:
|
||||
type: object
|
||||
required: [name, vpc, gateway_ip, cidr]
|
||||
required: [name, vpc, interface_ip, cidr]
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
|
|
@ -342,7 +342,7 @@ components:
|
|||
type: string
|
||||
description: Interface type key defined in the agent config (e.g. vms, internet, admin). Falls back to default_interface if omitted or unknown.
|
||||
example: vms
|
||||
gateway_ip:
|
||||
interface_ip:
|
||||
type: string
|
||||
format: ipv4
|
||||
description: Gateway IP for the subnet
|
||||
|
|
@ -377,7 +377,7 @@ components:
|
|||
type: string
|
||||
description: Resolved interface name from agent config
|
||||
example: br-000000
|
||||
gateway_ip:
|
||||
interface_ip:
|
||||
type: string
|
||||
example: "10.10.10.1"
|
||||
cidr:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type SubnetCreateRequest struct {
|
|||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
IfaceType string `json:"iface_type"`
|
||||
GatewayIP string `json:"gateway_ip"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ type Subnet struct {
|
|||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
LocalIface string `json:"local_iface"`
|
||||
GatewayIP string `json:"gateway_ip"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ func (s *Server) getSubnet(w http.ResponseWriter, _ *http.Request, name string)
|
|||
sub.VxlanID, _ = strconv.Atoi(value)
|
||||
case "local_iface":
|
||||
sub.LocalIface = value
|
||||
case "gateway_ip":
|
||||
sub.GatewayIP = value
|
||||
case "interface_ip":
|
||||
sub.InterfaceIP = value
|
||||
case "cidr":
|
||||
sub.CIDR = value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestPostSubnet_Created(t *testing.T) {
|
|||
Name: "sn-new",
|
||||
VPC: "vpc-1",
|
||||
IfaceType: "vms",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -95,7 +95,7 @@ func TestPostSubnet_IfaceTypeOptional(t *testing.T) {
|
|||
req := SubnetCreateRequest{
|
||||
Name: "sn-opt",
|
||||
VPC: "vpc-1",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
// IfaceType omis — doit utiliser default_interface
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ func TestPostSubnet_VPCNotFound(t *testing.T) {
|
|||
Name: "sn-1",
|
||||
VPC: "vpc-inexistant",
|
||||
IfaceType: "vms",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -132,7 +132,7 @@ func TestPostSubnet_Duplicate(t *testing.T) {
|
|||
Name: "sn-exist",
|
||||
VPC: "vpc-1",
|
||||
IfaceType: "vms",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -150,7 +150,7 @@ func TestPostSubnet_VPCDeleting(t *testing.T) {
|
|||
Name: "sn-1",
|
||||
VPC: "vpc-dying",
|
||||
IfaceType: "vms",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -169,7 +169,7 @@ func TestPostSubnet_BridgeMode_Success(t *testing.T) {
|
|||
VPC: "vpc-1",
|
||||
Mode: "bridge",
|
||||
IfaceType: "vms",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -195,7 +195,7 @@ func TestPostSubnet_UnknownMode(t *testing.T) {
|
|||
Name: "sn-1",
|
||||
VPC: "vpc-1",
|
||||
Mode: "vlan",
|
||||
GatewayIP: "10.0.0.1",
|
||||
InterfaceIP: "10.0.0.1",
|
||||
CIDR: "10.0.0.0/24",
|
||||
}
|
||||
body, _ := json.Marshal(req)
|
||||
|
|
@ -222,7 +222,7 @@ func TestGetSubnet_Found(t *testing.T) {
|
|||
kv.AddInDB(db, "subnet/sn-1/state", "created")
|
||||
kv.AddInDB(db, "subnet/sn-1/vpc", "vpc-1")
|
||||
kv.AddInDB(db, "subnet/sn-1/cidr", "10.0.0.0/24")
|
||||
kv.AddInDB(db, "subnet/sn-1/gateway_ip", "10.0.0.1")
|
||||
kv.AddInDB(db, "subnet/sn-1/interface_ip", "10.0.0.1")
|
||||
req := httptest.NewRequest(http.MethodGet, "/subnets/sn-1", nil)
|
||||
w := httptest.NewRecorder()
|
||||
s.SubnetByNameHandler(w, req)
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ func (s *Server) listSubnets(w http.ResponseWriter, _ *http.Request) {
|
|||
subnets[name].VxlanID, _ = strconv.Atoi(value)
|
||||
case "local_iface":
|
||||
subnets[name].LocalIface = value
|
||||
case "gateway_ip":
|
||||
subnets[name].GatewayIP = value
|
||||
case "interface_ip":
|
||||
subnets[name].InterfaceIP = value
|
||||
case "cidr":
|
||||
subnets[name].CIDR = value
|
||||
}
|
||||
|
|
@ -71,9 +71,9 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(ErrorResponse{Error: "invalid request body"})
|
||||
return
|
||||
}
|
||||
if req.Name == "" || req.VPC == "" || req.GatewayIP == "" || req.CIDR == "" {
|
||||
if req.Name == "" || req.VPC == "" || req.InterfaceIP == "" || req.CIDR == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(ErrorResponse{Error: "name, vpc, gateway_ip and cidr are required"})
|
||||
json.NewEncoder(w).Encode(ErrorResponse{Error: "name, vpc, interface_ip and cidr are required"})
|
||||
return
|
||||
}
|
||||
cmd := dispatcher.CreateSubnetCommand{
|
||||
|
|
@ -82,7 +82,7 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
|
|||
Mode: req.Mode,
|
||||
VxlanID: req.VxlanID,
|
||||
IfaceType: req.IfaceType,
|
||||
GatewayIP: req.GatewayIP,
|
||||
InterfaceIP: req.InterfaceIP,
|
||||
CIDR: req.CIDR,
|
||||
}
|
||||
if err := s.dispatcher.Prepare(cmd); err != nil {
|
||||
|
|
@ -118,8 +118,8 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
|
|||
sub.VxlanID, _ = strconv.Atoi(value)
|
||||
case "local_iface":
|
||||
sub.LocalIface = value
|
||||
case "gateway_ip":
|
||||
sub.GatewayIP = value
|
||||
case "interface_ip":
|
||||
sub.InterfaceIP = value
|
||||
case "cidr":
|
||||
sub.CIDR = value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type CreateSubnetCommand struct {
|
|||
Mode string
|
||||
VxlanID int
|
||||
IfaceType string
|
||||
GatewayIP string
|
||||
InterfaceIP string
|
||||
CIDR string
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ func (c CreateSubnetCommand) Prepare(db *badger.DB, cfg *configuration.Config) e
|
|||
kv.AddInDB(db, "subnet/"+c.Name+"/vpc", c.VPC)
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/mode", c.Mode)
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/local_iface", localIface)
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/gateway_ip", c.GatewayIP)
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/interface_ip", c.InterfaceIP)
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/cidr", c.CIDR)
|
||||
if c.Mode == "vxlan" {
|
||||
kv.AddInDB(db, "subnet/"+c.Name+"/vxlan_id", strconv.Itoa(c.VxlanID))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func TestCreateSubnetCommand_Prepare_Success(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err != nil {
|
||||
t.Fatalf("Prepare a échoué : %v", err)
|
||||
|
|
@ -40,7 +40,7 @@ func TestCreateSubnetCommand_Prepare_UsesIfaceTypeMapping(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
cmd.Prepare(db, testCfg())
|
||||
iface, _ := kv.GetFromDB(db, "subnet/sn-1/local_iface")
|
||||
|
|
@ -54,7 +54,7 @@ func TestCreateSubnetCommand_Prepare_UsesDefaultIfaceWhenTypeUnknown(t *testing.
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", VxlanID: 100,
|
||||
IfaceType: "inconnu", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "inconnu", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
cmd.Prepare(db, testCfg())
|
||||
iface, _ := kv.GetFromDB(db, "subnet/sn-1/local_iface")
|
||||
|
|
@ -69,7 +69,7 @@ func TestCreateSubnetCommand_Prepare_Duplicate(t *testing.T) {
|
|||
kv.AddInDB(db, "subnet/sn-exist/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-exist", VPC: "vpc-1", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err == nil {
|
||||
t.Error("Prepare devrait échouer sur un subnet déjà existant")
|
||||
|
|
@ -80,7 +80,7 @@ func TestCreateSubnetCommand_Prepare_VPCNotFound(t *testing.T) {
|
|||
_, db := newTestDispatcher(t)
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-inexistant", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err == nil {
|
||||
t.Error("Prepare devrait échouer si le VPC n'existe pas")
|
||||
|
|
@ -92,7 +92,7 @@ func TestCreateSubnetCommand_Prepare_VPCDeleting(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-dying/state", "deleting")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-dying", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err == nil {
|
||||
t.Error("Prepare devrait échouer si le VPC est en cours de suppression")
|
||||
|
|
@ -104,7 +104,7 @@ func TestCreateSubnetCommand_Prepare_VPCDeleted(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-gone/state", "deleted")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-gone", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err == nil {
|
||||
t.Error("Prepare devrait échouer si le VPC est supprimé")
|
||||
|
|
@ -116,7 +116,7 @@ func TestCreateSubnetCommand_Prepare_DefaultsToVxlanMode(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", VxlanID: 100,
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
cmd.Prepare(db, testCfg())
|
||||
mode, _ := kv.GetFromDB(db, "subnet/sn-1/mode")
|
||||
|
|
@ -133,7 +133,7 @@ func TestCreateSubnetCommand_Prepare_BridgeMode_Success(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", Mode: "bridge",
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err != nil {
|
||||
t.Fatalf("Prepare a échoué : %v", err)
|
||||
|
|
@ -153,7 +153,7 @@ func TestCreateSubnetCommand_Prepare_BridgeMode_NoVxlanID(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", Mode: "bridge",
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
cmd.Prepare(db, testCfg())
|
||||
if _, err := kv.GetFromDB(db, "subnet/sn-1/vxlan_id"); err == nil {
|
||||
|
|
@ -166,7 +166,7 @@ func TestCreateSubnetCommand_Prepare_UnknownMode(t *testing.T) {
|
|||
kv.AddInDB(db, "vpc/vpc-1/state", "created")
|
||||
cmd := CreateSubnetCommand{
|
||||
Name: "sn-1", VPC: "vpc-1", Mode: "vlan",
|
||||
IfaceType: "vms", GatewayIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
IfaceType: "vms", InterfaceIP: "10.0.0.1", CIDR: "10.0.0.0/24",
|
||||
}
|
||||
if err := cmd.Prepare(db, testCfg()); err == nil {
|
||||
t.Error("Prepare devrait échouer pour un mode inconnu")
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func createSubnet(db *badger.DB, subnetName string, d subnetData) error {
|
|||
switch d.mode {
|
||||
case "vxlan":
|
||||
if err := netns.Call(d.vpc, func() error {
|
||||
return netif.AddrAdd(d.bridge, d.gatewayIP)
|
||||
return netif.AddrAdd(d.bridge, d.interfaceIP)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("add addr to bridge in netns: %w", err)
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ func createSubnet(db *badger.DB, subnetName string, d subnetData) error {
|
|||
|
||||
switch d.mode {
|
||||
case "vxlan":
|
||||
if err := ebtables.DropARPToGateway(d.bridge, d.gatewayIP.String()); err != nil {
|
||||
if err := ebtables.DropARPToGateway(d.bridge, d.interfaceIP.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ebtables.DropDHCP(d.bridge); err != nil {
|
||||
|
|
@ -133,7 +133,7 @@ func setupVxlanHost(d subnetData, vethE string) error {
|
|||
func startDHCP(db *badger.DB, subnetName string, d subnetData) error {
|
||||
conf := dhcp.Config{
|
||||
Network: d.cidr,
|
||||
Gateway: d.gatewayIP,
|
||||
Gateway: d.interfaceIP,
|
||||
Name: d.vpc + "_" + d.bridge,
|
||||
ConfDir: "/etc/dnsmasq.d",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type subnetData struct {
|
|||
mode string
|
||||
vxlanID int
|
||||
localIface string
|
||||
gatewayIP net.IP
|
||||
interfaceIP net.IP
|
||||
cidr *net.IPNet
|
||||
}
|
||||
|
||||
|
|
@ -57,15 +57,15 @@ func loadSubnet(db *badger.DB, name string) (subnetData, error) {
|
|||
}
|
||||
d.localIface = localIface
|
||||
|
||||
gatewayIPStr, err := kv.GetFromDB(db, "subnet/"+name+"/gateway_ip")
|
||||
interfaceIPStr, err := kv.GetFromDB(db, "subnet/"+name+"/interface_ip")
|
||||
if err != nil {
|
||||
return d, fmt.Errorf("get gateway_ip: %w", err)
|
||||
return d, fmt.Errorf("get interface_ip: %w", err)
|
||||
}
|
||||
gatewayIP := net.ParseIP(gatewayIPStr)
|
||||
if gatewayIP == nil {
|
||||
return d, fmt.Errorf("invalid gateway_ip: %s", gatewayIPStr)
|
||||
interfaceIP := net.ParseIP(interfaceIPStr)
|
||||
if interfaceIP == nil {
|
||||
return d, fmt.Errorf("invalid interface_ip: %s", interfaceIPStr)
|
||||
}
|
||||
d.gatewayIP = gatewayIP
|
||||
d.interfaceIP = interfaceIP
|
||||
|
||||
cidrStr, err := kv.GetFromDB(db, "subnet/"+name+"/cidr")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func stopDHCP(db *badger.DB, subnetName string, d subnetData) error {
|
|||
func deleteSubnetVxlan(d subnetData) error {
|
||||
vxlanIface := fmt.Sprintf("vxlan-%d", d.vxlanID)
|
||||
|
||||
if err := ebtables.DeleteARPToGateway(d.bridge, d.gatewayIP.String()); err != nil {
|
||||
if err := ebtables.DeleteARPToGateway(d.bridge, d.interfaceIP.String()); err != nil {
|
||||
return fmt.Errorf("delete ebtables arp rule: %w", err)
|
||||
}
|
||||
if err := ebtables.DeleteDHCP(d.bridge); err != nil {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func StartVM(db *badger.DB, name string, cfg *configuration.Config) error {
|
|||
}
|
||||
|
||||
if err := netns.Call(d.vpcName, func() error {
|
||||
return iptables.AddMetadataRedirect(d.ip, d.gatewayIP, d.metadataPort)
|
||||
return iptables.AddMetadataRedirect(d.ip, d.interfaceIP, d.metadataPort)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("add metadata redirect: %w", err)
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ func StartVM(db *badger.DB, name string, cfg *configuration.Config) error {
|
|||
if err := metadata.StartMetadata(metadata.NoCloudConfig{
|
||||
Name: name,
|
||||
VpcName: d.vpcName,
|
||||
BindIP: d.gatewayIP,
|
||||
BindIP: d.interfaceIP,
|
||||
BindPort: d.metadataPort,
|
||||
Password: d.password,
|
||||
SSHKEY: d.sshkey,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
type vmData struct {
|
||||
subnetName string
|
||||
vpcName string
|
||||
gatewayIP string
|
||||
interfaceIP string
|
||||
bridge string
|
||||
tapID int
|
||||
ip string
|
||||
|
|
@ -43,11 +43,11 @@ func loadVM(db *badger.DB, name string) (vmData, error) {
|
|||
}
|
||||
d.vpcName = vpcName
|
||||
|
||||
gatewayIP, err := kv.GetFromDB(db, "subnet/"+subnetName+"/gateway_ip")
|
||||
interfaceIP, err := kv.GetFromDB(db, "subnet/"+subnetName+"/interface_ip")
|
||||
if err != nil {
|
||||
return d, fmt.Errorf("get gateway_ip: %w", err)
|
||||
return d, fmt.Errorf("get interface_ip: %w", err)
|
||||
}
|
||||
d.gatewayIP = gatewayIP
|
||||
d.interfaceIP = interfaceIP
|
||||
|
||||
tapIDStr, err := kv.GetFromDB(db, "vm/"+name+"/tap_id")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func StopVM(db *badger.DB, name string, cfg *configuration.Config) error {
|
|||
}
|
||||
|
||||
if err := netns.Call(d.vpcName, func() error {
|
||||
return iptables.DeleteMetadataRedirect(d.ip, d.gatewayIP, d.metadataPort)
|
||||
return iptables.DeleteMetadataRedirect(d.ip, d.interfaceIP, d.metadataPort)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("delete metadata redirect: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue