VMware Cloud Community
brietmax
Contributor
Contributor

email notification after vra deployment

hello,

I try to create a notification email with an ABX action for deployment completed and sen some information like IP adresss User name to login server name ..... to the requester.

Do you have any idea to do that

Labels (1)
Reply
0 Kudos
3 Replies
emacintosh
Hot Shot
Hot Shot

Not sure if this built-in yet, but we do that with vRO workflow....which i'm sure could also be done with an abx action.

 

We have a subscription that fires during the compute provisioning post event and is set to non-blocking (so it runs after all of the blocking stuff finishes).  In the workflow itslef, we pull out the stuff we want to email from the inputProperties variable, build a simple html email message and then push that off to a workflow that will actually send the email.

 

And that's it at a high-level.  On a side note, if the deployment fails, we do something similar but based on the deployment event instead of the provisioning event.

 

Reply
0 Kudos
brietmax
Contributor
Contributor

Thanks for the Reply

IS it possible to have the workflow

Regards

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot

I'm not sure I'd be allowed to export the workflow, but this is the meat of it. The workflow runs this scripted task then calls workflow to send the email if the proceed variable equals true.  The email workflow is custom, but wraps around the built-in send mail workflow - but i think the message is probably what is most interesting to you here?

 

This same workflow is called both during compute provision post (successes) and deployment request post (failures).  So some of the variables will only contain values in one scenario vs another, e.g. the failedMessage variable.  And some are "hardcoded" attribues of the workflow, like vraLink which is the base url of our vRA deployment.

 

Obviously, you can add/modify whichever properties of the compute or deployment that make sense for your environment.  I hope this helps a bit more.

 

var user = System.getContext().getParameter("__metadata_userName");
var event = System.getContext().getParameter("__metadata_eventTopicId");
var deploymentId = inputProperties.deploymentId;
var failedMessage = inputProperties.failureMessage;
var customProperties = inputProperties.customProperties;
var status = inputProperties.status;
var requestInputs = inputProperties.requestInputs;
var depLink = vraLink + "/catalog/#/deployment/" + deploymentId;

proceed = false;
address = user + "@company.com";

// Called from deployment
// Only email from this event if it's a failure
if(event.toLowerCase() == "deployment.request.post") {
    if(status.toLowerCase() == "failed") {
        proceed = true;

        subject = "Deployment Failed";
        body =  "The requested server build has failed.<br><br>";
        body += "<table><tr>";
        body += "<td><b>Error Message</b>:</td><td>" + failedMessage + "</td>";
        body += "</tr><tr>";
        body += "<td><b>Deployment ID:</b></td><td>" + deploymentId + "</td>";
        body += "</tr><tr>";
        body += "<td><b>Link:</b></td><td>" + depLink + "</td>";
        body += "</tr></table>";
    }
}

// Called from provisioning
// email successes from here so we can share the server name
if(event.toLowerCase() == "compute.provision.post"){
    proceed = true;

    subject = "Deployment Finished";
    body =  "The requested server build has completed.<br><br>";
    body += "<table><tr>";
    body += "<td><b>Server Name</b>:</td><td>" + inputProperties.resourceNames[0]; + "</td>";
    body += "</tr><tr>";
    body += "<td><b>Deployment ID:</b></td><td>" + deploymentId + "</td>";
    body += "</tr><tr>";
    body += "<td><b>Link:</b></td><td>" + depLink + "</td>";
    body += "</tr></table>";
}

 

Reply
0 Kudos