62
62
networks = manager.FlatManager.create_networks(self.net_manager,
63
63
admin_context, label, cidr,
64
64
False, 1, subnet_size, cidr_v6, gateway,
65
gateway_v6, quantum_net_id, None, dns1, dns2)
65
gateway_v6, quantum_net_id, None, dns1, dns2,
67
#TODO(tr3buchet): refactor passing in the ipam key so that
68
# it's no longer required. The reason it exists now is because
69
# nova insists on carving up IP blocks. What ends up happening is
70
# we create a v4 and an identically sized v6 block. The reason
71
# the quantum tests passed previosly is nothing prevented an
72
# incorrect v6 address from being assigned to the wrong subnet
67
74
if len(networks) != 1:
68
75
raise Exception(_("Error creating network entry"))
122
129
id_priority_map[net_id] = n['priority']
123
130
return sorted(net_list, key=lambda x: id_priority_map[x[0]])
125
def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
132
def allocate_fixed_ip(self, context, tenant_id, quantum_net_id,
133
network_tenant_id, vif_rec):
126
134
"""Allocates a single fixed IPv4 address for a virtual interface."""
127
135
admin_context = context.elevated()
128
136
network = db.network_get_by_uuid(admin_context, quantum_net_id)
147
155
associated with a Quantum Network UUID.
149
157
n = db.network_get_by_uuid(context.elevated(), net_id)
151
159
'network_id': n['uuid'],
152
160
'cidr': n['cidr'],
153
161
'gateway': n['gateway'],
154
162
'broadcast': n['broadcast'],
155
163
'netmask': n['netmask'],
156
165
'dns1': n['dns1'],
157
166
'dns2': n['dns2']}
167
#TODO(tr3buchet): I'm noticing we've assumed here that all dns is v4.
168
# this is probably bad as there is no way to add v6
159
171
'network_id': n['uuid'],
160
172
'cidr': n['cidr_v6'],
161
173
'gateway': n['gateway_v6'],
162
174
'broadcast': None,
175
'netmask': n['netmask_v6'],
166
return (subnet_data_v4, subnet_data_v6)
179
return [subnet_v4, subnet_v6]
181
def get_routes_by_ip_block(self, context, block_id, project_id):
182
"""Returns the list of routes for the IP block"""
168
185
def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
169
186
"""Returns a list of IPv4 address strings associated with
170
187
the specified virtual interface, based on the fixed_ips table.
189
# TODO(tr3buchet): link fixed_ips to vif by uuid so only 1 db call
172
190
vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
173
191
fixed_ips = db.fixed_ips_by_virtual_interface(context,
175
193
return [fixed_ip['address'] for fixed_ip in fixed_ips]
177
195
def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
228
246
ip['virtual_interface_id'])
229
247
allocated_ips.append((ip['address'], vif['uuid']))
230
248
return allocated_ips
250
def get_floating_ips_by_fixed_address(self, context, fixed_address):
251
return db.floating_ip_get_by_fixed_address(context, fixed_address)