cloudkick 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/cloudkick.gemspec +3 -2
  3. data/doc/ckpuppet.rb +59 -0
  4. metadata +3 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.2.10
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudkick}
8
- s.version = "0.2.9"
8
+ s.version = "0.2.10"
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-04-02}
12
+ s.date = %q{2010-04-22}
13
13
  s.default_executable = %q{cloudkick}
14
14
  s.description = %q{Ruby interface to the Cloudkick API}
15
15
  s.email = %q{support@cloudkick.com}
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "bin/cloudkick",
29
29
  "cloudkick.gemspec",
30
+ "doc/ckpuppet.rb",
30
31
  "doc/example.rb",
31
32
  "lib/cloudkick.rb",
32
33
  "lib/cloudkick/base.rb",
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'cloudkick'
3
+ require 'puppet'
4
+ require 'puppet/node'
5
+ require 'puppet/util/tagging'
6
+ require 'puppet/indirector/exec'
7
+
8
+ class Puppet::Node::Cloudkick < Puppet::Indirector::Code
9
+ include Puppet::Util::Tagging
10
+
11
+ # Create our client and cache
12
+ def client
13
+ key, secret = credentials
14
+ @client ||= Cloudkick::Base.new(key, secret)
15
+ end
16
+
17
+ def find(request)
18
+ nodes = client.get('nodes', "node:#{request.key}")
19
+ nodes.each do |n|
20
+ node = Puppet::Node.new(n.name)
21
+ node.classes = n.tags.reject { |t| ! valid_tag?(t) }
22
+ return node
23
+ end
24
+ return nil
25
+ end
26
+
27
+ def credentials
28
+ begin
29
+ key = ''
30
+ File.open('/etc/cloudkick.conf') do |f|
31
+ f.grep(/oauth_key (\w+)/) { key = $1 }
32
+ end
33
+
34
+ secret = ''
35
+ File.open('/etc/cloudkick.conf') do |f|
36
+ f.grep(/oauth_secret (\w+)/) { secret = $1 }
37
+ end
38
+
39
+ return key, secret
40
+ rescue
41
+ raise CommandFailed, 'Unable to open /etc/cloudkick.conf'
42
+ end
43
+ end
44
+ end
45
+
46
+ # If this is executed directly, we want to support specification of
47
+ # a host. If used this way, set 'node_terminus = /path/to/ckpuppet.rb'
48
+ # in puppet.conf.
49
+ # Drop this into $RUBYLIB/puppet/indirector/node/cloudkick.rb to use
50
+ # as a plugin, then set 'node_terminus = cloudkick' in puppet.conf.
51
+ if $0 == __FILE__
52
+ Puppet::Node.terminus_class = :cloudkick
53
+ if node = Puppet::Node.find(ARGV[0])
54
+ puts node.to_yaml
55
+ else
56
+ warn "Could not find #{ARGV[0]}"
57
+ exit 1
58
+ end
59
+ 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.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloudkick
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-02 00:00:00 -07:00
12
+ date: 2010-04-22 00:00:00 -07:00
13
13
  default_executable: cloudkick
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - VERSION
51
51
  - bin/cloudkick
52
52
  - cloudkick.gemspec
53
+ - doc/ckpuppet.rb
53
54
  - doc/example.rb
54
55
  - lib/cloudkick.rb
55
56
  - lib/cloudkick/base.rb