Module: Vagrant::MachineIndex::Entry::Remote::InstanceMethods

Defined in:
lib/vagrant/machine_index/remote.rb

Instance Method Summary collapse

Instance Method Details

#initialize(id, raw = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vagrant/machine_index/remote.rb', line 25

def initialize(id, raw=nil)
  @logger = Log4r::Logger.new("vagrant::machine_index::entry")

  @extra_data = {}
  @id = id
  # Do nothing if we aren't given a raw value. Otherwise, parse it.
  return if !raw

  @local_data_path  = raw["local_data_path"]
  @name             = raw["name"]
  @provider         = raw["provider"]
  @state            = raw["state"]
  @full_state       = raw["full_state"]
  @vagrantfile_name = raw["vagrantfile_name"]
  @vagrantfile_path = raw["vagrantfile_path"]
  # TODO(mitchellh): parse into a proper datetime
  @updated_at       = raw["updated_at"]
  @extra_data       = raw["extra_data"] || {}

  @machine_client = raw["machine"]

  # Be careful with the paths
  @local_data_path = nil  if @local_data_path == ""
  @vagrantfile_path = nil if @vagrantfile_path == ""

  # Convert to proper types
  @local_data_path = Pathname.new(@local_data_path) if @local_data_path
  @vagrantfile_path = Pathname.new(@vagrantfile_path) if @vagrantfile_path
end

#vagrant_env(home_path, opts = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vagrant/machine_index/remote.rb', line 55

def vagrant_env(home_path, opts={})
  Vagrant::Util::SilenceWarnings.silence! do
    Environment.new({
      cwd: @vagrantfile_path,
      home_path: home_path,
      local_data_path: @local_data_path,
      vagrantfile_name: @vagrantfile_name,
      client: @machine_client&.project,
    }.merge(opts))
  end
end

#valid?(home_path) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
# File 'lib/vagrant/machine_index/remote.rb', line 67

def valid?(home_path)
  # Always return true
  true
end