Vagrant::Machine
This is the class that will represent a machine that is managed by Vagrant. The class has a number of attributes associated with it and is meant to be a single API for managing the machines.
This commit is contained in:
parent
3519bf0372
commit
353610021c
|
@ -76,6 +76,7 @@ module Vagrant
|
|||
autoload :Errors, 'vagrant/errors'
|
||||
autoload :Guest, 'vagrant/guest'
|
||||
autoload :Hosts, 'vagrant/hosts'
|
||||
autoload :Machine, 'vagrant/machine'
|
||||
autoload :Plugin, 'vagrant/plugin'
|
||||
autoload :SSH, 'vagrant/ssh'
|
||||
autoload :TestHelpers, 'vagrant/test_helpers'
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
require "log4r"
|
||||
|
||||
module Vagrant
|
||||
# This represents a machine that Vagrant manages. This provides a singular
|
||||
# API for querying the state and making state changes to the machine, which
|
||||
# is backed by any sort of provider (VirtualBox, VMWare, etc.).
|
||||
class Machine
|
||||
# The box that is backing this machine.
|
||||
#
|
||||
# @return [Box]
|
||||
attr_reader :box
|
||||
|
||||
# Configuration for the machine.
|
||||
#
|
||||
# @return [Object]
|
||||
attr_reader :config
|
||||
|
||||
# The environment that this machine is a part of.
|
||||
#
|
||||
# @return [Environment]
|
||||
attr_reader :env
|
||||
|
||||
# Name of the machine. This is assigned by the Vagrantfile.
|
||||
#
|
||||
# @return [String]
|
||||
attr_reader :name
|
||||
|
||||
# Initialize a new machine.
|
||||
#
|
||||
# @param [String] name Name of the virtual machine.
|
||||
# @param [Object] provider The provider backing this machine. This is
|
||||
# currently expected to be a V1 `provider` plugin.
|
||||
# @param [Object] config The configuration for this machine.
|
||||
# @param [Box] box The box that is backing this virtual machine.
|
||||
# @param [Environment] env The environment that this machine is a
|
||||
# part of.
|
||||
def initialize(name, provider, config, box, env)
|
||||
@name = name
|
||||
@config = config
|
||||
@box = box
|
||||
@env = env
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
require File.expand_path("../../base", __FILE__)
|
||||
|
||||
describe Vagrant::Machine do
|
||||
include_context "unit"
|
||||
|
||||
let(:name) { "foo" }
|
||||
let(:provider) { Object.new }
|
||||
let(:box) { Object.new }
|
||||
let(:config) { Object.new }
|
||||
let(:environment) { isolated_environment }
|
||||
|
||||
let(:instance) { described_class.new(name, provider, config, box, environment) }
|
||||
|
||||
describe "attributes" do
|
||||
it "should provide access to the name" do
|
||||
instance.name.should == name
|
||||
end
|
||||
|
||||
it "should provide access to the configuration" do
|
||||
instance.config.should eql(config)
|
||||
end
|
||||
|
||||
it "should provide access to the box" do
|
||||
instance.box.should eql(box)
|
||||
end
|
||||
|
||||
it "should provide access to the environment" do
|
||||
instance.env.should eql(environment)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue