10 Replies Latest reply on Apr 13, 2015 10:24 AM by ppham99

    Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC

    DLally Enthusiast

      I have a vCO workflow that will add a user(owner) to the local admin.  I would like to automatically kick that workflow off after the machine is provisioned.  At this point I'm pretty well lost on the proper way.  Some info I've read says use designer, some info says just use vCO.  My current inputs are vc:virtualmachine, user(this will be owner of the vm) and environment.  Obviously I can't statically set these like normal, and the environment is a custom property that will need to be passed so that the script knows what domain to add the user from.

        • 1. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
          DLally Enthusiast

          From more reading it looks like using the workflow template and going from there might be the best option.  I've got a workflow setup, if anyone would like to check this out.

           

          I've been kind of going off this document, so I'm sure I'm still missing something important

          • 2. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
            awjudge Hot Shot

            You're on the right track as far as I can tell. The vCO workflow template has a set of Input Parameters which are always passed from the vCAC workflow into the vCO workflow. You can customise your workflow to suit. In order to get the properties of the vCAC machine that's been provisioned, I've found that the object type of VCAC:Entity is the place to start.

             

            There's a vCO Action called getPropertiesFromVirtualMachine which will list out all of the properties. From there you can make your workflow do pretty much anything you like.

             

            Let me know if you need an example.

            • 3. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
              DLally Enthusiast

              If you have an example, I'd greatly appreciate it it.  I'm going in blind right now tryign to do this from scatch.  if I can see an example to base myself off of, that would help a lot.

               

               

              I'll attach my workflow I'm starting with.  If you have a moment to take a look that'd be awesome.  I'm just trying to pull 2 properties from my VM, environment and owner.  The script removes the UPN from the owner name and depending on the environment property, adds user from the specified domain.  This workflow does exactly what I need, but it's just a matter of setting this thing up to run on MachineProvision workflow stub.  That is the hard part for me.

              • 4. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                awjudge Hot Shot

                So your workflow looks fine to me for the most part.

                 

                What is the problem you're having with the MachineProvision workflow stub?

                 

                You should be able to run the "Assign a State Change Workflow to a Blueprint and it's Virtual Machines" workflow to make the association.

                 

                You might also want to simplify your workflow slightly. Technically, you don't need the first scriptable task. You can get the properties you need from your Get Properties task.


                I've made some changes to your workflow, which might simplify things a bit.

                1 person found this helpful
                • 5. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                  DLally Enthusiast

                  Thanks for the example, however when I tested that I got an error "Invalid attribute type: Properties".  I simplified it down and just kept the "var user = System.getModule("com.vmware.library.vcac").getPropertyFromVirtualMachine(attVCACHost,vCACVm,'__Legacy.Workflow.User');" and removed the other scriptable tasks.  I just wante to run something simple to verify it works.  This is the same error i've been getting when trying to run any simple workflow template.

                   

                  On a side note, what's the difference between the way you pulled the properties than some other examples where they use something like this? var user = vCACVmProperties.get("__Legacy.Workflow.User")

                  • 6. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                    awjudge Hot Shot

                    Looking at the workflow now, you don't need the Input Parameter called vCACvmProperties, it's not used anywhere in your scriptable tasks, that should fix it.

                    • 7. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                      vjDuBB Enthusiast

                      There seems to always be multiple ways to accomplish any given task in vCO.  I typically preface all of my workflows with the attached scriptable task.  You will see that I capture 5-6 custom properties, some are reserved and some are properties that I use later.  They are brought in as Input Parameters and output as Attributes for use in other subworkflows within my master or wrapper wf.

                      1 person found this helpful
                      • 8. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                        DLally Enthusiast

                        Yeah that's the way i've taken it too.  But I have pretty much started doing as you have and just duplicating a template and adding my work inside that.  That way I can call in any custom property needed. 

                        • 9. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                          stvkpln Master
                          vExpert

                          Just my two cents on this, but I'm not a fan of calling on properties from external entities from within (what I refer to as) 'worker bee' workflows... I generally like to create the workflow with all of the inputs I need, then wrap them inside a master workflow that's responsible for capturing that information from whatever outside entity, and just pushing in those input values. It (generally) reduces the amount of effort in development of specific tasks and allows me to centrally aggregate value collection in one place.. unless I'm using outputs from one workflow in a subsequent workflow (that happens and can't always be avoided). Typically, if I can leverage straight up values, though... at least I know the structure of a workflow is good and all I'm troubleshooting when I get into end-to-end testing is whether the inputs are properly getting populated. Way less stress (in my opinion).

                          • 10. Re: Proper way to call workflow from ExternalWFStubs.MachineProvisioned from vCAC
                            ppham99 Lurker

                            I'm in the same boat with moving the computer to OU. I was able to use the forum that includes "editing" the MachineProvisioned with vcac designer but I found that it affects my other blueprints that dependent on this workflow. I've tried the guest customization but that doesn't work as well.


                            I also have tried the invoke a powershell script with the follwing command with no sucess (my powershell host is registered)


                            Any help will be greatly appreciated!