Merge lp:~vishvananda/nova/lp852771 into lp:~hudson-openstack/nova/milestone-proposed

Proposed by Vish Ishaya
Status: Merged
Approved by: Vish Ishaya
Approved revision: 1545
Merged at revision: 1181
Proposed branch: lp:~vishvananda/nova/lp852771
Merge into: lp:~hudson-openstack/nova/milestone-proposed
Diff against target: 82 lines (+26/-0)
2 files modified
nova/network/linux_net.py (+19/-0)
nova/network/manager.py (+7/-0)
To merge this branch: bzr merge lp:~vishvananda/nova/lp852771
Reviewer Review Type Date Requested Status
OpenStack release team Pending
Review via email: mp+76097@code.launchpad.net

Description of the change

Adds an optional flag to force dhcp releases on instance termination. This allows ips to be reused without having to wait for the lease to timeout.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/network/linux_net.py'
--- nova/network/linux_net.py 2011-09-07 20:10:05 +0000
+++ nova/network/linux_net.py 2011-09-19 20:13:58 +0000
@@ -540,6 +540,10 @@
540 return '\n'.join(hosts)540 return '\n'.join(hosts)
541541
542542
543def release_dhcp(dev, address, mac_address):
544 utils.execute('dhcp_release', dev, address, mac_address, run_as_root=True)
545
546
543# NOTE(ja): Sending a HUP only reloads the hostfile, so any547# NOTE(ja): Sending a HUP only reloads the hostfile, so any
544# configuration options (like dchp-range, vlan, ...)548# configuration options (like dchp-range, vlan, ...)
545# aren't reloaded.549# aren't reloaded.
@@ -790,6 +794,10 @@
790 return interface_driver.unplug(network)794 return interface_driver.unplug(network)
791795
792796
797def get_dev(network):
798 return interface_driver.get_dev(network)
799
800
793class LinuxNetInterfaceDriver(object):801class LinuxNetInterfaceDriver(object):
794 """Abstract class that defines generic network host API"""802 """Abstract class that defines generic network host API"""
795 """ for for all Linux interface drivers."""803 """ for for all Linux interface drivers."""
@@ -802,6 +810,11 @@
802 """Destory Linux device, return device name"""810 """Destory Linux device, return device name"""
803 raise NotImplementedError()811 raise NotImplementedError()
804812
813 def get_dev(self, network):
814 """Get device name"""
815 raise NotImplementedError()
816
817
805818
806# plugs interfaces using Linux Bridge819# plugs interfaces using Linux Bridge
807class LinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):820class LinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
@@ -823,6 +836,9 @@
823 return network['bridge']836 return network['bridge']
824837
825 def unplug(self, network):838 def unplug(self, network):
839 return self.get_dev(network)
840
841 def get_dev(self, network):
826 return network['bridge']842 return network['bridge']
827843
828 @classmethod844 @classmethod
@@ -947,6 +963,9 @@
947 return dev963 return dev
948964
949 def unplug(self, network):965 def unplug(self, network):
966 return self.get_dev(network)
967
968 def get_dev(self, network):
950 dev = "gw-" + str(network['id'])969 dev = "gw-" + str(network['id'])
951 return dev970 return dev
952971
953972
=== modified file 'nova/network/manager.py'
--- nova/network/manager.py 2011-09-14 21:57:52 +0000
+++ nova/network/manager.py 2011-09-19 20:13:58 +0000
@@ -110,6 +110,8 @@
110 'Network host to use for ip allocation in flat modes')110 'Network host to use for ip allocation in flat modes')
111flags.DEFINE_bool('fake_call', False,111flags.DEFINE_bool('fake_call', False,
112 'If True, skip using the queue and make local calls')112 'If True, skip using the queue and make local calls')
113flags.DEFINE_bool('force_dhcp_release', False,
114 'If True, send a dhcp release on instance termination')
113115
114116
115class AddressAlreadyAllocated(exception.Error):117class AddressAlreadyAllocated(exception.Error):
@@ -629,6 +631,11 @@
629 instance_id = instance_ref['id']631 instance_id = instance_ref['id']
630 self._do_trigger_security_group_members_refresh_for_instance(632 self._do_trigger_security_group_members_refresh_for_instance(
631 instance_id)633 instance_id)
634 if FLAGS.force_dhcp_release:
635 dev = self.driver.get_dev(fixed_ip_ref['network'])
636 vif = self.db.virtual_interface_get_by_instance_and_network(
637 context, instance_ref['id'], fixed_ip_ref['network']['id'])
638 self.driver.release_dhcp(dev, address, vif['address'])
632639
633 def lease_fixed_ip(self, context, address):640 def lease_fixed_ip(self, context, address):
634 """Called by dhcp-bridge when ip is leased."""641 """Called by dhcp-bridge when ip is leased."""

Subscribers

People subscribed via source and target branches