dff663872b47e882b0daf95f981c59676f31511f
[osm/vim-emu.git] / src / emuvim / api / openstack / resources / flow_classifier.py
1 import uuid
2
3
4 class FlowClassifier(object):
5 def __init__(self, name):
6 self.id = str(uuid.uuid4())
7 self.tenant_id = "abcdefghijklmnopqrstuvwxyz123456"
8 self.name = name
9 self.description = ""
10 self.ethertype = "IPv4"
11 self.protocol = None
12 self.source_port_range_min = 0
13 self.source_port_range_max = 0
14 self.destination_port_range_min = 0
15 self.destination_port_range_max = 0
16 self.source_ip_prefix = None
17 self.destination_ip_prefix = None
18 self.logical_source_port = ""
19 self.logical_destination_port = ""
20 self.l7_parameters = dict()
21
22 def create_dict(self, compute):
23 representation = {
24 "name": self.name,
25 "tenant_id": self.tenant_id,
26 "description": self.description,
27 "id": self.id,
28 }
29 if self.ethertype:
30 representation["ethertype"] = self.ethertype
31 if self.protocol:
32 representation["protocol"] = self.protocol
33 if self.source_port_range_min:
34 representation["source_port_range_min"] = self.source_port_range_min
35 if self.source_port_range_max:
36 representation["source_port_range_max"] = self.source_port_range_max
37 if self.destination_port_range_min:
38 representation["destination_port_range_min"] = self.destination_port_range_min
39 if self.destination_port_range_max:
40 representation["destination_port_range_max"] = self.destination_port_range_max
41 if self.source_ip_prefix:
42 representation["source_ip_prefix"] = self.source_ip_prefix
43 if self.destination_ip_prefix:
44 representation["destination_ip_prefix"] = self.destination_ip_prefix
45 if len(self.logical_source_port):
46 representation["logical_source_port"] = self.logical_source_port
47 if len(self.logical_destination_port):
48 representation["logical_destination_port"] = self.logical_destination_port
49 if len(self.l7_parameters.items()):
50 representation["l7_parameters"] = self.l7_parameters
51
52 return representation