module Vagrant::MachineIndex::Remote
This module enables the MachineIndex
for server mode
Attributes
client[RW]
Public Class Methods
new(*args, **opts)
click to toggle source
Initializes a MachineIndex
# File lib/vagrant/machine_index/remote.rb, line 86 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
prepended(klass)
click to toggle source
Add an attribute reader for the client when applied to the MachineIndex
class
# File lib/vagrant/machine_index/remote.rb, line 79 def self.prepended(klass) klass.class_eval do attr_reader :client end end
Public Instance Methods
delete(uuid)
click to toggle source
Deletes a machine by identifier.
@param [String] uuid Target identifier @return [Boolean] true if delete is successful
# File lib/vagrant/machine_index/remote.rb, line 100 def delete(uuid) @machines.delete(uuid) client.delete(uuid) end
each(reload=true, &block)
click to toggle source
Iterate over every machine in the index
# File lib/vagrant/machine_index/remote.rb, line 139 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)
click to toggle source
Accesses a machine by identifier.
@param [String] uuid Target identifier @return [MachineIndex::Entry]
# File lib/vagrant/machine_index/remote.rb, line 109 def get(uuid) client.get(uuid) end
include?(uuid)
click to toggle source
Tests if the index has the given identifier.
@param [String] ident Target identifier @return [Boolean]
# File lib/vagrant/machine_index/remote.rb, line 117 def include?(uuid) client.include?(uuid) end
recover(entry)
click to toggle source
# File lib/vagrant/machine_index/remote.rb, line 134 def recover(entry) #no-op end
release(*_)
click to toggle source
# File lib/vagrant/machine_index/remote.rb, line 121 def release(*_) #no-op end
set(entry)
click to toggle source
Creates/updates an entry object and returns the resulting entry.
@param [Entry] entry @return [Entry]
# File lib/vagrant/machine_index/remote.rb, line 129 def set(entry) entry_new = client.set(entry) @machines[entry.id] = entry_new end
to_proto()
click to toggle source
# File lib/vagrant/machine_index/remote.rb, line 150 def to_proto client.proto end