adapt createNetwork + default host addition

This commit is contained in:
0xdcarns
2023-02-13 15:17:13 -05:00
parent e308ed1866
commit 6643c9a401
2 changed files with 1 additions and 20 deletions

View File

@@ -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)