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
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue