mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 21:54:54 +08:00
Merge pull request #2028 from gravitl/fix/GRA-1200/default_hosts
adapt createNetwork + default host addition
This commit is contained in:
commit
ddf538da91
2 changed files with 1 additions and 20 deletions
|
@ -403,11 +403,6 @@ func createNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = logic.AddDefaultHostsToNetwork(network.NetID, servercfg.GetServer()); err != nil {
|
||||
logger.Log(0, fmt.Sprintf("failed to add default hosts to network [%v]: %v",
|
||||
network.NetID, err.Error()))
|
||||
}
|
||||
|
||||
defaultHosts := logic.GetDefaultHosts()
|
||||
for i := range defaultHosts {
|
||||
currHost := &defaultHosts[i]
|
||||
|
|
|
@ -216,6 +216,7 @@ func UpdateHostNetwork(h *models.Host, network string, add bool) (*models.Node,
|
|||
newNode := models.Node{}
|
||||
newNode.Server = servercfg.GetServer()
|
||||
newNode.Network = network
|
||||
newNode.HostID = h.ID
|
||||
if err := AssociateNodeToHost(&newNode, h); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -308,21 +309,6 @@ func GetDefaultHosts() []models.Host {
|
|||
return defaultHostList[:]
|
||||
}
|
||||
|
||||
// AddDefaultHostsToNetwork - adds a node to network for every default host on Netmaker server
|
||||
func AddDefaultHostsToNetwork(network, server string) error {
|
||||
// add default hosts to network
|
||||
defaultHosts := GetDefaultHosts()
|
||||
for i := range defaultHosts {
|
||||
newNode := models.Node{}
|
||||
newNode.Network = network
|
||||
newNode.Server = server
|
||||
if err := AssociateNodeToHost(&newNode, &defaultHosts[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetHostNetworks - fetches all the networks
|
||||
func GetHostNetworks(hostID string) []string {
|
||||
currHost, err := GetHost(hostID)
|
||||
|
|
Loading…
Add table
Reference in a new issue