Module: CloudstackClient::Snapshot

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

Instance Method Summary collapse

Instance Method Details

#list_snapshots(args = {}) ⇒ Object

Lists snapshots.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cloudstack_client/commands/snapshot.rb', line 8

def list_snapshots(args = {})
  params = {
    'command' => 'listSnapshots',
    'isrecursive' => 'true'
  }
  params['name'] = args[:name] if args[:name]

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

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

  if args[:account]
     = list_accounts({name: args[:account]}).first
    unless 
      puts "Error: Account #{args[:account]} not found."
      exit 1
    end
    params['domainid'] = ["domainid"]
    params['account'] = args[:account]
  end

  params['listall'] = args[:listall] if args[:listall]

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