Class: VagrantPlugins::Fabric::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-fabric/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-fabric/config.rb', line 13

def initialize
  @fabfile_path = UNSET_VALUE
  @fabric_path = UNSET_VALUE
  @python_path = UNSET_VALUE
  @tasks = UNSET_VALUE
  @remote = UNSET_VALUE
  @remote_install = UNSET_VALUE
  @remote_password = UNSET_VALUE
  @remote_current_dir = UNSET_VALUE
end

Instance Attribute Details

#fabfile_pathObject

Returns the value of attribute fabfile_path.



4
5
6
# File 'lib/vagrant-fabric/config.rb', line 4

def fabfile_path
  @fabfile_path
end

#fabric_pathObject

Returns the value of attribute fabric_path.



5
6
7
# File 'lib/vagrant-fabric/config.rb', line 5

def fabric_path
  @fabric_path
end

#python_pathObject

Returns the value of attribute python_path.



6
7
8
# File 'lib/vagrant-fabric/config.rb', line 6

def python_path
  @python_path
end

#remoteObject

Returns the value of attribute remote.



8
9
10
# File 'lib/vagrant-fabric/config.rb', line 8

def remote
  @remote
end

#remote_current_dirObject

Returns the value of attribute remote_current_dir.



11
12
13
# File 'lib/vagrant-fabric/config.rb', line 11

def remote_current_dir
  @remote_current_dir
end

#remote_installObject

Returns the value of attribute remote_install.



9
10
11
# File 'lib/vagrant-fabric/config.rb', line 9

def remote_install
  @remote_install
end

#remote_passwordObject

Returns the value of attribute remote_password.



10
11
12
# File 'lib/vagrant-fabric/config.rb', line 10

def remote_password
  @remote_password
end

#tasksObject

Returns the value of attribute tasks.



7
8
9
# File 'lib/vagrant-fabric/config.rb', line 7

def tasks
  @tasks
end

Instance Method Details

#execute(command) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-fabric/config.rb', line 35

def execute(command)
  output = ''
  begin
    IO.popen(command, "w+") do |f|
      f.close_write
      output = f.read
    end
    output
  rescue Errno::ENOENT
    false
  end
end

#finalize!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-fabric/config.rb', line 24

def finalize!
  @fabfile_path = "fabfile.py" if @fabfile_path == UNSET_VALUE
  @fabric_path = "fab" if @fabric_path == UNSET_VALUE
  @python_path = "python" if @python_path == UNSET_VALUE
  @tasks = [] if @tasks == UNSET_VALUE
  @remote = false if @remote == UNSET_VALUE
  @remote_install = false if @remote_install == UNSET_VALUE
  @remote_password = "vagrant" if @remote_password == UNSET_VALUE
  @remote_current_dir = "." if @remote_current_dir == UNSET_VALUE
end

#install_fabricObject



75
76
# File 'lib/vagrant-fabric/config.rb', line 75

def install_fabric()
end

#validate(env) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vagrant-fabric/config.rb', line 48

def validate(env)
  if not @remote == true
    errors = _detected_errors

    errors << "fabfile does not exist." if not File.exist?(fabfile_path)

    install_fabric if @remote == true and @install == true

    command = "#{fabric_path} -V"
    output = execute(command)
    errors << "fabric command does not exist." if not output

    command = "#{fabric_path} -f #{fabfile_path} -l"
    output = execute(command)
    errors << "#{fabfile_path} could not recognize by fabric." if not $?.success?

    for task in tasks
      task = task.split(':').first
      command = "#{fabric_path} -f #{fabfile_path} -d #{task}"
      output = execute(command)
      errors << "#{task} task does not exist." if not $?.success?
    end

    {"fabric provisioner" => errors}
  end
end