Module: CloudstackClient::Iso

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

Instance Method Summary collapse

Instance Method Details

#detach_iso(vm_id, args = {}) ⇒ Object

Detaches any ISO file (if any) currently attached to a virtual machine.



65
66
67
68
69
70
71
72
# File 'lib/cloudstack_client/commands/iso.rb', line 65

def detach_iso(vm_id, args = {})
  params = {
      'command' => 'detachIso',
      'virtualmachineid' => vm_id
  }
  json = send_request(params)
  args[:sync] ? send_request(params) : send_async_request(params)['virtualmachine']
end

#get_iso(name) ⇒ Object

Finds the template with the specified name.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cloudstack_client/commands/iso.rb', line 36

def get_iso(name)

  # TODO: use name parameter
  # listIsos in CloudStack 2.2 doesn't seem to work
  # when the name parameter is specified. When this is fixed,
  # the name parameter should be added to the request.
  params = {
      'command' => 'listIsos',
      'isoFilter' => 'executable'
  }
  json = send_request(params)

  isos = json['iso']
  if !isos then
    return nil
  end

  isos.each { |t|
    if t['name'] == name then
      return t
    end
  }

  nil
end

#list_isos(args = {}) ⇒ Object

Lists all isos that match the specified filter.

Allowable filter values are:

  • featured - isos that are featured and are public

  • self - isos that have been registered/created by the owner

  • self-executable - isos that have been registered/created by the owner that can be used to deploy a new VM

  • executable - all isos that can be used to deploy a new VM

  • community - isos that are public



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cloudstack_client/commands/iso.rb', line 16

def list_isos(args = {})
  filter = args[:filter] || 'featured'
  params = {
      'command' => 'listIsos',
      'isofilter' => filter
  }
  params['projectid'] = args[:project_id] if args[:project_id]
  params['zoneid'] = args[:zone_id] if args[:zone_id]
  if args[:listall]
    params['listall'] = true
    params['isrecursive'] = true
  end
  
  json = send_request(params)
  json['iso'] || []
end