Beispiel #1
0
 def fake_network_api_associate(self,
                                context,
                                instance,
                                floating_address=None,
                                fixed_address=None):
     floating_ips = ["10.10.10.10", "10.10.10.11"]
     if floating_address not in floating_ips:
         raise exception.FloatingIpNotFoundForAddress(
             address=floating_address)
Beispiel #2
0
def fake_floating_ip_get_by_address(context, address):
    if isinstance(address, FakeModel):
        # NOTE(tr3buchet): yo dawg, i heard you like addresses
        address = address['address']
    ips = filter(lambda i: i['address'] == address,
                 floating_ips)
    if not ips:
        raise exception.FloatingIpNotFoundForAddress(address=address)
    return FakeModel(ips[0])
Beispiel #3
0
 def _get_floating_ip_by_address(self, client, address):
     """Get floatingip from floating ip address."""
     data = client.list_floatingips(floating_ip_address=address)
     fips = data['floatingips']
     if len(fips) == 0:
         raise exception.FloatingIpNotFoundForAddress(address=address)
     elif len(fips) > 1:
         raise exception.FloatingIpMultipleFoundForAddress(address=address)
     return fips[0]
Beispiel #4
0
        def fake_network_api_associate(self, context, instance,
                                             floating_address=None,
                                             fixed_address=None):
            floating_ips = ["10.10.10.10", "10.10.10.11"]
            if floating_address not in floating_ips:
                    raise exception.FloatingIpNotFoundForAddress()

            self.stubs.Set(network.api.API, "associate_floating_ip",
                                             fake_network_api_associate)

            body = dict(addFloatingIp=dict(address='1.1.1.1'))
            req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
            self.assertRaises(webob.exc.HTTPNotFound,
                              self.manager._add_floating_ip,
                              req, 'test_inst', body)
Beispiel #5
0
 def network_api_get_floating_ip_by_address(self, context,
                                            floating_address):
     floating_ips = ["10.10.10.10", "10.10.10.11"]
     if floating_address not in floating_ips:
         raise exception.FloatingIpNotFoundForAddress(
             address=floating_address)
 def test_floatingip_delete_error_disassociate_3(self):
     raised_exc = exception.FloatingIpNotFoundForAddress(address='1.1.1.1')
     expected_exc = webob.exc.HTTPNotFound
     self._test_floatingip_delete_error_disassociate(
         raised_exc, expected_exc)
Beispiel #7
0
 def fake_associate_floating_ip(self, context, instance,
                       floating_address, fixed_address,
                       affect_auto_assigned=False):
     raise exception.FloatingIpNotFoundForAddress(
         address=floating_address)