Package com.vmware.vm

Class VMPowerOps


  • @Sample(name="vm-power-ops",
            description="Demonstrates VirtualMachine Power operations on multiple Virtual Machines. Works with groups of Virtual Machines all at one time. You must specify one of --vmname or --datacentername or --hostname or --all all Virtual Machines that match these criteria will have the power operation issued to them. For example to power off all the virtual machines visible use the options  --operation poweroff --all true together and all virtual machines will be turned off.")
    public class VMPowerOps
    extends ConnectedVimServiceBase
     VMPowerOps
    
     Demonstrates VirtualMachine Power operations on multiple Virtual Machines. 
     Works with groups of Virtual Machines all at one time.
    
     Parameters:
     url              [required] : url of the web service
     username         [required] : username for the authentication
     password         [required] : password for the authentication
     operation        [required] : type of the operation
                                   [poweron | poweroff | reset | suspend |
                                    reboot | shutdown | standby]
     datacentername   [optional] : name of the datacenter
     guestid          [optional] : guest id of the vm
     hostname         [optional] : name of the host
     vmname           [optional] : name of the virtual machine, use this option to send the power operation to only one virtual machine
     all              [optional] : perform power operations on ALL virtual machines under our control. defaults to false. [true|false]
    
     Command Line:
     run.bat com.vmware.vm.VMPowerOps --url [URLString] --username [User] --password [Password]
     --operation [Operation] --datacenter [DatacenterName]--guestid [GuestId] --hostname [HostName]
     --vmname [VMName] --all [true|false]
     
    • Constructor Detail

      • VMPowerOps

        public VMPowerOps()
    • Method Detail

      • setOperation

        @Option(name="operation",
                description="type of the operation\n[poweron | poweroff | reset | suspend | reboot | shutdown | standby]")
        public void setOperation​(java.lang.String operation)
      • setDatacenter

        @Option(name="datacentername",
                required=false,
                description="name of the datacenter. use this option to send power operations to all the virtual machines in an entire data center.")
        public void setDatacenter​(java.lang.String datacenter)
      • setGuestId

        @Option(name="guestid",
                required=false,
                description="guest id of the vm. use this option to send power operations to a single guest.")
        public void setGuestId​(java.lang.String guestId)
      • setHost

        @Option(name="hostname",
                required=false,
                description="name of the host. use this option to send power operations to all the virtual machines on a single host.")
        public void setHost​(java.lang.String host)
      • setVmName

        @Option(name="vmname",
                required=false,
                description="name of the virtual machine. Use this option to send power operations to only this virtual machine.")
        public void setVmName​(java.lang.String vmName)
      • setAll

        @Option(name="all",
                required=false,
                description="set to true to send power operation to all virtual machines that can be found. overrides all other options.")
        public void setAll​(java.lang.Boolean flag)
      • run

        @Action
        public void run()
                 throws com.vmware.vim25.RuntimeFaultFaultMsg,
                        com.vmware.vim25.InvalidPropertyFaultMsg
        Throws:
        com.vmware.vim25.RuntimeFaultFaultMsg
        com.vmware.vim25.InvalidPropertyFaultMsg
      • checkOptions

        public boolean checkOptions()
        The user must specify one of vmName or datacenter or host ... We add this check here to help prevent programmers from power cycling all the virtual machines on their entire vCenter server on accident.