Module: CloudstackClient::DiskOffering

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

Instance Method Summary collapse

Instance Method Details

#get_disk_offering(name) ⇒ Object

Get disk offering by name.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cloudstack_client/commands/disk_offering.rb', line 24

def get_disk_offering(name)

  # TODO: use name parameter
  # listServiceOfferings 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' => 'listDiskOfferings'
  }
  json = send_request(params)

  services = json['diskoffering']
  return nil unless services

  services.each { |s|
    if s['name'] == name then
      return s
    end
  }
  nil
end

#list_disk_offerings(domain = nil) ⇒ Object

Lists all available disk offerings.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudstack_client/commands/disk_offering.rb', line 8

def list_disk_offerings(domain = nil)
  params = {
      'command' => 'listDiskOfferings'
  }

  if domain
    params['domainid'] = list_domains(domain).first["id"]
  end

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