use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method stopIfRunning.
@Override
public boolean stopIfRunning(final String id, final Timeout timeout) throws InterruptedException {
VirtualMachine vm = getById(id);
switch(vm.powerState()) {
case DEALLOCATING:
case STARTING:
case DEALLOCATED:
return false;
case RUNNING:
log.info(vm.resourceGroupName() + " - " + vm.name() + " is running, stopping");
stop(id, timeout);
return true;
default:
throw new IllegalArgumentException("Unknown power state");
}
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method stop.
@Override
public void stop(final String id, final Timeout timeout) throws InterruptedException {
final VirtualMachine vm = getById(id);
stop(vm, timeout);
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method startAsync.
@Override
public Future<Void> startAsync(final String id) {
final VirtualMachine vm = getById(id);
final String threadName = "Azure Async Call" + vm.resourceGroupName() + " - " + vm.name();
ThreadRenameCallableWrap<Void> call = new ThreadRenameCallableWrap<Void>(threadName, new Callable<Void>() {
@Override
public Void call() throws Exception {
start(vm, Timeout.THIRTY_MINUTES);
return null;
}
});
return asynchronous.submit(call);
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method requestStartIfStopped.
@Override
public boolean requestStartIfStopped(final String id) {
VirtualMachine vm = getById(id);
switch(vm.powerState()) {
case RUNNING:
case DEALLOCATING:
case STARTING:
return false;
case DEALLOCATED:
log.info(vm.resourceGroupName() + " - " + vm.name() + " is deallocated, starting");
startAsync(id);
return true;
default:
throw new IllegalArgumentException("Unknown power state");
}
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method requestStopIfRunning.
@Override
public boolean requestStopIfRunning(final String id) {
VirtualMachine vm = getById(id);
switch(vm.powerState()) {
case DEALLOCATING:
case STARTING:
case DEALLOCATED:
return false;
case RUNNING:
log.info(vm.resourceGroupName() + " - " + vm.name() + " is running, stopping");
stopAsync(id);
return true;
default:
throw new IllegalArgumentException("Unknown power state");
}
}
Aggregations