Esempio n. 1
0
 def _test_handle_create_dhcp_owner_port(self, exc=None):
     subnet = {'cidr': '0.0.0.0/0', 'id': 'foo_subnet_id'}
     port = {
         'id': 'foo_port_id',
         'device_owner': 'network:dhcp',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'network_id': 'foo_network_id',
         'fixed_ips': [{
             'subnet_id': subnet['id']
         }]
     }
     expected_data = {
         'subnet_id': subnet['id'],
         'ip_address': subnet['cidr'],
         'mac_address': port['mac_address']
     }
     self.plugin.get_subnet.return_value = subnet
     if exc is None:
         nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port,
                                     'create_port')
         (self.plugin.lsn_manager.lsn_port_dhcp_setup.
          assert_called_once_with(mock.ANY, port['network_id'], port['id'],
                                  expected_data, subnet))
     else:
         self.plugin.lsn_manager.lsn_port_dhcp_setup.side_effect = exc
         self.assertRaises(n_exc.NeutronException,
                           nvp.handle_port_dhcp_access, self.plugin,
                           mock.ANY, port, 'create_port')
Esempio n. 2
0
 def _test_handle_create_dhcp_owner_port(self, exc=None):
     subnet = {
         'cidr': '0.0.0.0/0',
         'id': 'foo_subnet_id'
     }
     port = {
         'id': 'foo_port_id',
         'device_owner': 'network:dhcp',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'network_id': 'foo_network_id',
         'fixed_ips': [{'subnet_id': subnet['id']}]
     }
     expected_data = {
         'subnet_id': subnet['id'],
         'ip_address': subnet['cidr'],
         'mac_address': port['mac_address']
     }
     self.plugin.get_subnet.return_value = subnet
     if exc is None:
         nvp.handle_port_dhcp_access(
             self.plugin, mock.ANY, port, 'create_port')
         (self.plugin.lsn_manager.lsn_port_dhcp_setup.
          assert_called_once_with(mock.ANY, port['network_id'],
                                  port['id'], expected_data, subnet))
     else:
         self.plugin.lsn_manager.lsn_port_dhcp_setup.side_effect = exc
         self.assertRaises(n_exc.NeutronException,
                           nvp.handle_port_dhcp_access,
                           self.plugin, mock.ANY, port, 'create_port')
Esempio n. 3
0
 def _test_handle_user_port_no_fixed_ips(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'fixed_ips': []
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 4
0
 def _test_handle_user_port_no_fixed_ips(self, action, handler):
     port = {
         "id": "foo_port_id",
         "device_owner": "foo_device_owner",
         "network_id": "foo_network_id",
         "fixed_ips": [],
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 5
0
 def _test_handle_user_port_no_fixed_ips(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'fixed_ips': []
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 6
0
 def test_handle_delete_dhcp_owner_port(self):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'network:dhcp',
         'network_id': 'foo_network_id',
         'fixed_ips': [],
         'mac_address': 'aa:bb:cc:dd:ee:ff'
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, 'delete_port')
     self.plugin.lsn_manager.lsn_port_dispose.assert_called_once_with(
         mock.ANY, port['network_id'], port['mac_address'])
Esempio n. 7
0
 def _test_handle_user_port_disabled_dhcp(self, action, handler):
     port = {
         "id": "foo_port_id",
         "device_owner": "foo_device_owner",
         "network_id": "foo_network_id",
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "fixed_ips": [{"subnet_id": "foo_subnet_id", "ip_address": "1.2.3.4"}],
     }
     self.plugin.get_subnet.return_value = {"enable_dhcp": False}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 8
0
 def test_handle_delete_dhcp_owner_port(self):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'network:dhcp',
         'network_id': 'foo_network_id',
         'fixed_ips': [],
         'mac_address': 'aa:bb:cc:dd:ee:ff'
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, 'delete_port')
     self.plugin.lsn_manager.lsn_port_dispose.assert_called_once_with(
         mock.ANY, port['network_id'], port['mac_address'])
Esempio n. 9
0
 def _test_handle_user_port_disabled_dhcp(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'fixed_ips': [{'subnet_id': 'foo_subnet_id',
                        'ip_address': '1.2.3.4'}]
     }
     self.plugin.get_subnet.return_value = {'enable_dhcp': False}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 10
0
 def _test_handle_user_port(self, action, handler):
     port = {
         "id": "foo_port_id",
         "device_owner": "foo_device_owner",
         "network_id": "foo_network_id",
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "fixed_ips": [{"subnet_id": "foo_subnet_id", "ip_address": "1.2.3.4"}],
     }
     expected_data = {"ip_address": "1.2.3.4", "mac_address": "aa:bb:cc:dd:ee:ff"}
     self.plugin.get_subnet.return_value = {"enable_dhcp": True}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     handler.assert_called_once_with(mock.ANY, port["network_id"], "foo_subnet_id", expected_data)
Esempio n. 11
0
 def test_handle_delete_dhcp_owner_port(self):
     port = {
         "id": "foo_port_id",
         "device_owner": "network:dhcp",
         "network_id": "foo_network_id",
         "fixed_ips": [],
         "mac_address": "aa:bb:cc:dd:ee:ff",
     }
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, "delete_port")
     self.plugin.lsn_manager.lsn_port_dispose.assert_called_once_with(
         mock.ANY, port["network_id"], port["mac_address"]
     )
Esempio n. 12
0
 def _test_handle_user_port_disabled_dhcp(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'fixed_ips': [{
             'subnet_id': 'foo_subnet_id',
             'ip_address': '1.2.3.4'
         }]
     }
     self.plugin.get_subnet.return_value = {'enable_dhcp': False}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     self.assertEqual(0, handler.call_count)
Esempio n. 13
0
 def _test_handle_user_port(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'fixed_ips': [{'subnet_id': 'foo_subnet_id',
                        'ip_address': '1.2.3.4'}]
     }
     expected_data = {
         'ip_address': '1.2.3.4',
         'mac_address': 'aa:bb:cc:dd:ee:ff'
     }
     self.plugin.get_subnet.return_value = {'enable_dhcp': True}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     handler.assert_called_once_with(
         mock.ANY, port['network_id'], 'foo_subnet_id', expected_data)
Esempio n. 14
0
 def _test_handle_user_port(self, action, handler):
     port = {
         'id': 'foo_port_id',
         'device_owner': 'foo_device_owner',
         'network_id': 'foo_network_id',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'fixed_ips': [{
             'subnet_id': 'foo_subnet_id',
             'ip_address': '1.2.3.4'
         }]
     }
     expected_data = {
         'ip_address': '1.2.3.4',
         'mac_address': 'aa:bb:cc:dd:ee:ff'
     }
     self.plugin.get_subnet.return_value = {'enable_dhcp': True}
     nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, action)
     handler.assert_called_once_with(mock.ANY, port['network_id'],
                                     'foo_subnet_id', expected_data)
Esempio n. 15
0
 def _test_handle_create_dhcp_owner_port(self, exc=None):
     subnet = {"cidr": "0.0.0.0/0", "id": "foo_subnet_id"}
     port = {
         "id": "foo_port_id",
         "device_owner": "network:dhcp",
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "network_id": "foo_network_id",
         "fixed_ips": [{"subnet_id": subnet["id"]}],
     }
     expected_data = {"subnet_id": subnet["id"], "ip_address": subnet["cidr"], "mac_address": port["mac_address"]}
     self.plugin.get_subnet.return_value = subnet
     if exc is None:
         nvp.handle_port_dhcp_access(self.plugin, mock.ANY, port, "create_port")
         (
             self.plugin.lsn_manager.lsn_port_dhcp_setup.assert_called_once_with(
                 mock.ANY, port["network_id"], port["id"], expected_data, subnet
             )
         )
     else:
         self.plugin.lsn_manager.lsn_port_dhcp_setup.side_effect = exc
         self.assertRaises(
             n_exc.NeutronException, nvp.handle_port_dhcp_access, self.plugin, mock.ANY, port, "create_port"
         )