rig 0.3.5 → 0.3.6
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.
- data/lib/rig/command.rb +2 -0
- data/lib/rig/command/abstract.rb +17 -4
- data/lib/rig/command/account.rb +48 -0
- data/lib/rig/command/config.rb +37 -0
- data/lib/rig/command/instance/list.rb +2 -1
- data/lib/rig/command/main.rb +0 -16
- data/lib/rig/config.rb +20 -3
- data/lib/rig/model/account.rb +10 -0
- data/lib/rig/version.rb +1 -1
- metadata +5 -3
data/lib/rig/command.rb
CHANGED
data/lib/rig/command/abstract.rb
CHANGED
@@ -22,23 +22,36 @@ module Rig
|
|
22
22
|
puts table(columns, *rows)
|
23
23
|
end
|
24
24
|
|
25
|
-
def instance_list(list)
|
25
|
+
def instance_list(list, detailed=false)
|
26
26
|
rows = []
|
27
27
|
list.each do |server|
|
28
28
|
r = []
|
29
29
|
r << server.tags['Name']
|
30
30
|
r << server.tags['Environment']
|
31
31
|
r << server.tags['Role']
|
32
|
-
r << (server.tags['Protected'] ? '
|
32
|
+
r << (server.tags['Protected'] ? 'true' : '')
|
33
33
|
r << server.public_ip_address.to_s
|
34
|
-
|
34
|
+
if detailed
|
35
|
+
r << server.private_ip_address.to_s
|
36
|
+
end
|
35
37
|
r << server.flavor_id.to_s
|
36
38
|
r << server.id.to_s
|
37
39
|
r << server.state.to_s.downcase
|
38
40
|
rows << r
|
39
41
|
end
|
40
42
|
|
41
|
-
|
43
|
+
cols = []
|
44
|
+
cols << "Name"
|
45
|
+
cols << "Environment"
|
46
|
+
cols << "Role"
|
47
|
+
cols << "Protected"
|
48
|
+
cols << "Public IP"
|
49
|
+
cols << "Private IP" if detailed
|
50
|
+
cols << "Size"
|
51
|
+
cols << "Instance ID"
|
52
|
+
cols << "State"
|
53
|
+
|
54
|
+
print_table(cols, rows)
|
42
55
|
end
|
43
56
|
|
44
57
|
def execute
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Rig
|
2
|
+
module Command
|
3
|
+
module Account
|
4
|
+
class List < Abstract
|
5
|
+
def execute
|
6
|
+
list = Rig::Model::Account.list
|
7
|
+
rows = []
|
8
|
+
list.each do |n, f|
|
9
|
+
rows << [(Rig.config.default_account == n.to_s), (Rig.account.name == n.to_s), n, f]
|
10
|
+
end
|
11
|
+
print_table(%w{Default Current Name Location}, rows)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: figure out how to make this work with YAML references
|
16
|
+
#class Change < Abstract
|
17
|
+
# PROPS = %w{awsid awskey dnszone region}
|
18
|
+
# parameter "PROPERTY", "the property of config to change, must be one of #{PROPS.inspect}"
|
19
|
+
# parameter "VALUE", "the value to set for the property"
|
20
|
+
# def execute
|
21
|
+
# case property
|
22
|
+
# when "awsid"
|
23
|
+
# Rig.account.common.aws_access_key_id = value
|
24
|
+
# Rig.save_account
|
25
|
+
# when "awskey"
|
26
|
+
# Rig.account.common.aws_secret_access_key = value
|
27
|
+
# Rig.save_account
|
28
|
+
# when "dnszone"
|
29
|
+
# Rig.account.dns_zone = value
|
30
|
+
# Rig.save_account
|
31
|
+
# when "region"
|
32
|
+
# Rig.account.region = value
|
33
|
+
# Rig.save_account
|
34
|
+
# else
|
35
|
+
# puts "Property #{property} not supported"
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#end
|
39
|
+
|
40
|
+
class Main < Abstract
|
41
|
+
subcommand "list", "list the accounts available", List
|
42
|
+
#subcommand "change", "change account configuration values", Change
|
43
|
+
self.default_subcommand = "list"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
Rig::Command::Main.subcommand "account", "manage rig account files", Rig::Command::Account::Main
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Rig
|
2
|
+
module Command
|
3
|
+
module Config
|
4
|
+
class Change < Abstract
|
5
|
+
PROPS = %w{knife user}
|
6
|
+
parameter "PROPERTY", "the property of config to change, must be one of #{PROPS.inspect}"
|
7
|
+
parameter "VALUE", "the value to set for the property"
|
8
|
+
def execute
|
9
|
+
case property
|
10
|
+
when "knife"
|
11
|
+
Rig.config.chef.knife = value
|
12
|
+
Rig.save_configuration
|
13
|
+
when "user"
|
14
|
+
Rig.config.ssh.user = value
|
15
|
+
Rig.save_configuration
|
16
|
+
else
|
17
|
+
puts "Property #{property} not supported"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Dump < Abstract
|
23
|
+
def execute
|
24
|
+
puts "Rig Version: #{Rig::Version::STRING}"
|
25
|
+
puts Rig.config.to_yaml
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Main < Abstract
|
30
|
+
subcommand "dump", "dump configuration as yaml", Dump
|
31
|
+
subcommand "change", "Change configuration values from the command line", Change
|
32
|
+
self.default_subcommand = "dump"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Rig::Command::Main.subcommand "config", "manage rig configuration file", Rig::Command::Config::Main
|
@@ -6,6 +6,7 @@ module Rig
|
|
6
6
|
class List < Abstract
|
7
7
|
include Options::ShowAll
|
8
8
|
|
9
|
+
option %w{-d --detailed}, :flag, "show more information in table"
|
9
10
|
parameter "[ENV]", "environment"
|
10
11
|
|
11
12
|
def execute
|
@@ -15,7 +16,7 @@ module Rig
|
|
15
16
|
filters["tag:Environment"] = env if env
|
16
17
|
|
17
18
|
list = connection.servers.all(filters)
|
18
|
-
instance_list(list)
|
19
|
+
instance_list(list, detailed?)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/lib/rig/command/main.rb
CHANGED
@@ -3,22 +3,6 @@ require 'awesome_print'
|
|
3
3
|
module Rig
|
4
4
|
module Command
|
5
5
|
class Main < Abstract
|
6
|
-
option %w{--config}, :flag, "print configuration and exit" do |c|
|
7
|
-
puts "Rig Version: #{Rig::Version::STRING}"
|
8
|
-
puts Rig.config.to_yaml
|
9
|
-
exit(0)
|
10
|
-
end
|
11
|
-
|
12
|
-
subcommand "accounts", "show account list" do
|
13
|
-
def execute
|
14
|
-
list = Rig::Model::Account.list
|
15
|
-
rows = []
|
16
|
-
list.each do |n, f|
|
17
|
-
rows << [(Rig.config.default_account == n.to_s), (Rig.account.name == n.to_s), n, f]
|
18
|
-
end
|
19
|
-
print_table(%w{Default Current Name Location}, rows)
|
20
|
-
end
|
21
|
-
end
|
22
6
|
|
23
7
|
subcommand "chef", "test chef configuration" do
|
24
8
|
def execute
|
data/lib/rig/config.rb
CHANGED
@@ -23,10 +23,27 @@ module Rig
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def save_configuration
|
27
|
+
yaml = config.to_yaml
|
28
|
+
file = "#{configdir}/config.yml"
|
29
|
+
back = "#{file}.#{Time.now.to_i}"
|
30
|
+
puts "backing up configuration -> #{back}"
|
31
|
+
FileUtils.cp(file, back)
|
32
|
+
File.open(file, "w") {|f| f.write(yaml+"\n")}
|
33
|
+
puts "new configuration saved."
|
34
|
+
end
|
35
|
+
|
26
36
|
def account(name=get_account)
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
@account ||= begin
|
38
|
+
a = Rig::Model::Account.load(name)
|
39
|
+
a.name = name
|
40
|
+
a
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def save_account
|
45
|
+
name = Rig.account.name
|
46
|
+
Rig::Model::Account.save(name, Rig.account)
|
30
47
|
end
|
31
48
|
|
32
49
|
def get_config(name)
|
data/lib/rig/model/account.rb
CHANGED
@@ -15,6 +15,16 @@ module Rig
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def save(name, data)
|
19
|
+
yaml = data.to_yaml
|
20
|
+
file = "#{dir}/#{name}.yml"
|
21
|
+
back = "#{file}.#{Time.now.to_i}"
|
22
|
+
puts "backing up configuration -> #{back}"
|
23
|
+
FileUtils.cp(file, back)
|
24
|
+
File.open(file, "w") {|f| f.write(yaml+"\n")}
|
25
|
+
puts "new configuration saved."
|
26
|
+
end
|
27
|
+
|
18
28
|
private
|
19
29
|
def dir
|
20
30
|
"#{Rig.configdir}/accounts"
|
data/lib/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shawn Catanzarite
|
@@ -126,10 +126,12 @@ files:
|
|
126
126
|
- lib/rig/chef.rb
|
127
127
|
- lib/rig/command.rb
|
128
128
|
- lib/rig/command/abstract.rb
|
129
|
+
- lib/rig/command/account.rb
|
129
130
|
- lib/rig/command/balancer/destroy.rb
|
130
131
|
- lib/rig/command/balancer/list.rb
|
131
132
|
- lib/rig/command/balancer/main.rb
|
132
133
|
- lib/rig/command/balancer/view.rb
|
134
|
+
- lib/rig/command/config.rb
|
133
135
|
- lib/rig/command/dns/create.rb
|
134
136
|
- lib/rig/command/dns/destroy.rb
|
135
137
|
- lib/rig/command/dns/edit.rb
|