Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.NetworkOffering


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

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

         network = adminClient.getNetworkClient().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.getNetworkClient().listNetworks(
View Full Code Here


   @Test
   public void testCreateGuestVirtualNetwork() {
      if (!networksSupported)
         return;
      final NetworkOffering offering;
      try {
         offering = find(client.getOfferingClient().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.getNetworkClient().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().getOfferingClient().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
               .getNetworkClient()
               // 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

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

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

      final Zone zone = Iterables.find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
      final NetworkOffering offering = find(client.getOfferingClient().listNetworkOfferings(),
         NetworkOfferingPredicates.supportsGuestVirtualNetworks());

      if (offering != null) {
         Set<Network> suitableNetworks = Sets.filter(client.getNetworkClient().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.getNetworkClient().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

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

      NetworkOffering offering = getFirst(globalAdminClient.getOfferingClient().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.getOfferingClient().updateNetworkOffering(offering.getId(),
            UpdateNetworkOfferingOptions.Builder.name(prefix + name).availability(newValue));

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

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

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

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

         network = adminClient.getNetworkClient().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.getNetworkClient().listNetworks(
View Full Code Here

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

      final Zone zone = Iterables.find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
      final NetworkOffering offering = find(client.getOfferingClient().listNetworkOfferings(),
         NetworkOfferingPredicates.supportsGuestVirtualNetworks());
     
      Set<Network> suitableNetworks = Sets.filter(client.getNetworkClient().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.getNetworkClient().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

   @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.