summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyu Ishimoto <ryu@midokura.jp>2011-07-20 06:42:49 +0900
committerRyu Ishimoto <ryu@midokura.jp>2011-07-20 06:42:49 +0900
commit6fafda1ffbf2838ef33a4948303f24ed075c292d (patch)
tree37af627c606f8d21e90da1224b4d1ac54eabcf7c
parentf8a562edf819085820c1d6b4639f2331330cc454 (diff)
Renamed setup_vif_network to plug_vif
-rw-r--r--nova/compute/manager.py20
-rw-r--r--nova/network/manager.py4
-rw-r--r--nova/virt/libvirt/connection.py11
-rw-r--r--nova/virt/libvirt/vif.py16
-rw-r--r--nova/virt/vif.py4
5 files changed, 25 insertions, 30 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index eb52995be..0894052ce 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -299,7 +299,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info = self.network_api.allocate_for_instance(context,
instance, vpn=is_vpn)
LOG.debug(_("instance network_info: |%s|"), network_info)
- self.driver.setup_vif_network(context, instance['id'])
+ self.driver.plug_vifs(context, instance, network_info)
else:
# TODO(tr3buchet) not really sure how this should be handled.
# virt requires network_info to be passed in but stub_network
@@ -356,7 +356,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info = None
if not FLAGS.stub_network:
network_info = self.network_api.get_instance_nw_info(context,
- instance)
+ instance)
self.network_api.deallocate_for_instance(context, instance)
volumes = instance.get('volumes') or []
@@ -414,7 +414,7 @@ class ComputeManager(manager.SchedulerDependentManager):
self._update_state(context, instance_id, power_state.BUILDING)
network_info = self.network_api.get_instance_nw_info(context,
- instance_ref)
+ instance_ref)
self.driver.destroy(instance_ref, network_info)
image_ref = kwargs.get('image_ref')
instance_ref.image_ref = image_ref
@@ -642,7 +642,9 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_id,
power_state.NOSTATE,
'rescuing')
- self.driver.setup_vif_network(context, instance_id)
+ network_info = self.network_api.get_instance_nw_info(context,
+ instance_ref)
+ self.driver.plug_vifs(context, instance_ref, network_info)
_update_state = lambda result: self._update_state_callback(
self, context, instance_id, result)
self.driver.rescue(instance_ref, _update_state)
@@ -677,7 +679,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref = self.db.instance_get(context, instance_id)
network_info = self.network_api.get_instance_nw_info(context,
- instance_ref)
+ instance_ref)
self.driver.destroy(instance_ref, network_info)
usage_info = utils.usage_from_instance(instance_ref)
notifier.notify('compute.%s' % self.host,
@@ -698,7 +700,7 @@ class ComputeManager(manager.SchedulerDependentManager):
migration_ref = self.db.migration_get(context, migration_id)
network_info = self.network_api.get_instance_nw_info(context,
- instance_ref)
+ instance_ref)
self.driver.destroy(instance_ref, network_info)
topic = self.db.queue_get_for(context, FLAGS.compute_topic,
instance_ref['host'])
@@ -1203,16 +1205,18 @@ class ComputeManager(manager.SchedulerDependentManager):
#
# Retry operation is necessary because continuously request comes,
# concorrent request occurs to iptables, then it complains.
+ network_info = self.network_api.get_instance_nw_info(context,
+ instance_ref)
max_retry = FLAGS.live_migration_retry_count
for cnt in range(max_retry):
try:
- self.driver.setup_vif_network(context, instance_id)
+ self.driver.plug_vifs(context, instance_ref, network_info)
break
except exception.ProcessExecutionError:
if cnt == max_retry - 1:
raise
else:
- LOG.warn(_("setup_vif_network() failed %(cnt)d."
+ LOG.warn(_("plug_vifs() failed %(cnt)d."
"Retry up to %(max_retry)d for %(hostname)s.")
% locals())
time.sleep(1)
diff --git a/nova/network/manager.py b/nova/network/manager.py
index d5b8cf8dc..bf83bf4e6 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -444,7 +444,9 @@ class NetworkManager(manager.SchedulerDependentManager):
'id': network['id'],
'cidr': network['cidr'],
'cidr_v6': network['cidr_v6'],
- 'injected': network['injected']}
+ 'injected': network['injected'],
+ 'vlan': network['vlan'],
+ 'bridge_interface': network['bridge_interface']}
info = {
'label': network['label'],
'gateway': network['gateway'],
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 936e1b171..572503311 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -259,13 +259,10 @@ class LibvirtConnection(driver.ComputeDriver):
infos.append(info)
return infos
- def setup_vif_network(self, ctxt, instance_id):
- """Set up VIF networking on the host."""
- # FIXME: this is dying because DB has no networks for instances
- #networks = db.network_get_all_by_instance(ctxt, instance_id)
- #for network in networks:
- # self.vif_driver.plug(network)
- pass
+ def plug_vifs(self, ctxt, instance, network_info):
+ """Plugin VIFs into networks."""
+ for (network, mapping) in network_info:
+ self.vif_driver.plug(instance, network, mapping)
def destroy(self, instance, network_info, cleanup=True):
instance_name = instance['name']
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 4f7bb0b4d..820055cf0 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -30,15 +30,7 @@ flags.DEFINE_bool('allow_project_net_traffic',
'Whether to allow in project network traffic')
-class LibvirtVIF(object):
- """VIF class for libvirt"""
-
- def get_configurations(self, instance, network, mapping):
- """Get a dictionary of VIF configuration for libvirt interfaces."""
- raise NotImplementedError()
-
-
-class LibvirtBridge(LibvirtVIF):
+class LibvirtBridge(object):
"""Linux bridge VIF for Libvirt."""
def get_configurations(self, instance, network, mapping):
@@ -80,7 +72,7 @@ class LibvirtBridge(LibvirtVIF):
class LibvirtBridgeDriver(VIFDriver, LibvirtBridge):
"""VIF driver for Linux bridge."""
- def plug(self, network):
+ def plug(self, instance, network, mapping):
"""Ensure that the bridge exists, and add VIF to it."""
linux_net.ensure_bridge(network['bridge'],
network['bridge_interface'])
@@ -92,7 +84,7 @@ class LibvirtBridgeDriver(VIFDriver, LibvirtBridge):
class LibvirtVlanBridgeDriver(VIFDriver, LibvirtBridge):
"""VIF driver for Linux bridge with VLAN."""
- def plug(self, network):
+ def plug(self, instance, network, mapping):
"""Ensure that VLAN and bridge exist and add VIF to the bridge."""
linux_net.ensure_vlan_bridge(network['vlan'], network['bridge'],
network['bridge_interface'])
@@ -123,7 +115,7 @@ class LibvirtOpenVswitchDriver(VIFDriver):
print "using result = %s" % str(result)
return result
- def plug(self, network):
+ def plug(self, instance, network, mapping):
pass
def unplug(self, instance, network, mapping):
diff --git a/nova/virt/vif.py b/nova/virt/vif.py
index bab1bdac9..b78689957 100644
--- a/nova/virt/vif.py
+++ b/nova/virt/vif.py
@@ -21,10 +21,10 @@
class VIFDriver(object):
"""Abstract class that defines generic interfaces for all VIF drivers."""
- def plug(self, network):
+ def plug(self, instance, network, mapping):
"""Plug VIF into network."""
raise NotImplementedError()
- def unplug(self, network):
+ def unplug(self, instance, network, mapping):
"""Unplug VIF from network."""
raise NotImplementedError()