Sha256: 1127a755bc1add0e163773175e769d620e19c48557394154e52b371584c6e77d

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

module CloudstackClient

  module SystemVm

    ##
    # List system virtual machines.

    def list_system_vms(args = {})
      params = {
        'command' => 'listSystemVms'
      }

      if args[:zone]
        zone = get_zone(args[:zone])
        unless zone
          puts "Error: zone #{args[:project]} not found."
          exit 1
        end
        params['zoneid'] = zone['id']
      end

      params['state'] = args[:state] if args[:state]
      params['podid'] = args[:podid] if args[:podid]
      params['systemvmtype'] = args[:type] if args[:type]
      params['storageid'] = args[:storage_id] if args[:storage_id]

      json = send_request(params)
      json['systemvm'] || []
    end

    ##
    # Stop system VM.
    #

    def stop_system_vm(id, args = {})
      params = {
        'command' => 'stopSystemVm',
        'id' => id
      }
      params['forced'] = true if args[:forced]
      args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
    end

    ##
    # Start system VM.
    #

    def start_system_vm(id, args = {})
      params = {
        'command' => 'startSystemVm',
        'id' => id
      }
      args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
    end

    ##
    # Reboot sytem VM.
    #

    def reboot_system_vm(id, args = {})
      params = {
        'command' => 'rebootSystemVm',
        'id' => id
      }
      args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
    end

    ##
    # Destroy sytem VM.
    #

    def destroy_system_vm(id, args = {})
      params = {
          'command' => 'destroySystemVm',
          'id' => id
      }
      args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
    end

  end # module

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudstack_client-0.9.7 lib/cloudstack_client/commands/system_vm.rb