1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 SNAPS domain object for interface routers. Should contain attributes that
20 are shared amongst cloud providers
22 def __init__(self, **kwargs):
26 self.name = kwargs.get('name')
27 self.id = kwargs.get('id')
28 self.type = kwargs.get('provider:network_type')
30 def __eq__(self, other):
31 return (self.name == other.name and self.id == other.id and
32 self.type == other.type)
37 SNAPS domain object for interface routers. Should contain attributes that
38 are shared amongst cloud providers
40 def __init__(self, **kwargs):
44 self.name = kwargs.get('name')
45 self.id = kwargs.get('id')
46 self.cidr = kwargs.get('cidr')
48 def __eq__(self, other):
49 return (self.name == other.name and self.id == other.id and
50 self.cidr == other.cidr)
55 SNAPS domain object for ports. Should contain attributes that
56 are shared amongst cloud providers
58 def __init__(self, **kwargs):
61 :param name: the security group's name
62 :param id: the security group's id
63 :param ips: a list of IP addresses
65 self.name = kwargs.get('name')
66 self.id = kwargs.get('id')
67 self.ips = kwargs.get('ips')
68 self.mac_address = kwargs.get('mac_address')
69 self.allowed_address_pairs = kwargs.get('allowed_address_pairs')
71 def __eq__(self, other):
72 return (self.name == other.name and self.id == other.id and
73 self.ips == other.ips, self.mac_address == other.mac_address)
78 SNAPS domain object for routers. Should contain attributes that are shared
79 amongst cloud providers
81 def __init__(self, **kwargs):
84 :param name: the router's name
85 :param id: the router's id
87 self.name = kwargs.get('name')
88 self.id = kwargs.get('id')
89 self.status = kwargs.get('status')
90 self.tenant_id = kwargs.get('tenant_id')
91 self.admin_state_up = kwargs.get('admin_state_up')
92 self.external_gateway_info = kwargs.get('external_gateway_info')
94 def __eq__(self, other):
95 return (self.name == other.name and self.id == other.id and
96 self.status == other.status and
97 self.tenant_id == other.tenant_id and
98 self.admin_state_up == other.admin_state_up and
99 self.external_gateway_info == other.external_gateway_info)
102 class InterfaceRouter:
104 SNAPS domain object for interface routers. Should contain attributes that
105 are shared amongst cloud providers
107 def __init__(self, **kwargs):
111 self.id = kwargs.get('id')
112 self.subnet_id = kwargs.get('subnet_id')
113 self.port_id = kwargs.get('port_id')
115 def __eq__(self, other):
116 return (self.id == other.id and self.subnet_id == other.subnet_id and
117 self.port_id == other.port_id)
122 SNAPS domain object for SecurityGroups. Should contain attributes that
123 are shared amongst cloud providers
125 def __init__(self, **kwargs):
128 :param name: the security group's name
129 :param id: the security group's id
131 self.name = kwargs.get('name')
132 self.id = kwargs.get('id')
133 self.description = kwargs.get('description')
134 self.project_id = kwargs.get('project_id', kwargs.get('tenant_id'))
136 def __eq__(self, other):
137 return (self.name == other.name and self.id == other.id and
138 self.project_id == other.project_id)
141 class SecurityGroupRule:
143 SNAPS domain object for Security Group Rules. Should contain attributes
144 that are shared amongst cloud providers
146 def __init__(self, **kwargs):
149 :param id: the security group rule's id
150 :param sec_grp_id: the ID of the associated security group
151 :param description: the security group rule's description
152 :param direction: the security group rule's direction
153 :param ethertype: the security group rule's ethertype
154 :param port_range_min: the security group rule's port_range_min
155 :param port_range_max: the security group rule's port_range_max
156 :param protocol: the security group rule's protocol
157 :param remote_group_id: the security group rule's remote_group_id
158 :param remote_ip_prefix: the security group rule's remote_ip_prefix
160 self.id = kwargs.get('id')
161 self.security_group_id = kwargs.get('security_group_id')
162 self.description = kwargs.get('description')
163 self.direction = kwargs.get('direction')
164 self.ethertype = kwargs.get('ethertype')
165 self.port_range_min = kwargs.get('port_range_min')
166 self.port_range_max = kwargs.get('port_range_max')
167 self.protocol = kwargs.get('protocol')
168 self.remote_group_id = kwargs.get('remote_group_id')
169 self.remote_ip_prefix = kwargs.get('remote_ip_prefix')
171 def __eq__(self, other):
172 return (self.id == other.id and
173 self.security_group_id == other.security_group_id and
174 self.description == other.description and
175 self.direction == other.direction and
176 self.ethertype == other.ethertype and
177 self.port_range_min == other.port_range_min and
178 self.port_range_max == other.port_range_max and
179 self.protocol == other.protocol and
180 self.remote_group_id == other.remote_group_id and
181 self.remote_ip_prefix == other.remote_ip_prefix)