Package org.jclouds.ec2.features

Examples of org.jclouds.ec2.features.SubnetApi


   private Set<RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String group, int count,
         Template template) {
      String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation());
      String zone = getZoneFromLocationOrNull(template.getLocation());
      RunInstancesOptions instanceOptions = createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region,
            group, template);
      return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions);
   }
View Full Code Here


   @SuppressWarnings("unchecked")
   @Test
   public void testWhenInstancesPresentSingleCall() {

      EC2Client client = createMock(EC2Client.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);

      expect(client.getInstanceServices()).andReturn(instanceClient);

      // avoid imatcher fail.  if you change this, be sure to check multiple jres
      expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn(
            Set.class.cast(ImmutableSet.of(Reservation.builder().region("us-east-1")
                  .instances(ImmutableSet.of(instance1, instance2)).build())));

      replay(client, instanceClient);
View Full Code Here

   @SuppressWarnings( { "unchecked" })
   @Test
   public void testApplyWithIllegalStateException() throws UnknownHostException {
      final EC2Client client = createMock(EC2Client.class);
      KeyPairClient keyClient = createMock(KeyPairClient.class);
      final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);

      KeyPair pair = createMock(KeyPair.class);

      expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce();

      expect(uniqueIdSupplier.get()).andReturn("1");
      expect(keyClient.createKeyPairInRegion("region", "jclouds#group#1")).andThrow(new IllegalStateException());
      expect(uniqueIdSupplier.get()).andReturn("2");
      expect(keyClient.createKeyPairInRegion("region", "jclouds#group#2")).andReturn(pair);

      replay(client);
      replay(keyClient);
      replay(uniqueIdSupplier);
View Full Code Here

   }

   @Test(expectedExceptions = RuntimeException.class)
   public void testWhenEventualConsistencyExpiresIllegalStateException() throws ExecutionException {

      SecurityGroupClient client = createMock(SecurityGroupClient.class);
      Predicate<RegionAndName> tester = Predicates.alwaysFalse();

      client.createSecurityGroupInRegion("region", "group", "group");

      replay(client);

      CreateSecurityGroupIfNeeded function = new CreateSecurityGroupIfNeeded(client, tester);
      function.load(new RegionNameAndIngressRules("region", "group", new int[] { 22 }, true));
View Full Code Here

         Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
         assertNotNull(oneResult);
         assertEquals(oneResult.size(), 1);
         final SecurityGroup group = oneResult.iterator().next();
         assertEquals(group.getName(), group1Name);
         IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).port(80)
               .originatingFromSecurityGroupId(group1Id);
         AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id,
               group2CanHttpGroup1);
         assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
            @Override
View Full Code Here

         client.getTagApiForRegion(region).get().applyToResources(common, ids);
         for (NodeMetadata in : input)
            builder.add(addTagsForInstance(common, in));
      }
      if (logger.isDebugEnabled()) {
         Multimap<String, String> filter = new TagFilterBuilder().resourceIds(instancesById.keySet()).build();
         FluentIterable<Tag> tags = client.getTagApiForRegion(region).get().filter(filter);
         logger.debug("<< applied tags in region %s: %s", region, resourceToTagsAsMap(tags));
      }
      return builder.build();
   }
View Full Code Here

               .append("<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2010-06-15/\"><requestId>0a5a6b4d-c0d7-4531-9ba9-bbc0b94d2007</requestId><regionInfo><item><regionName>is-1</regionName><regionEndpoint>api.greenqloud.com</regionEndpoint></item></regionInfo></DescribeRegionsResponse>\n")
               .toString();

      Map<String, URI> expected = expected();

      DescribeRegionsResponseHandler handler = injector.getInstance(DescribeRegionsResponseHandler.class);
      Map<String, URI> result = factory.create(handler).parse(text);

      assertEquals(result.toString(), expected.toString());

   }
View Full Code Here

   }

   @Override
   protected Function<Object, IterableWithMarker<Subnet>> markerToNextForArg0(Optional<Object> arg0) {
      String region = arg0.isPresent() ? arg0.get().toString() : null;
      final SubnetApi subnetApi = api.getSubnetApi(region);
      return new Function<Object, IterableWithMarker<Subnet>>() {

         @SuppressWarnings("unchecked")
         @Override
         public IterableWithMarker<Subnet> apply(Object input) {
            PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
            return IterableWithMarker.class.cast(subnetApi.list(paginationOptions));
         }

         @Override
         public String toString() {
            return "listSubnets()";
View Full Code Here

      }

      @Override
      protected Function<Object, IterableWithMarker<ReferenceWithName>> markerToNextForArg0(Optional<Object> arg0) {
         String zone = arg0.isPresent() ? arg0.get().toString() : null;
         final SubnetApi subnetApi = api.getSubnetApiForZone(zone);
         return new Function<Object, IterableWithMarker<ReferenceWithName>>() {

            @SuppressWarnings("unchecked")
            @Override
            public IterableWithMarker<ReferenceWithName> apply(Object input) {
               PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
               return IterableWithMarker.class.cast(subnetApi.list(paginationOptions));
            }

            @Override
            public String toString() {
               return "list()";
View Full Code Here

      }

      @Override
      protected Function<Object, IterableWithMarker<Subnet>> markerToNextForArg0(Optional<Object> arg0) {
         String zone = arg0.isPresent() ? arg0.get().toString() : null;
         final SubnetApi subnetApi = api.getSubnetApiForZone(zone);
         return new Function<Object, IterableWithMarker<Subnet>>() {

            @SuppressWarnings("unchecked")
            @Override
            public IterableWithMarker<Subnet> apply(Object input) {
               PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
               return IterableWithMarker.class.cast(subnetApi.listInDetail(paginationOptions));
            }

            @Override
            public String toString() {
               return "list()";
View Full Code Here

TOP

Related Classes of org.jclouds.ec2.features.SubnetApi

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.