Class: Chef::Provisioning::MachineSpec

Inherits:
Object
  • Object
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.

Direct Known Subclasses

ChefMachineSpec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ MachineSpec

Returns a new instance of MachineSpec.



8
9
10
11
12
13
14
# File 'lib/chef/provisioning/machine_spec.rb', line 8

def initialize(node)
  @node = node
  # Upgrade from metal to chef_provisioning ASAP.
  if node['normal'] && !node['normal']['chef_provisioning'] && node['normal']['metal']
    node['normal']['chef_provisioning'] = node['normal'].delete('metal')
  end
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



16
17
18
# File 'lib/chef/provisioning/machine_spec.rb', line 16

def node
  @node
end

Instance Method Details

#driver_urlObject

URL to the driver. Convenience for location



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

def driver_url
  location ? location['driver_url'] : nil
end

#idObject

Globally unique identifier for this machine. Does not depend on the machine’s location or existence.



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

def id
  raise "id unimplemented"
end

#locationObject

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.



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

def location
  chef_provisioning_attr('location')
end

#location=(value) ⇒ Object

Set the location for this machine.



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

def location=(value)
  set_chef_provisioning_attr('location', value)
end

#nameObject

Name of the machine. Corresponds to the name in “machine ‘name’ do” …



29
30
31
# File 'lib/chef/provisioning/machine_spec.rb', line 29

def name
  node['name']
end

#save(action_handler) ⇒ Object

Save this node to the server. If you have significant information that could be lost, you should do this as quickly as possible. Data will be saved automatically for you after allocate_machine and ready_machine.



63
64
65
# File 'lib/chef/provisioning/machine_spec.rb', line 63

def save(action_handler)
  raise "save unimplemented"
end