@Test public void readNovaCredentialsTest() { Confs confs = mock(Confs.class); when(confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter())).thenReturn(novaCredentials.getAccountName()); when(confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter())).thenReturn(novaCredentials.getAccountPass()); when(confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter())).thenReturn(novaCredentials.getEndpoint()); when(confs.getProperty(NovaSetting.NOVA_VERSION.getParameter())).thenReturn(novaCredentials.getEndpoint()); when(confs.getProperty(NovaSetting.NOVA_REGION.getParameter())).thenReturn(novaCredentials.getRegion()); NovaCredentials credentials = NovaLauncher.readCredentials(confs); assertNotNull(credentials); }
public static NovaCredentials readCredentials(Confs confs) { String accountId = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter()); String accessKey = confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter()); String endpoint = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter()); String version = confs.getProperty(NovaSetting.NOVA_VERSION.getParameter()); String novaRegion = confs.getProperty(NovaSetting.NOVA_REGION.getParameter()); String novaNetworkId = confs.getProperty(NovaSetting.NOVA_NETWORKID.getParameter()); NovaCredentials novaCredentials = null; if (accountId != null && !accountId.isEmpty() && accessKey != null && !accessKey.isEmpty() && endpoint != null && !endpoint.isEmpty() && novaRegion != null && !novaRegion.isEmpty() && version != null && !version.isEmpty()) { novaCredentials = new NovaCredentials(); novaCredentials.setAccountName(accountId); novaCredentials.setAccountPass(accessKey); novaCredentials.setEndpoint(endpoint); novaCredentials.setRegion(novaRegion); novaCredentials.setVersion(version); novaCredentials.setNetworkId(novaNetworkId); } return novaCredentials; }
NovaLauncher extends Launcher { public static NovaCredentials readCredentials(Confs confs) { String accountId = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter()); String accessKey = confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter()); String endpoint = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter()); String version = confs.getProperty(NovaSetting.NOVA_VERSION.getParameter()); String novaRegion = confs.getProperty(NovaSetting.NOVA_REGION.getParameter()); String novaNetworkId = confs.getProperty(NovaSetting.NOVA_NETWORKID.getParameter()); NovaCredentials novaCredentials = null; if (accountId != null && !accountId.isEmpty() && accessKey != null && !accessKey.isEmpty() && endpoint != null && !endpoint.isEmpty() && novaRegion != null && !novaRegion.isEmpty() && version != null && !version.isEmpty()) { novaCredentials = new NovaCredentials(); novaCredentials.setAccountName(accountId); novaCredentials.setAccountPass(accessKey); novaCredentials.setEndpoint(endpoint); novaCredentials.setRegion(novaRegion); novaCredentials.setVersion(version); novaCredentials.setNetworkId(novaNetworkId); } return novaCredentials; } }
NovaLauncher extends Launcher { public static NovaCredentials readCredentials(Confs confs) { String accountId = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter()); String accessKey = confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter()); String endpoint = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter()); String version = confs.getProperty(NovaSetting.NOVA_VERSION.getParameter()); String novaRegion = confs.getProperty(NovaSetting.NOVA_REGION.getParameter()); String novaNetworkId = confs.getProperty(NovaSetting.NOVA_NETWORKID.getParameter()); NovaCredentials novaCredentials = null; if (accountId != null && !accountId.isEmpty() && accessKey != null && !accessKey.isEmpty() && endpoint != null && !endpoint.isEmpty() && novaRegion != null && !novaRegion.isEmpty() && version != null && !version.isEmpty()) { novaCredentials = new NovaCredentials(); novaCredentials.setAccountName(accountId); novaCredentials.setAccountPass(accessKey); novaCredentials.setEndpoint(endpoint); novaCredentials.setRegion(novaRegion); novaCredentials.setVersion(version); novaCredentials.setNetworkId(novaNetworkId); } return novaCredentials; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); }
NovaLauncher extends Launcher { public static NovaCredentials readCredentials(Confs confs) { String accountId = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter()); String accessKey = confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter()); String endpoint = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter()); String version = confs.getProperty(NovaSetting.NOVA_VERSION.getParameter()); String novaRegion = confs.getProperty(NovaSetting.NOVA_REGION.getParameter()); String novaNetworkId = confs.getProperty(NovaSetting.NOVA_NETWORKID.getParameter()); NovaCredentials novaCredentials = null; if (accountId != null && !accountId.isEmpty() && accessKey != null && !accessKey.isEmpty() && endpoint != null && !endpoint.isEmpty() && novaRegion != null && !novaRegion.isEmpty() && version != null && !version.isEmpty()) { novaCredentials = new NovaCredentials(); novaCredentials.setAccountName(accountId); novaCredentials.setAccountPass(accessKey); novaCredentials.setEndpoint(endpoint); novaCredentials.setRegion(novaRegion); novaCredentials.setVersion(version); novaCredentials.setNetworkId(novaNetworkId); } return novaCredentials; } 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 { public static NovaCredentials readCredentials(Confs confs) { String accountId = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ID_KEY.getParameter()); String accessKey = confs.getProperty(NovaSetting.NOVA_ACCESSKEY_KEY.getParameter()); String endpoint = confs.getProperty(NovaSetting.NOVA_ACCOUNT_ENDPOINT.getParameter()); String version = confs.getProperty(NovaSetting.NOVA_VERSION.getParameter()); String novaRegion = confs.getProperty(NovaSetting.NOVA_REGION.getParameter()); String novaNetworkId = confs.getProperty(NovaSetting.NOVA_NETWORKID.getParameter()); NovaCredentials novaCredentials = null; if (accountId != null && !accountId.isEmpty() && accessKey != null && !accessKey.isEmpty() && endpoint != null && !endpoint.isEmpty() && novaRegion != null && !novaRegion.isEmpty() && version != null && !version.isEmpty()) { novaCredentials = new NovaCredentials(); novaCredentials.setAccountName(accountId); novaCredentials.setAccountPass(accessKey); novaCredentials.setEndpoint(endpoint); novaCredentials.setRegion(novaRegion); novaCredentials.setVersion(version); novaCredentials.setNetworkId(novaNetworkId); } return novaCredentials; } 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);  }