File: instance_group_manager.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (51 lines) | stat: -rw-r--r-- 1,799 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
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
48
49
50
51
module Fog
  module Compute
    class Google
      class InstanceGroupManager < Fog::Model
        identity :name

        attribute :kind
        attribute :self_link, :aliases => "selfLink"
        attribute :description
        attribute :zone
        attribute :region
        attribute :instance_group, :aliases => "instanceGroup"
        attribute :instance_template, :aliases => "instanceTemplate"
        attribute :target_pools, :aliases => "targetPools"
        attribute :base_instance_name, :aliases => "baseInstanceName"
        attribute :current_actions, :aliases => "currentActions"
        attribute :target_size, :aliases => "targetSize"
        attribute :named_ports, :aliases => "namedPorts"

        def save
          requires :name, :zone, :base_instance_name, :target_size, :instance_template

          data = service.insert_instance_group_manager(name, zone.split("/")[-1], instance_template, base_instance_name,
          target_size, target_pools, named_ports, description)
          operation = Fog::Compute::Google::Operations.new(:service => service).get(data.name, zone.split("/")[-1])
          operation.wait_for { ready? }
          reload
        end

        def destroy(async = true)
          requires :name, :zone
          operation = service.delete_instance_group_manager(name, zone.split("/")[-1])
          operation.wait_for { ready? } unless async
          operation
        end

        def set_instance_template(instance_template)
          service.set_instance_template self, instance_template
        end

        def recreate_instances(instances)
          service.recreate_instances self, instances
        end

        def abandon_instances(instances)
          service.abandon_instances self, instances
        end
      end
    end
  end
end