File: insert_instance_group.rb

package info (click to toggle)
ruby-fog-google 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,568 kB
  • sloc: ruby: 16,711; sh: 40; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download
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
module Fog
  module Compute
    class Google
      class Mock
        def insert_instance_group(_group_name, _zone, _options = {})
          # :no-coverage:
          Fog::Mock.not_implemented
          # :no-coverage:
        end
      end

      class Real
        def insert_instance_group(group_name, zone, options = {})
          if options["network"]
            network_name = last_url_segment(options["network"])
          else
            network_name = GOOGLE_COMPUTE_DEFAULT_NETWORK
          end

          instance_group = ::Google::Apis::ComputeV1::InstanceGroup.new(
            :description => options["description"],
            :name => group_name,
            :network => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/networks/#{network_name}"
          )

          @compute.insert_instance_group(@project,
                                         last_url_segment(zone),
                                         instance_group)
        end

        def last_url_segment(network)
          network.split("/")[-1]
        end
      end
    end
  end
end