Class: Fog::Compute::Google::InstanceGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/google/models/instance_group.rb

Instance Method Summary collapse

Instance Method Details

#add_instance(instance_id) ⇒ Object



36
37
38
# File 'lib/fog/compute/google/models/instance_group.rb', line 36

def add_instance(instance_id)
  add_instances [instance_id]
end

#add_instances(instances) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fog/compute/google/models/instance_group.rb', line 40

def add_instances(instances)
  requires :identity, :zone

  service.add_instance_group_instances(
    identity, zone_name, format_instance_list(instances)
  )
end

#destroy(_async = true) ⇒ Object



30
31
32
33
34
# File 'lib/fog/compute/google/models/instance_group.rb', line 30

def destroy(_async = true)
  requires :name, :zone

  service.delete_instance_group(name, zone_name)
end

#list_instancesObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/compute/google/models/instance_group.rb', line 56

def list_instances
  requires :identity, :zone

  instance_list = []
  data = service.list_instance_group_instances(identity, zone_name)
  if data.items
    data.items.each do |instance|
      instance_list << service.servers.get(instance.instance.split("/")[-1], zone_name)
    end
  end
  instance_list
end

#network_nameObject



73
74
75
# File 'lib/fog/compute/google/models/instance_group.rb', line 73

def network_name
  network.nil? ? nil : network.split("/")[-1]
end

#remove_instances(instances) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/fog/compute/google/models/instance_group.rb', line 48

def remove_instances(instances)
  requires :identity, :zone

  service.remove_instance_group_instances(
    identity, zone_name, format_instance_list(instances)
  )
end

#saveObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/compute/google/models/instance_group.rb', line 19

def save
  requires :name, :zone

  options = {
    "network" => network_name,
    "subnetwork" => subnetwork_name
  }

  service.insert_instance_group(name, zone, options)
end

#subnetwork_nameObject



77
78
79
# File 'lib/fog/compute/google/models/instance_group.rb', line 77

def subnetwork_name
  subnetwork.nil? ? nil : subnetwork.split("/")[-1]
end

#zone_nameObject



69
70
71
# File 'lib/fog/compute/google/models/instance_group.rb', line 69

def zone_name
  zone.nil? ? nil : zone.split("/")[-1]
end