consolidated add default hosts to net function

This commit is contained in:
0xdcarns
2022-12-27 10:15:00 -05:00
parent 82479863f1
commit 875718d824
2 changed files with 18 additions and 9 deletions

View File

@@ -261,3 +261,18 @@ 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
}