f-28: add subnet default_route field
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
76a840b80a
commit
bb5698fdda
7 changed files with 99 additions and 38 deletions
|
|
@ -12,24 +12,26 @@ type VPC struct {
|
|||
}
|
||||
|
||||
type SubnetCreateRequest struct {
|
||||
Name string `json:"name"`
|
||||
VPC string `json:"vpc"`
|
||||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
IfaceType string `json:"iface_type"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
Name string `json:"name"`
|
||||
VPC string `json:"vpc"`
|
||||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
IfaceType string `json:"iface_type"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
DefaultRoute bool `json:"default_route"`
|
||||
}
|
||||
|
||||
type Subnet struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
VPC string `json:"vpc"`
|
||||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
LocalIface string `json:"local_iface"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
VPC string `json:"vpc"`
|
||||
Mode string `json:"mode"`
|
||||
VxlanID int `json:"vxlan_id"`
|
||||
LocalIface string `json:"local_iface"`
|
||||
InterfaceIP string `json:"interface_ip"`
|
||||
CIDR string `json:"cidr"`
|
||||
DefaultRoute bool `json:"default_route"`
|
||||
}
|
||||
|
||||
type VMInterface struct {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ func (s *Server) getSubnet(w http.ResponseWriter, _ *http.Request, name string)
|
|||
sub.InterfaceIP = value
|
||||
case "cidr":
|
||||
sub.CIDR = value
|
||||
case "default_route":
|
||||
sub.DefaultRoute = value == "true"
|
||||
}
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ func (s *Server) listSubnets(w http.ResponseWriter, _ *http.Request) {
|
|||
subnets[name].InterfaceIP = value
|
||||
case "cidr":
|
||||
subnets[name].CIDR = value
|
||||
case "default_route":
|
||||
subnets[name].DefaultRoute = value == "true"
|
||||
}
|
||||
}
|
||||
result := make([]Subnet, 0, len(subnets))
|
||||
|
|
@ -77,13 +79,14 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
cmd := dispatcher.CreateSubnetCommand{
|
||||
Name: req.Name,
|
||||
VPC: req.VPC,
|
||||
Mode: req.Mode,
|
||||
VxlanID: req.VxlanID,
|
||||
IfaceType: req.IfaceType,
|
||||
InterfaceIP: req.InterfaceIP,
|
||||
CIDR: req.CIDR,
|
||||
Name: req.Name,
|
||||
VPC: req.VPC,
|
||||
Mode: req.Mode,
|
||||
VxlanID: req.VxlanID,
|
||||
IfaceType: req.IfaceType,
|
||||
InterfaceIP: req.InterfaceIP,
|
||||
CIDR: req.CIDR,
|
||||
DefaultRoute: req.DefaultRoute,
|
||||
}
|
||||
if err := s.dispatcher.Prepare(cmd); err != nil {
|
||||
if _, dbErr := kv.GetFromDB(s.db, "subnet/"+req.Name+"/state"); dbErr == nil {
|
||||
|
|
@ -122,6 +125,8 @@ func (s *Server) postSubnet(w http.ResponseWriter, r *http.Request) {
|
|||
sub.InterfaceIP = value
|
||||
case "cidr":
|
||||
sub.CIDR = value
|
||||
case "default_route":
|
||||
sub.DefaultRoute = value == "true"
|
||||
}
|
||||
}
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue