Codota Logo
SecurityGroupPredicates
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
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)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • Collectors (java.util.stream)
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
  • JTable (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now