Class: GCE::Host::GCEClient

Inherits:
Object
  • Object
show all
Defined in:
lib/gce/host/gce_client.rb

Defined Under Namespace

Classes: Error, NotFound

Instance Method Summary collapse

Instance Method Details

#instances(condition = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gce/host/gce_client.rb', line 10

def instances(condition = {})
  filter = build_filter(condition)
  instances = []
  res = client.list_aggregated_instances(Config.project, filter: filter)
  instances.concat(res.items.values.map(&:instances).compact.flatten(1))
  while res.next_page_token
    res = client.list_aggregated_instances(Config.project, filter: filter, page_token: res.next_page_token)
    instances.concat(res.items.values.map(&:instances).compact.flatten(1))
  end
  instances
end