class Chef::Provisioning::ManagedEntry
Specification for a managed thing. Remembers where it was stored, and lets you stuff reference data in it.
Attributes
Public Class Methods
# 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
Public Instance Methods
# File lib/chef/provisioning/managed_entry.rb, line 20 def attrs data end
# 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 the given data
@param resource_type
[Symbol] The type of thing to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the thing to delete
@return [Boolean] Whether anything was deleted or not.
# File lib/chef/provisioning/managed_entry.rb, line 112 def delete_data(resource_type, name, action_handler) raise NotImplementedError, :delete_data end
URL to the driver.
# File lib/chef/provisioning/managed_entry.rb, line 56 def driver_url attrs['driver_url'] || (reference ? reference['driver_url'] : nil) end
# File lib/chef/provisioning/managed_entry.rb, line 59 def driver_url=(value) attrs['driver_url'] = value end
Get the given data
@param resource_type
[Symbol] The type of thing to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the thing to retrieve
@return [Hash,Array] The data, or `nil` if the data does not exist. Will be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
# File lib/chef/provisioning/managed_entry.rb, line 89 def get_data(resource_type, name) raise NotImplementedError, :delete_data end
Globally unique identifier for this machine. Does not depend on the machine's reference or existence.
# File lib/chef/provisioning/managed_entry.rb, line 28 def id managed_entry_store.identifier(resource_type, name) end
# File lib/chef/provisioning/managed_entry.rb, line 116 def identifier(resource_type, name) raise NotImplementedError, :identifier end
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.
# 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
Set the reference for this machine.
# File lib/chef/provisioning/managed_entry.rb, line 51 def reference=(value) self.attrs['reference'] = value end
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.
# 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 the given data
@param resource_type
[Symbol] The type of thing to save (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet …) @param name [String] The unique identifier of the thing to save @param data [Hash,Array] The data to save. Must be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
# File lib/chef/provisioning/managed_entry.rb, line 100 def save_data(resource_type, name, data, action_handler) raise NotImplementedError, :delete_data end