Module: CloudstackClient::SystemVm

Defined in:
lib/cloudstack_client/commands/system_vm.rb

Instance Method Summary collapse

Instance Method Details

#destroy_system_vm(id, args = {}) ⇒ Object

Destroy sytem VM.



72
73
74
75
76
77
78
# File 'lib/cloudstack_client/commands/system_vm.rb', line 72

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

#list_system_vms(args = {}) ⇒ Object

List system virtual machines.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cloudstack_client/commands/system_vm.rb', line 8

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

#reboot_system_vm(id, args = {}) ⇒ Object

Reboot sytem VM.



60
61
62
63
64
65
66
# File 'lib/cloudstack_client/commands/system_vm.rb', line 60

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

#start_system_vm(id, args = {}) ⇒ Object

Start system VM.



48
49
50
51
52
53
54
# File 'lib/cloudstack_client/commands/system_vm.rb', line 48

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

#stop_system_vm(id, args = {}) ⇒ Object

Stop system VM.



35
36
37
38
39
40
41
42
# File 'lib/cloudstack_client/commands/system_vm.rb', line 35

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