2016-03-07 17:13:03 +02:00
|
|
|
|
#!/usr/bin/python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
2016-03-16 17:26:25 +02:00
|
|
|
|
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
|
2016-03-07 17:13:03 +02:00
|
|
|
|
import json
|
|
|
|
|
|
2016-03-23 17:15:27 +02:00
|
|
|
|
from base.model.Profile import Profile
|
|
|
|
|
|
|
|
|
|
|
2016-03-07 17:13:03 +02:00
|
|
|
|
class Policy(object):
|
|
|
|
|
"""docstring for Policy"""
|
2016-03-23 17:15:27 +02:00
|
|
|
|
|
|
|
|
|
def __init__(self, message):
|
2016-03-16 17:26:25 +02:00
|
|
|
|
self.policy = message
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def ahenk_policy_version(self):
|
2016-04-03 00:58:33 +03:00
|
|
|
|
return self.policy['agentPolicyVersion']
|
2016-03-16 17:26:25 +02:00
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def ahenk_profiles(self):
|
2016-03-23 17:15:27 +02:00
|
|
|
|
profiles = []
|
2016-04-03 00:58:33 +03:00
|
|
|
|
for p in self.policy['agentPolicyProfiles']:
|
2016-03-16 17:26:25 +02:00
|
|
|
|
profiles.append(Profile(p))
|
|
|
|
|
return profiles
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def user_policy_version(self):
|
2016-03-24 17:55:23 +02:00
|
|
|
|
return self.policy['userPolicyVersion']
|
2016-03-16 17:26:25 +02:00
|
|
|
|
|
2016-03-18 18:20:14 +02:00
|
|
|
|
@property
|
|
|
|
|
def timestamp(self):
|
2016-04-04 18:15:18 +03:00
|
|
|
|
return self.policy['timestamp']
|
2016-03-18 18:20:14 +02:00
|
|
|
|
|
2016-03-16 17:26:25 +02:00
|
|
|
|
@property
|
|
|
|
|
def user_profiles(self):
|
2016-03-23 17:15:27 +02:00
|
|
|
|
profiles = []
|
2016-03-29 11:52:18 +03:00
|
|
|
|
try:
|
|
|
|
|
for p in self.policy['userPolicyProfiles']:
|
|
|
|
|
profiles.append(Profile(p))
|
|
|
|
|
return profiles
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return None
|
2016-03-21 12:00:45 +02:00
|
|
|
|
|
2016-04-04 18:15:18 +03:00
|
|
|
|
@property
|
|
|
|
|
def username(self):
|
|
|
|
|
return self.policy['username']
|
|
|
|
|
|
|
|
|
|
# TODO result mesajı dönerken döndür
|
2016-04-03 00:58:33 +03:00
|
|
|
|
@property
|
|
|
|
|
def ahenk_execution_id(self):
|
|
|
|
|
return self.policy['agentCommandExecutionId']
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def user_execution_id(self):
|
|
|
|
|
return self.policy['userCommandExecutionId']
|
|
|
|
|
|
2016-03-21 12:00:45 +02:00
|
|
|
|
def to_string(self):
|
|
|
|
|
return str(self.policy)
|
|
|
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
|
return json.load(self.policy)
|
2016-03-29 11:52:18 +03:00
|
|
|
|
|
2016-03-30 17:12:38 +03:00
|
|
|
|
def obj_name(self):
|
|
|
|
|
return "PROFILE"
|