Hi All,
Trying to explore on how to use host profile in vRO, was trying to create host profile by using Java script but its not happening. there is not much help i can get from vMware
communities
var myVcProfileCreateSpec = new VcProfileCreateSpec() ;
myVcProfileCreateSpec.annotation = "Test Annotation";
myVcProfileCreateSpec.enabled = true;
myVcProfileCreateSpec.name = "Sandy_Vro";
var myVcHostProfileManager = new VcHostProfileManager() ;
myVcHostProfileManager.createProfile(myVcProfileCreateSpec);
Getting Error below, what am i missing here ??? Please help.
[2018-05-22 09:03:50.565] [E] Unable to create object : VcHostProfileManager : com.vmware.vmo.plugin.vi4.model.VimHostProfileManager
[2018-05-22 09:03:50.603] [E] Workfow execution stack:
***
item: 'HostProfile/item1', state: 'failed', business state: 'null', exception: 'Unable to create object : VcHostProfileManager : com.vmware.vmo.plugin.vi4.model.VimHostProfileManager'
workflow: 'HostProfile' (3d61fc41-a4c1-43a4-ba1b-dcf5ca6ef6f3)
| 'input': name=Host type=VC:HostSystem value=dunes://service.dunes.ch/CustomSDKObject?id='xx.xx.com/host-1105'&dunesName='VC:HostSystem'
| 'no outputs'
| 'no attributes'
*** End of execution stack.
Thanks
Sandeep
Hi Sandeep,
vCenter-managed objects like VcHostProfileManager cannot be directly instatiated using new operator. Instead, you should obtain a reference to them via some other object.
In your case, you have a vCenter host object named Host. To obtain a reference to host profile manager from the host, you can try code something like the following:
var myVcHostProfileManager = Host.sdkConnection.hostProfileManager;
Hi Illev,
Thanks for that, now the error appearing in the console is removed, but executing the code didn't create host profile.
[2018-05-22 10:47:26.776] [E] Error in (Workflow:HostProfile / Host Profile (item1)#5) The request refers to an unexpected or unknown type.
[2018-05-22 10:47:26.793] [E] Workfow execution stack:
***
item: 'HostProfile/item1', state: 'failed', business state: 'null', exception: 'The request refers to an unexpected or unknown type. (Workflow:HostProfile / Host Profile (item1)#5)'
workflow: 'HostProfile' (3d61fc41-a4c1-43a4-ba1b-dcf5ca6ef6f3)
| 'input': name=Host type=VC:HostSystem value=dunes://service.dunes.ch/CustomSDKObject?id='xx.xxx.com/host-1105'&dunesName='VC:HostSystem'
| 'no outputs'
| 'no attributes'
*** End of execution stack.
Any clue on how to point out the error in the code or troubleshoot further?
The input parameter is variable 'Host' with input type is VC:HostSystem ( which is my reference host).
Competed code is
var myVcProfileCreateSpec = new VcProfileCreateSpec() ;
myVcProfileCreateSpec.annotation = "Test Annotation";
myVcProfileCreateSpec.enabled = true;
myVcProfileCreateSpec.name = "Sandy_Vro";
var myVcHostProfileManager = Host.sdkConnection.hostProfileManager;
myVcHostProfileManager.createProfile(myVcProfileCreateSpec);
Thanks
Sandeep
The error message points to the location of the error
Error in (Workflow:HostProfile / Host Profile (item1)#5)
So the error is on line #5, which, considering that the count start from 0, should be the last line where the call to createProfile() method is happening.
Which versions of vRO and vCenter do you use?
The vRO version we are using is 7.0.1.3533702.
Thanks
Sandeep
The vCenter version we use is 6.0, missed to mention in the previous post.
Thanks
Sandeep
I think the problem is that instead of the base class VcProfileCreateSpec you should use one of its descendant/child classes (check vCenter API documentation for this particular class hierarchy).
I'm having the same issue how to create a new host profile based on an ESXi host.
You cannot use the "sub object" VcHostProfileHostBasedConfigSpec as the createProfile method from the VcHostProfileManager requires a VcProfileCreateSpec as parameter.
That's my code:
var profileSpecs = VcHostProfileHostBasedConfigSpec(in_profileName, in_description, isProfileEnabled, in_referenceHost, profilesToExtract, useHostProfileEngine);
var hostProfileManager = VcPlugin.allSdkConnections[0].hostProfileManager;
hostProfileManager.createProfile(profileSpecs);
Error:
com.vmware.vim.vmomi.core.exception.MarshallException: Required argument not passed: createSpec
I totally understand the error message, but the documentation regarding esp. the object VcHostProfileHostBasedConfigSpec is very poor.
The code is not correct. The first line should use new operator to create an instance VcHostProfileHostBasedConfigSpec.
Something like var profileSpecs = new VcHostProfileHostBasedConfigSpec(...)
Also, which vRO version do you use? In my vRO 7.4 environment, the constructor is shown as having different number of arguments.
The following code seems to work in my environment (vRO 7.4 / vCenter 6)
// host variable is the input VC:HostSystem
var profileSpec = new VcHostProfileHostBasedConfigSpec("testprofileName", "test description", true, host, true);
var hostProfileManager = host.sdkConnection.hostProfileManager;
hostProfileManager.createProfile(profileSpec);
Hi Ilian,
oh i forgot the "new"!
Your code works also on my environment
Thank you very much
Hi Illev,
Im still facing error tried executing the code, but no luck
Error output:
2018-06-05 09:04:57.976] [E] Error in (Workflow:HostProfile / Host Profile (item1)#7) ; nested exception is:
java.io.IOException: java.io.IOException: Non nillable element 'host' is null.
[2018-06-05 09:04:58.002] [E] Workfow execution stack:
***
item: 'HostProfile/item1', state: 'failed', business state: 'null', exception: '; nested exception is:
java.io.IOException: java.io.IOException: Non nillable element 'host' is null. (Workflow:HostProfile / Host Profile (item1)#7)'
workflow: 'HostProfile' (3d61fc41-a4c1-43a4-ba1b-dcf5ca6ef6f3)
| 'input': name=Host type=VC:HostSystem value=dunes://service.dunes.ch/CustomSDKObject?id='xxx.xxx.com/host-963'&dunesName='VC:HostSystem'
| 'no outputs'
| 'no attributes'
*** End of execution stack.
vRO version 7.0.1
Thanks
Sandeep
Well, the error says that you haven't provided a valid value for 'host' parameter on line# 7. I guess you haven't bound properly the workflow input parameter 'Host' to this parameter.