Class: Pairhost::CLI
- Inherits:
-
Thor
- Object
- Thor
- Pairhost::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/pairhost.rb
Instance Method Summary collapse
- #attach(instance_id) ⇒ Object
- #create(name = nil) ⇒ Object
- #destroy ⇒ Object
- #detach ⇒ Object
- #init ⇒ Object
- #provision ⇒ Object
- #resume ⇒ Object
- #ssh ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #up ⇒ Object
- #verify ⇒ Object
Instance Method Details
#attach(instance_id) ⇒ Object
199 200 201 202 203 |
# File 'lib/pairhost.rb', line 199 def attach(instance_id) invoke :verify, [] Pairhost.write_instance_id(instance_id) invoke :status, [] end |
#create(name = nil) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/pairhost.rb', line 108 def create(name=nil) invoke :verify, [] if name == nil initials = `git config user.initials`.chomp.split("/").map(&:upcase).join(" ") name = "Pairhost (#{initials})" end puts "Provisioning \"#{name}\"..." server = Pairhost.create(name) puts "provisioned!" invoke :status, [] end |
#destroy ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/pairhost.rb', line 179 def destroy invoke :verify server = Pairhost.fetch! confirm = ask("Type 'yes' to confirm deleting '#{server.['Name']}'.\n>") return unless confirm == "yes" puts "Destroying..." server.destroy server.wait_for { state == "terminated" } puts "destroyed!" end |
#detach ⇒ Object
206 207 208 209 210 |
# File 'lib/pairhost.rb', line 206 def detach invoke :verify # TODO implement puts "Coming soon..." end |
#init ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/pairhost.rb', line 98 def init if File.exists?(Pairhost.config_file) STDERR.puts "pairhost: Already initialized." else FileUtils.mkdir_p File.dirname(Pairhost.config_file) FileUtils.cp(File.dirname(__FILE__) + '/../config.example.yml', Pairhost.config_file) end end |
#provision ⇒ Object
192 193 194 195 196 |
# File 'lib/pairhost.rb', line 192 def provision invoke :verify # TODO implement puts "Coming soon..." end |
#resume ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/pairhost.rb', line 125 def resume invoke :verify server = Pairhost.fetch! puts "Starting..." Pairhost.start(server.reload) puts "started!" invoke :status end |
#ssh ⇒ Object
157 158 159 160 161 |
# File 'lib/pairhost.rb', line 157 def ssh invoke :verify server = Pairhost.fetch! exec "ssh -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=QUIET pair@#{server.dns_name}" end |
#status ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/pairhost.rb', line 148 def status invoke :verify server = Pairhost.fetch! puts "#{server.id}: #{server.['Name']}" puts "State: #{server.state}" puts server.dns_name if server.dns_name end |
#stop ⇒ Object
168 169 170 171 172 173 174 |
# File 'lib/pairhost.rb', line 168 def stop invoke :verify server = Pairhost.fetch! puts "Shutting down..." Pairhost.stop(server) puts "shutdown!" end |