congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SecurityGroupPredicates
Code IndexAdd Tabnine to your IDE (free)

How to use
SecurityGroupPredicates
in
org.jclouds.cloudstack.predicates

Best Java code snippets using org.jclouds.cloudstack.predicates.SecurityGroupPredicates (Showing top 9 results out of 315)

origin: apache/jclouds

@Test
public void testPortInRangeForCidr() {
 assertTrue(portInRangeForCidr(11, "1.1.1.1/24").apply(group()));
 assertTrue(portInRangeForCidr(45, "1.1.1.1/24").apply(group()));
 assertFalse(portInRangeForCidr(45, "2.2.2.2/16").apply(group()));
 assertFalse(portInRangeForCidr(11, "2.2.2.2/16").apply(group()));
 assertFalse(portInRangeForCidr(11, "3.3.3.3/25").apply(group()));
}
origin: apache/jclouds

@Test
public void testHasCidr() {
 assertTrue(hasCidr("1.1.1.1/24").apply(group()));
 assertFalse(hasCidr("3.3.3.3/25").apply(group()));
}
origin: apache/jclouds

@Test
public void testNameEquals() {
 assertTrue(nameEquals("default").apply(group()));
 assertFalse(nameEquals("not-default").apply(group()));
}
origin: apache/jclouds

@Override
public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
 checkNotNull(group, "group");
 checkNotNull(ipPermission, "ipPermission");
 String id = checkNotNull(group.getId(), "group.getId()");
 org.jclouds.cloudstack.domain.SecurityGroup rawGroup = api.getSecurityGroupApi()
     .getSecurityGroup(id);
 if (!ipPermission.getCidrBlocks().isEmpty()) {
   for (IngressRule rule : filter(rawGroup.getIngressRules(),
       ruleCidrMatches(ipPermission.getIpProtocol().toString(),
           ipPermission.getFromPort(),
           ipPermission.getToPort(),
           ipPermission.getCidrBlocks()))) {
     jobComplete.apply(api.getSecurityGroupApi().revokeIngressRule(rule.getId()));
   }
 }
 if (!ipPermission.getTenantIdGroupNamePairs().isEmpty()) {
   for (IngressRule rule : filter(rawGroup.getIngressRules(),
       ruleGroupMatches(ipPermission.getIpProtocol().toString(),
           ipPermission.getFromPort(),
           ipPermission.getToPort(),
           ipPermission.getTenantIdGroupNamePairs()))) {
     jobComplete.apply(api.getSecurityGroupApi().revokeIngressRule(rule.getId()));
   }
 }
 return getSecurityGroupById(id);
}
origin: apache/jclouds

@Test
public void testRuleCidrMatches() {
 assertTrue(Iterables.any(group().getIngressRules(),
     ruleCidrMatches("tcp", 40, 50, ImmutableSet.of("1.1.1.1/24"))));
 assertFalse(Iterables.any(group().getIngressRules(),
     ruleCidrMatches("tcp", 40, 50, ImmutableSet.of("2.2.2.2/24"))));
}
origin: apache/jclouds

  @Test
  public void testRuleGroupMatches() {
   assertTrue(Iterables.any(group().getIngressRules(),
       ruleGroupMatches("tcp", 22, 22,
           ImmutableMultimap.<String, String>builder().put("adrian", "adriancole").build())));
   assertFalse(Iterables.any(group().getIngressRules(),
       ruleGroupMatches("tcp", 22, 22,
           ImmutableMultimap.<String, String>builder().put("adrian", "somegroup").build())));
   assertFalse(Iterables.any(group().getIngressRules(),
       ruleGroupMatches("tcp", 22, 22,
           ImmutableMultimap.<String, String>builder().put("someuser", "adriancole").build())));
  }
}
origin: apache/jclouds

@Test
public void testPortInRange() {
 assertTrue(portInRange(22).apply(group()));
 assertTrue(portInRange(45).apply(group()));
 assertFalse(portInRange(100).apply(group()));
}
origin: apache/jclouds

private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
 Zone zone = zoneIdToZone.get().getUnchecked(zoneId);
 if (supportsSecurityGroups().apply(zone)) {
   for (String group : groups) {
    for (SecurityGroup securityGroup : Iterables.filter(client.getSecurityGroupApi().listSecurityGroups(),
         SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
      logger.debug(">> deleting securityGroup(%s)", zoneAndName);
      client.getSecurityGroupApi().deleteSecurityGroup(securityGroup.getId());
      // TODO: test this clear happens
      securityGroupMap.invalidate(zoneAndName);
      logger.debug("<< deleted securityGroup(%s)", zoneAndName);
    }
   }
 }
}
origin: apache/jclouds

  private void authorizeGroupToItselfAndToTCPPortAndCidr(CloudStackApi client,
                             SecurityGroup securityGroup,
                             int port,
                             Set<String> cidrs) {
   for (String cidr : cidrs) {
     logger.debug(">> authorizing securityGroup(%s) permission to %s on port %d", securityGroup, cidr, port);
     if (!portInRangeForCidr(port, cidr).apply(securityGroup)) {
      jobComplete.apply(client.getSecurityGroupApi().authorizeIngressPortsToCIDRs(securityGroup.getId(),
                                              "TCP",
                                              port,
                                              port,
                                              ImmutableSet.of(cidr)));
      logger.debug("<< authorized securityGroup(%s) permission to %s on port %d", securityGroup, cidr, port);
     }
   }
  }
}
org.jclouds.cloudstack.predicatesSecurityGroupPredicates

Most used methods

  • portInRangeForCidr
  • ruleCidrMatches
    matches IngressRules with the given protocol, start and end port, and any of the given CIDRs.
  • ruleGroupMatches
    matches IngressRules with the given protocol, start and end port, and any of the given account/secur
  • hasCidr
  • nameEquals
    matches name of the given security group
  • nameMatches
    matches name of the given security group
  • portInRange

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now