Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.NetworkOffering


   @Test
   public void testCreateVlanIPRange() {
      skipIfNotGlobalAdmin();

      final Zone zone = Iterables.find(client.getZoneApi().listZones(), ZonePredicates.supportsAdvancedNetworks());
      final NetworkOffering offering = Iterables.tryFind(client.getOfferingApi().listNetworkOfferings(),
                                                         NetworkOfferingPredicates.supportsGuestVirtualNetworks()).orNull();

      if (offering != null) {
         Set<Network> suitableNetworks = Sets.filter(client.getNetworkApi().listNetworks(
                                                                                         zoneId(zone.getId()).isSystem(false).trafficType(TrafficType.GUEST)),
                                                     new Predicate<Network>() {
                                                        @Override
                                                        public boolean apply(Network network) {
                                                           return network.getNetworkOfferingId().equals(offering.getId());
                                                        }
                                                     });
        
         if (suitableNetworks.size() > 0) {
            network = Iterables.get(suitableNetworks, 0);
            usingExistingNetwork = true;
        
         } else if (network == null) {
            network = client.getNetworkApi().createNetworkInZone(zone.getId(),
                                                                 offering.getId(), "net-" + prefix, "jclouds test " + prefix);
            usingExistingNetwork = false;
         }
        
         range = globalAdminClient.getVlanClient().createVlanIPRange("172.19.1.1", "172.19.1.199", CreateVlanIPRangeOptions.Builder
                                                                     .accountInDomain(user.getAccount(), user.getDomainId())
View Full Code Here


               assertTrue(adminJobComplete.apply(
                  adminClient.getNetworkApi().deleteNetwork(net.getId())), net.toString());
            }
         }

         NetworkOffering offering = getFirst(
            client.getOfferingApi().listNetworkOfferings(
               ListNetworkOfferingsOptions.Builder.zoneId(template.getZoneId()).specifyVLAN(true)), null);
         checkNotNull(offering, "No network offering found");
         logger.info("Using network offering: " + offering);

         network = adminClient.getNetworkApi().createNetworkInZone(
            template.getZoneId(), offering.getId(), prefix + "-ip-network", "",
            CreateNetworkOptions.Builder.startIP("192.168.0.1").endIP("192.168.0.5")
               .netmask("255.255.255.0").gateway("192.168.0.1").vlan("21"));
         logger.info("Created network: " + network);

         Network requiredNetwork = getOnlyElement(filter(adminClient.getNetworkApi().listNetworks(
View Full Code Here

   @Test(groups = "live", enabled = true)
   public void testUpdateNetworkOffering() throws Exception {
      skipIfNotGlobalAdmin();

      NetworkOffering offering = getFirst(globalAdminClient.getOfferingApi().listNetworkOfferings(), null);
      assertNotNull(offering, "Unable to test, no network offering found.");

      String name = offering.getName();
      NetworkOfferingAvailabilityType availability = offering.getAvailability();

      try {
         NetworkOfferingAvailabilityType newValue = OPTIONAL;
         if (availability == OPTIONAL) {
            newValue = REQUIRED;
         }
         NetworkOffering updated = globalAdminClient.getOfferingApi().updateNetworkOffering(offering.getId(),
            UpdateNetworkOfferingOptions.Builder.name(prefix + name).availability(newValue));

         assertEquals(updated.getName(), prefix + name);
         assertEquals(updated.getAvailability(), newValue);

      } finally {
         globalAdminClient.getOfferingApi().updateNetworkOffering(offering.getId(),
            UpdateNetworkOfferingOptions.Builder.name(name).availability(availability));
      }
View Full Code Here

   @Test
   public void testCreateVlanIPRange() {
      skipIfNotGlobalAdmin();

      final Zone zone = Iterables.find(client.getZoneApi().listZones(), ZonePredicates.supportsAdvancedNetworks());
      final NetworkOffering offering = Iterables.tryFind(client.getOfferingApi().listNetworkOfferings(),
                                                         NetworkOfferingPredicates.supportsGuestVirtualNetworks()).orNull();

      if (offering != null) {
         Set<Network> suitableNetworks = Sets.filter(client.getNetworkApi().listNetworks(
                                                                                         zoneId(zone.getId()).isSystem(false).trafficType(TrafficType.GUEST)),
                                                     new Predicate<Network>() {
                                                        @Override
                                                        public boolean apply(Network network) {
                                                           return network.getNetworkOfferingId().equals(offering.getId());
                                                        }
                                                     });

         if (!suitableNetworks.isEmpty()) {
            network = Iterables.get(suitableNetworks, 0);
            usingExistingNetwork = true;

         } else if (network == null) {
            network = client.getNetworkApi().createNetworkInZone(zone.getId(),
                                                                 offering.getId(), "net-" + prefix, "jclouds test " + prefix);
            usingExistingNetwork = false;
         }

         range = globalAdminClient.getVlanClient().createVlanIPRange("172.19.1.1", "172.19.1.199", CreateVlanIPRangeOptions.Builder
                                                                     .accountInDomain(user.getAccount(), user.getDomainId())
View Full Code Here

               assertTrue(adminJobComplete.apply(
                  adminClient.getNetworkApi().deleteNetwork(net.getId())), net.toString());
            }
         }

         NetworkOffering offering = getFirst(
            client.getOfferingApi().listNetworkOfferings(
               ListNetworkOfferingsOptions.Builder.zoneId(template.getZoneId()).specifyVLAN(true)), null);
         checkNotNull(offering, "No network offering found");
         logger.info("Using network offering: " + offering);

         network = adminClient.getNetworkApi().createNetworkInZone(
            template.getZoneId(), offering.getId(), prefix + "-ip-network", "",
            CreateNetworkOptions.Builder.startIP("192.168.0.1").endIP("192.168.0.5")
               .netmask("255.255.255.0").gateway("192.168.0.1").vlan("21"));
         logger.info("Created network: " + network);

         Network requiredNetwork = getOnlyElement(filter(adminClient.getNetworkApi().listNetworks(
View Full Code Here

      Set<NetworkOffering> response = client.getOfferingApi().listNetworkOfferings();
      assert null != response;
      long offeringCount = response.size();
      assertTrue(offeringCount >= 0);
      for (NetworkOffering offering : response) {
         NetworkOffering newDetails = Iterables.getOnlyElement(client.getOfferingApi().listNetworkOfferings(
               ListNetworkOfferingsOptions.Builder.id(offering.getId())));
         assertEquals(offering, newDetails);
         assertEquals(offering, client.getOfferingApi().getNetworkOffering(offering.getId()));
         assert offering.getId() != null : offering;
         assert offering.getName() != null : offering;
View Full Code Here

   @Test
   public void testCreateGuestVirtualNetwork() {
      if (!networksSupported)
         return;
      final NetworkOffering offering;
      try {
         offering = find(client.getOfferingApi().listNetworkOfferings(),
               NetworkOfferingPredicates.supportsGuestVirtualNetworks());

      } catch (NoSuchElementException e) {
         Logger.getAnonymousLogger().log(Level.SEVERE, "guest networks not supported, skipping test");
         return;
      }
      String name = prefix + "-virtual";

      Network network = null;
      try {
         network = client.getNetworkApi().createNetworkInZone(zone.getId(), offering.getId(), name, name);
         checkNetwork(network);
      } catch (IllegalStateException e) {
         Logger.getAnonymousLogger().log(Level.SEVERE, "couldn't create a network, skipping test", e);
      } finally {
         if (network != null) {
View Full Code Here

   public void testCreateVLANNetwork() {
      skipIfNotDomainAdmin();
      if (!networksSupported)
         return;

      final NetworkOffering offering;
      try {
         offering = get(
               cloudStackContext.getApi().getOfferingApi().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0);
      } catch (NoSuchElementException e) {
         Logger.getAnonymousLogger().log(Level.SEVERE, "VLAN networks not supported, skipping test");
         return;
      }
      String name = prefix + "-vlan";

      Network network = null;
      try {
         network = domainAdminClient
               .getNetworkApi()
               // startIP/endIP/netmask/gateway must be specified together
               .createNetworkInZone(zone.getId(), offering.getId(), name, name,
                     vlan("65").startIP("192.168.1.2").netmask("255.255.255.0").gateway("192.168.1.1"));
         checkNetwork(network);
      } catch (IllegalStateException e) {
         Logger.getAnonymousLogger().log(Level.SEVERE, "couldn't create a network, skipping test", e);
      } finally {
View Full Code Here

TOP

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

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.