Class: ChefMetal::MachineSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_metal/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.



7
8
9
# File 'lib/chef_metal/machine_spec.rb', line 7

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



11
12
13
# File 'lib/chef_metal/machine_spec.rb', line 11

def node
  @node
end

Instance Method Details

#driver_urlObject

URL to the driver. Convenience for location



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

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.



17
18
19
# File 'lib/chef_metal/machine_spec.rb', line 17

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-metal will do its darnedest to not lose this information.



37
38
39
# File 'lib/chef_metal/machine_spec.rb', line 37

def location
  metal_attr('location')
end

#location=(value) ⇒ Object

Set the location for this machine.



44
45
46
# File 'lib/chef_metal/machine_spec.rb', line 44

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

#nameObject

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



24
25
26
# File 'lib/chef_metal/machine_spec.rb', line 24

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.



58
59
60
# File 'lib/chef_metal/machine_spec.rb', line 58

def save(action_handler)
  raise "save unimplemented"
end