Class: DEIS::Base

Inherits:
Object
  • Object
show all
Includes:
Thor::Shell
Defined in:
lib/rdeis/base.rb

Direct Known Subclasses

Bootstrap, Storage, Upgrade

Constant Summary collapse

YES =
"\u2713"
NO =
"\u274C"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def cluster
  @cluster
end

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def environment
  @environment
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def output
  @output
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def path
  @path
end

#proxyObject

Returns the value of attribute proxy.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def proxy
  @proxy
end

#sshObject

Returns the value of attribute ssh.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def ssh
  @ssh
end

#verboseObject

Returns the value of attribute verbose.



4
5
6
# File 'lib/rdeis/base.rb', line 4

def verbose
  @verbose
end

Instance Method Details

#local_profileObject



27
28
29
30
31
# File 'lib/rdeis/base.rb', line 27

def local_profile
  file = "#{ENV['HOME']}/.profile"
  `> #{file}` if ! File.exists?(file)
  file
end

#local_shellObject



23
24
25
# File 'lib/rdeis/base.rb', line 23

def local_shell
  `echo $SHELL | sed -E "s#/bin/##"`.strip
end

#local_shell_env_include(profile, file_to_include) ⇒ Object



37
38
39
40
# File 'lib/rdeis/base.rb', line 37

def local_shell_env_include(profile, file_to_include)
  content = File.open(profile, "r"){ |f| f.read }.gsub(". #{file_to_include}", "") + "\n. #{file_to_include}"
  File.open(profile, "w") { |f| f.write(content) }
end

#log(cmd) ⇒ Object



9
10
11
# File 'lib/rdeis/base.rb', line 9

def log(cmd)
  say "[#{@proxy} #{Time.now}] #{cmd}", :black if @verbose
end

#remote_profileObject



33
34
35
# File 'lib/rdeis/base.rb', line 33

def remote_profile
  "$HOME/.profile"
end

#run(command) ⇒ Object

run commands either locally or remotely



14
15
16
17
18
19
20
21
# File 'lib/rdeis/base.rb', line 14

def run(command)
  self.log(command)
  if @proxy
    return @ssh.exec!(command)
  else
    return `#{command}`.strip
  end
end