Class: Chef::Provisioning::MachineSpec

Inherits:
ManagedEntry show all
Defined in:
lib/chef/provisioning/machine_spec.rb

Overview

Specification for a machine. Sufficient information to find and contact it after it has been set up.

Instance Attribute Summary

Attributes inherited from ManagedEntry

#data, #managed_entry_store, #name, #resource_type

Instance Method Summary collapse

Methods inherited from ManagedEntry

#delete, #delete_data, #driver_url, #driver_url=, #get_data, #id, #identifier, #save, #save_data

Constructor Details

#initialize(*args) ⇒ MachineSpec

Returns a new instance of MachineSpec.



10
11
12
13
14
15
16
17
# File 'lib/chef/provisioning/machine_spec.rb', line 10

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

Instance Method Details

#attrsObject



21
22
23
24
# File 'lib/chef/provisioning/machine_spec.rb', line 21

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

#from_imageObject



50
51
52
# File 'lib/chef/provisioning/machine_spec.rb', line 50

def from_image
  attrs['from_image']
end

#from_image=(value) ⇒ Object



53
54
55
# File 'lib/chef/provisioning/machine_spec.rb', line 53

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

#referenceObject Also known as: location

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.



35
36
37
# File 'lib/chef/provisioning/machine_spec.rb', line 35

def reference
  attrs['reference'] || attrs['location']
end

#reference=(value) ⇒ Object Also known as: location=

Set the location for this machine.



42
43
44
45
# File 'lib/chef/provisioning/machine_spec.rb', line 42

def reference=(value)
  attrs.delete('location')
  attrs['reference'] = value
end