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.admin_state_up = kwargs.get('admin_state_up')
29 self.shared = kwargs.get('shared')
30 self.external = kwargs.get('router:external', kwargs.get('external'))
31 self.type = kwargs.get('provider:network_type', kwargs.get('type'))
33 def __eq__(self, other):
34 return (self.name == other.name and self.id == other.id and
35 self.admin_state_up == other.admin_state_up and
36 self.shared == other.shared and
37 self.external == other.external and self.type == other.type)
42 SNAPS domain object for interface routers. Should contain attributes that
43 are shared amongst cloud providers
45 def __init__(self, **kwargs):
49 self.name = kwargs.get('name')
50 self.id = kwargs.get('id')
51 self.cidr = kwargs.get('cidr')
52 self.ip_version = kwargs.get('ip_version')
53 self.gateway_ip = kwargs.get('gateway_ip')
54 self.enable_dhcp = kwargs.get('enable_dhcp')
55 self.dns_nameservers = kwargs.get('dns_nameservers')
56 self.host_routes = kwargs.get('host_routes')
57 self.ipv6_ra_mode = kwargs.get('ipv6_ra_mode')
58 self.ipv6_address_mode = kwargs.get('ipv6_address_mode')
62 if ('allocation_pools' in kwargs and
63 len(kwargs['allocation_pools']) > 0):
64 # Will need to ultimately support a list of pools
65 pools = kwargs['allocation_pools'][0]
67 self.start = pools['start']
69 self.end = pools['end']
71 def __eq__(self, other):
72 return (self.name == other.name and
73 self.id == other.id and
74 self.cidr == other.cidr and
75 self.ip_version == other.ip_version and
76 self.gateway_ip == other.gateway_ip and
77 self.enable_dhcp == other.enable_dhcp and
78 self.dns_nameservers == other.dns_nameservers and
79 self.host_routes == other.host_routes and
80 self.ipv6_ra_mode == other.ipv6_ra_mode and
81 self.ipv6_address_mode == other.ipv6_address_mode and
82 self.start == other.start and self.end == other.end)
87 SNAPS domain object for ports. Should contain attributes that
88 are shared amongst cloud providers
90 def __init__(self, **kwargs):
93 :param name: the security group's name
94 :param id: the security group's id
95 :param ips: a list of IP addresses
97 self.name = kwargs.get('name')
98 self.id = kwargs.get('id')
99 self.ips = kwargs.get('ips')
100 self.mac_address = kwargs.get('mac_address')
101 self.allowed_address_pairs = kwargs.get('allowed_address_pairs')
103 def __eq__(self, other):
104 return (self.name == other.name and self.id == other.id and
105 self.ips == other.ips, self.mac_address == other.mac_address)
110 SNAPS domain object for routers. Should contain attributes that are shared
111 amongst cloud providers
113 def __init__(self, **kwargs):
116 :param name: the router's name
117 :param id: the router's id
119 self.name = kwargs.get('name')
120 self.id = kwargs.get('id')
121 self.status = kwargs.get('status')
122 self.tenant_id = kwargs.get('tenant_id')
123 self.admin_state_up = kwargs.get('admin_state_up')
124 self.external_gateway_info = kwargs.get('external_gateway_info')
126 def __eq__(self, other):
127 return (self.name == other.name and self.id == other.id and
128 self.status == other.status and
129 self.tenant_id == other.tenant_id and
130 self.admin_state_up == other.admin_state_up and
131 self.external_gateway_info == other.external_gateway_info)
134 class InterfaceRouter:
136 SNAPS domain object for interface routers. Should contain attributes that
137 are shared amongst cloud providers
139 def __init__(self, **kwargs):
143 self.id = kwargs.get('id')
144 self.subnet_id = kwargs.get('subnet_id')
145 self.port_id = kwargs.get('port_id')
147 def __eq__(self, other):
148 return (self.id == other.id and self.subnet_id == other.subnet_id and
149 self.port_id == other.port_id)
154 SNAPS domain object for SecurityGroups. Should contain attributes that
155 are shared amongst cloud providers
157 def __init__(self, **kwargs):
160 :param name: the security group's name
161 :param id: the security group's id
163 self.name = kwargs.get('name')
164 self.id = kwargs.get('id')
165 self.description = kwargs.get('description')
166 self.project_id = kwargs.get('project_id', kwargs.get('tenant_id'))
168 def __eq__(self, other):
169 return (self.name == other.name and self.id == other.id and
170 self.project_id == other.project_id)
173 class SecurityGroupRule:
175 SNAPS domain object for Security Group Rules. Should contain attributes
176 that are shared amongst cloud providers
178 def __init__(self, **kwargs):
181 :param id: the security group rule's id
182 :param sec_grp_id: the ID of the associated security group
183 :param description: the security group rule's description
184 :param direction: the security group rule's direction
185 :param ethertype: the security group rule's ethertype
186 :param port_range_min: the security group rule's port_range_min
187 :param port_range_max: the security group rule's port_range_max
188 :param protocol: the security group rule's protocol
189 :param remote_group_id: the security group rule's remote_group_id
190 :param remote_ip_prefix: the security group rule's remote_ip_prefix
192 self.id = kwargs.get('id')
193 self.security_group_id = kwargs.get('security_group_id')
194 self.description = kwargs.get('description')
195 self.direction = kwargs.get('direction')
196 self.ethertype = kwargs.get('ethertype')
197 self.port_range_min = kwargs.get('port_range_min')
198 self.port_range_max = kwargs.get('port_range_max')
199 self.protocol = kwargs.get('protocol')
200 self.remote_group_id = kwargs.get('remote_group_id')
201 self.remote_ip_prefix = kwargs.get('remote_ip_prefix')
203 def __eq__(self, other):
204 return (self.id == other.id and
205 self.security_group_id == other.security_group_id and
206 self.description == other.description and
207 self.direction == other.direction and
208 self.ethertype == other.ethertype and
209 self.port_range_min == other.port_range_min and
210 self.port_range_max == other.port_range_max and
211 self.protocol == other.protocol and
212 self.remote_group_id == other.remote_group_id and
213 self.remote_ip_prefix == other.remote_ip_prefix)