@Test public void testForkGroup() throws KaramelException{ SecurityGroupRule rule = mock(SecurityGroupRule.class); String uniqueGroup = NovaSetting.NOVA_UNIQUE_GROUP_NAME(clusterName, groupName); String uniqueDescription = NovaSetting.NOVA_UNIQUE_GROUP_DESCRIPTION(clusterName, groupName); Ingress ingress = Ingress.builder() .fromPort(0) .toPort(65535) .ipProtocol(IpProtocol.TCP) .build(); when(novaContext.getSecurityGroupApi()).thenReturn(securityGroupApi); when(securityGroupApi.createWithDescription(uniqueGroup, uniqueDescription)).thenReturn(securityGroupCreated); when(securityGroupCreated.getId()).thenReturn("10"); when(securityGroupApi.createRuleAllowingCidrBlock("10", ingress, "0.0.0.0/0")).thenReturn(rule); NovaLauncher novaLauncher = new NovaLauncher(novaContext, sshKeyPair); JsonCluster cluster = mock(JsonCluster.class); ClusterRuntime clusterRuntime = mock(ClusterRuntime.class); List<JsonGroup> groups = new ArrayList<>(); JsonGroup group = mock(JsonGroup.class); groups.add(group); when(group.getName()).thenReturn(groupName); when(cluster.getGroups()).thenReturn(groups); when(group.getProvider()).thenReturn(nova); when(cluster.getProvider()).thenReturn(nova); when(cluster.getName()).thenReturn(clusterName); String groupId = novaLauncher.forkGroup(cluster,clusterRuntime,groupName); assertEquals("10", groupId); }
@Override public String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name) throws KaramelException { JsonGroup jg = UserClusterDataExtractor.findGroup(definition,name); Provider provider = UserClusterDataExtractor.getGroupProvider(definition,name); Nova nova = (Nova) provider; Set<String> ports = new HashSet<>(); ports.addAll(Settings.AWS_VM_PORTS_DEFAULT); String groupId = createSecurityGroup(definition.getName(), jg.getName(), nova, ports); return groupId; }
NovaLauncher extends Launcher { @Override public String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name) throws KaramelException { JsonGroup jg = UserClusterDataExtractor.findGroup(definition,name); Provider provider = UserClusterDataExtractor.getGroupProvider(definition,name); Nova nova = (Nova) provider; Set<String> ports = new HashSet<>(); ports.addAll(Settings.AWS_VM_PORTS_DEFAULT); String groupId = createSecurityGroup(definition.getName(), jg.getName(), nova, ports); return groupId; } }
NovaLauncher extends Launcher { @Override public String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name) throws KaramelException { JsonGroup jg = UserClusterDataExtractor.findGroup(definition,name); Provider provider = UserClusterDataExtractor.getGroupProvider(definition,name); Nova nova = (Nova) provider; Set<String> ports = new HashSet<>(); ports.addAll(Settings.AWS_VM_PORTS_DEFAULT); String groupId = createSecurityGroup(definition.getName(), jg.getName(), nova, ports); return groupId; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); }
NovaLauncher extends Launcher { @Override public String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name) throws KaramelException { JsonGroup jg = UserClusterDataExtractor.findGroup(definition,name); Provider provider = UserClusterDataExtractor.getGroupProvider(definition,name); Nova nova = (Nova) provider; Set<String> ports = new HashSet<>(); ports.addAll(Settings.AWS_VM_PORTS_DEFAULT); String groupId = createSecurityGroup(definition.getName(), jg.getName(), nova, ports); return groupId; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder); static NovaCredentials readCredentials(Confs confs); String createSecurityGroup(String clusterName, String groupName, Nova nova, Set<String> ports); boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld); boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes); @Override void cleanup(JsonCluster definition, ClusterRuntime runtime); void cleanup(String clusterName, Set<String> vmIds, Set<String> vmNames, Map<String, String> groupRegion); @Override String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name); @Override List<MachineRuntime> forkMachines(JsonCluster definition, ClusterRuntime runtime, String name); static Predicate<NodeMetadata> withPredicate(final Set<String> ids, final Set<String> names,
                                                      final Set<String> groupNames); }
NovaLauncher extends Launcher { @Override public String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name) throws KaramelException { JsonGroup jg = UserClusterDataExtractor.findGroup(definition,name); Provider provider = UserClusterDataExtractor.getGroupProvider(definition,name); Nova nova = (Nova) provider; Set<String> ports = new HashSet<>(); ports.addAll(Settings.AWS_VM_PORTS_DEFAULT); String groupId = createSecurityGroup(definition.getName(), jg.getName(), nova, ports); return groupId; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder); static NovaCredentials readCredentials(Confs confs); String createSecurityGroup(String clusterName, String groupName, Nova nova, Set<String> ports); boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld); boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes); @Override void cleanup(JsonCluster definition, ClusterRuntime runtime); void cleanup(String clusterName, Set<String> vmIds, Set<String> vmNames, Map<String, String> groupRegion); @Override String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name); @Override List<MachineRuntime> forkMachines(JsonCluster definition, ClusterRuntime runtime, String name); static Predicate<NodeMetadata> withPredicate(final Set<String> ids, final Set<String> names,
                                                      final Set<String> groupNames);  }