use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class ResourceStatusLists method aggregate.
public static CloudResourceStatus aggregate(Iterable<CloudResourceStatus> cloudResourceStatuses) {
ResourceStatus status = null;
StringBuilder statusReason = new StringBuilder();
for (CloudResourceStatus crs : cloudResourceStatuses) {
ResourceStatus currentStatus = crs.getStatus();
if (status == null) {
status = currentStatus;
}
switch(currentStatus) {
case FAILED:
status = currentStatus;
statusReason.append(crs.getStatusReason()).append('\n');
break;
default:
if (currentStatus.isTransient()) {
status = currentStatus;
}
}
}
if (status == null) {
status = ResourceStatus.FAILED;
statusReason.append("Resources does not have any state");
}
return new CloudResourceStatus(null, status, statusReason.toString());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class LaunchStackComponentTest method testLaunchStack.
@Test
public void testLaunchStack() {
LaunchStackResult lsr = sendCloudRequest();
List<CloudResourceStatus> r = lsr.getResults();
assertEquals(ResourceStatus.CREATED, r.get(0).getStatus());
assertNull(lsr.getErrorDetails());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class TestApplicationContext method cloudConnectors.
@Bean
public CloudConnector cloudConnectors() throws Exception {
CloudResource resource = new Builder().type(ResourceType.HEAT_STACK).name("ref").build();
when(cloudConnector.authentication()).thenReturn(authenticator);
when(cloudConnector.credentials()).thenReturn(credentialConnector);
when(credentialConnector.create(any(AuthenticatedContext.class))).thenReturn(new CloudCredentialStatus(null, CredentialStatus.CREATED));
when(credentialConnector.delete(any(AuthenticatedContext.class))).thenReturn(new CloudCredentialStatus(null, CredentialStatus.DELETED));
when(authenticator.authenticate(any(), any())).thenReturn(g.createAuthenticatedContext());
when(cloudConnector.platform()).thenReturn(Platform.platform("TESTCONNECTOR"));
when(cloudConnector.variant()).thenReturn(Variant.variant("TESTVARIANT"));
when(cloudConnector.resources()).thenReturn(resourceConnector);
when(cloudConnector.instances()).thenReturn(instanceConnector);
when(cloudConnector.metadata()).thenReturn(collector);
when(resourceConnector.launch(any(), any(), any(), any(), anyLong())).thenReturn(Collections.singletonList(new CloudResourceStatus(resource, ResourceStatus.CREATED)));
when(resourceConnector.terminate(any(), any(), any())).thenReturn(Collections.singletonList(new CloudResourceStatus(resource, ResourceStatus.DELETED)));
when(resourceConnector.update(any(), any(), any())).thenReturn(Collections.singletonList(new CloudResourceStatus(resource, ResourceStatus.UPDATED)));
when(resourceConnector.upscale(any(), any(), any())).thenReturn(Collections.singletonList(new CloudResourceStatus(resource, ResourceStatus.UPDATED)));
when(resourceConnector.downscale(any(), any(), any(), anyList(), anyMap())).thenReturn(Collections.singletonList(new CloudResourceStatus(resource, ResourceStatus.UPDATED)));
when(instanceConnector.check(any(), any())).thenReturn(Collections.singletonList(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.STARTED)));
CloudVmInstanceStatus collectInstanceStatus = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.IN_PROGRESS);
when(collector.collect(any(), any(), any())).thenReturn(Collections.singletonList(new CloudVmMetaDataStatus(collectInstanceStatus, new CloudInstanceMetaData("privateIp", "publicIp", "hypervisor"))));
when(instanceConnector.start(any(), any(), any())).thenReturn(Collections.singletonList(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.STARTED)));
when(instanceConnector.stop(any(), any(), any())).thenReturn(Collections.singletonList(new CloudVmInstanceStatus(cloudInstance, InstanceStatus.STOPPED)));
when(instanceConnector.getConsoleOutput(any(), eq(cloudInstance))).thenReturn(g.getSshFingerprint() + " RSA/n-----END SSH HOST KEY FINGERPRINTS-----");
when(instanceConnector.getConsoleOutput(any(), eq(cloudInstanceBad))).thenReturn("XYZ RSA/n-----END SSH HOST KEY FINGERPRINTS-----");
return cloudConnector;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class AbstractResourceConnector method update.
@Override
public List<CloudResourceStatus> update(AuthenticatedContext auth, CloudStack stack, List<CloudResource> resources) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), resources, true);
// group
List<CloudResource> groupResources = groupResourceService.getGroupResources(platform, resources);
List<CloudResourceStatus> groupStatuses = groupResourceService.update(context, auth, stack.getNetwork(), stack.getCloudSecurity(), groupResources);
// network
List<CloudResource> networkResources = networkResourceService.getNetworkResources(platform, resources);
List<CloudResourceStatus> networkStatuses = networkResourceService.update(context, auth, stack.getNetwork(), stack.getCloudSecurity(), networkResources);
groupStatuses.addAll(networkStatuses);
return groupStatuses;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class AbstractResourceConnector method launch.
@Override
public List<CloudResourceStatus> launch(AuthenticatedContext auth, CloudStack stack, PersistenceNotifier notifier, AdjustmentType adjustmentType, Long threshold) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), null, true);
// network
List<CloudResourceStatus> cloudResourceStatuses = networkResourceService.buildResources(context, auth, stack.getNetwork(), stack.getCloudSecurity());
context.addNetworkResources(getCloudResources(cloudResourceStatuses));
// group
List<CloudResourceStatus> groupStatuses = groupResourceService.buildResources(context, auth, stack.getGroups(), stack.getNetwork(), stack.getCloudSecurity());
cloudResourceStatuses.addAll(groupStatuses);
// compute
List<CloudResourceStatus> computeStatuses = computeResourceService.buildResourcesForLaunch(context, auth, stack.getGroups(), stack.getImage(), stack.getTags(), adjustmentType, threshold);
cloudResourceStatuses.addAll(computeStatuses);
return cloudResourceStatuses;
}
Aggregations