@Test public void isAddressRoutable () { final SubnetUtils.SubnetInfo privateBlock1 = new SubnetUtils("10.0.0.0/8").getInfo(); final SubnetUtils.SubnetInfo privateBlock2 = new SubnetUtils("172.16.0.0/16").getInfo(); final SubnetUtils.SubnetInfo privateBlock3 = new SubnetUtils("192.168.1.0/24").getInfo(); doReturn(Set.of(privateBlock1, privateBlock2), Set.of(privateBlock2, privateBlock3), Set.of(privateBlock3, privateBlock1)) .when(awsEC2Platform) .getRoutableCidrBlocks(); assertTrue(awsEC2Platform.isAddressRoutable("172.16.1.192")); assertFalse(awsEC2Platform.isAddressRoutable("10.1.2.3")); assertTrue(awsEC2Platform.isAddressRoutable("10.1.2.3")); assertFalse(awsEC2Platform.isAddressRoutable("fake")); }
public boolean isAddressRoutable (String privateIPAddress) { return getRoutableCidrBlocks().stream().anyMatch(subnetInfo -> { try { return subnetInfo.isInRange(privateIPAddress); } catch (RuntimeException e) { return false; } }); }
AwsEC2Platform extends Platform implements SshBasedExperiment<AwsEC2Container> { public boolean isAddressRoutable (String privateIPAddress) { return getRoutableCidrBlocks().stream().anyMatch(subnetInfo -> { try { return subnetInfo.isInRange(privateIPAddress); } catch (RuntimeException e) { return false; } }); } }
AwsEC2Platform extends Platform implements SshBasedExperiment<AwsEC2Container> { public boolean isAddressRoutable (String privateIPAddress) { return getRoutableCidrBlocks().stream().anyMatch(subnetInfo -> { try { return subnetInfo.isInRange(privateIPAddress); } catch (RuntimeException e) { return false; } }); } @Autowired  AwsEC2Platform(AmazonEC2 amazonEC2, ContainerManager containerManager, AwsEC2SelfAwareness awsEC2SelfAwareness); private  AwsEC2Platform(); }
AwsEC2Platform extends Platform implements SshBasedExperiment<AwsEC2Container> { public boolean isAddressRoutable (String privateIPAddress) { return getRoutableCidrBlocks().stream().anyMatch(subnetInfo -> { try { return subnetInfo.isInRange(privateIPAddress); } catch (RuntimeException e) { return false; } }); } @Autowired  AwsEC2Platform(AmazonEC2 amazonEC2, ContainerManager containerManager, AwsEC2SelfAwareness awsEC2SelfAwareness); private  AwsEC2Platform(); void setFilter(@NotNull Map<String, List<String>> filter); void setGroupingTags(List<String> groupingTags); void setSSHPrivateKeys(@NotNull Map<String, String> sshPrivateKeys); Map<String, String> getImageIdToUsernameMap(); void setImageIdToUsernameMap(Map<String, String> imageIdToUsernameMap); @Override ApiStatus getApiStatus(); @JsonIgnore Collection<SubnetUtils.SubnetInfo> getRoutableCidrBlocks(); void setRoutableCidrBlocks(Collection<String> routableCidrBlocks); boolean isAddressRoutable(String privateIPAddress); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateRoster(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String instanceId); void stopInstance(String... instanceIds); void terminateInstance(String... instanceIds); void startInstance(String... instanceIds); void restartInstance(String... instanceIds); void setSecurityGroupIds(String networkInterfaceId, Collection<String> securityGroupIds); String getChaosSecurityGroupForInstance(String instanceId); boolean isContainerTerminated(String instanceId); boolean isAutoscalingGroupAtDesiredInstances(String autoScalingGroupName); boolean hasKey(String keyName); @Override void recycleContainer(AwsEC2Container container); void triggerAutoscalingUnhealthy(String instanceId); @Override String getEndpoint(AwsEC2Container container); @Override SSHCredentials getSshCredentials(AwsEC2Container container); boolean isStarted(AwsEC2Container awsEC2Container); Map<String, Set<String>> getNetworkInterfaceToSecurityGroupsMap(String instanceId); boolean verifySecurityGroupIdsOfNetworkInterfaceMap(String instanceId, Map<String, Set<String>> originalSecurityGroups); }
AwsEC2Platform extends Platform implements SshBasedExperiment<AwsEC2Container> { public boolean isAddressRoutable (String privateIPAddress) { return getRoutableCidrBlocks().stream().anyMatch(subnetInfo -> { try { return subnetInfo.isInRange(privateIPAddress); } catch (RuntimeException e) { return false; } }); } @Autowired  AwsEC2Platform(AmazonEC2 amazonEC2, ContainerManager containerManager, AwsEC2SelfAwareness awsEC2SelfAwareness); private  AwsEC2Platform(); void setFilter(@NotNull Map<String, List<String>> filter); void setGroupingTags(List<String> groupingTags); void setSSHPrivateKeys(@NotNull Map<String, String> sshPrivateKeys); Map<String, String> getImageIdToUsernameMap(); void setImageIdToUsernameMap(Map<String, String> imageIdToUsernameMap); @Override ApiStatus getApiStatus(); @JsonIgnore Collection<SubnetUtils.SubnetInfo> getRoutableCidrBlocks(); void setRoutableCidrBlocks(Collection<String> routableCidrBlocks); boolean isAddressRoutable(String privateIPAddress); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateRoster(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String instanceId); void stopInstance(String... instanceIds); void terminateInstance(String... instanceIds); void startInstance(String... instanceIds); void restartInstance(String... instanceIds); void setSecurityGroupIds(String networkInterfaceId, Collection<String> securityGroupIds); String getChaosSecurityGroupForInstance(String instanceId); boolean isContainerTerminated(String instanceId); boolean isAutoscalingGroupAtDesiredInstances(String autoScalingGroupName); boolean hasKey(String keyName); @Override void recycleContainer(AwsEC2Container container); void triggerAutoscalingUnhealthy(String instanceId); @Override String getEndpoint(AwsEC2Container container); @Override SSHCredentials getSshCredentials(AwsEC2Container container); boolean isStarted(AwsEC2Container awsEC2Container); Map<String, Set<String>> getNetworkInterfaceToSecurityGroupsMap(String instanceId); boolean verifySecurityGroupIdsOfNetworkInterfaceMap(String instanceId, Map<String, Set<String>> originalSecurityGroups);  }