use of com.sequenceiq.cloudbreak.cloud.model.CloudInstance.INSTANCE_NAME in project cloudbreak by hortonworks.
the class AzureVirtualMachineService method fillVmStatuses.
private void fillVmStatuses(List<CloudInstance> cloudInstances, AzureVirtualMachinesWithStatuses virtualMachineListResult) {
Map<String, VirtualMachine> virtualMachines = virtualMachineListResult.getVirtualMachines();
List<CloudVmInstanceStatus> statuses = virtualMachineListResult.getStatuses();
LOGGER.info("Fill vm statuses from returned virtualmachines from azure: {}", virtualMachines.keySet());
for (CloudInstance cloudInstance : cloudInstances) {
virtualMachines.values().stream().filter(virtualMachine -> virtualMachine.name().equals(cloudInstance.getInstanceId())).findFirst().ifPresentOrElse(virtualMachine -> {
PowerState virtualMachinePowerState = virtualMachine.powerState();
String computerName = virtualMachine.computerName();
cloudInstance.putParameter(INSTANCE_NAME, computerName);
statuses.add(new CloudVmInstanceStatus(cloudInstance, AzureInstanceStatus.get(virtualMachinePowerState)));
}, () -> statuses.stream().filter(cvis -> cvis.getCloudInstance().getInstanceId() != null && cvis.getCloudInstance().getInstanceId().equals(cloudInstance.getInstanceId())).findAny().ifPresentOrElse(cloudInstanceWithStatus -> logTheStatusOfTheCloudInstance(cloudInstanceWithStatus), () -> statuses.add(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.TERMINATED))));
}
}
Aggregations