I posted this question on the VMTN communities and on Twitter but unfortunately was met with tumbleweed!
Basically i have a requirement to be able to automatically add a VASA provider in vCenter. My first port of call was PowerCli but i couldn’t find a cmdlet that would help. I then decided to use Onyx (Look out for a blog post on Onyx tomorrow!) which basically captures commands executed against vCenter but again nada! So the next option was API.
Disclaimer: I am not a developer! I am however pig headed and do not like giving up!! If you’re still interested read on!
I researched the API and found RegisterProvider_Task. Ok Promising!
I went and downloaded the vSphere Management SDK which is a bundle containing multiple SDK’s including the vSphere Storage Management SDK (sms). I had never played with Java before so had to do some research on syntax and on how to compile etc. Some good resources here. I dug through the SDK samples and found SampleProvider.java which had enough detail for me to be able to construct a java file with the commands that i needed to register my provider without needing to reinvent the wheel or learn java coding!
To compile java code you need to have a Java Development Kit (jdk) installed and it is best to add the path to your jdk installation to your path environment variable. (I’m using windows) I did hit an issue when trying to compile the code where i was getting “Could not find main class” errors. I was able to work around this by adding -cp “.;C:\Path to the following SDK .jar files sms.jar, sms-apputils.jar, vim25.jar”, So my compile command looked like this
javac -cp “.;C:\Software\SDK\sms-sdk\java\JAXWS\lib/*” RegisterProvider.java (where all the .jar files were in the same /lib directory)
Once the source code was compiled i was able to call it with a good old windows batch file! As i said i’m not a developer so i’m sure there is a more elegant/more efficient way to do this so if you have one please let me know!
I’ve uploaded the code to GitHub here. Comments welcome!!
Final note: This could also be done in python using a wrapper that was created of the “official” VMware pyVMomi python SDK. The VMware SDK doesnt have the sms modules implemented yet but this wrapper does. I had some issues with the syntax in Python though so in the interests of time decided to go with the java SDK. I plan to revisit the Python SDK when i have more time and will post an update if i get it working.