Sha256: 017fd8e5dfd2d746da65b292aa9a3aaf09f16f53dc00df7d7ac1cde27abfe513

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module FogExtensions
  module DigitalOcean
    module Server
      extend ActiveSupport::Concern

      attr_accessor :image_id

      def identity_to_s
        identity.to_s
      end

      def vm_description
        flavor.try(:name)
      end

      def flavor
        requires :flavor_id
        @flavor ||= service.flavors.get(flavor_id.to_i)
      end

      def flavor_name
        requires :flavor
        @flavor_name ||= @flavor.try(:name)
      end

      def image
        requires :image_id
        @image ||= service.images.get(image_id.to_i)
      end

      def image_name
        @image_name ||= @image.try(:name)
      end

      def region
        requires :region_id
        @region ||= service.regions.get(region_id.to_i)
      end

      def region_name
        requires :region
        @region_name ||= @region.try(:name)
      end

      def ip_addresses
        [ipv4_address, ipv6_address].flatten.select(&:present?)
      end

      def state
        requires :status
        @state ||= status
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_digitalocean-1.2.0 app/models/concerns/fog_extensions/digitalocean/server.rb