VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Dismiss failed deployment request with vRO

I'm trying to use orchestrator to dismiss failed deployment requests of which we have thousands.  I've tried this few lines of code but it errors out:

var requestService = host.createCatalogClient().getCatalogConsumerRequestService();
var request = requestService.getRequest(requestId);
requestService.deleteRequest(requestId);

It presents me with an error: "Changing Request State from PROVIDER_FAILED to DELETED is not allowed."

So I'm assuming I need to dismiss these instead of delete them.  Since these fail to deploy any resources I don't have a operation I can kick off.  I have two choices to either resubmit or dismiss.  I'm just not sure how to accomplish this via orchestrator.  I've started poking around with the vCACCAFERequestsHelper but not getting too far.  If someone has already put together a workflow for this and would share that would be much appreciated!

0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert
Jump to solution

Not sure about vCACCAFE but with REST API you can dismiss:

POST https://vra.corp.local/catalog-service/api/consumer/requests/$id/dismiss/

restClient = host.createRestClient("com.vmware.csp.core.cafe.catalog.api");

restClient.post("consumer/...

View solution in original post

4 Replies
xian_
Expert
Expert
Jump to solution

Not sure about vCACCAFE but with REST API you can dismiss:

POST https://vra.corp.local/catalog-service/api/consumer/requests/$id/dismiss/

restClient = host.createRestClient("com.vmware.csp.core.cafe.catalog.api");

restClient.post("consumer/...

qc4vmware
Virtuoso
Virtuoso
Jump to solution

I was just logging in here to update what I'd found which does include using the  rest api.  It would be nice if they would do 2 things (and maybe this is available in 8.x already) add the "dismissed" attribute to the vCACCAFE:CatalogItemRequest object and also add the function for dismissing to the same object.  I teamed this up with a postgres query to dump a list of request id's:

SELECT id FROM cat_request WHERE dismissed = false and state = 'PROVIDER_FAILED' and resource_id IS NULL ORDER BY requestnumber;

 

I then loop through the request id's and dismiss them all:

var catEndpoint = "com.vmware.csp.core.cafe.catalog.api";
var restClient = host.createRestClient(catEndpoint);
System.log(restClient.getUrl());

var dismissFile = new MimeAttachment();
dismissFile.content = "";
for each (var reqId in reqIds) {
    var dismissUrl = "consumer/requests/" + reqId + "/dismiss";
    var dismissResponse = restClient.postFile(dismissUrl,dismissFile); 
}

0 Kudos
xian_
Expert
Expert
Jump to solution

You do not have to use the Postgres directly ( + equals to space but easier to encode for me, using curl), this should provide the same result:

/catalog-service/api/consumer/requests?$orderby=requestNumber+desc&$skip=0&$top=1000&$filter=((state+eq+%27PROVIDER_FAILED%27)+and+(dismissed+eq+false))

Could not find resource_id in the API but not sure if required for you...

qc4vmware
Virtuoso
Virtuoso
Jump to solution

For my cleanup I'm not expecting any resources so that is really a sanity check.  I'll probably stick with the direct postgres queries for now.  I'm pretty decent and comfortable in sql world.  Good tip though.  I really need to get better with the odata filters.

0 Kudos