Examples of NetworkConnectionSection


Examples of org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection

      return task;
   }

   public static NetworkConnectionSection getNetworkConnectionSection() {
      NetworkConnectionSection section = NetworkConnectionSection.builder()
            .build();

      return section;
   }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection

      return task;
   }

   public static NetworkConnectionSection getNetworkConnectionSection() {
      NetworkConnectionSection section = NetworkConnectionSection.builder()
            .build();

      return section;
   }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection

      // Get URI for child VM
      String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId();

      // The method under test
      try {
         NetworkConnectionSection section = getNetworkConnectionSection.apply(vmUrn);

         // Check the retrieved object is well formed
         checkNetworkConnectionSection(section);
      } catch (Exception e) {
         Throwables.propagate(e);
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection

  
   protected void attachVmToVAppNetwork(Vm vm, String vAppNetworkName) {
      Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getId())
               .getNetworkConnections();

      NetworkConnectionSection section = NetworkConnectionSection.builder()
               .info("info")
               .primaryNetworkConnectionIndex(0)
               .build();
     
      for (NetworkConnection networkConnection : networkConnections) {
         NetworkConnection newNetworkConnection = networkConnection.toBuilder()
                  .network(vAppNetworkName)
                  .isConnected(true)
                  .networkConnectionIndex(0)
                  .ipAddressAllocationMode(IpAddressAllocationMode.POOL)
                  .build();
        
         section = section.toBuilder().networkConnection(newNetworkConnection).build();
      }
      Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getId(), section);
      assertTaskSucceedsLong(configureNetwork);
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

   public void ensureVmHasAllocationModeOrPooled(VApp vApp, @Nullable IpAddressAllocationMode ipAllocationMode) {
      Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation));

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

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      checkArgument(checkNotNull(payload, "NetworkConnectionSection") instanceof NetworkConnectionSection,
            "this binder is only valid for NetworkConnectionSection!");
      NetworkConnectionSection net = NetworkConnectionSection.class.cast(payload);
      XMLBuilder networkConnectionSection;
      try {
         networkConnectionSection = XMLBuilder.create("NetworkConnectionSection").a("xmlns", ns)
               .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1").a("type", net.getType())
               .a("href", net.getHref().toASCIIString()).a("ovf:required", "false");
         networkConnectionSection.e("ovf:Info").t(net.getInfo());

         if (net.getPrimaryNetworkConnectionIndex() != null)
            networkConnectionSection.e("PrimaryNetworkConnectionIndex").t(
                  net.getPrimaryNetworkConnectionIndex().toString());
         for (NetworkConnection networkConnection : net.getConnections()) {
            XMLBuilder networkConnectionSectionChild = networkConnectionSection.e("NetworkConnection").a("network",
                  networkConnection.getNetwork());
            networkConnectionSectionChild.e("NetworkConnectionIndex").t(
                  networkConnection.getNetworkConnectionIndex() + "");
            if (networkConnection.getExternalIpAddress() != null)
               networkConnectionSectionChild.e("ExternalIpAddress").t(networkConnection.getExternalIpAddress());
            if (networkConnection.getIpAddress() != null)
               networkConnectionSectionChild.e("IpAddress").t(networkConnection.getIpAddress());
            networkConnectionSectionChild.e("IsConnected").t(networkConnection.isConnected() + "");
            if (networkConnection.getMACAddress() != null)
               networkConnectionSectionChild.e("MACAddress").t(networkConnection.getMACAddress());
            if (networkConnection.getIpAddressAllocationMode() != null)
               networkConnectionSectionChild.e("IpAddressAllocationMode").t(
                     networkConnection.getIpAddressAllocationMode().toString());
         }

         if (net.getEdit() != null)
            networkConnectionSection.e("Link").a("rel", "edit").a("type", net.getType())
                  .a("href", net.getHref().toASCIIString());

         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request = super.bindToRequest(request, networkConnectionSection.asString(outputProperties));
         request.getPayload().getContentMetadata().setContentType(net.getType());
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

   public void ensureVmHasAllocationModeOrPooled(VApp vApp, @Nullable IpAddressAllocationMode ipAllocationMode) {
      Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation));

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

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

   protected ReferenceType edit;
   protected Integer primaryNetworkConnectionIndex;
   protected boolean inConnections;

   public NetworkConnectionSection getResult() {
      return new NetworkConnectionSection(section.getType(), section.getHref(), info, primaryNetworkConnectionIndex,
               connections, edit);
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

public class NetworkConnectionSectionHandlerTest {
   public void testVCloud1_0() {
      InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
      Injector injector = Guice.createInjector(new SaxParserModule());
      Factory factory = injector.getInstance(ParseSax.Factory.class);
      NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
               .parse(is);
      checkNetworkConnectionSection(result);
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.NetworkConnectionSection

   public void ensureVmHasAllocationModeOrPooled(VApp vApp, @Nullable IpAddressAllocationMode ipAllocationMode) {
      Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation));

      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()));
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.