Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.Network


   }

   @Test
   public void testAdvancedWhenNoNetworkEligible() {
      AdvancedNetworkOptionsConverter converter = new AdvancedNetworkOptionsConverter();
      Network unsuitableNetwork = Network.builder()
         .id("25").zoneId(ZONE_ID)
         .build();

      boolean exceptionThrown = false;
      try {
         converter.apply(CloudStackTemplateOptions.NONE, ImmutableMap.of(unsuitableNetwork.getId(), unsuitableNetwork), ZONE_ID, DeployVirtualMachineOptions.NONE);
      } catch (IllegalArgumentException e) {
         exceptionThrown = true;
      }
      assertTrue(exceptionThrown);
   }
View Full Code Here


         public boolean apply(Network network) {
            return network != null && network.getState().equals("Implemented");
         }
      });
      assertTrue(Iterables.size(networks) >= 1);
      Network network = Iterables.get(networks, 0);
      assertNotNull(network);

      // Create a VM and stop it
      String defaultTemplate = template != null ? template.getImageId() : null;
      vmForCreation = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network, defaultTemplate, client, jobComplete, virtualMachineRunning);
View Full Code Here

         public boolean apply(Network network) {
            return network != null && network.getName().equals("Virtual Network");
         }
      });
      assertEquals(Iterables.size(networks), 1);
      Network network = Iterables.getOnlyElement(networks, null);
      assertNotNull(network);
      Set<OSType> osTypes = client.getGuestOSApi().listOSTypes();
      OSType osType = Iterables.getFirst(osTypes, null);

      // Register a template
View Full Code Here

      checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking");
      if (!templateOptions.getNetworks().isEmpty()) {
         options.networkIds(templateOptions.getNetworks());
      } else if (templateOptions.getIpsToNetworks().isEmpty()) {
         checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId);
         Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null);
         if (defaultNetworkInZone == null) {
             defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null);
         }
         if (defaultNetworkInZone == null) {
             throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks);
         } else {
             options.networkId(defaultNetworkInZone.getId());
         }
      }
      return options;
   }
View Full Code Here

@Test(groups = "unit")
public class NetworkPredicatesTest {

   public void testHasLoadBalancerService() {
      Network network = Network.builder().id("204").services(ImmutableSet.of(NetworkService.builder().name("Lb").build())).build();

      assert hasLoadBalancerService().apply(network);
      assert !supportsStaticNAT().apply(network);
      assert !supportsPortForwarding().apply(network);
View Full Code Here

      assert !supportsPortForwarding().apply(network);

   }

   public void testSupportsStaticNATFindsWhenFirewallHasStaticNatFeature() {
      Network network = Network
            .builder()
            .id("204")
            .services(
                  ImmutableSet.of(NetworkService.builder().name("Firewall").capabilities(
                        ImmutableMap.<String, String> of("StaticNat", "true")).build()))
View Full Code Here

      assert supportsStaticNAT().apply(network);
      assert !supportsPortForwarding().apply(network);
   }

   public void testNoSupport() {
      Network network = Network.builder().id("204")
            .services(ImmutableSet.of(NetworkService.builder().name("Firewall").capabilities(
                  ImmutableMap.<String, String> of()).build())).build();

      assert !hasLoadBalancerService().apply(network);
      assert !supportsStaticNAT().apply(network);
View Full Code Here

      assert !supportsStaticNAT().apply(network);
      assert !supportsPortForwarding().apply(network);
   }

   public void testSupportsPortForwardingFindsWhenFirewallHasPortForwardingFeature() {
      Network network = Network
            .builder()
            .id("204")
            .services(
                  ImmutableSet.of(NetworkService.builder().name("Firewall").capabilities(
                        ImmutableMap.<String, String> of("PortForwarding", "true")).build())).build();
View Full Code Here

      assert !supportsStaticNAT().apply(network);
      assert supportsPortForwarding().apply(network);
   }

   public void testSupportsPortForwardingAndStaticNATWhenFirewallHasFeatures() {
      Network network = Network
            .builder()
            .id("204")
            .services(
                  ImmutableSet.of(NetworkService.builder().name("Firewall").capabilities(
                        ImmutableMap.<String, String> of("StaticNat", "true", "PortForwarding", "true")).build())).build();
View Full Code Here

      assert !hasLoadBalancerService().apply(network);

   }

   public void testDefaultNetworkInZone() {
      Network defaultInZone = Network.builder().id("42-1").isDefault(true).zoneId("42").build();
      Network defaultNotInZone = Network.builder().id("200-1").isDefault(true).zoneId("200").build();
      Network notDefaultInZone = Network.builder().id("42-2").isDefault(false).zoneId("42").build();
      Network notDefaultNotInZone = Network.builder().id("200-2").isDefault(false).zoneId("200").build();

      Predicate<Network> predicate = defaultNetworkInZone("42");
      assertTrue(predicate.apply(defaultInZone));
      assertFalse(predicate.apply(defaultNotInZone));
      assertFalse(predicate.apply(notDefaultInZone));
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.domain.Network

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.