Sha256: 4b479e5c3cdc831451559d854e014fa232011ce56522af76f5fe3ff6e9fe8ad8

Contents?: true

Size: 1.78 KB

Versions: 8

Compression:

Stored size: 1.78 KB

Contents

module Brightbox
  class DetailedServer < Server
    def to_row
      row_attributes = attributes

      row_attributes[:compatibility_mode] = row_attributes["compatibility_mode"]

      if server_type
        row_attributes[:type] = server_type['id']
        row_attributes[:type_handle] = server_type['handle']
        row_attributes[:type_name] = server_type['name']
        row_attributes[:ram] = server_type['ram']
        row_attributes[:cores] = server_type['cores']
        row_attributes[:disk] = server_type['disk_size'].to_i
      end

      if image
        row_attributes[:image_name] = image.name
        row_attributes[:arch] = image.arch
      end

      row_attributes[:private_ips] = interfaces.map { |i| i['ipv4_address'] }.join(", ")
      row_attributes[:ipv6_address] = interfaces.map { |i| i['ipv6_address'] }.join(", ")

      row_attributes[:cloud_ip_ids] = cloud_ips.map { |i| i['id'] }.join(", ")
      row_attributes[:cloud_ips] = cloud_ips.map { |i| i['public_ip'] }.join(", ")
      row_attributes[:snapshots] = snapshots.map { |i| i['id'] }.join(", ")

      if server_groups
        row_attributes[:server_groups] = server_groups.map { |sg| sg['id'] }.join(", ")
      end

      row_attributes
    end

    def self.default_field_order
      [
        :id,
        :status,
        :locked,
        :name,
        :created_at,
        :deleted_at,
        :zone,
        :type,
        :type_name,
        :type_handle,
        :ram,
        :cores,
        :disk,
        :compatibility_mode,
        :image,
        :image_name,
        :arch,
        :private_ips,
        :cloud_ips,
        :ipv6_address,
        :cloud_ip_ids,
        :hostname,
        :fqdn,
        :public_hostname,
        :ipv6_hostname,
        :snapshots,
        :server_groups
      ]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
brightbox-cli-2.7.1 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.7.0 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.6.0 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.5.0 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.4.1 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.4.0 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.3.4 lib/brightbox-cli/detailed_server.rb
brightbox-cli-2.3.3 lib/brightbox-cli/detailed_server.rb