mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 16:57:51 +08:00
[NET-494 / ACC-322] New free tier limits (#2495)
* Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code * Rename var * Rename consts and use iota * Use switch instead of repeated else if * Rename limits related vars * Introduce new free tier limits * Measure new limits and report on license validation * Separate usage and limits, have new ones * Don't check for hosts and clients limits, but for machines instead * Error on egress creation @ free tier w/ internet gateways * Remove clients and hosts limit from code
This commit is contained in:

committed by
GitHub

parent
449f3f947b
commit
8ce7da2ce9
@@ -158,14 +158,14 @@ func GetHost(hostid string) (*models.Host, error) {
|
||||
|
||||
// CreateHost - creates a host if not exist
|
||||
func CreateHost(h *models.Host) error {
|
||||
hosts, err := GetAllHosts()
|
||||
if err != nil && !database.IsEmptyRecord(err) {
|
||||
return err
|
||||
hosts, hErr := GetAllHosts()
|
||||
clients, cErr := GetAllExtClients()
|
||||
if (hErr != nil && !database.IsEmptyRecord(hErr)) ||
|
||||
(cErr != nil && !database.IsEmptyRecord(cErr)) ||
|
||||
len(hosts)+len(clients) >= MachinesLimit {
|
||||
return errors.New("free tier limits exceeded on machines")
|
||||
}
|
||||
if len(hosts) >= Hosts_Limit {
|
||||
return errors.New("free tier limits exceeded on hosts")
|
||||
}
|
||||
_, err = GetHost(h.ID.String())
|
||||
_, err := GetHost(h.ID.String())
|
||||
if (err != nil && !database.IsEmptyRecord(err)) || (err == nil) {
|
||||
return ErrHostExists
|
||||
}
|
||||
|
Reference in New Issue
Block a user