Search in sources :

Example 1 with StackResource

use of com.woorea.openstack.heat.StackResource in project AJSC by att.

the class OpenStackStackService method getStacks.

/**
 * Obtains a list (unfiltered) of all stacks that exist on the provider and returns them to the caller.
 *
 * @return A list of all stacks that exist. Note that the list may be empty.
 * @throws ZoneException
 *             - If the context is closed, a login has not occurred, or an error happened trying to contact the
 *             provider.
 * @see com.att.cdp.zones.StackService#getStacks()
 */
@Override
public List<Stack> getStacks() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Orchestration");
    RequestState.put(RequestState.SERVICE_URL, connector.getEndpoint());
    ArrayList<Stack> list = new ArrayList<>();
    Heat heat = connector.getClient();
    StackResource resource = heat.getStacks();
    try {
        /*
             * Get a list of stacks, then call byName api for each one to get the detail for the stack.
             */
        Stacks osStacks = resource.list().execute();
        if (osStacks != null) {
            for (com.woorea.openstack.heat.model.Stack osStack : osStacks) {
                list.add(getStack(osStack.getStackName(), osStack.getId()));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Heat(com.woorea.openstack.heat.Heat) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) Stacks(com.woorea.openstack.heat.model.Stacks) Stack(com.att.cdp.zones.model.Stack) AbstractStack(com.att.cdp.zones.spi.AbstractStack) OpenStackStack(com.att.cdp.openstack.model.OpenStackStack) StackResource(com.woorea.openstack.heat.StackResource)

Example 2 with StackResource

use of com.woorea.openstack.heat.StackResource in project AJSC by att.

the class OpenStackStackService method createNativeStack.

/**
 * This method is used to request a stack construction using whatever the native capabilities of the provider are.
 * The caller of this method must know the inherent capabilities of the underlying provider they are using in order
 * to use this method. Also, using this method partially violates and nullifies the benefits of the abstraction. The
 * return value from this method will still be the <code>Stack</code> object that is represented in the abstraction.
 *
 * @throws ZoneException
 *             If there is a problem making the request
 * @see com.att.cdp.zones.StackService#createNativeStack(java.lang.String, java.lang.String)
 */
@Override
public Stack createNativeStack(String stackName, String content) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Orchestration");
    RequestState.put(RequestState.SERVICE_URL, connector.getEndpoint());
    Heat heat = connector.getClient();
    StackResource resource = heat.getStacks();
    CreateStackParam model = new CreateStackParam();
    model.setTimeoutMinutes(5);
    model.setStackName(stackName);
    model.setTemplate(content);
    OpenStackStack stack = null;
    try {
        com.woorea.openstack.heat.model.Stack osStack = resource.create(model).execute();
        if (osStack != null) {
            stack = (OpenStackStack) getStack(stackName, osStack.getId());
        // stack = new OpenStackStack(context, osStack);
        // stack.setName(stackName);
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return stack;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackStack(com.att.cdp.openstack.model.OpenStackStack) Heat(com.woorea.openstack.heat.Heat) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) CreateStackParam(com.woorea.openstack.heat.model.CreateStackParam) StackResource(com.woorea.openstack.heat.StackResource)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)2 OpenStackStack (com.att.cdp.openstack.model.OpenStackStack)2 Context (com.att.cdp.zones.Context)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)2 Heat (com.woorea.openstack.heat.Heat)2 StackResource (com.woorea.openstack.heat.StackResource)2 Stack (com.att.cdp.zones.model.Stack)1 AbstractStack (com.att.cdp.zones.spi.AbstractStack)1 CreateStackParam (com.woorea.openstack.heat.model.CreateStackParam)1 Stacks (com.woorea.openstack.heat.model.Stacks)1 ArrayList (java.util.ArrayList)1