mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 16:58:46 -03:30
Prevent creating a job if the license is expired
This commit is contained in:
@@ -959,6 +959,21 @@ class JobAccess(BaseAccess):
|
|||||||
def can_add(self, data):
|
def can_add(self, data):
|
||||||
if not data or '_method' in data: # So the browseable API will work?
|
if not data or '_method' in data: # So the browseable API will work?
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
reader = TaskSerializer()
|
||||||
|
validation_info = reader.from_file()
|
||||||
|
if 'test' in sys.argv or 'jenkins' in sys.argv:
|
||||||
|
validation_info['free_instances'] = 99999999
|
||||||
|
validation_info['time_remaining'] = 99999999
|
||||||
|
validation_info['grace_period_remaining'] = 99999999
|
||||||
|
|
||||||
|
if validation_info.get('time_remaining', None) is None:
|
||||||
|
raise PermissionDenied("license is missing")
|
||||||
|
if validation_info.get("grace_period_remaining") <= 0:
|
||||||
|
raise PermissionDenied("license has expired")
|
||||||
|
if validation_info.get('free_instances', 0) < 0:
|
||||||
|
raise PermissionDenied("Host Count exceeds available instances")
|
||||||
|
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
add_data = dict(data.items())
|
add_data = dict(data.items())
|
||||||
|
|||||||
Reference in New Issue
Block a user