Sha256: 6d91b9a1b48f32dcc0d653d0be9399c7f378b477b15d23a4af4aa381c0690783

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 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

      collection_path 'projects/:project_id/machines'

      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

1 entries across 1 versions & 1 rubygems

Version Path
rancher-api-0.6.0 lib/rancher/api/models/machine.rb