cloudkick 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/cloudkick +14 -0
- data/cloudkick.gemspec +8 -2
- data/lib/cloudkick.rb +5 -5
- data/lib/cloudkick/base.rb +2 -0
- data/lib/cloudkick/command.rb +27 -0
- data/lib/cloudkick/commands/base.rb +33 -0
- data/lib/cloudkick/commands/parallel.rb +22 -0
- data/lib/cloudkick/node.rb +2 -9
- metadata +9 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/cloudkick
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
6
|
+
|
7
|
+
require 'cloudkick'
|
8
|
+
require 'cloudkick/command'
|
9
|
+
|
10
|
+
args = ARGV.dup
|
11
|
+
ARGV.clear
|
12
|
+
command = args.shift.strip rescue 'help'
|
13
|
+
|
14
|
+
Cloudkick::Command.run(command, args)
|
data/cloudkick.gemspec
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cloudkick}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cloudkick"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-22}
|
13
|
+
s.default_executable = %q{cloudkick}
|
13
14
|
s.description = %q{Ruby interface to the Cloudkick API}
|
14
15
|
s.email = %q{support@cloudkick.com}
|
16
|
+
s.executables = ["cloudkick"]
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE",
|
17
19
|
"README.rdoc"
|
@@ -23,10 +25,14 @@ Gem::Specification.new do |s|
|
|
23
25
|
"README.rdoc",
|
24
26
|
"Rakefile",
|
25
27
|
"VERSION",
|
28
|
+
"bin/cloudkick",
|
26
29
|
"cloudkick.gemspec",
|
27
30
|
"doc/example.rb",
|
28
31
|
"lib/cloudkick.rb",
|
29
32
|
"lib/cloudkick/base.rb",
|
33
|
+
"lib/cloudkick/command.rb",
|
34
|
+
"lib/cloudkick/commands/base.rb",
|
35
|
+
"lib/cloudkick/commands/parallel.rb",
|
30
36
|
"lib/cloudkick/node.rb",
|
31
37
|
"test/helper.rb",
|
32
38
|
"test/test_cloudkick-gem.rb"
|
data/lib/cloudkick.rb
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
15
|
-
require 'crack'
|
16
|
-
require 'oauth'
|
14
|
+
module Cloudkick; end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/cloudkick')
|
17
|
+
|
18
|
+
require 'base'
|
19
|
+
require 'node'
|
data/lib/cloudkick/base.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'commands/base'
|
2
|
+
|
3
|
+
Dir["#{File.dirname(__FILE__)}/commands/*"].each { |c| require c }
|
4
|
+
|
5
|
+
module Cloudkick
|
6
|
+
module Command
|
7
|
+
class InvalidCommand < RuntimeError; end
|
8
|
+
class CommandFailed < RuntimeError; end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def run(command, args)
|
12
|
+
run_internal(command, args.dup)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_internal(command, args)
|
16
|
+
klass, method = parse(command)
|
17
|
+
runner = klass.new(args)
|
18
|
+
raise InvalidCommand unless runner.respond_to?(method)
|
19
|
+
runner.send(method)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse(command)
|
23
|
+
return eval("Cloudkick::Command::#{command.capitalize}"), :index
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Cloudkick::Command
|
2
|
+
class Base
|
3
|
+
attr_accessor :args
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@args = args
|
7
|
+
end
|
8
|
+
|
9
|
+
def client
|
10
|
+
if !@client
|
11
|
+
key, secret = credentials
|
12
|
+
@client = Cloudkick::Base.new(key, secret)
|
13
|
+
end
|
14
|
+
|
15
|
+
return @client
|
16
|
+
end
|
17
|
+
|
18
|
+
def credentials
|
19
|
+
key = ''
|
20
|
+
File.open('/etc/cloudkick.conf') do |f|
|
21
|
+
f.grep(/oauth_key (\w+)/) { key = $1 }
|
22
|
+
end
|
23
|
+
|
24
|
+
secret = ''
|
25
|
+
File.open('/etc/cloudkick.conf') do |f|
|
26
|
+
f.grep(/oauth_secret (\w+)/) { secret = $1 }
|
27
|
+
end
|
28
|
+
|
29
|
+
return key, secret
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module Cloudkick::Command
|
4
|
+
class Pssh < Base
|
5
|
+
def index
|
6
|
+
file = Tempfile.new('ck')
|
7
|
+
|
8
|
+
client.get('nodes').each do |node|
|
9
|
+
file.puts node.ipaddress
|
10
|
+
end
|
11
|
+
|
12
|
+
file.flush
|
13
|
+
exec("pssh -h #{file.path} -l #{@args[0]} -o #{args[1]} #{args[2]}")
|
14
|
+
file.close
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Pscp < Base
|
19
|
+
def index
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/cloudkick/node.rb
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
+
require 'crack'
|
15
|
+
|
14
16
|
module Cloudkick
|
15
17
|
class Node < Base
|
16
18
|
|
@@ -65,14 +67,5 @@ module Cloudkick
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
def pssh(command)
|
69
|
-
file = File.new('pssh-ips.txt', 'w')
|
70
|
-
|
71
|
-
@nodes.each do |node|
|
72
|
-
file.puts node.ipaddress
|
73
|
-
end
|
74
|
-
|
75
|
-
"run: pssh -h pssh-ips.txt -o /tmp/ck \'#{command}\'"
|
76
|
-
end
|
77
70
|
end
|
78
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cloudkick
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
13
|
-
default_executable:
|
12
|
+
date: 2010-02-22 00:00:00 -08:00
|
13
|
+
default_executable: cloudkick
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: crack
|
@@ -34,8 +34,8 @@ dependencies:
|
|
34
34
|
version:
|
35
35
|
description: Ruby interface to the Cloudkick API
|
36
36
|
email: support@cloudkick.com
|
37
|
-
executables:
|
38
|
-
|
37
|
+
executables:
|
38
|
+
- cloudkick
|
39
39
|
extensions: []
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
@@ -48,10 +48,14 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
|
+
- bin/cloudkick
|
51
52
|
- cloudkick.gemspec
|
52
53
|
- doc/example.rb
|
53
54
|
- lib/cloudkick.rb
|
54
55
|
- lib/cloudkick/base.rb
|
56
|
+
- lib/cloudkick/command.rb
|
57
|
+
- lib/cloudkick/commands/base.rb
|
58
|
+
- lib/cloudkick/commands/parallel.rb
|
55
59
|
- lib/cloudkick/node.rb
|
56
60
|
- test/helper.rb
|
57
61
|
- test/test_cloudkick-gem.rb
|