Package org.jclouds.openstack.nova.v2_0.domain

Examples of org.jclouds.openstack.nova.v2_0.domain.SecurityGroup$ConcreteBuilder


         // make sure we made our dummy group and also let in the user's group
         assertEquals(ImmutableSortedSet.copyOf(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group, group));

         // make sure our dummy group has no rules
         SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null,
                  "jclouds#" + group));
         assert secgroup.size() == 0 : secgroup;

         // try to run a script with the original keyPair
         runScriptWithCreds(group, first.getOperatingSystem(),
               LoginCredentials.builder().user(first.getCredentials().identity).privateKey(result.getKeyMaterial())
                     .build());
View Full Code Here


         // make sure we made our dummy group and also let in the user's group
         assertEquals(newTreeSet(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group, group));

         // make sure our dummy group has no rules
         SecurityGroup secgroup = getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(instance
                  .getRegion(), "jclouds#" + group));

         assert secgroup.size() == 0 : secgroup;

         // try to run a script with the original keyPair
         runScriptWithCreds(group, first.getOperatingSystem(), LoginCredentials.builder().user(
                  first.getCredentials().identity).privateKey(result.getKeyMaterial()).build());
View Full Code Here

   public void testApplyInputStream() {

      InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml");

      Set<SecurityGroup> expected = ImmutableSet.of(
            new SecurityGroup(defaultRegion, "sg-3c6ef654", "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers",
                  ImmutableSet.of(new IpPermission(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(),
                        ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")))),
            new SecurityGroup(defaultRegion, "sg-867309ab", "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A",
                  ImmutableSet.of(new IpPermission(IpProtocol.TCP, 6000, 7000, ImmutableMultimap
                        .<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of()))));

      DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
      addDefaultRegionToHandler(handler);
View Full Code Here

      Multimap<String, String> userIdGroupPairs = LinkedHashMultimap.create();
      userIdGroupPairs.put("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "jclouds#cluster#world");

      Set<SecurityGroup> expected = ImmutableSet.of(
            new SecurityGroup(defaultRegion, "sg-3c6ef654", "jclouds#cluster#world", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Cluster",
                  ImmutableSet.of(
                        new IpPermission(IpProtocol.TCP, 22, 22, ImmutableMultimap.<String, String> of(),
                              ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")),
                        new IpPermission(IpProtocol.ALL, -1, -1, userIdGroupPairs,
                              ImmutableSet.<String> of(), ImmutableSet.<String> of()))));
View Full Code Here

         // make sure we made our dummy group and also let in the user's group
         assertEquals(ImmutableSortedSet.copyOf(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group, group));

         // make sure our dummy group has no rules
         SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null,
                  "jclouds#" + group));
         assert secgroup.size() == 0 : secgroup;

         // try to run a script with the original keyPair
         runScriptWithCreds(group, first.getOperatingSystem(),
               LoginCredentials.builder().user(first.getCredentials().identity).privateKey(result.getKeyMaterial())
                     .build());
View Full Code Here

      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResourceWithContentType("/describe_securitygroups_extension_single.xml", "text/xml")).build();

      EC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filter, filterResponse);

      SecurityGroup group = getOnlyElement(apiWhenExist.getSecurityGroupApi().get().describeSecurityGroupsInRegionWithFilter("us-east-1",
              ImmutableMultimap.<String, String>builder()
                      .put("owner-id", "993194456877")
                      .build()));

      assertEquals(group.getId(), "sg-3c6ef654");
   }
View Full Code Here

   void testDescribe() {
      for (String region : ec2Api.getConfiguredRegions()) {
         Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
         assertNotNull(allResults);
         if (!allResults.isEmpty()) {
            final SecurityGroup group = getLast(allResults);
            // in case there are multiple groups with the same name, which is the case with VPC
            ImmutableSet<SecurityGroup> expected = FluentIterable.from(allResults)
                    .filter(new Predicate<SecurityGroup>() {
                       @Override
                       public boolean apply(SecurityGroup in) {
                          return group.getName().equals(in.getName());
                       }
                    }).toSet();
            ImmutableSet<SecurityGroup> result = ImmutableSet.copyOf(client.describeSecurityGroupsInRegion(region,
                    group.getName()));
            // the above command has a chance of returning less groups than the original
            assertTrue(expected.containsAll(result), "group(s) for name not found");
         }
      }
   }
View Full Code Here

   void testFilter() {
      for (String region : ec2Api.getConfiguredRegions()) {
         Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
         assertNotNull(allResults);
         if (!allResults.isEmpty()) {
            final SecurityGroup group = getLast(allResults);
            // in case there are multiple groups with the same name, which is the case with VPC
            ImmutableSet<SecurityGroup> expected = FluentIterable.from(allResults)
                    .filter(new Predicate<SecurityGroup>() {
                       @Override
                       public boolean apply(SecurityGroup in) {
                          return group.getName().equals(in.getName());
                       }
                    }).toSet();
            ImmutableSet<SecurityGroup> result = ImmutableSet.copyOf(client.describeSecurityGroupsInRegionWithFilter(region,
                    ImmutableMultimap.<String, String>builder()
                            .put("group-name", group.getName()).build()));
            // the above command has a chance of returning less groups than the original
            assertTrue(expected.containsAll(result), "group(s) for name not found");
         }
      }
   }
View Full Code Here

   void testFilterInvalid() {
      for (String region : ec2Api.getConfiguredRegions()) {
         Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
         assertNotNull(allResults);
         if (!allResults.isEmpty()) {
            final SecurityGroup group = getLast(allResults);
            // in case there are multiple groups with the same name, which is the case with VPC
            ImmutableSet<SecurityGroup> expected = FluentIterable.from(allResults)
                    .filter(new Predicate<SecurityGroup>() {
                       @Override
                       public boolean apply(SecurityGroup in) {
                          return group.getName().equals(in.getName());
                       }
                    }).toSet();
            ImmutableSet<SecurityGroup> result = ImmutableSet.copyOf(client.describeSecurityGroupsInRegionWithFilter(region,
                    ImmutableMultimap.<String, String>builder()
                            .put("invalid-filter", group.getName()).build()));
         }
      }
   }
View Full Code Here

   private void verifySecurityGroup(String groupName, String description) {
      Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, groupName);
      assertNotNull(oneResult);
      assertEquals(oneResult.size(), 1);
      SecurityGroup listPair = oneResult.iterator().next();
      assertEquals(listPair.getName(), groupName);
      assertEquals(listPair.getDescription(), description);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.SecurityGroup$ConcreteBuilder

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.