@Test public void listGroupRules() { securityGroupStartingRules("dc1", groupPermission(8888, "111.0.0.0/8"), groupPermission(7000, "222.0.0.0/8"), groupPermission(7000, "1.1.1.1/32")); replayAll(); assertEquals(Netmask.fromCidr(Arrays.asList("222.0.0.0/8", "1.1.1.1/32")), service().listGroupRules("cassandra_ringName", "dc1", 7000)); }
@VisibleForTesting Set<Netmask> listGroupRules(String securityGroupName, String dataCenter, int port) { ImmutableSet.Builder<Netmask> rules = ImmutableSet.builder(); Set<SecurityGroupPermission> permissions = securityGroupService.getPermissions( securityGroupName, dataCenter); for (SecurityGroupPermission permission : permissions) { if (permission.getPortRange().contains(port)) { rules.addAll(permission.getNetmasks()); } } return rules.build(); }
SecurityGroupUpdaterService extends AbstractScheduledService implements ScheduledServiceMBean { @VisibleForTesting Set<Netmask> listGroupRules(String securityGroupName, String dataCenter, int port) { ImmutableSet.Builder<Netmask> rules = ImmutableSet.builder(); Set<SecurityGroupPermission> permissions = securityGroupService.getPermissions( securityGroupName, dataCenter); for (SecurityGroupPermission permission : permissions) { if (permission.getPortRange().contains(port)) { rules.addAll(permission.getNetmasks()); } } return rules.build(); } }
SecurityGroupUpdaterService extends AbstractScheduledService implements ScheduledServiceMBean { @VisibleForTesting Set<Netmask> listGroupRules(String securityGroupName, String dataCenter, int port) { ImmutableSet.Builder<Netmask> rules = ImmutableSet.builder(); Set<SecurityGroupPermission> permissions = securityGroupService.getPermissions( securityGroupName, dataCenter); for (SecurityGroupPermission permission : permissions) { if (permission.getPortRange().contains(port)) { rules.addAll(permission.getNetmasks()); } } return rules.build(); } @Inject  SecurityGroupUpdaterService(
      CassandraRingService cassandraRingService,
      SecurityGroupService securityGroupService,
      @Named(SecurityGroupModule.SECURITY_GROUP_DATACENTERS_PROPERTY)
          Function<CassandraInstance, String> dataCenterTransformFunction,
      @Named(SecurityGroupModule.CASSANDRA_GOSSIP_PORT_PROPERTY) int listenPort,
      @Named(SecurityGroupModule.CASSANDRA_SSL_GOSSIP_PORT_PROPERTY) int sslListenPort,
      @Named(SecurityGroupModule.CASSANDRA_RING_SSL_ENABLED) Set<String> sslEnabledRings,
      @Named(SecurityGroupModule.SECURITY_GROUP_UPDATE_PERIOD_PROPERTY) Duration updatePeriod,
      @Named(SecurityGroupModule.SECURITY_GROUP_NAME_PREFIX_PROPERTY) String securityGroupNamePrefix); }
SecurityGroupUpdaterService extends AbstractScheduledService implements ScheduledServiceMBean { @VisibleForTesting Set<Netmask> listGroupRules(String securityGroupName, String dataCenter, int port) { ImmutableSet.Builder<Netmask> rules = ImmutableSet.builder(); Set<SecurityGroupPermission> permissions = securityGroupService.getPermissions( securityGroupName, dataCenter); for (SecurityGroupPermission permission : permissions) { if (permission.getPortRange().contains(port)) { rules.addAll(permission.getNetmasks()); } } return rules.build(); } @Inject  SecurityGroupUpdaterService(
      CassandraRingService cassandraRingService,
      SecurityGroupService securityGroupService,
      @Named(SecurityGroupModule.SECURITY_GROUP_DATACENTERS_PROPERTY)
          Function<CassandraInstance, String> dataCenterTransformFunction,
      @Named(SecurityGroupModule.CASSANDRA_GOSSIP_PORT_PROPERTY) int listenPort,
      @Named(SecurityGroupModule.CASSANDRA_SSL_GOSSIP_PORT_PROPERTY) int sslListenPort,
      @Named(SecurityGroupModule.CASSANDRA_RING_SSL_ENABLED) Set<String> sslEnabledRings,
      @Named(SecurityGroupModule.SECURITY_GROUP_UPDATE_PERIOD_PROPERTY) Duration updatePeriod,
      @Named(SecurityGroupModule.SECURITY_GROUP_NAME_PREFIX_PROPERTY) String securityGroupNamePrefix); @Override void runOneIteration(); }
SecurityGroupUpdaterService extends AbstractScheduledService implements ScheduledServiceMBean { @VisibleForTesting Set<Netmask> listGroupRules(String securityGroupName, String dataCenter, int port) { ImmutableSet.Builder<Netmask> rules = ImmutableSet.builder(); Set<SecurityGroupPermission> permissions = securityGroupService.getPermissions( securityGroupName, dataCenter); for (SecurityGroupPermission permission : permissions) { if (permission.getPortRange().contains(port)) { rules.addAll(permission.getNetmasks()); } } return rules.build(); } @Inject  SecurityGroupUpdaterService(
      CassandraRingService cassandraRingService,
      SecurityGroupService securityGroupService,
      @Named(SecurityGroupModule.SECURITY_GROUP_DATACENTERS_PROPERTY)
          Function<CassandraInstance, String> dataCenterTransformFunction,
      @Named(SecurityGroupModule.CASSANDRA_GOSSIP_PORT_PROPERTY) int listenPort,
      @Named(SecurityGroupModule.CASSANDRA_SSL_GOSSIP_PORT_PROPERTY) int sslListenPort,
      @Named(SecurityGroupModule.CASSANDRA_RING_SSL_ENABLED) Set<String> sslEnabledRings,
      @Named(SecurityGroupModule.SECURITY_GROUP_UPDATE_PERIOD_PROPERTY) Duration updatePeriod,
      @Named(SecurityGroupModule.SECURITY_GROUP_NAME_PREFIX_PROPERTY) String securityGroupNamePrefix); @Override void runOneIteration();  }