Merge "hyperv: Remove vestigial nova-network support"
This commit is contained in:
commit
56eac06561
@ -25,50 +25,17 @@ from nova.virt.hyperv import vif
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class HyperVNovaNetworkVIFPluginTestCase(test_base.HyperVBaseTestCase):
|
||||
def setUp(self):
|
||||
super(HyperVNovaNetworkVIFPluginTestCase, self).setUp()
|
||||
self.vif_driver = vif.HyperVNovaNetworkVIFPlugin()
|
||||
|
||||
def test_plug(self):
|
||||
self.flags(vswitch_name='fake_vswitch_name', group='hyperv')
|
||||
fake_vif = {'id': mock.sentinel.fake_id}
|
||||
|
||||
self.vif_driver.plug(mock.sentinel.instance, fake_vif)
|
||||
netutils = self.vif_driver._netutils
|
||||
netutils.connect_vnic_to_vswitch.assert_called_once_with(
|
||||
'fake_vswitch_name', mock.sentinel.fake_id)
|
||||
|
||||
|
||||
class HyperVVIFDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
def setUp(self):
|
||||
super(HyperVVIFDriverTestCase, self).setUp()
|
||||
self.vif_driver = vif.HyperVVIFDriver()
|
||||
self.vif_driver._netutils = mock.MagicMock()
|
||||
self.vif_driver._vif_plugin = mock.MagicMock()
|
||||
|
||||
@mock.patch.object(vif.nova.network, 'is_neutron')
|
||||
def test_init_neutron(self, mock_is_neutron):
|
||||
mock_is_neutron.return_value = True
|
||||
|
||||
driver = vif.HyperVVIFDriver()
|
||||
self.assertIsInstance(driver._vif_plugin, vif.HyperVNeutronVIFPlugin)
|
||||
|
||||
@mock.patch.object(vif.nova.network, 'is_neutron')
|
||||
def test_init_nova(self, mock_is_neutron):
|
||||
mock_is_neutron.return_value = False
|
||||
|
||||
driver = vif.HyperVVIFDriver()
|
||||
self.assertIsInstance(driver._vif_plugin,
|
||||
vif.HyperVNovaNetworkVIFPlugin)
|
||||
|
||||
def test_plug(self):
|
||||
vif = {'type': model.VIF_TYPE_HYPERV}
|
||||
# this is handled by neutron so just assert it doesn't blow up
|
||||
self.vif_driver.plug(mock.sentinel.instance, vif)
|
||||
|
||||
self.vif_driver._vif_plugin.plug.assert_called_once_with(
|
||||
mock.sentinel.instance, vif)
|
||||
|
||||
@mock.patch.object(vif, 'os_vif')
|
||||
@mock.patch.object(vif.os_vif_util, 'nova_to_osvif_instance')
|
||||
@mock.patch.object(vif.os_vif_util, 'nova_to_osvif_vif')
|
||||
@ -95,11 +62,9 @@ class HyperVVIFDriverTestCase(test_base.HyperVBaseTestCase):
|
||||
|
||||
def test_unplug(self):
|
||||
vif = {'type': model.VIF_TYPE_HYPERV}
|
||||
# this is handled by neutron so just assert it doesn't blow up
|
||||
self.vif_driver.unplug(mock.sentinel.instance, vif)
|
||||
|
||||
self.vif_driver._vif_plugin.unplug.assert_called_once_with(
|
||||
mock.sentinel.instance, vif)
|
||||
|
||||
@mock.patch.object(vif, 'os_vif')
|
||||
@mock.patch.object(vif.os_vif_util, 'nova_to_osvif_instance')
|
||||
@mock.patch.object(vif.os_vif_util, 'nova_to_osvif_vif')
|
||||
|
@ -517,8 +517,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
self._vmops._neutron_failed_callback,
|
||||
mock.sentinel.event_name, mock.sentinel.instance)
|
||||
|
||||
@mock.patch.object(vmops.utils, 'is_neutron')
|
||||
def test_get_neutron_events(self, mock_is_neutron):
|
||||
def test_get_neutron_events(self):
|
||||
network_info = [{'id': mock.sentinel.vif_id1, 'active': True},
|
||||
{'id': mock.sentinel.vif_id2, 'active': False},
|
||||
{'id': mock.sentinel.vif_id3}]
|
||||
@ -526,16 +525,13 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
events = self._vmops._get_neutron_events(network_info)
|
||||
self.assertEqual([('network-vif-plugged', mock.sentinel.vif_id2)],
|
||||
events)
|
||||
mock_is_neutron.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(vmops.utils, 'is_neutron')
|
||||
def test_get_neutron_events_no_timeout(self, mock_is_neutron):
|
||||
def test_get_neutron_events_no_timeout(self):
|
||||
self.flags(vif_plugging_timeout=0)
|
||||
network_info = [{'id': mock.sentinel.vif_id1, 'active': True}]
|
||||
|
||||
events = self._vmops._get_neutron_events(network_info)
|
||||
self.assertEqual([], events)
|
||||
mock_is_neutron.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(vmops.VMOps, '_attach_pci_devices')
|
||||
@mock.patch.object(vmops.VMOps, '_requires_secure_boot')
|
||||
|
@ -14,8 +14,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
|
||||
import os_vif
|
||||
from os_win import utilsfactory
|
||||
|
||||
@ -28,55 +26,15 @@ from nova.network import os_vif_util
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class HyperVBaseVIFPlugin(object):
|
||||
@abc.abstractmethod
|
||||
def plug(self, instance, vif):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def unplug(self, instance, vif):
|
||||
pass
|
||||
|
||||
|
||||
class HyperVNeutronVIFPlugin(HyperVBaseVIFPlugin):
|
||||
"""Neutron VIF plugin."""
|
||||
|
||||
def plug(self, instance, vif):
|
||||
# Neutron takes care of plugging the port
|
||||
pass
|
||||
|
||||
def unplug(self, instance, vif):
|
||||
# Neutron takes care of unplugging the port
|
||||
pass
|
||||
|
||||
|
||||
class HyperVNovaNetworkVIFPlugin(HyperVBaseVIFPlugin):
|
||||
"""Nova network VIF plugin."""
|
||||
|
||||
def __init__(self):
|
||||
self._netutils = utilsfactory.get_networkutils()
|
||||
|
||||
def plug(self, instance, vif):
|
||||
self._netutils.connect_vnic_to_vswitch(CONF.hyperv.vswitch_name,
|
||||
vif['id'])
|
||||
|
||||
def unplug(self, instance, vif):
|
||||
# TODO(alepilotti) Not implemented
|
||||
pass
|
||||
|
||||
|
||||
class HyperVVIFDriver(object):
|
||||
def __init__(self):
|
||||
self._netutils = utilsfactory.get_networkutils()
|
||||
if nova.network.is_neutron():
|
||||
self._vif_plugin = HyperVNeutronVIFPlugin()
|
||||
else:
|
||||
self._vif_plugin = HyperVNovaNetworkVIFPlugin()
|
||||
|
||||
def plug(self, instance, vif):
|
||||
vif_type = vif['type']
|
||||
if vif_type == model.VIF_TYPE_HYPERV:
|
||||
self._vif_plugin.plug(instance, vif)
|
||||
# neutron takes care of plugging the port
|
||||
pass
|
||||
elif vif_type == model.VIF_TYPE_OVS:
|
||||
vif = os_vif_util.nova_to_osvif_vif(vif)
|
||||
instance = os_vif_util.nova_to_osvif_instance(instance)
|
||||
@ -94,7 +52,8 @@ class HyperVVIFDriver(object):
|
||||
def unplug(self, instance, vif):
|
||||
vif_type = vif['type']
|
||||
if vif_type == model.VIF_TYPE_HYPERV:
|
||||
self._vif_plugin.unplug(instance, vif)
|
||||
# neutron takes care of unplugging the port
|
||||
pass
|
||||
elif vif_type == model.VIF_TYPE_OVS:
|
||||
vif = os_vif_util.nova_to_osvif_vif(vif)
|
||||
instance = os_vif_util.nova_to_osvif_instance(instance)
|
||||
|
@ -41,7 +41,6 @@ from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova import utils
|
||||
from nova.virt import configdrive
|
||||
from nova.virt import hardware
|
||||
from nova.virt.hyperv import block_device_manager
|
||||
@ -345,11 +344,11 @@ class VMOps(object):
|
||||
# already up will not undergo that transition, and for
|
||||
# anything that might be stale (cache-wise) assume it's
|
||||
# already up so we don't block on it.
|
||||
if utils.is_neutron() and CONF.vif_plugging_timeout:
|
||||
if CONF.vif_plugging_timeout:
|
||||
return [('network-vif-plugged', vif['id'])
|
||||
for vif in network_info if vif.get('active') is False]
|
||||
else:
|
||||
return []
|
||||
|
||||
return []
|
||||
|
||||
def create_instance(self, instance, network_info, root_device,
|
||||
block_device_info, vm_gen, image_meta):
|
||||
|
Loading…
Reference in New Issue
Block a user