VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Problems getting VM power state part 2 solutions

Branching off from another thread to work on the final solution: This was my original post from this message string http://communities.vmware.com/message/1637244#1637244

I went ahead and tried creating a custom decision. I used the following code in the script portion of the decision:

if (vm.state = "poweredOn") {

return true;

} else {

return false;

}

but I get an error when I run the workflow stating that there is no property called "state". vm is of type vc:virtualmachine . Do I have the syntax wrong somewhere? Do I need to somehow set an attribute or output to the value of vm.state in the main input and output parameters? Help a newbie out here to get this sample working.

Paul

Andreas answered with this:

Hi Paul,

1) this is a solved thread - next time pls open an own thread

2) powerState is part of runtimeInfo and not of VM so your code should look like this:

return (VM.runtime.powerState == "poweredOn");

The term in brackets is bool, so you can return it direct.

In Java you use "=" to assign values! With "==" you check for equal or "!=" on not equal.

So the code above returns true on a powered on VM and false for powered off and suspended.

Think that solved your question.

This didn't quite solve my question. That code returns a powerState object.

return (vm.runtime.powerState.name == "poweredOn");

Does the trick though.

So my question is why does the documentation list "state" as a property of vc:virtualmachine? Is that a documentation error or related to the bug referenced in the release notes?

Also where is the best place to see a listing of all the properties and methods for the different object types? Sorry but I am a total novice when it comes to the dev side of things. Is this found in the api documentation set?

Paul

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi,

sorry for the frogotten .name - powerState is an enumeration.

For me the easiest way to look for methods an properties is the API explorer in VCO-Client (Menu - Tools - API explorer). So i have a own window to search the API) when i'm editing workflows or action. Also there is a small API explorer frame in edit window - but i use this only for a quick view.

In wich documentation (doc / page) do you read vc:virtualmachine.state?

-


don't forget: award points to helpful answers

Regards,

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com

View solution in original post

Reply
0 Kudos
6 Replies
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi,

sorry for the frogotten .name - powerState is an enumeration.

For me the easiest way to look for methods an properties is the API explorer in VCO-Client (Menu - Tools - API explorer). So i have a own window to search the API) when i'm editing workflows or action. Also there is a small API explorer frame in edit window - but i use this only for a quick view.

In wich documentation (doc / page) do you read vc:virtualmachine.state?

-


don't forget: award points to helpful answers

Regards,

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

I was inside of orchestrator using the api explorer. The scriptable object type for vc:virtualmachine. It lists the following properties: Name, vimhost, id, istemplate, state, and connectionstate . How did you make the connection between vc:virtualmachine and runtime.name ? runtime is not listed as a method or property.

Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi,

do we talk about the same? Here is my view on vc:virtualmachine properties

Beyond this methods are listed. What did you use?

-


don't forget: award points to helpful answers

Regards,

visit

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Ok... I see now. This is the screen I was looking at. I didn't notice the reference at the very top of the screen before which would have taken me to the object. I also see a link to external documentation when I look at that object. Thanks for helping an orchestrator newb out!

Paul

Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast
Jump to solution

Hi Paul,

you're welcome.

Did you notice that your screenshot shows the type and mine the object. The icon before vm is grey and mine green. Beyond the type you have the link in API explorer to the scripting object.

-


don't forget: award points to helpful answers

Regards,

visit

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Yeah I see how the docs all link up now. Thanks.

Reply
0 Kudos