class Bcome::Node::Server::Dynamic::Gcp

Public Class Methods

dynamic_server_type() click to toggle source
# File lib/objects/node/server/dynamic/gcp.rb, line 6
def dynamic_server_type
  :gcp
end
new_from_gcp_instance(gcp_instance, parent) click to toggle source
# File lib/objects/node/server/dynamic/gcp.rb, line 10
def new_from_gcp_instance(gcp_instance, parent)
  identifier = gcp_instance.name

  ## For now we support only the first network interface
  first_interface = gcp_instance.network_interfaces.first
  network_ip = first_interface.network_ip

  ## And we get the first access config (terraform uses the same pattern for accessing GCP machines also)
  first_access_config = first_interface.access_configs ? first_interface.access_configs.first : nil
  nat_ip = first_access_config ? first_access_config.nat_ip : nil

  params = {
    identifier: identifier,
    description: "GCP server - #{identifier}",
    internal_ip_address: network_ip,
    public_ip_address: nat_ip,
    gcp_server: gcp_instance
  }

  new(parent: parent, views: params)
end

Public Instance Methods

cloud_server() click to toggle source
# File lib/objects/node/server/dynamic/gcp.rb, line 42
def cloud_server
  views[:gcp_server]
end
do_generate_cloud_tags() click to toggle source
# File lib/objects/node/server/dynamic/gcp.rb, line 37
def do_generate_cloud_tags
  raw_labels = cloud_server.labels ? cloud_server.labels.deep_symbolize_keys : {}
  ::Bcome::Node::Meta::Cloud.new(raw_labels)
end
host() click to toggle source
# File lib/objects/node/server/dynamic/gcp.rb, line 33
def host
  'GCP'
end