rig 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +67 -0
  5. data/Rakefile +2 -0
  6. data/bin/rig +15 -0
  7. data/lib/rig.rb +2 -0
  8. data/lib/rig/capistrano.rb +54 -0
  9. data/lib/rig/chef.rb +53 -0
  10. data/lib/rig/cloud.rb +4 -0
  11. data/lib/rig/cloud/balancer.rb +40 -0
  12. data/lib/rig/cloud/connection.rb +40 -0
  13. data/lib/rig/cloud/dns.rb +56 -0
  14. data/lib/rig/cloud/environment.rb +214 -0
  15. data/lib/rig/cloud/instance.rb +64 -0
  16. data/lib/rig/cloud/userdata.rb +111 -0
  17. data/lib/rig/command.rb +42 -0
  18. data/lib/rig/command/abstract.rb +36 -0
  19. data/lib/rig/command/balancer/destroy.rb +16 -0
  20. data/lib/rig/command/balancer/list.rb +21 -0
  21. data/lib/rig/command/balancer/main.rb +13 -0
  22. data/lib/rig/command/balancer/view.rb +19 -0
  23. data/lib/rig/command/dns/create.rb +19 -0
  24. data/lib/rig/command/dns/destroy.rb +16 -0
  25. data/lib/rig/command/dns/edit.rb +20 -0
  26. data/lib/rig/command/dns/list.rb +21 -0
  27. data/lib/rig/command/dns/main.rb +13 -0
  28. data/lib/rig/command/environment/create.rb +24 -0
  29. data/lib/rig/command/environment/destroy.rb +18 -0
  30. data/lib/rig/command/environment/list.rb +30 -0
  31. data/lib/rig/command/environment/main.rb +15 -0
  32. data/lib/rig/command/instance/create.rb +27 -0
  33. data/lib/rig/command/instance/destroy.rb +20 -0
  34. data/lib/rig/command/instance/list.rb +25 -0
  35. data/lib/rig/command/instance/main.rb +16 -0
  36. data/lib/rig/command/instance/ssh.rb +32 -0
  37. data/lib/rig/command/instance/tag/get.rb +41 -0
  38. data/lib/rig/command/instance/tag/main.rb +14 -0
  39. data/lib/rig/command/instance/tag/remove.rb +44 -0
  40. data/lib/rig/command/instance/tag/set.rb +47 -0
  41. data/lib/rig/command/instance/view.rb +20 -0
  42. data/lib/rig/command/keypair/list.rb +14 -0
  43. data/lib/rig/command/keypair/main.rb +11 -0
  44. data/lib/rig/command/main.rb +48 -0
  45. data/lib/rig/command/options.rb +97 -0
  46. data/lib/rig/config.rb +68 -0
  47. data/lib/rig/version.rb +10 -0
  48. data/rig.gemspec +39 -0
  49. metadata +196 -0
@@ -0,0 +1,97 @@
1
+ require 'rig'
2
+ require 'yaml'
3
+
4
+ module Rig
5
+ module Command
6
+ module Options
7
+
8
+ module Config
9
+ #def self.included(base)
10
+ # base.class_eval do
11
+ # option %w{-c --config}, "CONFIG", "configuration file" do |f|
12
+ # e = File.expand_path(f)
13
+ # raise "Config file #{f} (#{e}) does not exist" unless File.exists?(e)
14
+ # e
15
+ # end
16
+ # def default_config
17
+ # ENV['RIG_CONFIG'] || "~/.rig"
18
+ # end
19
+ # end
20
+ #end
21
+ end
22
+
23
+ module AwsKey
24
+ def self.included(base)
25
+ base.class_eval do
26
+ option %w{-k --key}, "KEY", "aws access key id"
27
+ end
28
+ end
29
+ end
30
+
31
+ module AwsSecret
32
+ def self.included(base)
33
+ base.class_eval do
34
+ option %w{-s --secret}, "SECRET", "aws secret access key"
35
+ end
36
+ end
37
+ end
38
+
39
+ module AwsAmi
40
+ def self.included(base)
41
+ base.class_eval do
42
+ option %w{--ami}, "AMI", "aws ami id"
43
+ def default_ami
44
+ ENV['RIG_AWS_AMI'] || Rig.config.ami || nil
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ module AwsRegion
51
+ def self.included(base)
52
+ base.class_eval do
53
+ option %w{--region}, "AMI", "aws region"
54
+ def default_region
55
+ ENV['RIG_AWS_REGION'] || Rig.config.region || nil
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ module AwsKeypair
62
+ def self.included(base)
63
+ base.class_eval do
64
+ option %w{--keypair}, "KEYPAIR", "aws key pair name"
65
+ def default_keypair
66
+ ENV['RIG_AWS_KEYPAIR'] || Rig.config.keypair || nil
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ module Instance
73
+ def self.included(base)
74
+ base.class_eval do
75
+ option %w{-i --iid}, "IID", "instance id"
76
+ end
77
+ end
78
+ end
79
+
80
+ module InstanceName
81
+ def self.included(base)
82
+ base.class_eval do
83
+ option %w{-n --iname}, "INAME", "instance name"
84
+ end
85
+ end
86
+ end
87
+
88
+ module ShowAll
89
+ def self.included(base)
90
+ base.class_eval do
91
+ option %w{-a --all}, :flag, "override default filters and show everything", :attribute_name => :showall
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,68 @@
1
+
2
+ module Rig
3
+ class << self
4
+ def config
5
+ @configuration ||= begin
6
+ f = ENV["RIG_CONFIG"] || "~/.rig"
7
+ file = File.expand_path(f)
8
+ #puts "loading file: #{f}"
9
+ raise "Configuration not found: #{f} (#{file})" unless File.exists?(file)
10
+ yaml = YAML.load_file(file)
11
+ Rig::Oconfig.new(yaml['rig'])
12
+ end
13
+ end
14
+ end
15
+
16
+ class Oconfig
17
+ def initialize(data={})
18
+ @data = {}
19
+ update!(data)
20
+ end
21
+
22
+ def update!(data)
23
+ data.each do |key, value|
24
+ self[key] = value
25
+ end
26
+ end
27
+
28
+ def [](key)
29
+ @data[key.to_sym]
30
+ end
31
+
32
+ def []=(key, value)
33
+ if value.kind_of?(Hash)
34
+ @data[key.to_sym] = Oconfig.new(value)
35
+ elsif value.kind_of?(Array)
36
+ @data[key.to_sym] = []
37
+ value.each do |v|
38
+ @data[key.to_sym] << Oconfig.new(v)
39
+ end
40
+ else
41
+ @data[key.to_sym] = value
42
+ end
43
+ end
44
+
45
+ def method_missing(sym, *args)
46
+ if sym.to_s =~ /(.+)=$/
47
+ self[$1] = args.first
48
+ else
49
+ self[sym]
50
+ end
51
+ end
52
+
53
+ def to_hash
54
+ out = {}
55
+ @data.each do |k, v|
56
+ out[k.to_s] = v.kind_of?(Oconfig) ? v.to_hash : v
57
+ end
58
+ out
59
+ end
60
+
61
+ if defined?(YAML)
62
+ def to_yaml
63
+ to_hash.to_yaml
64
+ end
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,10 @@
1
+ unless defined?(Rig::Version)
2
+ module Rig
3
+ module Version
4
+ MAJOR = 0
5
+ MINOR = 3
6
+ TINY = 1
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rig/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Shawn Catanzarite"]
6
+ gem.email = ["xenonsoul@gmail.com"]
7
+ gem.description = %q{Cloud provisioning tool built on ruby fog}
8
+ gem.summary = %q{Cloud provisioning tool built on ruby fog}
9
+ gem.homepage = "https://github.com/shawncatz/rig"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "rig"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Rig::Version::STRING
17
+
18
+ # command line
19
+ gem.add_dependency "clamp"
20
+
21
+ # talk to cloud
22
+ gem.add_dependency "fog"
23
+
24
+ # check if parameter is ip address
25
+ gem.add_dependency "ipaddress"
26
+
27
+ # pretty ascii tables
28
+ # possibly change this to use Formatador?
29
+ gem.add_dependency "terminal-table"
30
+
31
+ # user-data templates
32
+ gem.add_dependency "erubis"
33
+
34
+ # print awesome
35
+ gem.add_dependency "awesome_print"
36
+
37
+ # Ruby Object Notation - easy config objects
38
+ #gem.add_dependency "ribbon"
39
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rig
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
11
+ platform: ruby
12
+ authors:
13
+ - Shawn Catanzarite
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-23 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: clamp
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: fog
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: ipaddress
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: terminal-table
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :runtime
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: erubis
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ type: :runtime
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: awesome_print
92
+ prerelease: false
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ type: :runtime
103
+ version_requirements: *id006
104
+ description: Cloud provisioning tool built on ruby fog
105
+ email:
106
+ - xenonsoul@gmail.com
107
+ executables:
108
+ - rig
109
+ extensions: []
110
+
111
+ extra_rdoc_files: []
112
+
113
+ files:
114
+ - .gitignore
115
+ - Gemfile
116
+ - LICENSE
117
+ - README.md
118
+ - Rakefile
119
+ - bin/rig
120
+ - lib/rig.rb
121
+ - lib/rig/capistrano.rb
122
+ - lib/rig/chef.rb
123
+ - lib/rig/cloud.rb
124
+ - lib/rig/cloud/balancer.rb
125
+ - lib/rig/cloud/connection.rb
126
+ - lib/rig/cloud/dns.rb
127
+ - lib/rig/cloud/environment.rb
128
+ - lib/rig/cloud/instance.rb
129
+ - lib/rig/cloud/userdata.rb
130
+ - lib/rig/command.rb
131
+ - lib/rig/command/abstract.rb
132
+ - lib/rig/command/balancer/destroy.rb
133
+ - lib/rig/command/balancer/list.rb
134
+ - lib/rig/command/balancer/main.rb
135
+ - lib/rig/command/balancer/view.rb
136
+ - lib/rig/command/dns/create.rb
137
+ - lib/rig/command/dns/destroy.rb
138
+ - lib/rig/command/dns/edit.rb
139
+ - lib/rig/command/dns/list.rb
140
+ - lib/rig/command/dns/main.rb
141
+ - lib/rig/command/environment/create.rb
142
+ - lib/rig/command/environment/destroy.rb
143
+ - lib/rig/command/environment/list.rb
144
+ - lib/rig/command/environment/main.rb
145
+ - lib/rig/command/instance/create.rb
146
+ - lib/rig/command/instance/destroy.rb
147
+ - lib/rig/command/instance/list.rb
148
+ - lib/rig/command/instance/main.rb
149
+ - lib/rig/command/instance/ssh.rb
150
+ - lib/rig/command/instance/tag/get.rb
151
+ - lib/rig/command/instance/tag/main.rb
152
+ - lib/rig/command/instance/tag/remove.rb
153
+ - lib/rig/command/instance/tag/set.rb
154
+ - lib/rig/command/instance/view.rb
155
+ - lib/rig/command/keypair/list.rb
156
+ - lib/rig/command/keypair/main.rb
157
+ - lib/rig/command/main.rb
158
+ - lib/rig/command/options.rb
159
+ - lib/rig/config.rb
160
+ - lib/rig/version.rb
161
+ - rig.gemspec
162
+ homepage: https://github.com/shawncatz/rig
163
+ licenses: []
164
+
165
+ post_install_message:
166
+ rdoc_options: []
167
+
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ hash: 3
176
+ segments:
177
+ - 0
178
+ version: "0"
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ hash: 3
185
+ segments:
186
+ - 0
187
+ version: "0"
188
+ requirements: []
189
+
190
+ rubyforge_project:
191
+ rubygems_version: 1.8.21
192
+ signing_key:
193
+ specification_version: 3
194
+ summary: Cloud provisioning tool built on ruby fog
195
+ test_files: []
196
+