Set Virtual Machine State operation

The Set Virtual Machine State operation changes the existing state of a virtual machine (VM). This topic illustrates the actor adapter request and response and describes the elements used in the request.

The following table describes the elements for the adapter request:

Adapter request elements for the Set Virtual Machine State operation

Element

Description

Required

<operation-name>

Specifies the name of the operation: set-virtual-machine-state

Yes

<arguments>

Contains the elements that specify the details of the VM whose state needs to be changed

Yes

<target>

Contains a dynamic target configuration or uses a predefined target configuration of the Hyper-V server on which the request is executed

Note

If you do not specify a dynamic target in the adapter request, the default adapter configuration is used.

The <target> element contains the following elements:

  • <host>
  • <user-name>
  • <password>
  • <timeout-secs>

Conditional; required if a target is referenced or specified in the request

<host>

Specifies the host name or the IP address of the Hyper-V server

The <host> element applies to a dynamic target.

Conditional; required when specifying a dynamic target

<user-name>

Specifies the user name to be used to connect to the Hyper-V server

The <user-name> element applies to a dynamic target.

Conditional; required when specifying a dynamic target

<password>

Specifies the password that corresponds to the <user-name> provided

The <password> element applies to a dynamic target.

The <password> element can contain an encryption-type attribute that indicates whether the password specified is encrypted.

Valid values for encryption-type: base64, plain (default)

Conditional; required if <user-name> is specified

<timeout-secs>

Specifies the time, in seconds, after which the attempt to connect to the Hyper-V server fails

Default value: 60

No

<vm>

Specifies the name of the VM whose state needs to be changed

Yes

<vm-guid>

Specifies the globally unique identifier (GUID) of a particular VM to restrict the operation to that VM if multiple VMs have the same name

No

<state>

Specifies the new state of the VM

Valid values:

  • Running
  • Stopped
  • Suspended
  • Paused

Yes

The following figure shows a sample <items> XML element for the Set Virtual Machine State operation:

 Sample



<items>
   	<item>
 	  <target>
 		<host>10.111.8.222</host>
	 	<user-name>administrator</user-name>
        	<password   encryption-type="Base64">pwd</password>   
	 	<timeout-secs>120</timeout-secs>
	  </target>
 	  <vm>Win2003</vm>
 	 <vm-guid><vm-guid>
	 <state>stopped</state>
 	</item>
 	<item>
 	  <target>
	  	<host>pw-mmm-abc-dv00</host>
	  	<user-name>administrator</user-name>
          	<password>pwd</password>   
 	  </target>
 	  <vm>vw-pun-bpa-dv04</vm>
	  <state>paused</state>
	</item>
 	<item>
 	   <vm>Win2003</vm>
	   <state>running</state>
 	</item>
 	<item>
	  <target>Config1</target>
	  <vm>Win2003</vm>
	  <state>suspended</state>
	</item>
</items> 

The following figure shows a sample adapter request for the Set Virtual Machine State operation:

 Sample adapter request for the Set Virtual Machine State operation


<ms-hyperv-request>
    <operation-name>set-virtual-machine-state</operation-name>
    <arguments>
      <target>
        <host>10.111.8.222</host>
        <user-name>administrator</user-name>
        <password encryption-type="Base64">pwd</password>
        <timeout-secs>120</timeout-secs>
      </target>
      <vm>Win2003</vm>
      <vm-guid />
      <state>stopped</state>
    </arguments>
    <arguments>
      <target>
        <host>pw-mmm-abc-dv00</host>
        <user-name>administrator</user-name>
        <password>pwd</password>
      </target>
      <vm>vw-pun-abc-dv04</vm>
      <state>paused</state>
    </arguments>
    <arguments>
      <vm>Win2003</vm>
      <state>running</state>
    </arguments>
    <arguments>
      <target>Config1</target>
      <vm>Win2003</vm>
      <state>suspended</state>
    </arguments>
</ms-hyperv-request> 

The following figure shows a sample adapter response for the Set Virtual Machine State operation:

 Sample adapter response for the Set Virtual Machine State operation


<ms-hyperv-response>
  <metadata>
    <status>success</status>
    <response-count>4</response-count>
  </metadata>
  <responses>
    <SetVirtualMachineStateResponse>
      <metadata>
        <target>10.111.8.222</target>
        <status>success</status>
        <count>1</count>
      </metadata>
      <items>
        <item>
          <vm-element-name>Win2003</vm-element-name>
          <genus>2</genus>
          <class>Msvm_ComputerSystem</class>
          <superclass>CIM_ComputerSystem</superclass>
          <dynasty>CIM_ManagedElement</dynasty>
          <relpath>Msvm_ComputerSystem.CreationClassName="Msvm_Com</relpath>
          <property-count>29</property-count>
          <derivation>{CIM_ComputerSystem, CIM_System, CIM_EnabledLog</derivation>
          <server>pw-mmm-abc-dv00</server>
          <namespace>root\virtualization</namespace>
          <path>\\pw-mmm-abc-dv00\root\virtualization:Msvm_Comp</path>
          <assigned-numa-node-list>{1}</assigned-numa-node-list>
          <caption>Virtual Machine</caption>
          <creation-class-name>Msvm_ComputerSystem</creation-class-name>
          <dedicated></dedicated>
          <description>Microsoft Virtual Machine</description>
          <element-name>Win2003</element-name>
          <enabled-default>2</enabled-default>
          <state>Running</state>
          <health-state>5</health-state>
          <identifying-descriptions></identifying-descriptions>
          <install-date>20120220093808.000000-000</install-date>
          <name>8677942E-BDAB-4001-BE6A-9B7950FD47A4</name>
          <name-format></name-format>
          <on-time-in-milliseconds>26738</on-time-in-milliseconds>
          <operational-status>{2}</operational-status>
          <other-dedicated-descriptions></other-dedicated-descriptions>
          <other-enabled-state></other-enabled-state>
          <other-identifying-info></other-identifying-info>
          <power-management-capabilities></power-management-capabilities>
          <primary-owner-contact></primary-owner-contact>
          <primary-owner-name></primary-owner-name>
          <process-i-d>5564</process-i-d>
          <requested-state>Not Applicable</requested-state>
          <reset-capability>1</reset-capability>
          <roles></roles>
          <status></status>
          <status-descriptions>{Operating normally}</status-descriptions>
          <time-of-last-configuration-change>20120312104359.082383-000</time-of-last-configuration-change>
          <time-of-last-state-change>20120312104359.000000-000</time-of-last-state-change>
        </item>
      </items>
    </SetVirtualMachineStateResponse>
    <SetVirtualMachineStateResponse>
      <metadata>
        <target>pw-mmm-abc-dv00</target>
        <status>success</status>
        <count>1</count>
      </metadata>
      <items>
        <item>
          <vm-element-name>vw-pun-bpa-dv04</vm-element-name>
          <genus>2</genus>
          <class>Msvm_ComputerSystem</class>
          <superclass>CIM_ComputerSystem</superclass>
          <dynasty>CIM_ManagedElement</dynasty>
          <relpath>Msvm_ComputerSystem.CreationClassName="Msvm_Com</relpath>
          <property-count>29</property-count>
          <derivation>{CIM_ComputerSystem, CIM_System, CIM_EnabledLog</derivation>
          <server>pw-mmm-abc-dv00</server>
          <namespace>root\virtualization</namespace>
          <path>\\pw-mmm-abc-dv00\root\virtualization:Msvm_Comp</path>
          <assigned-numa-node-list>{1}</assigned-numa-node-list>
          <caption>Virtual Machine</caption>
          <creation-class-name>Msvm_ComputerSystem</creation-class-name>
          <dedicated></dedicated>
          <description>Microsoft Virtual Machine</description>
          <element-name>vw-pun-bpa-dv04</element-name>
          <enabled-default>2</enabled-default>
          <state>Running</state>
          <health-state>5</health-state>
          <identifying-descriptions></identifying-descriptions>
          <install-date>20120308055715.000000-000</install-date>
          <name>5EB9769F-F25A-4D7B-B8DD-ECCE57FF9CDC</name>
          <name-format></name-format>
          <on-time-in-milliseconds>341850046</on-time-in-milliseconds>
          <operational-status>{2}</operational-status>
          <other-dedicated-descriptions></other-dedicated-descriptions>
          <other-enabled-state></other-enabled-state>
          <other-identifying-info></other-identifying-info>
          <power-management-capabilities></power-management-capabilities>
          <primary-owner-contact></primary-owner-contact>
          <primary-owner-name></primary-owner-name>
          <process-i-d>5872</process-i-d>
          <requested-state>Not Applicable</requested-state>
          <reset-capability>1</reset-capability>
          <roles></roles>
          <status></status>
          <status-descriptions>{Operating normally}</status-descriptions>
          <time-of-last-configuration-change>20120312104315.917108-000</time-of-last-configuration-change>
          <time-of-last-state-change>20120312104315.000000-000</time-of-last-state-change>
        </item>
      </items>
    </SetVirtualMachineStateResponse>
    <SetVirtualMachineStateResponse>
      <metadata>
        <target>10.111.8.222</target>
        <status>success</status>
        <count>1</count>
      </metadata>
      <items>
        <item>
          <vm-element-name>Win2003</vm-element-name>
          <genus>2</genus>
          <class>Msvm_ComputerSystem</class>
          <superclass>CIM_ComputerSystem</superclass>
          <dynasty>CIM_ManagedElement</dynasty>
          <relpath>Msvm_ComputerSystem.CreationClassName="Msvm_Com</relpath>
          <property-count>29</property-count>
          <derivation>{CIM_ComputerSystem, CIM_System, CIM_EnabledLog</derivation>
          <server>pw-mmm-abc-dv00</server>
          <namespace>root\virtualization</namespace>
          <path>\\pw-mmm-abc-dv00\root\virtualization:Msvm_Comp</path>
          <assigned-numa-node-list>{}</assigned-numa-node-list>
          <caption>Virtual Machine</caption>
          <creation-class-name>Msvm_ComputerSystem</creation-class-name>
          <dedicated></dedicated>
          <description>Microsoft Virtual Machine</description>
          <element-name>Win2003</element-name>
          <enabled-default>2</enabled-default>
          <state>Stopped</state>
          <health-state>5</health-state>
          <identifying-descriptions></identifying-descriptions>
          <install-date>20120220093808.000000-000</install-date>
          <name>8677942E-BDAB-4001-BE6A-9B7950FD47A4</name>
          <name-format></name-format>
          <on-time-in-milliseconds>0</on-time-in-milliseconds>
          <operational-status>{2}</operational-status>
          <other-dedicated-descriptions></other-dedicated-descriptions>
          <other-enabled-state></other-enabled-state>
          <other-identifying-info></other-identifying-info>
          <power-management-capabilities></power-management-capabilities>
          <primary-owner-contact></primary-owner-contact>
          <primary-owner-name></primary-owner-name>
          <process-i-d>0</process-i-d>
          <requested-state>Not Applicable</requested-state>
          <reset-capability>1</reset-capability>
          <roles></roles>
          <status></status>
          <status-descriptions>{Operating normally}</status-descriptions>
          <time-of-last-configuration-change>20120312104428.129634-000</time-of-last-configuration-change>
          <time-of-last-state-change>20120312104428.000000-000</time-of-last-state-change>
        </item>
      </items>
    </SetVirtualMachineStateResponse>
    <SetVirtualMachineStateResponse>
      <metadata>
        <target>pw-mmm-abc-dv00</target>
        <status>success</status>
        <count>1</count>
      </metadata>
      <items>
        <item>
          <vm-element-name>Win2003</vm-element-name>
          <genus>2</genus>
          <class>Msvm_ComputerSystem</class>
          <superclass>CIM_ComputerSystem</superclass>
          <dynasty>CIM_ManagedElement</dynasty>
          <relpath>Msvm_ComputerSystem.CreationClassName="Msvm_Com</relpath>
          <property-count>29</property-count>
          <derivation>{CIM_ComputerSystem, CIM_System, CIM_EnabledLog</derivation>
          <server>pw-mmm-abc-dv00</server>
          <namespace>root\virtualization</namespace>
          <path>\\pw-mmm-abc-dv00\root\virtualization:Msvm_Comp</path>
          <assigned-numa-node-list>{1}</assigned-numa-node-list>
          <caption>Virtual Machine</caption>
          <creation-class-name>Msvm_ComputerSystem</creation-class-name>
          <dedicated></dedicated>
          <description>Microsoft Virtual Machine</description>
          <element-name>Win2003</element-name>
          <enabled-default>2</enabled-default>
          <state>Running</state>
          <health-state>5</health-state>
          <identifying-descriptions></identifying-descriptions>
          <install-date>20120220093808.000000-000</install-date>
          <name>8677942E-BDAB-4001-BE6A-9B7950FD47A4</name>
          <name-format></name-format>
          <on-time-in-milliseconds>3057</on-time-in-milliseconds>
          <operational-status>{2}</operational-status>
          <other-dedicated-descriptions></other-dedicated-descriptions>
          <other-enabled-state></other-enabled-state>
          <other-identifying-info></other-identifying-info>
          <power-management-capabilities></power-management-capabilities>
          <primary-owner-contact></primary-owner-contact>
          <primary-owner-name></primary-owner-name>
          <process-i-d>3748</process-i-d>
          <requested-state>Not Applicable</requested-state>
          <reset-capability>1</reset-capability>
          <roles></roles>
          <status></status>
          <status-descriptions>{Operating normally}</status-descriptions>
          <time-of-last-configuration-change>20120312104437.942052-000</time-of-last-configuration-change>
          <time-of-last-state-change>20120312104437.000000-000</time-of-last-state-change>
        </item>
      </items>
    </SetVirtualMachineStateResponse>
  </responses>
</ms-hyperv-response> 

Was this page helpful? Yes No Submitting... Thank you

Comments