Class: Chef::Provisioning::ManagedEntry
- Inherits:
-
Object
- Object
- Chef::Provisioning::ManagedEntry
- Defined in:
- lib/chef/provisioning/managed_entry.rb
Overview
Specification for a managed thing. Remembers where it was stored, and lets you stuff reference data in it.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#managed_entry_store ⇒ Object
readonly
Returns the value of attribute managed_entry_store.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
Instance Method Summary collapse
- #attrs ⇒ Object
- #delete(action_handler) ⇒ Object
-
#delete_data(resource_type, name, action_handler) ⇒ Boolean
Delete the given data.
-
#driver_url ⇒ Object
URL to the driver.
- #driver_url=(value) ⇒ Object
-
#get_data(resource_type, name) ⇒ Hash, Array
Get the given data.
-
#id ⇒ Object
Globally unique identifier for this machine.
- #identifier(resource_type, name) ⇒ Object
-
#initialize(managed_entry_store, resource_type, name, data = nil) ⇒ ManagedEntry
constructor
A new instance of ManagedEntry.
-
#reference ⇒ Object
Reference to this managed thing.
-
#reference=(value) ⇒ Object
Set the reference for this machine.
-
#save(action_handler) ⇒ Object
Save this node to the server.
-
#save_data(resource_type, name, data, action_handler) ⇒ Object
Save the given data.
Constructor Details
#initialize(managed_entry_store, resource_type, name, data = nil) ⇒ ManagedEntry
Returns a new instance of ManagedEntry.
8 9 10 11 12 13 |
# File 'lib/chef/provisioning/managed_entry.rb', line 8 def initialize(managed_entry_store, resource_type, name, data=nil) @managed_entry_store = managed_entry_store @resource_type = resource_type @name = name @data = data || {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
18 19 20 |
# File 'lib/chef/provisioning/managed_entry.rb', line 18 def data @data end |
#managed_entry_store ⇒ Object (readonly)
Returns the value of attribute managed_entry_store.
15 16 17 |
# File 'lib/chef/provisioning/managed_entry.rb', line 15 def managed_entry_store @managed_entry_store end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/chef/provisioning/managed_entry.rb', line 17 def name @name end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
16 17 18 |
# File 'lib/chef/provisioning/managed_entry.rb', line 16 def resource_type @resource_type end |
Instance Method Details
#attrs ⇒ Object
20 21 22 |
# File 'lib/chef/provisioning/managed_entry.rb', line 20 def attrs data end |
#delete(action_handler) ⇒ Object
72 73 74 |
# File 'lib/chef/provisioning/managed_entry.rb', line 72 def delete(action_handler) managed_entry_store.delete_data(resource_type, name, action_handler) end |
#delete_data(resource_type, name, action_handler) ⇒ Boolean
Delete the given data
112 113 114 |
# File 'lib/chef/provisioning/managed_entry.rb', line 112 def delete_data(resource_type, name, action_handler) raise NotImplementedError, :delete_data end |
#driver_url ⇒ Object
URL to the driver.
56 57 58 |
# File 'lib/chef/provisioning/managed_entry.rb', line 56 def driver_url attrs['driver_url'] || (reference ? reference['driver_url'] : nil) end |
#driver_url=(value) ⇒ Object
59 60 61 |
# File 'lib/chef/provisioning/managed_entry.rb', line 59 def driver_url=(value) attrs['driver_url'] = value end |
#get_data(resource_type, name) ⇒ Hash, Array
Get the given data
89 90 91 |
# File 'lib/chef/provisioning/managed_entry.rb', line 89 def get_data(resource_type, name) raise NotImplementedError, :delete_data end |
#id ⇒ Object
Globally unique identifier for this machine. Does not depend on the machine’s reference or existence.
28 29 30 |
# File 'lib/chef/provisioning/managed_entry.rb', line 28 def id managed_entry_store.identifier(resource_type, name) end |
#identifier(resource_type, name) ⇒ Object
116 117 118 |
# File 'lib/chef/provisioning/managed_entry.rb', line 116 def identifier(resource_type, name) raise NotImplementedError, :identifier end |
#reference ⇒ Object
Reference to this managed thing. 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.
41 42 43 44 45 46 |
# File 'lib/chef/provisioning/managed_entry.rb', line 41 def reference # Backcompat: old data bags didn't have the "reference" field. If we have # no reference field in the data, and the data bag is non-empty, return # the root of the data bag. attrs['reference'] || attrs['location'] || (attrs == {} ? nil : attrs) end |
#reference=(value) ⇒ Object
Set the reference for this machine.
51 52 53 |
# File 'lib/chef/provisioning/managed_entry.rb', line 51 def reference=(value) self.attrs['reference'] = value 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.
68 69 70 |
# File 'lib/chef/provisioning/managed_entry.rb', line 68 def save(action_handler) managed_entry_store.save_data(resource_type, name, data, action_handler) end |
#save_data(resource_type, name, data, action_handler) ⇒ Object
Save the given data
100 101 102 |
# File 'lib/chef/provisioning/managed_entry.rb', line 100 def save_data(resource_type, name, data, action_handler) raise NotImplementedError, :delete_data end |