Package org.jclouds.net.domain

Examples of org.jclouds.net.domain.IpPermission$Builder


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


      SecurityGroup newGroup = extension.addIpPermission(IpProtocol.UDP, 11, 11, emptyMultimap(),
              ImmutableSet.of("1.1.1.1/24"), emptyStringSet(), origGroup);

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

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

      assertNotNull(newPerm);
      assertEquals(newPerm.getIpProtocol(), IpProtocol.UDP);
      assertEquals(newPerm.getFromPort(), 11);
      assertEquals(newPerm.getToPort(), 11);
      assertEquals(newPerm.getCidrBlocks().size(), 1);
      assertTrue(newPerm.getCidrBlocks().contains("1.1.1.1/24"));
   }
View Full Code Here

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(22);
      builder.tenantIdGroupNamePair("adrian", "adriancole");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = new SecurityGroupBuilder().id("13").build();

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

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

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

      assertNotNull(newPerm);
      assertEquals(newPerm.getIpProtocol(), IpProtocol.TCP);
      assertEquals(newPerm.getFromPort(), 22);
      assertEquals(newPerm.getToPort(), 22);
      assertEquals(newPerm.getCidrBlocks().size(), 0);
      assertEquals(newPerm.getTenantIdGroupNamePairs().size(), 1);
      assertTrue(newPerm.getTenantIdGroupNamePairs().containsEntry("adrian", "adriancole"));
   }
View Full Code Here

      SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP, 22, 22,
              permBuilder.build(), emptyStringSet(), emptyStringSet(), origGroup);

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

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

      assertNotNull(newPerm);
      assertEquals(newPerm.getIpProtocol(), IpProtocol.TCP);
      assertEquals(newPerm.getFromPort(), 22);
      assertEquals(newPerm.getToPort(), 22);
      assertEquals(newPerm.getCidrBlocks().size(), 0);
      assertEquals(newPerm.getTenantIdGroupNamePairs().size(), 1);
      assertTrue(newPerm.getTenantIdGroupNamePairs().containsEntry("adrian", "adriancole"));
   }
View Full Code Here

      builder.ipProtocol(IpProtocol.UDP);
      builder.fromPort(11);
      builder.toPort(11);
      builder.cidrBlock("1.1.1.1/24");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = new SecurityGroupBuilder().id("13").build();

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

      builder.ipProtocol(IpProtocol.TCP);
      builder.fromPort(22);
      builder.toPort(22);
      builder.tenantIdGroupNamePair("adrian", "adriancole");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = new SecurityGroupBuilder().id("13").build();

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

         .CIDR("0.0.0.0/0")
         .build();

      IngressRuleToIpPermission converter = new IngressRuleToIpPermission();

      IpPermission convertedPerm = converter.apply(ruleToConvert);

      assertEquals(convertedPerm.getIpProtocol(), IpProtocol.fromValue(ruleToConvert.getProtocol()));
      assertEquals(convertedPerm.getFromPort(), ruleToConvert.getStartPort());
      assertEquals(convertedPerm.getToPort(), ruleToConvert.getEndPort());
      assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
      assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 1);
      assertTrue(convertedPerm.getGroupIds().size() == 0);
   }
View Full Code Here

      builder.ipProtocol(IpProtocol.UDP);
      builder.fromPort(11);
      builder.toPort(11);
      builder.cidrBlock("1.1.1.1/24");

      IpPermission perm = builder.build();

      SecurityGroup origGroup = new SecurityGroupBuilder().id("13").build();

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

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

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

      assertNotNull(newPerm);
      assertEquals(newPerm.getIpProtocol(), IpProtocol.UDP);
      assertEquals(newPerm.getFromPort(), 11);
      assertEquals(newPerm.getToPort(), 11);
      assertEquals(newPerm.getCidrBlocks().size(), 1);
      assertTrue(newPerm.getCidrBlocks().contains("1.1.1.1/24"));
   }
View Full Code Here

    /**
     * @return Extra IP permissions to be configured on this entity's location.
     */
    protected Collection<IpPermission> getIpPermissions(JcloudsLocationSecurityGroupCustomizer customizer) {
        IpPermission dockerPort = IpPermission.builder()
                .ipProtocol(IpProtocol.TCP)
                .fromPort(getEntity().getAttribute(DockerHost.DOCKER_PORT))
                .toPort(getEntity().getAttribute(DockerHost.DOCKER_PORT))
                .cidrBlock(customizer.getBrooklynCidrBlock())
                .build();
        IpPermission dockerSslPort = IpPermission.builder()
                .ipProtocol(IpProtocol.TCP)
                .fromPort(getEntity().getAttribute(DockerHost.DOCKER_SSL_PORT))
                .toPort(getEntity().getAttribute(DockerHost.DOCKER_SSL_PORT))
                .cidrBlock(customizer.getBrooklynCidrBlock())
                .build();
        IpPermission dockerPortForwarding = IpPermission.builder()
                .ipProtocol(IpProtocol.TCP)
                .fromPort(49000)
                .toPort(49900)
                .cidrBlock(Cidr.UNIVERSAL.toString())
                .build();
        List<IpPermission> permissions = MutableList.of(dockerPort, dockerSslPort, dockerPortForwarding);

        if (getEntity().getConfig(DockerInfrastructure.WEAVE_ENABLED)) {
            Integer weavePort = ((DockerHost) getEntity()).getInfrastructure()
                    .getAttribute(DockerInfrastructure.WEAVE_INFRASTRUCTURE)
                    .getConfig(WeaveContainer.WEAVE_PORT);
            IpPermission weaveTcpPort = IpPermission.builder()
                    .ipProtocol(IpProtocol.TCP)
                    .fromPort(weavePort)
                    .toPort(weavePort)
                    .cidrBlock(Cidr.UNIVERSAL.toString()) // TODO could be tighter restricted?
                    .build();
            permissions.add(weaveTcpPort);
            IpPermission weaveUdpPort = IpPermission.builder()
                    .ipProtocol(IpProtocol.UDP)
                    .fromPort(weavePort)
                    .toPort(weavePort)
                    .cidrBlock(Cidr.UNIVERSAL.toString()) // TODO could be tighter restricted?
                    .build();
View Full Code Here

      }
      if (Iterables.size(groupIds) > 0) {
         ipBuilder.groupIds(groupIds);
      }

      IpPermission perm = ipBuilder.build();

      SecurityGroupBuilder builder = SecurityGroupBuilder.fromSecurityGroup(checkNotNull(group, "group"));

      builder.ipPermission(perm);
View Full Code Here

TOP

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

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.