Class: Stackato

Inherits:
Object
  • Object
show all
Defined in:
lib/conan/stackato.rb

Defined Under Namespace

Classes: Commands

Instance Method Summary collapse

Constructor Details

#initialize(paas_user, paas_password, paas_space, dry_run = false) ⇒ Stackato

Returns a new instance of Stackato.



44
45
46
47
48
49
50
# File 'lib/conan/stackato.rb', line 44

def initialize(paas_user, paas_password, paas_space, dry_run=false)
  @paas_user = paas_user
  @paas_password = paas_password
  @paas_space = paas_space
  @dry_run = dry_run
  @paas_manifest = "stackato.yml"
end

Instance Method Details

#bg_deploy(work_dir, app, deployment) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/conan/stackato.rb', line 96

def bg_deploy(work_dir, app, deployment)
  puts ''
  Dir.chdir(work_dir){
    raise RuntimeError.new "Blue/green deployment is not implemented for the stackato v3 client yet"
    
    # login(deployment.paas_target)

    # push app

    #if app.is_inactive_node_operational?
      # switch (remap nodes)
      # clean (delete inactive nodes)
    #else
      # raise RuntimeError.new "#{app}'s inactive node is not operational. Skipping switch and clean."
    #end
  }
end

#deploy(work_dir, app, deployment, force = false) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/conan/stackato.rb', line 63

def deploy(work_dir, app, deployment, force=false)
  puts ''
  Dir.chdir(work_dir){
    (deployment.paas_target)

    paas_app_name = deployment.name(app)
    yield paas_app_name if block_given?

    # print out the stackato.yml for posterity
    puts '------------------------------------------------------------------------------'

    File.open(@paas_manifest, "r") do |f|
      while (line = f.gets)
        puts "#{line}"
      end
    end
    puts '------------------------------------------------------------------------------'
    puts ''

    if (force)
      puts "Deleting #{paas_app_name} if it exists. May be force be with you!"
      @commands.delete(paas_app_name)
    end

    puts "Pushing #{paas_app_name}"
    @commands.push(@paas_manifest)

    deployment.active_urls(app).each do |url|
      @commands.map(paas_app_name, url)
    end
  }
end

#login(paas_target) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/conan/stackato.rb', line 52

def (paas_target)
  # login only one time per target, and only one target at a time
  if (@session != paas_target)
    @session = paas_target
    @commands = Commands.new(paas_target, @dry_run)
    unless @paas_user.nil?
      @commands.(@paas_user, @paas_password, @paas_space)
    end
  end
end