Module: Vagrant::MachineIndex::Remote
- Defined in:
- lib/vagrant/machine_index/remote.rb
Overview
This module enables the MachineIndex for server mode
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
-
.prepended(klass) ⇒ Object
Add an attribute reader for the client when applied to the MachineIndex class.
Instance Method Summary collapse
-
#delete(uuid) ⇒ Boolean
Deletes a machine by identifier.
-
#each(reload = true, &block) ⇒ Object
Iterate over every machine in the index.
-
#get(uuid) ⇒ MachineIndex::Entry
Accesses a machine by identifier.
-
#include?(uuid) ⇒ Boolean
Tests if the index has the given identifier.
-
#initialize(*args, **opts) ⇒ Object
Initializes a MachineIndex.
- #recover(entry) ⇒ Object
- #release(*_) ⇒ Object
-
#set(entry) ⇒ Entry
Creates/updates an entry object and returns the resulting entry.
- #to_proto ⇒ Object
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
78 79 80 |
# File 'lib/vagrant/machine_index/remote.rb', line 78 def client @client end |
Class Method Details
.prepended(klass) ⇒ Object
Add an attribute reader for the client when applied to the MachineIndex class
82 83 84 85 86 |
# File 'lib/vagrant/machine_index/remote.rb', line 82 def self.prepended(klass) klass.class_eval do attr_reader :client end end |
Instance Method Details
#delete(uuid) ⇒ Boolean
Deletes a machine by identifier.
103 104 105 106 |
# File 'lib/vagrant/machine_index/remote.rb', line 103 def delete(uuid) @machines.delete(uuid) client.delete(uuid) end |
#each(reload = true, &block) ⇒ Object
Iterate over every machine in the index
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/vagrant/machine_index/remote.rb', line 142 def each(reload=true, &block) if reload client.all.each do |m| @machines[m.id] = m end end @logger.debug("machines: #{@machines.keys}") @machines.each_value(&block) end |
#get(uuid) ⇒ MachineIndex::Entry
Accesses a machine by identifier.
112 113 114 |
# File 'lib/vagrant/machine_index/remote.rb', line 112 def get(uuid) client.get(uuid) end |
#include?(uuid) ⇒ Boolean
Tests if the index has the given identifier.
120 121 122 |
# File 'lib/vagrant/machine_index/remote.rb', line 120 def include?(uuid) client.include?(uuid) end |
#initialize(*args, **opts) ⇒ Object
Initializes a MachineIndex
89 90 91 92 93 94 95 96 97 |
# File 'lib/vagrant/machine_index/remote.rb', line 89 def initialize(*args, **opts) @logger = Log4r::Logger.new("vagrant::machine_index") @client = opts[:client] if @client.nil? raise ArgumentError, "Remote client is required for `#{self.class.name}'" end @machines = {} end |
#recover(entry) ⇒ Object
137 138 139 |
# File 'lib/vagrant/machine_index/remote.rb', line 137 def recover(entry) #no-op end |
#release(*_) ⇒ Object
124 125 126 |
# File 'lib/vagrant/machine_index/remote.rb', line 124 def release(*_) #no-op end |
#set(entry) ⇒ Entry
Creates/updates an entry object and returns the resulting entry.
132 133 134 135 |
# File 'lib/vagrant/machine_index/remote.rb', line 132 def set(entry) entry_new = client.set(entry) @machines[entry.id] = entry_new end |
#to_proto ⇒ Object
153 154 155 |
# File 'lib/vagrant/machine_index/remote.rb', line 153 def to_proto client.proto end |