Пример #1
0
 def test_subnet_exists_with_bad_subnet(self):
     subnet_id = uuidutils.generate_uuid()
     with mock.patch('octavia.common.utils.get_network_driver') as net_mock:
         net_mock.return_value.get_subnet = mock.Mock(
             side_effect=network_base.SubnetNotFound('Subnet not found'))
         self.assertRaises(exceptions.InvalidSubresource,
                           validate.subnet_exists, subnet_id)
Пример #2
0
 def test_subnet_exists_with_bad_subnet(self):
     with mock.patch(
             'octavia.common.utils.get_network_driver') as net_mock:
         net_mock.return_value.get_subnet = mock.Mock(
             side_effect=network_base.SubnetNotFound('Subnet not found'))
         subnet_id = uuidutils.generate_uuid()
         self.assertEqual(validate.subnet_exists(subnet_id), False)
Пример #3
0
 def test_create_with_bad_subnet(self):
     with mock.patch('octavia.common.utils.get_network_driver') as net_mock:
         net_mock.return_value.get_subnet = mock.Mock(
             side_effect=network_base.SubnetNotFound('Subnet not found'))
         subnet_id = uuidutils.generate_uuid()
         response = self.create_member(self.pool_id,
                                       '10.0.0.1',
                                       80,
                                       subnet_id=subnet_id,
                                       status=400)
         err_msg = 'Subnet ' + subnet_id + ' not found.'
         self.assertEqual(response.get('faultstring'), err_msg)
Пример #4
0
 def test_create_with_bad_subnet(self, **optionals):
     with mock.patch(
             'octavia.common.utils.get_network_driver') as net_mock:
         net_mock.return_value.get_subnet = mock.Mock(
             side_effect=network_base.SubnetNotFound('Subnet not found'))
         subnet_id = uuidutils.generate_uuid()
         lb_json = {'name': 'test1',
                    'vip': {'subnet_id': subnet_id,
                            'ip_address': '10.0.0.1'},
                    'project_id': self.project_id}
         lb_json.update(optionals)
         response = self.post(self.LBS_PATH, lb_json, expect_errors=True)
         err_msg = 'Subnet ' + subnet_id + ' not found.'
         self.assertEqual(response.json.get('faultstring'), err_msg)
Пример #5
0
 def get_subnet(self, subnet_id):
     try:
         subnet = self.neutron_client.show_subnet(subnet_id)
         return utils.convert_subnet_dict_to_model(subnet)
     except neutron_client_exceptions.NotFound:
         message = _LE(
             'Subnet not found '
             '(subnet id: {subnet_id}.').format(subnet_id=subnet_id)
         LOG.exception(message)
         raise base.SubnetNotFound(message)
     except Exception:
         message = _LE(
             'Error retrieving subnet '
             '(subnet id: {subnet_id}.').format(subnet_id=subnet_id)
         LOG.exception(message)
         raise base.NetworkException(message)