Class: VagrantPlugins::Blockwart::BwManage

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-blockwart/bwmanage.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ BwManage

Returns a new instance of BwManage.



5
6
7
# File 'lib/vagrant-blockwart/bwmanage.rb', line 5

def initialize(repo_path)
	@repo_path = repo_path
end

Instance Method Details

#apply(node, interactive = false) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/vagrant-blockwart/bwmanage.rb', line 32

def apply(node, interactive=false)
	node = node.gsub(/[^a-zA-Z0-9\-\_\.]/,'')
	if interactive
		return bw_cli("apply #{node} -i", ret_stdout=false)
	else
		return bw_cli("apply #{node}", ret_stdout=false)
	end
end

#bw_cli(params, ret_stdout = true) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vagrant-blockwart/bwmanage.rb', line 9

def bw_cli(params, ret_stdout=true)
	params = params.gsub(/[^a-zA-Z0-9\-\_\.\s]/,'')
	old_path = Dir.pwd
	Dir.chdir(@repo_path)
	if ret_stdout
		result = `bw #{params}`
	else
		result = system("bw #{params}")
	end
	Dir.chdir(old_path)
	return result
end

#node_hostsObject



27
28
29
30
# File 'lib/vagrant-blockwart/bwmanage.rb', line 27

def node_hosts()
	nodes = bw_cli("nodes --hostnames")
	return nodes.split("\n")
end

#nodesObject



22
23
24
25
# File 'lib/vagrant-blockwart/bwmanage.rb', line 22

def nodes()
	nodes = bw_cli("nodes")
	return nodes.split("\n")
end