VMware Cloud Community
SatishPatil
Enthusiast
Enthusiast
Jump to solution

TagCategory

Hi All,

I need to get TagCategory during VM creation. The request to create vm is fired from vcac. Then it executes a flow in VCO. I read VCO does not currently support Tag Category. Then started using powerCli cmdlets in VCO

The following is the script.

try{

  var session = powerShellHost.openSession();

  var sessionID = session.getSessionId()

System.getModule("com.vmware.library.powershell.generated").addPSSnapIn(powerShellHost,sessionID,"VMware.VimAutomation.Core",false,false,false,"","","") ;


var actionResult = System.getModule("com.vmware.library.powershell.generated").connectVIServer(powerShellHost,sessionID,"vcenterHost",443,null,null,"userid","Password",null,null,null,null,null,null,null,null,null,null,null) ;

var oSession = powerShellHost.getSession(sessionID);

var cmd = oSession.addCommandFromString('Get-TagCategory');

var res = System.getModule("com.vmware.library.powershell").invokeCommand(powerShellHost,sessionID) ;

  System.log("Result of TagCategory:"+res.getXml());

}

catch(err){

System.log(err);

}

finally{

  powerShellHost.closeSession(session.getSessionId());

}

addPSSnapIn takes long time. Is this normal?


connectVIServer method is called but actionResult is not used in the script. I have seen similar behavior in powercli example workflows. Is it required to connect.


invokeCommand sometimes throws out of memory. What is wrong in the script.


Is it possible to convert invokeComand return object into VCO object with ConvertTO method?


Thanks in advance.


0 Kudos
1 Solution

Accepted Solutions
SatishPatil
Enthusiast
Enthusiast
Jump to solution

Memory issue is resolved after increasing powershell memory on the server. It was 150mb then changed to 1024 mb. I followed the following link to increase the memory.

http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/30/learn-how-to-configure-powershell-memo...

View solution in original post

0 Kudos
1 Reply
SatishPatil
Enthusiast
Enthusiast
Jump to solution

Memory issue is resolved after increasing powershell memory on the server. It was 150mb then changed to 1024 mb. I followed the following link to increase the memory.

http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/30/learn-how-to-configure-powershell-memo...

0 Kudos