mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Prevent creating a job if the license is expired
This commit is contained in:
parent
e3d89b5419
commit
5e0917cd92
@ -959,6 +959,21 @@ class JobAccess(BaseAccess):
|
||||
def can_add(self, data):
|
||||
if not data or '_method' in data: # So the browseable API will work?
|
||||
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:
|
||||
return True
|
||||
add_data = dict(data.items())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user