use of com.microsoft.azure.management.compute.VirtualMachine in project cloudbreak by hortonworks.
the class AzureResourceConnector method collectInstanceResourcesToRemove.
private Map<String, Object> collectInstanceResourcesToRemove(AuthenticatedContext ac, CloudStack stack, AzureClient client, AzureCredentialView azureCredentialView, String stackName, CloudInstance instance) {
String instanceId = instance.getInstanceId();
Long privateId = instance.getTemplate().getPrivateId();
AzureDiskType azureDiskType = AzureDiskType.getByValue(instance.getTemplate().getVolumeType());
String attachedDiskStorageName = azureStorage.getAttachedDiskStorageName(azureStorage.getArmAttachedStorageOption(stack.getParameters()), azureCredentialView, privateId, ac.getCloudContext(), azureDiskType);
Map<String, Object> resourcesToRemove = new HashMap<>();
resourcesToRemove.put(ATTACHED_DISK_STORAGE_NAME, attachedDiskStorageName);
try {
VirtualMachine virtualMachine = client.getVirtualMachine(stackName, instanceId);
List<String> networkInterfaceIds = virtualMachine.networkInterfaceIds();
Collection<String> networkInterfacesNames = new ArrayList<>();
Collection<String> publicIpAddressNames = new ArrayList<>();
for (String interfaceId : networkInterfaceIds) {
NetworkInterface networkInterface = client.getNetworkInterfaceById(interfaceId);
String interfaceName = networkInterface.name();
networkInterfacesNames.add(interfaceName);
Collection<String> ipNames = new HashSet<>();
for (NicIPConfiguration ipConfiguration : networkInterface.ipConfigurations().values()) {
if (ipConfiguration.publicIPAddressId() != null && ipConfiguration.getPublicIPAddress().name() != null) {
ipNames.add(ipConfiguration.getPublicIPAddress().name());
}
}
publicIpAddressNames.addAll(ipNames);
}
resourcesToRemove.put(NETWORK_INTERFACES_NAMES, networkInterfacesNames);
resourcesToRemove.put(PUBLIC_ADDRESS_NAME, publicIpAddressNames);
collectRemovableDisks(resourcesToRemove, virtualMachine);
} catch (CloudException e) {
if (e.response().code() != AzureConstants.NOT_FOUND) {
throw new CloudConnectorException(e.body().message(), e);
}
} catch (RuntimeException e) {
throw new CloudConnectorException("can't collect instance resources", e);
}
return resourcesToRemove;
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method start.
@Override
public void start(final String id, final Timeout timeout) throws InterruptedException {
final VirtualMachine vm = getById(id);
start(vm, timeout);
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method restart.
@Override
public void restart(final String id, final Timeout timeout) throws InterruptedException {
final VirtualMachine vm = getById(id);
restart(vm, timeout);
}
use of com.microsoft.azure.management.compute.VirtualMachine in project stdlib by petergeneric.
the class AzureVMControlImpl method stopAsync.
@Override
public Future<Void> stopAsync(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 {
stop(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 restartAsync.
@Override
public Future<Void> restartAsync(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 {
restart(vm, Timeout.THIRTY_MINUTES);
return null;
}
});
return asynchronous.submit(call);
}
Aggregations