Examples of NetworkConnection


Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

    Reference network = Iterables.getLast(networks);

    // Copy existing section and edit fields
    NetworkConnectionSection oldSection = vmApi
        .getNetworkConnectionSection(vmUrn);
    NetworkConnection newNetworkConnection = NetworkConnection.builder()
        .network(network.getName()).networkConnectionIndex(1)
        .ipAddressAllocationMode(IpAddressAllocationMode.DHCP).build();
    NetworkConnectionSection newSection = oldSection.toBuilder()
        .networkConnection(newNetworkConnection).build();

    // The method under test
    Task editNetworkConnectionSection = vmApi.editNetworkConnectionSection(
        vmUrn, newSection);
    assertTrue(retryTaskSuccess.apply(editNetworkConnectionSection),
        String.format(TASK_COMPLETE_TIMELY,
            "editNetworkConnectionSection"));

    // Retrieve the modified section
    NetworkConnectionSection modified = vmApi
        .getNetworkConnectionSection(vmUrn);

    // Check the retrieved object is well formed
    checkNetworkConnectionSection(modified);

    // Check the section was modified correctly
    for (NetworkConnection connection : modified.getNetworkConnections()) {
      if (connection.getNetwork().equals(
          newNetworkConnection.getNetwork())) {
        assertEquals(connection.getIpAddressAllocationMode(),
            newNetworkConnection.getIpAddressAllocationMode());
        assertSame(connection.getNetworkConnectionIndex(), newNetworkConnection
            .getNetworkConnectionIndex());
      }
    }
  }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

      // vapp contains a network configuration. we should add the vm to this
      // vapp network
      else {
         if (vAppHasNetworkConfigured(vApp)) {
            VAppNetworkConfiguration vAppNetworkConfiguration = getVAppNetworkConfig(vApp);
            NetworkConnection networkConnection = NetworkConnection.builder()
                     .network(vAppNetworkConfiguration.getNetworkName())
                     .ipAddressAllocationMode(IpAddressAllocationMode.DHCP).build();

            NetworkConnectionSection networkConnectionSection = NetworkConnectionSection.builder().info("networkInfo")
                     .primaryNetworkConnectionIndex(0).networkConnection(networkConnection).build();
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

  
   private void cleanUpNetworkConnectionSection(Vm toAddVm) {
      NetworkConnectionSection networkConnectionSection = vmApi.getNetworkConnectionSection(toAddVm.getId());
      Set<NetworkConnection> networkConnections = networkConnectionSection.getNetworkConnections();
      for (NetworkConnection networkConnection : networkConnections) {
         NetworkConnection newNetworkConnection = networkConnection.toBuilder().isConnected(false).build();
         networkConnectionSection = networkConnectionSection.toBuilder().networkConnection(newNetworkConnection)
                  .build();
      }

      Task configureNetwork = vmApi.editNetworkConnectionSection(toAddVm.getId(), networkConnectionSection);
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

      // vapp contains a network configuration. we should add the vm to this
      // vapp network
      else {
         if (vAppHasNetworkConfigured(vApp)) {
            VAppNetworkConfiguration vAppNetworkConfiguration = getVAppNetworkConfig(vApp);
            NetworkConnection networkConnection = NetworkConnection.builder()
                     .network(vAppNetworkConfiguration.getNetworkName())
                     .ipAddressAllocationMode(IpAddressAllocationMode.DHCP).build();

            NetworkConnectionSection networkConnectionSection = NetworkConnectionSection.builder().info("networkInfo")
                     .primaryNetworkConnectionIndex(0).networkConnection(networkConnection).build();
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

  
   private void cleanUpNetworkConnectionSection(Vm toAddVm) {
      NetworkConnectionSection networkConnectionSection = vmApi.getNetworkConnectionSection(toAddVm.getId());
      Set<NetworkConnection> networkConnections = networkConnectionSection.getNetworkConnections();
      for (NetworkConnection networkConnection : networkConnections) {
         NetworkConnection newNetworkConnection = networkConnection.toBuilder().isConnected(false).build();
         networkConnectionSection = networkConnectionSection.toBuilder().networkConnection(newNetworkConnection)
                  .build();
      }

      Task configureNetwork = vmApi.editNetworkConnectionSection(toAddVm.getId(), networkConnectionSection);
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection

               .info("info")
               .primaryNetworkConnectionIndex(0)
               .build();
     
      for (NetworkConnection networkConnection : networkConnections) {
         NetworkConnection newNetworkConnection = networkConnection.toBuilder()
                  .network(vAppNetworkName)
                  .isConnected(true)
                  .networkConnectionIndex(0)
                  .ipAddressAllocationMode(IpAddressAllocationMode.POOL)
                  .build();
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnection

      Vm vm = get(vApp.getChildren(), 0);

      NetworkConnectionSection net = vm.getNetworkConnectionSection();
      checkArgument(net.getConnections().size() > 0, "no connections on vm %s", vm);

      NetworkConnection toConnect = findWithPoolAllocationOrFirst(net);

      if (ipAllocationMode == null)
         ipAllocationMode = toConnect.getIpAddressAllocationMode();

      // make sure that we are in fact allocating ips
      if (ipAllocationMode == IpAddressAllocationMode.NONE)
         ipAllocationMode = IpAddressAllocationMode.POOL;

      if (toConnect.isConnected() && toConnect.getIpAddressAllocationMode() == ipAllocationMode
               && toConnect.getNetwork().equals(networkToConnect.getName())) {
         // then we don't need to change the network settings, and can save a call
      } else {
         Builder builder = net.toBuilder();
         builder.connections(ImmutableSet.of(toConnect.toBuilder().network(networkToConnect.getName()).connected(true)
                  .ipAddressAllocationMode(ipAllocationMode).build()));
         logger.trace(">> updating networkConnection vm(%s)", vm.getName());

         waitForTask(client.getVmClient().updateNetworkConnectionOfVm(builder.build(), vm.getHref()));
         logger.trace("<< updated networkConnection vm(%s)", vm.getName());
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnection

   protected boolean connected;
   protected String MACAddress;
   protected IpAddressAllocationMode ipAddressAllocationMode;

   public NetworkConnection getResult() {
      NetworkConnection connection = new NetworkConnection(network, networkConnectionIndex, ipAddress,
               externalIpAddress, connected, MACAddress, ipAddressAllocationMode);
      this.network = null;
      this.networkConnectionIndex = -1;
      this.ipAddress = null;
      this.externalIpAddress = null;
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnection

      Vm vm = get(vApp.getChildren(), 0);

      NetworkConnectionSection net = vm.getNetworkConnectionSection();
      checkArgument(net.getConnections().size() > 0, "no connections on vm %s", vm);

      NetworkConnection toConnect = findWithPoolAllocationOrFirst(net);

      if (ipAllocationMode == null)
         ipAllocationMode = toConnect.getIpAddressAllocationMode();

      // make sure that we are in fact allocating ips
      if (ipAllocationMode == IpAddressAllocationMode.NONE)
         ipAllocationMode = IpAddressAllocationMode.POOL;

      if (toConnect.isConnected() && toConnect.getIpAddressAllocationMode() == ipAllocationMode
               && toConnect.getNetwork().equals(networkToConnect.getName())) {
         // then we don't need to change the network settings, and can save a call
      } else {
         Builder builder = net.toBuilder();
         builder.connections(ImmutableSet.of(toConnect.toBuilder().network(networkToConnect.getName()).connected(true)
                  .ipAddressAllocationMode(ipAllocationMode).build()));
         logger.trace(">> updating networkConnection vm(%s)", vm.getName());

         waitForTask(client.getVmApi().updateNetworkConnectionOfVm(builder.build(), vm.getHref()));
         logger.trace("<< updated networkConnection vm(%s)", vm.getName());
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnection

public class NetworkConnectionHandlerTest extends BaseHandlerTest {

   public void testDefault() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/networkconnection.xml");

      NetworkConnection result = factory.create(injector.getInstance(NetworkConnectionHandler.class)).parse(is);

      checkNetworkConnection(result);

   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.