Example #1
0
    def test_create_hosting_device_resources_exception(self):
        complementary_id = 'fake_complementary_id'
        tenant_id = 'fake_tenantid'
        mgmt_context = {
            'mgmt_nw_id': 'fake_mgmt_nw_id',
            'mgmt_sec_grp_id': 'fake_mgmt_sec_grp_id'
        }
        max_hosted = 'fake_max_hosted'
        mock_delete_resources = mock.MagicMock()
        mocked_plugin = mock.MagicMock()
        mocked_plugin.create_port = mock.MagicMock(
            side_effect=n_exc.NeutronException)

        mock_ctx = mock.MagicMock()
        with mock.patch.object(VIFHotPlugPluggingDriver,
                               '_core_plugin') as plugin:
            plugin.__get__ = mock.MagicMock(return_value=mocked_plugin)
            vif_plugging_driver = VIFHotPlugPluggingDriver()
            vif_plugging_driver.delete_hosting_device_resources = (
                mock_delete_resources)
            result = vif_plugging_driver.create_hosting_device_resources(
                mock_ctx, complementary_id, tenant_id, mgmt_context,
                max_hosted)
            self.assertEqual(True, mocked_plugin.create_port.called)
            self.assertEqual(1, mocked_plugin.create_port.call_count)
            self.assertEqual(True, mock_delete_resources.called)
            self.assertEqual(1, mock_delete_resources.call_count)
            self.assertEqual(None, result['mgmt_port'])
            self.assertEqual([], result['ports'])
    def test_create_hosting_device_resources_exception(self):
        complementary_id = 'fake_complementary_id'
        tenant_id = 'fake_tenantid'
        mgmt_context = {'mgmt_nw_id': 'fake_mgmt_nw_id',
                        'mgmt_sec_grp_id': 'fake_mgmt_sec_grp_id'}
        max_hosted = 'fake_max_hosted'
        mock_delete_resources = mock.MagicMock()
        mocked_plugin = mock.MagicMock()
        mocked_plugin.create_port = mock.MagicMock(
            side_effect=n_exc.NeutronException)

        mock_ctx = mock.MagicMock()
        with mock.patch.object(VIFHotPlugPluggingDriver,
                               '_core_plugin') as plugin:
            plugin.__get__ = mock.MagicMock(return_value=mocked_plugin)
            vif_plugging_driver = VIFHotPlugPluggingDriver()
            vif_plugging_driver.delete_hosting_device_resources = (
                mock_delete_resources)
            result = vif_plugging_driver.create_hosting_device_resources(
                mock_ctx, complementary_id, tenant_id, mgmt_context,
                max_hosted)
            self.assertEqual(True, mocked_plugin.create_port.called)
            self.assertEqual(1, mocked_plugin.create_port.call_count)
            self.assertEqual(True, mock_delete_resources.called)
            self.assertEqual(1, mock_delete_resources.call_count)
            self.assertEqual(None, result['mgmt_port'])
            self.assertEqual([], result['ports'])
 def test_create_hosting_device_resources(self):
     complementary_id = 'fake_complementary_id'
     tenant_id = 'fake_tenantid'
     mgmt_context = {'mgmt_nw_id': 'fake_mgmt_nw_id',
                     'mgmt_sec_grp_id': 'fake_mgmt_sec_grp_id'}
     max_hosted = 'fake_max_hosted'
     mocked_plugin = mock.MagicMock()
     mock_ctx = mock.MagicMock()
     with mock.patch.object(VIFHotPlugPluggingDriver,
                            '_core_plugin') as plugin:
         plugin.__get__ = mock.MagicMock(return_value=mocked_plugin)
         vif_plugging_driver = VIFHotPlugPluggingDriver()
         vif_plugging_driver.create_hosting_device_resources(
             mock_ctx, complementary_id, tenant_id, mgmt_context,
             max_hosted)
         self.assertEqual(True, mocked_plugin.create_port.called)
         self.assertEqual(1, mocked_plugin.create_port.call_count)
Example #4
0
 def test_create_hosting_device_resources(self):
     complementary_id = 'fake_complementary_id'
     tenant_id = 'fake_tenantid'
     mgmt_context = {
         'mgmt_nw_id': 'fake_mgmt_nw_id',
         'mgmt_sec_grp_id': 'fake_mgmt_sec_grp_id'
     }
     max_hosted = 'fake_max_hosted'
     mocked_plugin = mock.MagicMock()
     mock_ctx = mock.MagicMock()
     with mock.patch.object(VIFHotPlugPluggingDriver,
                            '_core_plugin') as plugin:
         plugin.__get__ = mock.MagicMock(return_value=mocked_plugin)
         vif_plugging_driver = VIFHotPlugPluggingDriver()
         vif_plugging_driver.create_hosting_device_resources(
             mock_ctx, complementary_id, tenant_id, mgmt_context,
             max_hosted)
         self.assertEqual(True, mocked_plugin.create_port.called)
         self.assertEqual(1, mocked_plugin.create_port.call_count)