pairhost 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/README.md +11 -0
- data/Rakefile +1 -0
- data/bin/pairhost +172 -0
- data/config.example.yml +9 -0
- data/config.yml +10 -0
- data/lib/pairhost/version.rb +3 -0
- data/lib/pairhost.rb +5 -0
- data/pairhost.gemspec +20 -0
- data/update-nx.sh +16 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.0.0)
|
5
|
+
excon (0.9.6)
|
6
|
+
fog (1.1.2)
|
7
|
+
builder
|
8
|
+
excon (~> 0.9.0)
|
9
|
+
formatador (~> 0.2.0)
|
10
|
+
mime-types
|
11
|
+
multi_json (~> 1.0.3)
|
12
|
+
net-scp (~> 1.0.4)
|
13
|
+
net-ssh (>= 2.1.3)
|
14
|
+
nokogiri (~> 1.5.0)
|
15
|
+
ruby-hmac
|
16
|
+
formatador (0.2.1)
|
17
|
+
mime-types (1.17.2)
|
18
|
+
multi_json (1.0.4)
|
19
|
+
net-scp (1.0.4)
|
20
|
+
net-ssh (>= 1.99.1)
|
21
|
+
net-ssh (2.3.0)
|
22
|
+
nokogiri (1.5.1)
|
23
|
+
ruby-hmac (0.4.0)
|
24
|
+
thor (0.14.6)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
fog (= 1.1.2)
|
31
|
+
thor (= 0.14.6)
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Pairhost
|
2
|
+
|
3
|
+
Create an EC2 instance for Relevance, Inc. remote pairing! It creates the instance and reports the public DNS name right from the command line.
|
4
|
+
|
5
|
+
## How To Use
|
6
|
+
|
7
|
+
# install bundler
|
8
|
+
bundle install
|
9
|
+
cp config.example.yml config.yml
|
10
|
+
# edit the config to use real EC2 & AMI stuff (ask me if you need it)
|
11
|
+
#TODO: ./pairhost up
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/pairhost
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'fog'
|
5
|
+
require 'thor'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
class Pairhost
|
9
|
+
def initialize
|
10
|
+
@config = YAML.load(File.open("./config.yml"))
|
11
|
+
@instance_id = File.read(File.expand_path('~/.pairhost/instance')).chomp
|
12
|
+
|
13
|
+
Fog.credentials = Fog.credentials.merge(
|
14
|
+
:private_key_path => @config['private_key_path'],
|
15
|
+
)
|
16
|
+
|
17
|
+
@connection = Fog::Compute.new(
|
18
|
+
:provider => @config['provider'],
|
19
|
+
:aws_secret_access_key => @config['aws_secret_access_key'],
|
20
|
+
:aws_access_key_id => @config['aws_access_key_id'],
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
server_options = {
|
26
|
+
"tags" => {"Name" => "DevOps Dev (LK FTW)"},
|
27
|
+
"image_id" => @config['ami_id'],
|
28
|
+
"flavor_id" => @config['flavor_id'],
|
29
|
+
"key_name" => @config['key_name'],
|
30
|
+
}
|
31
|
+
|
32
|
+
puts "Provisioning..."
|
33
|
+
server = @connection.servers.create(server_options)
|
34
|
+
server.wait_for { ready? }
|
35
|
+
puts "provisioned!"
|
36
|
+
server
|
37
|
+
end
|
38
|
+
|
39
|
+
def start(server)
|
40
|
+
puts "Starting..."
|
41
|
+
server.start
|
42
|
+
server.wait_for { ready? }
|
43
|
+
puts "Started!"
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_ssh(server)
|
47
|
+
# Try to ssh in every 3 seconds until
|
48
|
+
# we get a response or one minute passes
|
49
|
+
server.wait_for(60, 3) do
|
50
|
+
begin
|
51
|
+
puts "Trying to ssh..."
|
52
|
+
output = ssh('/bin/pwd')
|
53
|
+
puts output.inspect
|
54
|
+
output
|
55
|
+
rescue => e
|
56
|
+
puts "ssh failed... exception was #{e}"
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def fetch_server
|
63
|
+
@connection.servers.get(@instance_id) if @instance_id
|
64
|
+
end
|
65
|
+
|
66
|
+
def display_status(server)
|
67
|
+
puts "#{server.id}: #{server.tags['Name']}"
|
68
|
+
puts server.state
|
69
|
+
puts server.dns_name if server.dns_name
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class PairhostCLI < Thor
|
74
|
+
desc "ssh", "SSH to your pairhost"
|
75
|
+
def ssh
|
76
|
+
server = Pairhost.new.fetch_server
|
77
|
+
exec "ssh -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=QUIET pair@#{server.reload.dns_name}"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "status", "Print the status of your pairhost"
|
81
|
+
def status
|
82
|
+
ph = Pairhost.new
|
83
|
+
server = ph.fetch_server
|
84
|
+
ph.display_status(server)
|
85
|
+
end
|
86
|
+
|
87
|
+
map "stop" => :shutdown
|
88
|
+
map "halt" => :shutdown
|
89
|
+
|
90
|
+
desc "shutdown", "Stop your pairhost"
|
91
|
+
def shutdown
|
92
|
+
ph = Pairhost.new
|
93
|
+
server = ph.fetch_server
|
94
|
+
puts "Shutting down..."
|
95
|
+
server.stop
|
96
|
+
server.wait_for { state == "stopped" }
|
97
|
+
puts "shutdown!"
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "attach", "Start using an existing pairhost given its EC2 instance ID"
|
101
|
+
def attach
|
102
|
+
puts "coming soon..."
|
103
|
+
end
|
104
|
+
|
105
|
+
# TODO: replace with "up" (which does a "create" or a "start" as appropriate)
|
106
|
+
# create asks for a name, but gives you a default based on the $CWD and git initials, if any
|
107
|
+
desc "up", "Create a new pairhost or start your stopped pairhost"
|
108
|
+
def up
|
109
|
+
ph = Pairhost.new
|
110
|
+
server = ph.fetch_server
|
111
|
+
|
112
|
+
if server
|
113
|
+
ph.start(server)
|
114
|
+
else
|
115
|
+
server = ph.create
|
116
|
+
end
|
117
|
+
|
118
|
+
ph.display_status(server)
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "destroy", "Terminate your pairhost"
|
122
|
+
def destroy
|
123
|
+
server = fetch_server
|
124
|
+
puts "Destroying..."
|
125
|
+
server.destroy
|
126
|
+
server.wait_for { state == "terminated" }
|
127
|
+
puts "destroyed!"
|
128
|
+
end
|
129
|
+
|
130
|
+
desc "list", "List all instances on your EC2 account"
|
131
|
+
def list
|
132
|
+
@config[:pairhost].connection.servers.each do |server|
|
133
|
+
puts server.tags['Name']
|
134
|
+
puts server.inspect
|
135
|
+
puts
|
136
|
+
puts
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "initials", "DEBUG: just a test task for getting the current git initials"
|
141
|
+
def initials
|
142
|
+
initials = `git config user.initials`.chomp.split("/").map(&:upcase).join(" ")
|
143
|
+
puts initials.inspect
|
144
|
+
end
|
145
|
+
|
146
|
+
desc "init", "Setup your ~/.pairhost directory with default config"
|
147
|
+
def init
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
=begin
|
153
|
+
vagrant commands:
|
154
|
+
box --> ignore?
|
155
|
+
destroy
|
156
|
+
gem --> ignore
|
157
|
+
halt
|
158
|
+
init --> ignore
|
159
|
+
package --> ignore
|
160
|
+
provision
|
161
|
+
reload
|
162
|
+
resume
|
163
|
+
ssh
|
164
|
+
ssh-config --> ignore?
|
165
|
+
status
|
166
|
+
suspend
|
167
|
+
up
|
168
|
+
=end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
PairhostCLI.start
|
data/config.example.yml
ADDED
data/config.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
provider: 'AWS'
|
2
|
+
aws_secret_access_key: 'aOWCyMXgpFd452aBh4BRyPGkR/RtQ9G0qQX/5aQV'
|
3
|
+
aws_access_key_id: 'AKIAIQZWXGD2S56W2MMQ'
|
4
|
+
|
5
|
+
# 608860329496/Ubuntu 11.04 64-bit Pairhost (2011-10-26)
|
6
|
+
ami_id: 'ami-9360affa'
|
7
|
+
flavor_id: 'm1.large'
|
8
|
+
|
9
|
+
key_name: 'relevance_aws'
|
10
|
+
private_key_path: '~/.ssh/relevance_aws/relevance_aws.pem'
|
data/lib/pairhost.rb
ADDED
data/pairhost.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "pairhost/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "pairhost"
|
7
|
+
s.version = Pairhost::VERSION
|
8
|
+
s.authors = ["Larry Karnowski"]
|
9
|
+
s.email = ["larry@hickorywind.org"]
|
10
|
+
s.homepage = "http://www.github.com/karnowski/pairhost"
|
11
|
+
s.summary = %q{Automate creation of Relevance pairhost EC2 instances.}
|
12
|
+
s.description = %q{A Vagrant-like command line interface for creating, managing, and using EC2 pairhosts.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
|
18
|
+
s.add_runtime_dependency "fog", "1.1.2"
|
19
|
+
s.add_runtime_dependency "thor", "0.14.6"
|
20
|
+
end
|
data/update-nx.sh
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
echo "Note, you may need to update the link for this to really work!"
|
4
|
+
|
5
|
+
sudo apt-get -y remove nxserver
|
6
|
+
sudo rm -rf /usr/NX /etc/NX
|
7
|
+
|
8
|
+
# note the link changes every week or so:
|
9
|
+
# be sure to grab the Debian amd64 package!
|
10
|
+
# http://www.nomachine.com/preview/select-package-virtual-desktop-workstation.php?os=linux
|
11
|
+
|
12
|
+
wget http://64.34.161.181/download/4.0/Linux/VDW/nxserver_vdw_4.0.132-8_amd64.deb
|
13
|
+
sudo dpkg -i nxserver_*.deb
|
14
|
+
|
15
|
+
echo "You should see the NX server (nxhtd) running in the process list below!"
|
16
|
+
ps aux | grep nx
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pairhost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Larry Karnowski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fog
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.14.6
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.14.6
|
46
|
+
description: A Vagrant-like command line interface for creating, managing, and using
|
47
|
+
EC2 pairhosts.
|
48
|
+
email:
|
49
|
+
- larry@hickorywind.org
|
50
|
+
executables:
|
51
|
+
- pairhost
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- Gemfile.lock
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/pairhost
|
61
|
+
- config.example.yml
|
62
|
+
- config.yml
|
63
|
+
- lib/pairhost.rb
|
64
|
+
- lib/pairhost/version.rb
|
65
|
+
- pairhost.gemspec
|
66
|
+
- update-nx.sh
|
67
|
+
homepage: http://www.github.com/karnowski/pairhost
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.21
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Automate creation of Relevance pairhost EC2 instances.
|
91
|
+
test_files: []
|