Class: DEIS::Destroy

Inherits:
Storage show all
Includes:
Thor::Shell
Defined in:
lib/rdeis/destroy.rb

Constant Summary

Constants inherited from Storage

Storage::BASE_PATH, Storage::ENV_VAR_PATH

Constants inherited from Base

Base::NO, Base::YES

Instance Attribute Summary collapse

Attributes inherited from Base

#ssh

Instance Method Summary collapse

Methods inherited from Storage

file, get, load, removal_complete, save, set, subset, subunset

Methods inherited from Base

#local_profile, #local_shell, #local_shell_env_include, #log, #remote_profile, #run

Constructor Details

#initialize(options) ⇒ Destroy

Returns a new instance of Destroy.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rdeis/destroy.rb', line 7

def initialize(options)
  @options = options
  @repo = DEIS::Git.name
  @verbose = options["verbose"]
  @environment = options["environment"]
  @cluster = options["cluster"]
  # location data that fetch from env as well as options from thor
  @proxy = if ! options["proxy"].nil? then options["proxy"] elsif ! ENV['RDEIS_PROXY'].nil? then ENV['RDEIS_PROXY'] else nil end
  @base_path = if ! options["path"].nil? then options["path"] elsif ! ENV['RDEIS_PATH'].nil? then ENV['RDEIS_PATH'] else ENV['HOME'] end
  # git data
  @ref = DEIS::Git.ref
  @branch = DEIS::Git.branch
  @remote = DEIS::Git.remote

  @name = @repo.gsub("_", "-")+"-"+@environment
  @deploy_to = @base_path.to_s + "/"+ @name + "/"
  @ssh = SSH.new({:host => @proxy, :user => nil}) if ! @proxy.nil?
end

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def cluster
  @cluster
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def environment
  @environment
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def options
  @options
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def output
  @output
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def path
  @path
end

#proxyObject

Returns the value of attribute proxy.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def proxy
  @proxy
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/rdeis/destroy.rb', line 5

def verbose
  @verbose
end

Instance Method Details

#allObject

runs everyhing in order



49
50
51
52
53
54
# File 'lib/rdeis/destroy.rb', line 49

def all
  self.domains
  self.scale
  self.remove
  say "Complete", :blue
end

#domainsObject



27
28
29
30
31
32
33
34
# File 'lib/rdeis/destroy.rb', line 27

def domains
  dom = DEIS::Domains.new(@options)
  list = DEIS::Parse.list_array_to_var_string_array(dom.list(nil, nil))
  dom.unset(list) if ! list.nil? && list.length > 0 
  # now deploy the change
  deploy = DEIS::Deploy.new(@options)
  deploy.domains("rm")
end

#removeObject



43
44
45
46
# File 'lib/rdeis/destroy.rb', line 43

def remove
  base = DEIS::Deploy.new(options)
  base.run("deis destroy -a #{@name} --confirm=#{@name}")
end

#scaleObject



36
37
38
39
40
41
# File 'lib/rdeis/destroy.rb', line 36

def scale
  procs = []
  DEIS::Parse.procs.each{|name| procs.push("#{name}=0") }
  deploy = DEIS::Deploy.new(@options)
  deploy.scale(procs) if ! procs.nil? && procs.length > 0
end