mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-22 00:19:39 +08:00
adapt createNetwork + default host addition
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user