VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Import unmanaged vCenter vm's programmatically.

I'm looking for a way to import a an unmanaged vCenter vm.  Basically the same thing I can do by running the infrastructure organizer.  I am trying to build a vCO workflow to do this and have tried using the workflow "vCloud Automation Center\Infrastructure Administration\Extensibility\Discovery\Import vCenter Virtual Machine" which comes with the 6.1 vCO plugin but this doesn't seem to work.  I've also been poking through the api documentation and I don't see anything that would seem to map to the infrastructure organization.  At this point all I have come up with is to tag the vm's with some meta data and generate a csv based off the metadata for use with a bulk import or something of that nature.  If there is a better way I'd love to hear it!

Paul

1 Solution

Accepted Solutions
qc4vmware
Virtuoso
Virtuoso
Jump to solution

After some trial and error I have discovered the error of my ways.  The vCO workflow requires that "identityUser" is a user with rights to perform the registration.  They do not specify this in api explorer anywhere I can see.  I had been specifying the same value for this as I was for "owner".  This is also not a required parameter which it seems it should be.  The workflow also does not error out if the registration fails which it should.  There are most definitely errors in the vCAC logs (thankfully) which made it apparent to what was occurring (or rather not). Its also worth noting that only the user name is required not the password as well.  I'm not sure what the logic is here.  It seems like this should be running under the context of the vCO user executing the workflow.

View solution in original post

Reply
0 Kudos
13 Replies
qc4vmware
Virtuoso
Virtuoso
Jump to solution

After some trial and error I have discovered the error of my ways.  The vCO workflow requires that "identityUser" is a user with rights to perform the registration.  They do not specify this in api explorer anywhere I can see.  I had been specifying the same value for this as I was for "owner".  This is also not a required parameter which it seems it should be.  The workflow also does not error out if the registration fails which it should.  There are most definitely errors in the vCAC logs (thankfully) which made it apparent to what was occurring (or rather not). Its also worth noting that only the user name is required not the password as well.  I'm not sure what the logic is here.  It seems like this should be running under the context of the vCO user executing the workflow.

Reply
0 Kudos
vmwaredownload
Enthusiast
Enthusiast
Jump to solution

Hi qc4vmware,

We are working on the same "Import a vCenter VM to vCAC" workflow. Requirement is this :

1. Cloning a machine which is under the vCAC.

2. Importing the cloned VM from vCenter to vCAC.

We are able to do the 1st action. For 2nd action, we don't want any manual interaction processes like importing the cloned VM through Infrastructure Organizer or Bulk Import. We want to automate the 2nd action. As soon as the VM is cloned it should get imported to vCAC. For this to happen we figured this "Import a vCenter VM to vCAC" workflow would help. Just to explore this workflow we tried to run it but encountered some issues here.

The cloned VM (vCenter VM) is selected for input manually. We mention the other inputs like Reservation, Hosts, user and other stuffs. We are getting stuck in the workflow as shown in Fig 1. When we debug the issue the output of the action elemet "getVirtualMachineByexternalRefID" is showing "Null". What is that we are going wrong here?

Help us out!! Smiley Happy

- SK

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

What are your versions of vCO and vCAC plugin?  It sounds like you are hitting the issue with the most recent version(s) where they have changed the way the vCenter vm lookup is executed.  I forget the exact details off the top of my head but if you have vCO 6.1 plugin installed make sure you also have the additional workflow package installed that deals with this.  It is separate from the .vmoapp file you use for installing the plugin but available from the download page.

Reply
0 Kudos
vmwaredownload
Enthusiast
Enthusiast
Jump to solution

We are using the new version of vCO 5.5.2 and vCAC 6.1 setup. The plug-in is vCAC 6.1 which comes as a inbuilt item in vCO. I found the "com.vmware.vcac61_uuid_wf_patch" package in the download page along with the .vmoapp file. I downloaded and imported the package to the vCO. This package doesn't contain any specific Import vCenter VM workflow. Am I missing something here? This is really needed for us.

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

That updated workflow package will fix (I think) the piece of the import workflow which is breaking.  It looks like the step that is breaking is due to the previous step returning a null value for the vCenter vm.  That updated packaged should resolve that issue.

Make sure when you import the package that you force all items to import.  By default I believe most of the items are not going to be checked.

Reply
0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

Hi qc! Thanks for circling back and reporting your findings. Can you be a little more specific in how you got this to work? I am under the impression you are using the "Import vCenter Virtual Machine" Workflow under vCAC-->Infrastructure Administration-->Extensibility-->Discovery, but I am not able to get this to work. The workflows are finishing without error, but I don't see any new items added when I check my item list. Am I forgetting something?

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

You will likely need to inspect the IaaS logs to discover where the error is occurring. I have never seen that workflow generate an error condition in vCO but I ran into several problems which did show up in the IaaS logs.   The errors were pretty easy to interpret. If you aren't seeing any errors I am not sure where to point you.

Sirry
Enthusiast
Enthusiast
Jump to solution

Without trying to take up too much of your time, I think I've narrowed down my issue to not providing a valid IdentityUser field...

can you tell me what you used as input for the required "Identity User" field in the presentation layer of the workflow?

it eventually ties to this script function:

vm.register(owner, identityUser, templateId, hostReservationId, hostStorageReservationId, null);

I see some previous KB articles about issues in 6.0.1, but I'm running on 6.1 (just like you?) so there shouldn't be any issues?

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Like I said it needs to be a user with the correct permissions to perform the import.  I'm not sure off the top of my head exactly what role in vCAC the user needs to have but I specified a user which is basically a super user in our environment.  The user account is an infrastructure administrator and has access in just about any other administrative aspect.  I would try logging into the gui and running the infrastructure organizer.  If you can successfully import vm's with that utility I believe the workflows will function if you specify that same user as the IdentityUser.  Sorry I can't be more specific about the exact configuration of the IdentityUser.  The documentation on the infra organizer might have those specifics.

Reply
0 Kudos
Sirry
Enthusiast
Enthusiast
Jump to solution

Edit: It worked! Thank you very much. I think I must have done something terribly wrong last time I input the ID, but copying the user string used in "Machine owner" seems to work now. I struck that option out in the past since it didn't appear to function properly, but it ended up being an oversight by me the entire time.

It also looks like my team has been tackling another issue that you mentioned here: vCO output as criteria for triggering an approval policy ...

Were you able to make any progress there? If we come up with anything, we'll probably tack it to the end of your post, but so far it does not look promising... they're using some sort of clause system that they do not document at all....

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Not really on the approval policies.  I have not examined the triggers in 6.1 but as far as I know nothing has changed.

Reply
0 Kudos
thawkbravo
Enthusiast
Enthusiast
Jump to solution

Hi vmwaredownload

Were you able to successfully make this work. I am exactly working on the same funtionality. I was able to get the second part working. But ran into some issues in 1st part where selecting next available host name from vCAC and get available IP from vCAC to change IP after cloning. How did you guys overcome this ? Any insight woudl be really helpful. We are in 5.2, in 5.2 there is no 'ExternalRefID' column in 'VirtualMachines' table. I was able to get this entity by UUID instead Ref Id (MoRef).

Thanks

Reply
0 Kudos
rszymczak
Hot Shot
Hot Shot
Jump to solution

In addition to your findings I want to cleaify things:

- The register process requires you to select a blueprint that the imported vm will be assigned with

- When registring the VM with vRA it will be pushed through the lifecycle of that blueprint (you can watch that process in the events view in vRA)

- if that blueprint has any custom properties, e.g. it has a property to start a vRO workflow a provision time, than that will be executed (which comes in kinda handy!)

The "identity user" will be used to fill the property "__Legacy.Workflow.User". It seems that any user with the permission to request the choosen blueprint may be used for that job. It is however not the same as the "requestedfor" / "requestedby" user, which will be the user you specify as "owner". Dunno what __Legacy.Workflow.User is used for, but we can guess that some lagacy component of IAAS requires it.

Reply
0 Kudos