~markmc/nova/flat-dhcp-without-bridge-iface

« back to all changes in this revision

Viewing changes to nova/virt/libvirt/vif.py

  • Committer: Tarmac
  • Author(s): Ryu Ishimoto, Dan Wendlandt
  • Date: 2011-08-19 08:54:49 UTC
  • mfrom: (1360.7.18 nova-quantum-vifid)
  • Revision ID: tarmac-20110819085449-g5rs3tfsdhumopsr
Added uuid column in virtual_interfaces table, and an OpenStack extension API for virtual interfaces to expose these IDs.  Also set this UUID as one of the external IDs in the OVS vif driver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
class LibvirtOpenVswitchDriver(VIFDriver):
101
101
    """VIF driver for Open vSwitch."""
102
102
 
 
103
    def get_dev_name(_self, iface_id):
 
104
        return "tap-" + iface_id[0:15]
 
105
 
103
106
    def plug(self, instance, network, mapping):
104
 
        vif_id = str(instance['id']) + "-" + str(network['id'])
105
 
        dev = "tap-%s" % vif_id
106
 
        iface_id = "nova-" + vif_id
 
107
        iface_id = mapping['vif_uuid']
 
108
        dev = self.get_dev_name(iface_id)
107
109
        if not linux_net._device_exists(dev):
108
110
            utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
109
111
                          run_as_root=True)
127
129
    def unplug(self, instance, network, mapping):
128
130
        """Unplug the VIF from the network by deleting the port from
129
131
        the bridge."""
130
 
        vif_id = str(instance['id']) + "-" + str(network['id'])
131
 
        dev = "tap-%s" % vif_id
 
132
        dev = self.get_dev_name(mapping['vif_uuid'])
132
133
        try:
133
134
            utils.execute('ovs-vsctl', 'del-port',
134
 
                          network['bridge'], dev, run_as_root=True)
 
135
                          FLAGS.libvirt_ovs_bridge, dev, run_as_root=True)
135
136
            utils.execute('ip', 'link', 'delete', dev, run_as_root=True)
136
137
        except exception.ProcessExecutionError:
137
138
            LOG.warning(_("Failed while unplugging vif of instance '%s'"),