110
111
'Network host to use for ip allocation in flat modes')
111
112
flags.DEFINE_bool('fake_call', False,
112
113
'If True, skip using the queue and make local calls')
114
flags.DEFINE_bool('force_dhcp_release', False,
115
'If True, send a dhcp release on instance termination')
115
118
class AddressAlreadyAllocated(exception.Error):
396
400
self.compute_api.trigger_security_group_members_refresh(admin_context,
403
def get_vifs_by_instance(self, context, instance_id):
404
vifs = self.db.virtual_interface_get_by_instance(context,
408
def get_instance_uuids_by_ip_filter(self, context, filters):
409
fixed_ip_filter = filters.get('fixed_ip')
410
ip_filter = re.compile(str(filters.get('ip')))
411
ipv6_filter = re.compile(str(filters.get('ip6')))
413
# NOTE(jkoelker) Should probably figure out a better way to do
414
# this. But for now it "works", this could suck on
417
vifs = self.db.virtual_interface_get_all(context)
421
if vif['instance_id'] is None:
424
fixed_ipv6 = vif.get('fixed_ipv6')
425
if fixed_ipv6 and ipv6_filter.match(fixed_ipv6):
426
# NOTE(jkoelker) Will need to update for the UUID flip
427
results.append({'instance_id': vif['instance_id'],
430
for fixed_ip in vif['fixed_ips']:
431
if not fixed_ip or not fixed_ip['address']:
433
if fixed_ip['address'] == fixed_ip_filter:
434
results.append({'instance_id': vif['instance_id'],
435
'ip': fixed_ip['address']})
437
if ip_filter.match(fixed_ip['address']):
438
results.append({'instance_id': vif['instance_id'],
439
'ip': fixed_ip['address']})
441
for floating_ip in fixed_ip.get('floating_ips', []):
442
if not floating_ip or not floating_ip['address']:
444
if ip_filter.match(floating_ip['address']):
445
results.append({'instance_id': vif['instance_id'],
446
'ip': floating_ip['address']})
449
# NOTE(jkoelker) Until we switch over to instance_uuid ;)
450
ids = [res['instance_id'] for res in results]
451
uuid_map = self.db.instance_get_id_to_uuid_mapping(context, ids)
453
res['instance_uuid'] = uuid_map.get(res['instance_id'])
399
456
def _get_networks_for_instance(self, context, instance_id, project_id,
400
457
requested_networks=None):
401
458
"""Determine & return which networks an instance should connect to."""
689
746
instance_id = instance_ref['id']
690
747
self._do_trigger_security_group_members_refresh_for_instance(
749
if FLAGS.force_dhcp_release:
750
dev = self.driver.get_dev(fixed_ip_ref['network'])
751
vif = self.db.virtual_interface_get_by_instance_and_network(
752
context, instance_ref['id'], fixed_ip_ref['network']['id'])
753
self.driver.release_dhcp(dev, address, vif['address'])
693
755
def lease_fixed_ip(self, context, address):
694
756
"""Called by dhcp-bridge when ip is leased."""