Search in sources :

Example 6 with StackInfoMapper

use of org.onap.so.openstack.mappers.StackInfoMapper in project so by onap.

the class MsoHeatUtils method deleteStack.

/**
 * Delete a stack (by Name/ID) in a tenant. If the stack is not found, it will be considered a successful deletion.
 * The return value is a StackInfo object which contains the current stack status.
 *
 * The client may choose to let the adapter poll Openstack for completion of the stack deletion, or may handle
 * polling itself via separate query calls. In either case, a StackInfo object will be returned. When polling is
 * enabled, a final status of NOTFOUND is expected. When not polling, a status of DELETING is expected.
 *
 * There is no rollback from a successful stack deletion. A deletion failure will also result in an undefined stack
 * state - the components may or may not have been all or partially deleted, so the resulting stack must be
 * considered invalid.
 *
 * @param tenantId The Openstack ID of the tenant in which to perform the delete
 * @param cloudOwner the cloud owner of the cloud site in which to delete the stack
 * @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack.
 * @param stackName The name/id of the stack to delete. May be simple or canonical
 * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
 * @return A StackInfo object
 * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
 * @throws MsoCloudSiteNotFound
 */
public StackInfo deleteStack(String tenantId, String cloudOwner, String cloudSiteId, String stackName, boolean pollForCompletion, int timeoutMinutes) throws MsoException {
    Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId);
    StackInfo stackInfo = null;
    if (currentStack == null || DELETE_COMPLETE.equals(currentStack.getStackStatus())) {
        stackInfo = new StackInfo(stackName, HeatStatus.NOTFOUND);
        stackInfo.setOperationPerformed(false);
    } else {
        currentStack = deleteStack(currentStack, timeoutMinutes, cloudSiteId, tenantId, pollForCompletion);
        stackInfo = new StackInfoMapper(currentStack).map();
        stackInfo.setName(stackName);
        stackInfo.setOperationPerformed(true);
        if (currentStack != null) {
            stackInfo.setCanonicalName(currentStack.getStackName() + "/" + currentStack.getId());
        }
    }
    return stackInfo;
}
Also used : StackInfoMapper(org.onap.so.openstack.mappers.StackInfoMapper) StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack)

Example 7 with StackInfoMapper

use of org.onap.so.openstack.mappers.StackInfoMapper in project so by onap.

the class PollService method pollCreateResource.

private StackInfo pollCreateResource(int pollingTimeout, String cloudSiteId, String tenantId, String stackId, MutableBoolean success) throws MsoException {
    Stack currentStack = createCurrentStack(stackId);
    Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
    msoHeatUtils.postProcessStackCreate(stack, false, 0, false, cloudSiteId, tenantId, null);
    success.setTrue();
    return new StackInfoMapper(stack).map();
}
Also used : StackInfoMapper(org.onap.so.openstack.mappers.StackInfoMapper) Stack(com.woorea.openstack.heat.model.Stack)

Aggregations

Stack (com.woorea.openstack.heat.model.Stack)7 StackInfoMapper (org.onap.so.openstack.mappers.StackInfoMapper)7 StackInfo (org.onap.so.openstack.beans.StackInfo)4 MsoException (org.onap.so.openstack.exceptions.MsoException)3 Heat (com.woorea.openstack.heat.Heat)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 CreateStackParam (com.woorea.openstack.heat.model.CreateStackParam)1 UpdateStackParam (com.woorea.openstack.heat.model.UpdateStackParam)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 RestClient (org.onap.so.client.RestClient)1 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)1 MsoStackNotFound (org.onap.so.openstack.exceptions.MsoStackNotFound)1 MsoTenantNotFound (org.onap.so.openstack.exceptions.MsoTenantNotFound)1