Skip to content

Instantly share code, notes, and snippets.

@yaronp68
Created March 15, 2012 09:10
Show Gist options
  • Save yaronp68/2043105 to your computer and use it in GitHub Desktop.
Save yaronp68/2043105 to your computer and use it in GitHub Desktop.
@Override
public void stopManagementMachines()
throws TimeoutException, CloudProvisioningException {
final String token = createAuthenticationToken();
final long endTime = calcEndTimeInMillis(
DEFAULT_SHUTDOWN_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
List<Node> nodes;
try {
nodes = listServers(token);
} catch (final OpenstackException e) {
throw new CloudProvisioningException(e);
}
final List<String> ids = new LinkedList<String>();
for (final Node node : nodes) {
if (node.getName().startsWith(
this.serverNamePrefix)) {
try {
ids.add(node.getId());
} catch (final Exception e) {
throw new CloudProvisioningException(e);
}
}
}
try {
terminateServers(
ids, token, endTime);
} catch (final TimeoutException e) {
throw e;
} catch (final Exception e) {
throw new CloudProvisioningException("Failed to shut down managememnt machines", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment