Sha256: 24ac91e18aa9d66cf814a19e4d65edbb70e33cd691afb0bf9ed791e67b7181f2

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'rancher/api/models/machine/driver_config'

module Rancher
  module Api
    class Machine
      include Her::Model
      include Helpers::Model

      DIGITAL_OCEAN = 'digitalocean'.freeze
      VMWARE_VSPHERE = 'vmwarevsphere'.freeze

      attributes :name, :state, :amazonec2Config, :azureConfig, :description,
                 :digitaloceanConfig, :driver, :exoscaleConfig, :externalId,
                 :labels, :openstackConfig, :packetConfig, :rackspaceConfig,
                 :removed, :softlayerConfig, :virtualboxConfig,
                 :vmwarevcloudairConfig, :vmwarevsphereConfig

      has_many :hosts

      class << self
        def transitioning
          all.select { |m| m.transitioning.eql?('yes') }
        end

        def active
          where(state: 'active')
        end
      end

      def driver_config
        case driver
        when DIGITAL_OCEAN, VMWARE_VSPHERE
          DriverConfig.new(attributes["#{driver}Config"])
        end
      end

      def driver_config=(dc)
        case driver
        when DIGITAL_OCEAN, VMWARE_VSPHERE
          attributes["#{driver}Config"] = dc.attributes
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rancher-api-0.7.0 lib/rancher/api/models/machine.rb
rancher-api-0.5.2 lib/rancher/api/models/machine.rb
rancher-api-0.5.1 lib/rancher/api/models/machine.rb
rancher-api-0.5.0 lib/rancher/api/models/machine.rb