Package com.cloud.network.nicira

Examples of com.cloud.network.nicira.LogicalRouterPort


          // store the switchport for rollback
          LogicalSwitchPort lsp = null;
         
          try {
            // Create the outside port for the router
            LogicalRouterPort lrpo = new LogicalRouterPort();
            lrpo.setAdminStatusEnabled(true);
            lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
            lrpo.setTags(tags);
            List<String> outsideIpAddresses = new ArrayList<String>();
            outsideIpAddresses.add(publicNetworkIpAddress);
            lrpo.setIpAddresses(outsideIpAddresses);
            lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
           
            // Attach the outside port to the gateway service on the correct VLAN
            L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
            if (cmd.getVlanId() != 0) {
              attachment.setVlanId(cmd.getVlanId());
            }
            _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
           
            // Create the inside port for the router
            LogicalRouterPort lrpi = new LogicalRouterPort();
            lrpi.setAdminStatusEnabled(true);
            lrpi.setDisplayName(truncate(routerName + "-inside-port", 40));
            lrpi.setTags(tags);
            List<String> insideIpAddresses = new ArrayList<String>();
            insideIpAddresses.add(internalNetworkAddress);
            lrpi.setIpAddresses(insideIpAddresses);
            lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
           
            // Create the inside port on the lswitch
              lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true);
              lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
          
            // Attach the inside router port to the lswitch port with a PatchAttachment
              _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(),
                  new PatchAttachment(lsp.getUuid()));
           
            // Attach the inside lswitch port to the router with a PatchAttachment
              _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(),
                  new PatchAttachment(lrpi.getUuid()));
             
              // Setup the source nat rule
              SourceNatRule snr = new SourceNatRule();
              snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
              snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
View Full Code Here


      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) {
View Full Code Here

  @Test
  public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
    _resource.configure("NiciraNvpResource", _parameters);
   
    LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
    LogicalRouterPort lrp = mock(LogicalRouterPort.class);
    LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lrc.getUuid()).thenReturn("ccccc");
    when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
    when(lsp.getUuid()).thenReturn("fffff");
    when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
    when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
    when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
    CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
View Full Code Here

  @Test
  public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
    _resource.configure("NiciraNvpResource", _parameters);
   
    LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
    LogicalRouterPort lrp = mock(LogicalRouterPort.class);
    LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lrc.getUuid()).thenReturn("ccccc");
    when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
    when(lsp.getUuid()).thenReturn("fffff");
    when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
    when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
    when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
    when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
View Full Code Here

            // store the switchport for rollback
            LogicalSwitchPort lsp = null;

            try {
                // Create the outside port for the router
                LogicalRouterPort lrpo = new LogicalRouterPort();
                lrpo.setAdminStatusEnabled(true);
                lrpo.setDisplayName(truncate(routerName + "-outside-port", NAME_MAX_LEN));
                lrpo.setTags(tags);
                List<String> outsideIpAddresses = new ArrayList<String>();
                outsideIpAddresses.add(publicNetworkIpAddress);
                lrpo.setIpAddresses(outsideIpAddresses);
                lrpo = niciraNvpApi.createLogicalRouterPort(lrc.getUuid(), lrpo);

                // Attach the outside port to the gateway service on the correct VLAN
                L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
                if (cmd.getVlanId() != 0) {
                    attachment.setVlanId(cmd.getVlanId());
                }
                niciraNvpApi.updateLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);

                // Create the inside port for the router
                LogicalRouterPort lrpi = new LogicalRouterPort();
                lrpi.setAdminStatusEnabled(true);
                lrpi.setDisplayName(truncate(routerName + "-inside-port", NAME_MAX_LEN));
                lrpi.setTags(tags);
                List<String> insideIpAddresses = new ArrayList<String>();
                insideIpAddresses.add(internalNetworkAddress);
                lrpi.setIpAddresses(insideIpAddresses);
                lrpi = niciraNvpApi.createLogicalRouterPort(lrc.getUuid(), lrpi);

                // Create the inside port on the lswitch
                lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", NAME_MAX_LEN), tags, true);
                lsp = niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);

                // Attach the inside router port to the lswitch port with a PatchAttachment
                niciraNvpApi.updateLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(), new PatchAttachment(lsp.getUuid()));

                // Attach the inside lswitch port to the router with a PatchAttachment
                niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), new PatchAttachment(lrpi.getUuid()));

                // Setup the source nat rule
                SourceNatRule snr = new SourceNatRule();
                snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
                snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
View Full Code Here

        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) {
View Full Code Here

    @Test
    public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
        resource.configure("NiciraNvpResource", parameters);

        final LogicalRouter lrc = mock(LogicalRouter.class);
        final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
        final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
        when(lrc.getUuid()).thenReturn("ccccc");
        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
        when(lsp.getUuid()).thenReturn("fffff");
        when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenReturn(lrc);
        when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
        when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
        final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
View Full Code Here

    @Test
    public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
        resource.configure("NiciraNvpResource", parameters);

        final LogicalRouter lrc = mock(LogicalRouter.class);
        final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
        final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
        when(lrc.getUuid()).thenReturn("ccccc");
        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
        when(lsp.getUuid()).thenReturn("fffff");
        when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenReturn(lrc);
        when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
        when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
        when(nvpApi.createLogicalRouterNatRule((String)any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
View Full Code Here

    @Test
    public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
        _resource.configure("NiciraNvpResource", _parameters);

        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
        when(lrc.getUuid()).thenReturn("ccccc");
        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
        when(lsp.getUuid()).thenReturn("fffff");
        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
View Full Code Here

    @Test
    public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
        _resource.configure("NiciraNvpResource", _parameters);

        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
        when(lrc.getUuid()).thenReturn("ccccc");
        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
        when(lsp.getUuid()).thenReturn("fffff");
        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
        when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
View Full Code Here

TOP

Related Classes of com.cloud.network.nicira.LogicalRouterPort

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.