Class: ChefMetal::ImageSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_metal/image_spec.rb

Overview

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

Direct Known Subclasses

ChefImageSpec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_data) ⇒ ImageSpec

Returns a new instance of ImageSpec.



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

def initialize(image_data)
  @image_data = image_data
end

Instance Attribute Details

#image_dataObject (readonly)

Returns the value of attribute image_data.



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

def image_data
  @image_data
end

Instance Method Details

#driver_urlObject

URL to the driver. Convenience for location



57
58
59
# File 'lib/chef_metal/image_spec.rb', line 57

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

#idObject

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



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

def id
  raise "id unimplemented"
end

#locationObject

Location of this image. This should be a freeform hash, with enough information for the driver to look it up and create a image 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/image_spec.rb', line 37

def location
  image_data['location']
end

#location=(value) ⇒ Object

Set the location for this image.



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

def location=(value)
  image_data['location'] = value
end

#machine_optionsObject



48
49
50
# File 'lib/chef_metal/image_spec.rb', line 48

def machine_options
  image_data['machine_options']
end

#machine_options=(value) ⇒ Object



52
53
54
# File 'lib/chef_metal/image_spec.rb', line 52

def machine_options=(value)
  image_data['machine_options'] = value
end

#nameObject

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



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

def name
  image_data['id']
end

#save(action_handler) ⇒ Object

Save this image_data to the server. If you have significant information that could be lost, you should do this as quickly as possible. image_data will be saved automatically for you after allocate_image and ready_image.



66
67
68
# File 'lib/chef_metal/image_spec.rb', line 66

def save(action_handler)
  raise "save unimplemented"
end