-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKiplingTrafficFlow.py
55 lines (45 loc) · 2.04 KB
/
KiplingTrafficFlow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 23 12:44:19 2021
@author: eslam
"""
import netaddr
import csv
from DAAS import DAAS
class KiplingTrafficFlow:
"""
Machine learning could be used to discover hidden patterns in data.
UserID=eslam,destinationID="Server",AppID="SSH",ContentID="Content",When="Noon",Where="Cairo"
"""
#def __init__(self,UserID=None,destinationID=None,AppID=None,ContentID=None,When=None,Where=None,*initial_data,**kwargs):
def __init__(self,*initial_data,**kwargs):
for dictionary in initial_data:
for key in dictionary:
setattr(self,key,dictionary[key])
for key in kwargs:
setattr(self,key,kwargs[key])
def __eq__(self,other):
if (self.UserID == other.UserID and self.destinationID == other.destinationID and self.AppID == other.AppID and self.ContentID == other.ContentID and self.When == other.When and self.Where == other.Where):
return True
else:
return False
def __ne__(self,other):
return not self.__eq__(other)
# if __name__ == "__main__":
# # eslam = DAAS(identity="Exchange",ip='1.1.1.1/32')
# # ahmed = DAAS(identity="Exchange",ip='1.1.1.2/32')
# # eslamFlow = KiplingTrafficFlow(UserID=eslam,AppID="SSH",ContentID="Content",When="Noon",Where="Cairo")
# # ahmedFlow = KiplingTrafficFlow(UserID=ahmed,AppID="SSH",ContentID="Content",When="Noon",Where="Cairo")
# # print(eslamFlow != ahmedFlow)
# # file = pd.read_csv("staticFlows.csv")
# # print (file)
# # flow = {"UserID":"eslamdict", "destinationID":"Server","AppID":"SSH","ContentID":"Content","When":"Noon","Where":"Cairo"}
# # flowDict = KiplingTrafficFlow(flow)
# # print (flowDict.Where)
# with open('StaticPolicyAgentPolicies.csv') as f:
# flowsDict = [{k: v for k, v in row.items()}
# for row in csv.DictReader(f, skipinitialspace=True)]
# print (flowsDict)
# for flow in flowsDict:
# policyFlow = KiplingTrafficFlow(flow)
# print(policyFlow.UserID)