VMware Aria

 View Only
  • 1.  Service broker: cannot parse MimeType in custom forms

    Posted 6 days ago

    Hello everyone,

    I need your help to solve a problem that is driving me crazy : I got an error from service broker, trying to parse a file passed as inputFile(Mime).

    I'll explain my usecase:

    • users upload a txt into Service broker with a list of vms (VMs List)
    • In VMs field I put an action that parse "VMs List" and check if the vm exists in our environment

    If I run the workflow in Orchestrator, everything runs fine :

    but if run from Service Broker, it fails with error :

    I'm running on 8.18 Automation and the code for checkVmsFromFile is here :

    //load file content split by lines
    var fileContent = inputfile.content.split(/\r\n|\n/)
    //System.log("fileContent > " + fileContent)
    vmWithError = new Array()
    
    
    for each (var vmName in fileContent) {
        //System.log("vmName > " + vmName)
        var found = Server.findAllForType("VC:VirtualMachine", "xpath:name='" + vmName + "'")
        //System.log(found.length)
        //check if the inserted vm exists or not    
        if ( found.length == 0) {
            System.log(vmName + " NOT FOUND")
            vmWithError.push(vmName + " NOT FOUND")
        }
    }
    
    
    if ( vmWithError.length == 0 ) {
        vmWithError.push("Check VMs SUCCESSFULLY Completed")
    }
    
    
    return vmWithError.sort()

    Can someone help me to solve this problem ?



  • 2.  RE: Service broker: cannot parse MimeType in custom forms

    Posted 4 days ago

    I had a similar issue where I was trying to use input validation for MimeAttachment inputs and got the same error. I opened and case and received the following repsonse: "Upon checking internally I confirmed that unfortunately using file uploads in service broker is not supported. You can use them only if you are running the workflow directly in vRO. "

    What is working in my case is simply use MimeAttachments as inputs but don't do the the input validation. Just pass is to the workflow. In the first step I validate the correct MimeType and fileextension. If that fails the workflow fails too.

    In your case another approach could be to use the TextArea input and let the user just paste the list of VMs as a string and than process this string by splitting it to allow multiple ways of input, like comma, semiclon, space or tab seperation. Something like the following and then go on from there.

    var array = input.replace(/["']/g, "").split(/[\s\n,;]/g);




  • 3.  RE: Service broker: cannot parse MimeType in custom forms

    Posted 3 days ago

    Hi Valentin ,

    thanks for your reply, I also opened a case that is still "Under Investigation" by Broadcom.

    I like your approach and will use it as a workaround and hope the problem will be solved.




  • 4.  RE: Service broker: cannot parse MimeType in custom forms

    Posted 2 days ago

    Back to you mate ... with a different error. As for mime, also this work-around runs smmotly in orchestrator and Service Broker fails :

    the code of the action is :

    var content = inputText.replace(/["']/g, "").split(/[,;\r\n|\n]/g);
    
    var vmWithError = new Array()
    for each (var vmName in content) {
        //System.log("vmName > " + vmName)
        var found = Server.findAllForType("VC:VirtualMachine", "xpath:name='" + vmName + "'")
        //System.log(found.length)
        //check if the inserted vm exists or not    
        if ( found.length == 0) {
            System.log(vmName + " NOT FOUND")
            vmWithError.push(vmName + " NOT FOUND")
        } else {
            //
        }
    }
    
    if ( vmWithError.length == 0 ) {
        vmWithError.push("Check VMs SUCCESSFULLY Completed")
    }
    
    return vmWithError.sort().toString()

    where inputText is the text area




  • 5.  RE: Service broker: cannot parse MimeType in custom forms

    Posted 2 days ago

    I tried recreating it and for me it works in service broker. I did it like this:

    Action Code:

    // Return empty array if input is not present
    if (!vms) {
        System.log("List is empty")
        return [];
    }
    
    // Split input to array
    var list = vms.replace(/["']/g, "").split(/[,;\r\n|\n]/g);
    
    // Cleanup
    var arr = list.filter(function(el) {
        return el != null && el !== '';
    });
    
    // Get all VMs
    var allVMs = VcPlugin.getAllVirtualMachines(["name"], null);
    System.log("Total VMs: " + allVMs.length);
    
    // Create empty array
    var vmsNotFound = [];
    
    // Interate over cleaned up list of VM names
    arr.forEach(function(vmName) {
        // Check if VM name exists
        var result = allVMs.filter(function(vm) {
            return vm.name.toLowerCase() === vmName.toLowerCase().trim();
        });
        // Push to list of not found VMs when above query does not return any results
        if (!result || result.length === 0) {
            vmsNotFound.push(vmName)
        }
    });
    
    // Return list of not found VM names
    return vmsNotFound;
    

    Workflow with two variables, one string, one array of string.

    Value options for "check" map to "vms".

    This works in service broker.

    "Check" contains the list of not found VM names.

    Workflow does run too and completes.




  • 6.  RE: Service broker: cannot parse MimeType in custom forms

    Posted 2 days ago

    thanks mate, it works!