Package com.cloud.agent.api

Examples of com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer


   
    private Answer executeRequest(ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
      try {
        NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
        if (ports.getResultCount() != 1) {
          return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
        }
        LogicalRouterPort lrp = ports.getResults().get(0);
        lrp.setIpAddresses(cmd.getPublicCidrs());
        _niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
       
        return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() +
            " ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
        } catch (NiciraNvpApiException e) {
          if (numRetries > 0) {
            return retry(cmd, --numRetries);
          }
          else {
            return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
          }
        }
     
    }
View Full Code Here


                }
                cidrs.add(ip.getAddress().addr() + "/" + NetUtils.getCidrSize(ip.getNetmask()));
            }
            ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
                    niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
            ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
            //FIXME answer can be null if the host is down
            return answer.getResult();
        }
        else {
            s_logger.debug("No need to provision ip addresses as we are not providing L3 services.");
        }
View Full Code Here

        when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
        when(_hostDao.findById(42L)).thenReturn(hvo);
        deviceList.add(nndVO);
        when(_niciraNvpDao.listByPhysicalNetwork(42L)).thenReturn(deviceList);

        ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
        when(answer.getResult()).thenReturn(true);
        when(_agentManager.easySend(eq(42L), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);

        assertTrue(_element.applyIps(network, ipAddresses, services));

        verify(_agentManager, atLeast(1)).easySend(eq(42L),
View Full Code Here

    when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
    when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
    doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
    when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);
   
    ConfigurePublicIpsOnLogicalRouterAnswer answer =
        (ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
    assertFalse(answer.getResult());
   
  }
View Full Code Here

        when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
        when(hostDao.findById(NETWORK_ID)).thenReturn(hvo);
        deviceList.add(nndVO);
        when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(deviceList);

        final ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
        when(answer.getResult()).thenReturn(true);
        when(agentManager.easySend(eq(NETWORK_ID), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);

        assertTrue(element.applyIps(network, ipAddresses, services));

        verify(agentManager, atLeast(1)).easySend(eq(NETWORK_ID), argThat(new ArgumentMatcher<ConfigurePublicIpsOnLogicalRouterCommand>() {
View Full Code Here

    private Answer executeRequest(final ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
        try {
            NiciraNvpList<LogicalRouterPort> ports = niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
            if (ports.getResultCount() != 1) {
                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
            }
            LogicalRouterPort lrp = ports.getResults().get(0);
            lrp.setIpAddresses(cmd.getPublicCidrs());
            niciraNvpApi.updateLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);

            return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + " ip addresses on logical router uuid " +
                cmd.getLogicalRouterUuid());
        } catch (NiciraNvpApiException e) {
            if (numRetries > 0) {
                return retry(cmd, --numRetries);
            } else {
                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
            }
        }

    }
View Full Code Here

        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
        when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
        doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalRouterPort((String)any(), (LogicalRouterPort)any());
        when(nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa", "bbbbb")).thenReturn(list);

        final ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)resource.executeRequest(cmd);
        assertFalse(answer.getResult());

    }
View Full Code Here

                }
                cidrs.add(ip.getAddress().addr() + "/" + NetUtils.getCidrSize(ip.getNetmask()));
            }
            ConfigurePublicIpsOnLogicalRouterCommand cmd =
                    new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
            ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)agentMgr.easySend(niciraNvpHost.getId(), cmd);
            //FIXME answer can be null if the host is down
            return answer.getResult();
        } else {
            s_logger.debug("No need to provision ip addresses as we are not providing L3 services.");
        }

        return true;
View Full Code Here

        when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
        when(_hostDao.findById(42L)).thenReturn(hvo);
        deviceList.add(nndVO);
        when(_niciraNvpDao.listByPhysicalNetwork(42L)).thenReturn(deviceList);

        ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
        when(answer.getResult()).thenReturn(true);
        when(_agentManager.easySend(eq(42L), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);

        assertTrue(_element.applyIps(network, ipAddresses, services));

        verify(_agentManager, atLeast(1)).easySend(eq(42L),
View Full Code Here

        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
        when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
        when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);

        ConfigurePublicIpsOnLogicalRouterAnswer answer =
                (ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
        assertFalse(answer.getResult());

    }
View Full Code Here

TOP

Related Classes of com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.