Bug 512622 - Stack property support in CFT
Summary: Stack property support in CFT
Status: RESOLVED FIXED
Alias: None
Product: CFT
Classification: ECD
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal
Target Milestone: 1.1.0 M7   Edit
Assignee: Elson Yuen CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2017-02-23 05:59 EST by Carlo Alberto Ferraris CLA
Modified: 2017-05-19 14:14 EDT (History)
2 users (show)

See Also:


Attachments
Stack screenshot (128.39 KB, image/png)
2017-05-15 18:18 EDT, Nieraj Singh CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carlo Alberto Ferraris CLA 2017-02-23 05:59:47 EST
Would it be possible to surface in the CFT UI the stack property of an application? Our deployments in Rakuten have multiple stacks and this makes it, unfortunately, impossible to use CFT to drive application deploys. 
Ideally, CFT should pull the list of stacks from the /v2/stacks endpoint, but as a starting point even just allowing users to type the stack name should be enough.
Comment 1 Nieraj Singh CLA 2017-03-30 17:31:24 EDT
We've targeted this for the Oxygen release. 

CFT uses two types of CF Java clients: v1 and v2 versions. The v2 version as used by CFT is maintained here:

https://github.com/eclipse/cft/tree/master/org.eclipse.cft.server.client

Fortunately, it already has Java API to fetch stacks, and it is defined in the v2 CF Java client CloudFoundryOperations:

https://github.com/cloudfoundry/cf-java-client/blob/d0cd4dae1872afdfdb8be92cba9548ee992e4993/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/CloudFoundryOperations.java#L124

However, we haven't integrated this into the CFT framework yet. We will plan to do so for the Oxygen release and expose stacks in the CFT UI.


General steps to adopt stacks would be:

1. Define a v2 client Stack wrapper (e.g. CFStack) so that we don't rely on v2 types in CFT

2. Add a public method to the CloudFoundryServerBehaviour that will return a list of CFStack, much like what we do with other CF entities

3. In the implementation of the method, delegate to the v2 client provider, and fetches stacks using something like this:

operations.stacks().list().map(CFWrapper::wrap).collectList()

where the CFWrapper wraps a v2 Stack into a CFStack

4. We have to then decide how to expose this list of stacks in the CFT UI.

Steps 1-3 are straightforward, but the UI part is something we should discuss. If any one has any ideas, please contribute them here. Thanks
Comment 2 Nieraj Singh CLA 2017-03-30 18:11:03 EDT
We also need to make a change to the condition in which the CFT v2 client provider loads the v2 client:

https://github.com/eclipse/cft/blob/master/org.eclipse.cft.server.client/src/org/eclipse/cft/server/client/v2/internal/V2CFClientProvider.java#L47

Right now it is tied to checking if there is a doppler log streaming URL as well as the CC API version. We need to broaden this so that this client loads for other Cloud targets.

Consequently, I'd say this feature is also tied to how we continue to make changes to the CFT framework to support additional CF clients, which is also another feature for Oxygen:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=514512

I prefer to pursue this option first to obtain stacks from the v2 client, rather than implement a direct request call to the /v2/stacks endpoint in our own v1 snapshot client:

https://github.com/nierajsingh/cf-java-client/tree/cft-1.0.0-java-client-1.1.4-patch

If in the worst case, there are complications to using the v2 client, we can always fall back to the v1 client, and add support to it to fetch the list of stacks directly from the endpoint, as we've done in the past for other CF operations.
Comment 3 Nieraj Singh CLA 2017-05-15 18:18:28 EDT
Created attachment 268352 [details]
Stack screenshot
Comment 4 Nieraj Singh CLA 2017-05-15 18:23:44 EDT
We have added UI support to show available stack values when deploying an application for the first time. 

There is now a stack drop-down UI in the second page of the deployment wizard, which allows users to select a stack.

This new feature is available in the CFT Oxygen nightly build that can be installed from here:

http://download.eclipse.org/cft/oxygen/nightly/

As well as it will be available in the Oxygen M7 milestone.

If this is sufficient for now, we can close this item.

See the attached screenshot.
Comment 5 Elson Yuen CLA 2017-05-19 11:46:38 EDT
Marking this as resolved since this function has been implemented (see comment #3 and #4 for details).