Examples of Zone


Examples of org.jclouds.cloudstack.domain.Zone

      Set<Zone> response = client.getZoneClient().listZones();
      assert null != response;
      long zoneCount = response.size();
      assertTrue(zoneCount >= 0);
      for (Zone zone : response) {
         Zone newDetails = Iterables.getOnlyElement(client.getZoneClient().listZones(
               ListZonesOptions.Builder.id(zone.getId())));
         assertEquals(zone, newDetails);
         assertEquals(zone, client.getZoneClient().getZone(zone.getId()));
         assert zone.getId() != null : zone;
         assert zone.getName() != null : zone;
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

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

      Zone zone = null;
      String zoneName = prefix + "-zone";
      try {
         zone = globalAdminClient.getZoneClient().createZone(zoneName,
            NetworkType.BASIC, "8.8.8.8", "10.10.10.10");

         assertNotNull(zone);
         assertEquals(zone, globalAdminClient.getZoneClient().getZone(zone.getId()));
         assertEquals(zone.getNetworkType(), NetworkType.BASIC);
         assertEquals(zone.getDNS(), ImmutableList.of("8.8.8.8"));
         assertEquals(zone.getInternalDNS(), ImmutableList.of("10.10.10.10"));

         Zone updated = globalAdminClient.getZoneClient().updateZone(zone.getId(),
            name(zoneName + "-2").externalDns(ImmutableList.of("8.8.4.4")));
         assertEquals(updated.getId(), zone.getId());
         assertEquals(updated.getDNS(), ImmutableList.of("8.8.4.4"));

      } finally {
         if (zone != null) {
            globalAdminClient.getZoneClient().deleteZone(zone.getId());
         }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

   @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
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getId()).andReturn("sec-1234").anyTimes();
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(zone.isSecurityGroupsEnabled()).andReturn(false);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

   @Override
   public SecurityGroup apply(ZoneSecurityGroupNamePortsCidrs input) {
      checkNotNull(input, "input");

      String zoneId = input.getZone();
      Zone zone = zoneIdToZone.get().getUnchecked(zoneId);

      checkArgument(supportsSecurityGroups().apply(zone),
                    "Security groups are required, but the zone %s does not support security groups", zoneId);
      logger.debug(">> creating securityGroup %s", input);
      try {
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

         "options class %s should have been assignable from CloudStackTemplateOptions", template.getOptions()
         .getClass());
      Map<String, Network> networks = networkSupplier.get();

      final String zoneId = template.getLocation().getId();
      Zone zone = zoneIdToZone.get().getUnchecked(zoneId);

      CloudStackTemplateOptions templateOptions = template.getOptions().as(CloudStackTemplateOptions.class);

      checkState(optionsConverters.containsKey(zone.getNetworkType()), "no options converter configured for network type %s", zone.getNetworkType());
      DeployVirtualMachineOptions options = displayName(name).name(name);
      if (templateOptions.getAccount() != null) {
          options.accountInDomain(templateOptions.getAccount(), templateOptions.getDomainId());
      } else if (templateOptions.getDomainId() != null) {
          options.domainId(templateOptions.getDomainId());
      }
     
      OptionsConverter optionsConverter = optionsConverters.get(zone.getNetworkType());
      options = optionsConverter.apply(templateOptions, networks, zoneId, options);

      if (templateOptions.getIpOnDefaultNetwork() != null) {
         options.ipOnDefaultNetwork(templateOptions.getIpOnDefaultNetwork());
      }

      if (templateOptions.getIpsToNetworks().size() > 0) {
         options.ipsToNetworks(templateOptions.getIpsToNetworks());
      }

      if (templateOptions.getKeyPair() != null) {
         SshKeyPair keyPair = null;
         if (templateOptions.getLoginPrivateKey() != null) {
            String pem = templateOptions.getLoginPrivateKey();
            keyPair = SshKeyPair.builder().name(templateOptions.getKeyPair())
               .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
            keyPairCache.asMap().put(keyPair.getName(), keyPair);
            options.keyPair(keyPair.getName());
         } else if (client.getSSHKeyPairClient().getSSHKeyPair(templateOptions.getKeyPair()) != null) {
            keyPair = client.getSSHKeyPairClient().getSSHKeyPair(templateOptions.getKeyPair());
         }
         if (keyPair != null) {
            keyPairCache.asMap().put(keyPair.getName(), keyPair);
            options.keyPair(keyPair.getName());
         }
      } else if (templateOptions.shouldGenerateKeyPair()) {
         SshKeyPair keyPair = keyPairCache.getUnchecked(namingConvention.create()
                                                        .sharedNameForGroup(group));
         keyPairCache.asMap().put(keyPair.getName(), keyPair);
         templateOptions.keyPair(keyPair.getName());
         options.keyPair(keyPair.getName());
      }

      if (supportsSecurityGroups().apply(zone)) {
         List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());

         if (templateOptions.getSecurityGroupIds().size() == 0
             && inboundPorts.size() > 0
             && templateOptions.shouldGenerateSecurityGroup()) {
            String securityGroupName = namingConvention.create().sharedNameForGroup(group);
            SecurityGroup sg = securityGroupCache.getUnchecked(ZoneSecurityGroupNamePortsCidrs.builder()
                                                               .zone(zone.getId())
                                                               .name(securityGroupName)
                                                               .ports(ImmutableSet.copyOf(inboundPorts))
                                                               .cidrs(ImmutableSet.<String> of()).build());
            options.securityGroupId(sg.getId());
         }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();
View Full Code Here

Examples of org.jclouds.cloudstack.domain.Zone

      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();
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.