mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
add ability to set failover nodes
This commit is contained in:
parent
29ce2fa57a
commit
54258bcbac
2 changed files with 6 additions and 3 deletions
|
@ -754,9 +754,10 @@ func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
|
|||
func createIngressGateway(w http.ResponseWriter, r *http.Request) {
|
||||
var params = mux.Vars(r)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
failover := r.Header.Get("failover") == "yes"
|
||||
nodeid := params["nodeid"]
|
||||
netid := params["network"]
|
||||
node, err := logic.CreateIngressGateway(netid, nodeid)
|
||||
node, err := logic.CreateIngressGateway(netid, nodeid, failover)
|
||||
if err != nil {
|
||||
logger.Log(0, r.Header.Get("user"),
|
||||
fmt.Sprintf("failed to create ingress gateway on node [%s] on network [%s]: %v",
|
||||
|
|
|
@ -172,7 +172,7 @@ func DeleteEgressGateway(network, nodeid string) (models.Node, error) {
|
|||
}
|
||||
|
||||
// CreateIngressGateway - creates an ingress gateway
|
||||
func CreateIngressGateway(netid string, nodeid string) (models.Node, error) {
|
||||
func CreateIngressGateway(netid string, nodeid string, failover bool) (models.Node, error) {
|
||||
|
||||
var postUpCmd, postDownCmd string
|
||||
node, err := GetNodeByID(nodeid)
|
||||
|
@ -224,7 +224,9 @@ func CreateIngressGateway(netid string, nodeid string) (models.Node, error) {
|
|||
node.PostUp = postUpCmd
|
||||
node.PostDown = postDownCmd
|
||||
node.UDPHolePunch = "no"
|
||||
|
||||
if failover {
|
||||
node.Failover = "yes"
|
||||
}
|
||||
data, err := json.Marshal(&node)
|
||||
if err != nil {
|
||||
return models.Node{}, err
|
||||
|
|
Loading…
Reference in a new issue