mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-18 14:54:23 +08:00
consolidated add default hosts to net function
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user