Sha256: 13aff4ca4259308d47fefd6e23dbe3edf60809d9fb23399ce2b37e02e6a155c8

Contents?: true

Size: 1.4 KB

Versions: 39

Compression:

Stored size: 1.4 KB

Contents

require 'chef/provisioning/managed_entry'

class Chef
module Provisioning
  #
  # Specification for a machine. Sufficient information to find and contact it
  # after it has been set up.
  #
  class MachineSpec < ManagedEntry
    def initialize(*args)
      super
      data['name'] ||= name
      # Upgrade from metal to chef_provisioning ASAP.
      if data['normal'] && !data['normal']['chef_provisioning'] && data['normal']['metal']
        data['normal']['chef_provisioning'] = data['normal'].delete('metal')
      end
    end

    alias :node :data

    def attrs
      data['normal'] ||= {}
      data['normal']['chef_provisioning'] ||= {}
    end

    #
    # Location of this machine. This should be a freeform hash, with enough
    # information for the driver to look it up and create a Machine object to
    # access it.
    #
    # This MUST include a 'driver_url' attribute with the driver's URL in it.
    #
    # chef-provisioning will do its darnedest to not lose this information.
    #
    def reference
      attrs['reference'] || attrs['location']
    end

    #
    # Set the location for this machine.
    #
    def reference=(value)
      attrs.delete('location')
      attrs['reference'] = value
    end

    alias :location :reference
    alias :location= :reference=

    def from_image
      attrs['from_image']
    end
    def from_image=(value)
      attrs['from_image'] = value
    end
  end
end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
chef-provisioning-2.7.6 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.7.4 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.7.2 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.7.1 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.7.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.6.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.5.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.4.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.3.2 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.3.1 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.3.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.2.1 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.2.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.1.1 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.1.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.0.2 lib/chef/provisioning/machine_spec.rb
chef-provisioning-2.0.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-1.9.1 lib/chef/provisioning/machine_spec.rb
chef-provisioning-1.9.0 lib/chef/provisioning/machine_spec.rb
chef-provisioning-1.8.1 lib/chef/provisioning/machine_spec.rb