use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class GroupResourceService method deleteResources.
public List<CloudResourceStatus> deleteResources(ResourceBuilderContext context, AuthenticatedContext auth, Collection<CloudResource> resources, Network network, boolean cancellable) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
List<CloudResourceStatus> results = new ArrayList<>();
List<GroupResourceBuilder> builderChain = resourceBuilders.group(cloudContext.getPlatform());
for (int i = builderChain.size() - 1; i >= 0; i--) {
GroupResourceBuilder builder = builderChain.get(i);
List<CloudResource> specificResources = getResources(resources, builder.resourceType());
for (CloudResource resource : specificResources) {
if (resource.getStatus() == CommonStatus.CREATED) {
CloudResource deletedResource = builder.delete(context, auth, resource, network);
if (deletedResource != null) {
PollTask<List<CloudResourceStatus>> task = statusCheckFactory.newPollResourceTask(builder, auth, Collections.singletonList(deletedResource), context, cancellable);
List<CloudResourceStatus> pollerResult = syncPollingScheduler.schedule(task);
results.addAll(pollerResult);
}
}
resourceNotifier.notifyDeletion(resource, cloudContext);
}
}
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class NetworkResourceService method buildResources.
public List<CloudResourceStatus> buildResources(ResourceBuilderContext context, AuthenticatedContext auth, Network network, Security security) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
List<CloudResourceStatus> results = new ArrayList<>();
for (NetworkResourceBuilder builder : resourceBuilders.network(cloudContext.getPlatform())) {
PollGroup pollGroup = InMemoryStateStore.getStack(auth.getCloudContext().getId());
if (pollGroup != null && CANCELLED.equals(pollGroup)) {
break;
}
try {
CloudResource buildableResource = builder.create(context, auth, network);
createResource(auth, buildableResource);
CloudResource resource = builder.build(context, auth, network, security, buildableResource);
updateResource(auth, resource);
PollTask<List<CloudResourceStatus>> task = statusCheckFactory.newPollResourceTask(builder, auth, Collections.singletonList(resource), context, true);
List<CloudResourceStatus> pollerResult = syncPollingScheduler.schedule(task);
results.addAll(pollerResult);
} catch (ResourceNotNeededException e) {
LOGGER.warn("Skipping resource creation: {}", e.getMessage());
}
}
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class OpenStackUtils method heatStatus.
public CloudResourceStatus heatStatus(CloudResource resource, Stack heatStack) {
String status = heatStack.getStatus();
LOGGER.info("Heat stack status of: {} is: {}", heatStack, status);
CloudResourceStatus heatResourceStatus = new CloudResourceStatus(resource, HeatStackStatus.mapResourceStatus(status), heatStack.getStackStatusReason());
LOGGER.debug("Cloud resource status: {}", heatResourceStatus);
return heatResourceStatus;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class OpenStackResourceConnector method check.
@Override
public List<CloudResourceStatus> check(AuthenticatedContext authenticatedContext, List<CloudResource> resources) {
List<CloudResourceStatus> results = newArrayList();
OSClient<?> client = openStackClient.createOSClient(authenticatedContext);
String stackName = utils.getStackName(authenticatedContext);
List<CloudResource> osResourceList = openStackClient.getResources(stackName, authenticatedContext.getCloudCredential());
List<CloudResource> otherResources = newArrayList();
CloudResourceStatus heatStatus = null;
for (CloudResource resource : resources) {
if (resource.getType() == ResourceType.HEAT_STACK) {
heatStatus = checkByResourceType(authenticatedContext, client, stackName, osResourceList, resource);
results.add(heatStatus);
} else {
otherResources.add(resource);
}
}
if (heatStatus != null) {
for (CloudResource resource : otherResources) {
if (heatStatus.getStatus() == ResourceStatus.CREATED) {
results.add(checkByResourceType(authenticatedContext, client, stackName, osResourceList, resource));
} else {
results.add(new CloudResourceStatus(resource, ResourceStatus.CREATED));
}
}
}
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class MockResourceConnector method upscale.
@Override
public List<CloudResourceStatus> upscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources) {
List<CloudResourceStatus> cloudResourceStatuses = new ArrayList<>();
for (CloudResource cloudResource : resources) {
CloudResourceStatus cloudResourceStatus = new CloudResourceStatus(cloudResource, CREATED);
cloudResourceStatuses.add(cloudResourceStatus);
}
int createResourceCount = 0;
for (int i = 0; i < stack.getGroups().size(); i++) {
createResourceCount += stack.getGroups().get(i).getInstancesSize();
}
createResourceCount -= resources.size();
if (createResourceCount > 0) {
for (int i = 0; i < createResourceCount; i++) {
CloudResource cloudResource = new Builder().type(ResourceType.MOCK_INSTANCE).status(CommonStatus.CREATED).name("cloudinstance" + cloudResourceStatuses.size()).reference("").persistent(true).build();
cloudResourceStatuses.add(new CloudResourceStatus(cloudResource, CREATED));
}
}
return cloudResourceStatuses;
}
Aggregations