Search in sources :

Example 31 with InstanceTemplate

use of com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate in project cloudbreak by hortonworks.

the class CloudMetaDataStatuses method createCloudVmMetaDataStatuses.

private List<CloudVmMetaDataStatus> createCloudVmMetaDataStatuses(Collection<CloudInstance> cloudInstances) {
    List<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = new ArrayList<>();
    for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
        CloudVmMetaDataStatus oldCloudVmMetaDataStatus = stringCloudVmMetaDataStatusEntry.getValue();
        InstanceTemplate oldTemplate = oldCloudVmMetaDataStatus.getCloudVmInstanceStatus().getCloudInstance().getTemplate();
        Optional<CloudInstance> cloudInstance = cloudInstances.stream().filter(instance -> Objects.equals(instance.getTemplate().getPrivateId(), oldTemplate.getPrivateId())).findFirst();
        if (cloudInstance.isPresent()) {
            CloudInstance newCloudInstance = new CloudInstance(stringCloudVmMetaDataStatusEntry.getKey(), cloudInstance.get().getTemplate(), cloudInstance.get().getAuthentication(), cloudInstance.get().getParameters());
            CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(newCloudInstance, oldCloudVmMetaDataStatus.getCloudVmInstanceStatus().getStatus());
            CloudVmMetaDataStatus newCloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, oldCloudVmMetaDataStatus.getMetaData());
            cloudVmMetaDataStatuses.add(newCloudVmMetaDataStatus);
        }
    }
    return cloudVmMetaDataStatuses;
}
Also used : Collection(java.util.Collection) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) TypeToken(com.google.common.reflect.TypeToken) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) Gson(com.google.gson.Gson) Map(java.util.Map) Entry(java.util.Map.Entry) ITResponse(com.sequenceiq.it.spark.ITResponse) Optional(java.util.Optional) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) ArrayList(java.util.ArrayList) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Aggregations

InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)31 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)25 ArrayList (java.util.ArrayList)17 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)16 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)13 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)11 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)9 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)8 Group (com.sequenceiq.cloudbreak.cloud.model.Group)8 HashMap (java.util.HashMap)7 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)6 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)5 AmazonCloudFormationClient (com.amazonaws.services.cloudformation.AmazonCloudFormationClient)5 CreateTagsRequest (com.amazonaws.services.ec2.model.CreateTagsRequest)5 Instance (com.amazonaws.services.ec2.model.Instance)5 Reservation (com.amazonaws.services.ec2.model.Reservation)5 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)5 CloudInstanceMetaData (com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData)5 Test (org.junit.Test)5 InstanceGroupType (com.sequenceiq.cloudbreak.api.model.InstanceGroupType)4