VMware Cloud Community
Mr_G_Grant
Enthusiast
Enthusiast
Jump to solution

Start SSH on ESXi host

Hi Guys,

I'm trying to get a scriptable task to start SSH on an ESXi host and its not quite happening. I'll try to explain briefly what I've done so far.

So I've created an attribute / array of ESXi hosts and created an input to use the array as predefined objects. Next I have a scriptable task as follows where its going wrong.

// Start SSH service on ESXi host
var myVcHostServiceSystem = new VcHostServiceSystem() ;
myVcHostServiceSystem.startService("TSM-SSH")

System.log ("Starting SSH service on: " + host.name);

This keeps on failing saying

Unable to create object : VcHostServiceSystem : com.vmware.vmo.plugin.vi4.model.VimHostServiceSystem

Can anybody shed some light?

Thanks

Mr G

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Well, the error says it Smiley Happy VcHostServiceSystem represents ServiceSystem managed object, and managed objects shouldn't be directly instantiated in scripting using the Javascript's operator new syntax:

var myVcHostServiceSystem = new VcHostServiceSystem(); // won't work for managed objects

Instead, you should fetch a reference to the managed objects. For this particular case, it looks like you can get it from the host, using the following scripting code:

var myVcHostServiceSystem = host.configManager.serviceSystem; // 'host' is your ESXi host object of type VC:HostSystem / VcHostSystem

View solution in original post

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Well, the error says it Smiley Happy VcHostServiceSystem represents ServiceSystem managed object, and managed objects shouldn't be directly instantiated in scripting using the Javascript's operator new syntax:

var myVcHostServiceSystem = new VcHostServiceSystem(); // won't work for managed objects

Instead, you should fetch a reference to the managed objects. For this particular case, it looks like you can get it from the host, using the following scripting code:

var myVcHostServiceSystem = host.configManager.serviceSystem; // 'host' is your ESXi host object of type VC:HostSystem / VcHostSystem

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Just to add to this thread, I actually blogged about this 5 years ago and the code is still valid Smiley Wink

Manage Services on your ESXi hosts with vCO

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos