keystone.token(access.getToken().getId());
Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
novaClient.token(access.getToken().getId());
Servers servers = novaClient.servers().list(true).execute();
if(servers.getList().size() > 0) {
// Server has to be in activated state.
ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId());
stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
stopServer.execute();
// Wait until server shutdown. Or 400 error occurs.
Thread.sleep(5000);
ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId());
startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
startServer.execute();
}
}