Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.Network


*/
@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

   @Test
   public void testAdvancedAutoDetectNetwork() {
      AdvancedNetworkOptionsConverter converter = new AdvancedNetworkOptionsConverter();

      Network eligibleNetwork = Network.builder()
         .id("25").zoneId(ZONE_ID).isDefault(true).services(ImmutableSet.of(firewallServiceWithStaticNat))
         .build();
      DeployVirtualMachineOptions optionsActual = converter.apply(CloudStackTemplateOptions.NONE,
         ImmutableMap.of(eligibleNetwork.getId(), eligibleNetwork), ZONE_ID, DeployVirtualMachineOptions.NONE);
      DeployVirtualMachineOptions optionsExpected = DeployVirtualMachineOptions.Builder.networkId("25");
      assertEquals(optionsActual, optionsExpected);
   }
View Full Code Here

   }

   @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 = VirtualMachineClientLiveTest.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.getGuestOSClient().listOSTypes();
      OSType osType = Iterables.getFirst(osTypes, null);

      // Register a template
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.