Package org.jclouds.net.domain

Examples of org.jclouds.net.domain.IpPermission


   @SuppressWarnings("unchecked")
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(checkNotNull(input, "input") instanceof IpPermission, "this binder is only valid for IpPermission");
      IpPermission perm = (IpPermission) input;
      return (R) request.toBuilder().replaceFormParams(IpPermissions.buildFormParametersForIndex(0, perm)).build();
   }
View Full Code Here


      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);
      Set<SecurityGroup> result = factory.create(handler).parse(is);
View Full Code Here

      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()))));

      DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
      addDefaultRegionToHandler(handler);
      Set<SecurityGroup> result = factory.create(handler).parse(is);
View Full Code Here

         .toPort(20)
         .group(group)
         .parentGroupId("some-other-id")
         .build();

      IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
      assertTrue(convertedPerm.getGroupIds().contains("az-1.region-a.geo-1/some-id"));
      assertTrue(convertedPerm.getCidrBlocks().size() == 0);
   }
View Full Code Here

         .toPort(20)
         .ipRange("0.0.0.0/0")
         .parentGroupId("some-other-id")
         .build();

      IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
      assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
      assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 0);
   }
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(22);
      builder.cidrBlock("10.2.6.0/24");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");

      assertNotNull(origGroup);
      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(22);
      builder.groupId("admin/11111");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");

      assertNotNull(origGroup);
      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(40);
      builder.cidrBlock("0.0.0.0/0");

      IpPermission perm = builder.build();

      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();

      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
      groupBuilder.id("jclouds#some-group");
      groupBuilder.providerId("sg-3c6ef654");
      groupBuilder.name("jclouds#some-group");
      groupBuilder.location(new LocationBuilder()
                            .scope(LocationScope.REGION)
                            .id(region)
                            .description("region")
                            .build());
     
      SecurityGroup origGroup = groupBuilder.build();

      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(1, newPerm.getCidrBlocks().size());
      assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
   }
View Full Code Here

                                                         emptyStringSet(),
                                                         origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(1, newPerm.getCidrBlocks().size());
      assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
   }
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(40);
      builder.tenantIdGroupNamePair("993194456877", "jclouds#some-group");

      IpPermission perm = builder.build();

      SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();

      SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
      groupBuilder.id("jclouds#some-group");
      groupBuilder.providerId("sg-3c6ef654");
      groupBuilder.name("jclouds#some-group");
      groupBuilder.location(new LocationBuilder()
                            .scope(LocationScope.REGION)
                            .id(region)
                            .description("region")
                            .build());
      groupBuilder.ownerId("993194456877");
     
      SecurityGroup origGroup = groupBuilder.build();

      SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);

      assertEquals(1, newGroup.getIpPermissions().size());

      IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());

      assertNotNull(newPerm);
      assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
      assertEquals(22, newPerm.getFromPort());
      assertEquals(40, newPerm.getToPort());
      assertEquals(0, newPerm.getCidrBlocks().size());
      assertEquals(1, newPerm.getTenantIdGroupNamePairs().size());
      assertTrue(newPerm.getTenantIdGroupNamePairs().keySet().contains(origGroup.getOwnerId()));
      assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getName()));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.net.domain.IpPermission

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.