def handle(self, request, data):
        try:
            api.server_add_floating_ip(request,
                                       data['instance_id'],
                                       data['floating_ip_id'])
            LOG.info('Associating Floating IP "%s" with Instance "%s"'
                                % (data['floating_ip'], data['instance_id']))
            messages.info(request, 'Successfully associated Floating IP: %s \
with Instance: %s'
                                    % (data['floating_ip'],
                                       data['instance_id']))
        except novaclient_exceptions.ClientException, e:
            LOG.error("ClientException in FloatingIpAssociate", exc_info=True)
            messages.error(request, 'Error associating Floating IP: %s'
                                     % e.message)
Ejemplo n.º 2
0
    def test_server_add_floating_ip(self):
        server = api.nova.Server(self.servers.first(), self.request)
        floating_ip = self.floating_ips.first()
        novaclient = self.stub_novaclient()

        novaclient.floating_ips = self.mox.CreateMockAnything()
        novaclient.servers = self.mox.CreateMockAnything()
        novaclient.servers.get(server.id).AndReturn(server)
        novaclient.floating_ips.get(floating_ip.id).AndReturn(floating_ip)
        novaclient.servers.add_floating_ip(server.id, floating_ip.ip) \
                          .AndReturn(server)
        self.mox.ReplayAll()

        server = api.server_add_floating_ip(self.request, server.id,
                                            floating_ip.id)
        self.assertIsInstance(server, api.nova.Server)
Ejemplo n.º 3
0
    def test_server_add_floating_ip(self):
        server = api.nova.Server(self.servers.first(), self.request)
        floating_ip = self.floating_ips.first()
        novaclient = self.stub_novaclient()

        novaclient.floating_ips = self.mox.CreateMockAnything()
        novaclient.servers = self.mox.CreateMockAnything()
        novaclient.servers.get(server.id).AndReturn(server)
        novaclient.floating_ips.get(floating_ip.id).AndReturn(floating_ip)
        novaclient.servers.add_floating_ip(server.id, floating_ip.ip) \
                          .AndReturn(server)
        self.mox.ReplayAll()

        server = api.server_add_floating_ip(self.request,
                                            server.id,
                                            floating_ip.id)
        self.assertIsInstance(server, api.nova.Server)