mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 09:22:42 +08:00
GRA-1298: License check changes, free tier limits for saas (#2418)
* set free tier limits through config * add host limit to config * check for host limit on free tier * fix license validation, replace node limit with hosts * add hosts to telemetry data * debug init * validate license every 1hr * hook manager, api to fetch server usage * hook manager, server usage api * encode json server usage api * update ngork url * update license validation endpoint * avoid setting limits on eer * adding hotfix * correct users limits env var * add comments to exported funcs --------- Co-authored-by: afeiszli <alex.feiszli@gmail.com>
This commit is contained in:
@@ -93,7 +93,14 @@ func GetHost(hostid string) (*models.Host, error) {
|
||||
|
||||
// CreateHost - creates a host if not exist
|
||||
func CreateHost(h *models.Host) error {
|
||||
_, err := GetHost(h.ID.String())
|
||||
hosts, err := GetAllHosts()
|
||||
if err != nil && !database.IsEmptyRecord(err) {
|
||||
return err
|
||||
}
|
||||
if len(hosts) >= Hosts_Limit {
|
||||
return errors.New("free tier limits exceeded on hosts")
|
||||
}
|
||||
_, err = GetHost(h.ID.String())
|
||||
if (err != nil && !database.IsEmptyRecord(err)) || (err == nil) {
|
||||
return ErrHostExists
|
||||
}
|
||||
|
Reference in New Issue
Block a user