Driver#name -> Driver#container_name
This commit is contained in:
parent
ee9bfa4189
commit
ed552b6af0
2 changed files with 12 additions and 12 deletions
|
@ -14,20 +14,20 @@ module Vagrant
|
||||||
# a name.
|
# a name.
|
||||||
class ContainerNotFound < StandardError; end
|
class ContainerNotFound < StandardError; end
|
||||||
|
|
||||||
attr_reader :name
|
attr_reader :container_name
|
||||||
|
|
||||||
def initialize(name, cli = CLI.new(name))
|
def initialize(container_name, cli = CLI.new(container_name))
|
||||||
@name = name
|
@container_name = container_name
|
||||||
@cli = cli
|
@cli = cli
|
||||||
@logger = Log4r::Logger.new("vagrant::provider::lxc::driver")
|
@logger = Log4r::Logger.new("vagrant::provider::lxc::driver")
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate!
|
def validate!
|
||||||
raise ContainerNotFound if @name && ! @cli.list.include?(@name)
|
raise ContainerNotFound if @container_name && ! @cli.list.include?(@container_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_path
|
def base_path
|
||||||
Pathname.new("#{CONTAINERS_PATH}/#{@name}")
|
Pathname.new("#{CONTAINERS_PATH}/#{@container_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def rootfs_path
|
def rootfs_path
|
||||||
|
@ -35,7 +35,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(name, template_path, template_options = {})
|
def create(name, template_path, template_options = {})
|
||||||
@cli.name = @name = name
|
@cli.name = @container_name = name
|
||||||
|
|
||||||
import_template(template_path) do |template_name|
|
import_template(template_path) do |template_name|
|
||||||
@logger.debug "Creating container..."
|
@logger.debug "Creating container..."
|
||||||
|
@ -102,7 +102,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def state
|
def state
|
||||||
if @name
|
if @container_name
|
||||||
@cli.state
|
@cli.state
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -134,7 +134,7 @@ module Vagrant
|
||||||
CONTAINERS_PATH = '/var/lib/lxc'
|
CONTAINERS_PATH = '/var/lib/lxc'
|
||||||
|
|
||||||
def base_path
|
def base_path
|
||||||
Pathname.new("#{CONTAINERS_PATH}/#{@name}")
|
Pathname.new("#{CONTAINERS_PATH}/#{@container_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def rootfs_path
|
def rootfs_path
|
||||||
|
@ -142,7 +142,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_template(path)
|
def import_template(path)
|
||||||
template_name = "vagrant-tmp-#{@name}"
|
template_name = "vagrant-tmp-#{@container_name}"
|
||||||
tmp_template_path = LXC_TEMPLATES_PATH.join("lxc-#{template_name}").to_s
|
tmp_template_path = LXC_TEMPLATES_PATH.join("lxc-#{template_name}").to_s
|
||||||
|
|
||||||
@logger.debug 'Copying LXC template into place'
|
@logger.debug 'Copying LXC template into place'
|
||||||
|
|
|
@ -58,7 +58,7 @@ module Vagrant
|
||||||
|
|
||||||
def state
|
def state
|
||||||
state_id = nil
|
state_id = nil
|
||||||
state_id = :not_created if !@driver.name
|
state_id = :not_created if !@driver.container_name
|
||||||
state_id = @driver.state if !state_id
|
state_id = @driver.state if !state_id
|
||||||
state_id = :unknown if !state_id
|
state_id = :unknown if !state_id
|
||||||
LXC::MachineState.new(state_id)
|
LXC::MachineState.new(state_id)
|
||||||
|
|
Loading…
Reference in a new issue