rudy 0.4.0 → 0.6.0

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 (135) hide show
  1. data/CHANGES.txt +54 -30
  2. data/README.rdoc +100 -12
  3. data/Rakefile +103 -8
  4. data/Rudyfile +119 -0
  5. data/bin/ird +175 -0
  6. data/bin/rudy +259 -156
  7. data/bin/rudy-ec2 +228 -95
  8. data/bin/rudy-s3 +76 -0
  9. data/bin/rudy-sdb +67 -0
  10. data/lib/annoy.rb +270 -0
  11. data/lib/console.rb +30 -9
  12. data/lib/escape.rb +305 -0
  13. data/lib/rudy.rb +151 -182
  14. data/lib/rudy/aws.rb +56 -49
  15. data/lib/rudy/aws/ec2.rb +47 -292
  16. data/lib/rudy/aws/ec2/address.rb +157 -0
  17. data/lib/rudy/aws/ec2/group.rb +301 -0
  18. data/lib/rudy/aws/ec2/image.rb +168 -0
  19. data/lib/rudy/aws/ec2/instance.rb +434 -0
  20. data/lib/rudy/aws/ec2/keypair.rb +104 -0
  21. data/lib/rudy/aws/ec2/snapshot.rb +98 -0
  22. data/lib/rudy/aws/ec2/volume.rb +230 -0
  23. data/lib/rudy/aws/ec2/zone.rb +77 -0
  24. data/lib/rudy/aws/s3.rb +54 -0
  25. data/lib/rudy/aws/sdb.rb +298 -0
  26. data/lib/rudy/aws/sdb/error.rb +46 -0
  27. data/lib/rudy/{metadata/backup.rb → backup.rb} +26 -51
  28. data/lib/rudy/cli.rb +157 -0
  29. data/lib/rudy/cli/aws/ec2/addresses.rb +105 -0
  30. data/lib/rudy/cli/aws/ec2/candy.rb +208 -0
  31. data/lib/rudy/cli/aws/ec2/groups.rb +121 -0
  32. data/lib/rudy/cli/aws/ec2/images.rb +196 -0
  33. data/lib/rudy/cli/aws/ec2/instances.rb +194 -0
  34. data/lib/rudy/cli/aws/ec2/keypairs.rb +53 -0
  35. data/lib/rudy/cli/aws/ec2/snapshots.rb +49 -0
  36. data/lib/rudy/cli/aws/ec2/volumes.rb +104 -0
  37. data/lib/rudy/cli/aws/ec2/zones.rb +22 -0
  38. data/lib/rudy/cli/aws/s3/buckets.rb +50 -0
  39. data/lib/rudy/cli/aws/s3/store.rb +22 -0
  40. data/lib/rudy/cli/aws/sdb/domains.rb +41 -0
  41. data/lib/rudy/cli/candy.rb +8 -0
  42. data/lib/rudy/{command → cli}/config.rb +34 -24
  43. data/lib/rudy/cli/disks.rb +35 -0
  44. data/lib/rudy/cli/machines.rb +94 -0
  45. data/lib/rudy/cli/routines.rb +57 -0
  46. data/lib/rudy/config.rb +77 -72
  47. data/lib/rudy/config/objects.rb +29 -0
  48. data/lib/rudy/disks.rb +248 -0
  49. data/lib/rudy/global.rb +121 -0
  50. data/lib/rudy/huxtable.rb +340 -0
  51. data/lib/rudy/machines.rb +245 -0
  52. data/lib/rudy/metadata.rb +123 -13
  53. data/lib/rudy/routines.rb +47 -0
  54. data/lib/rudy/routines/helpers/diskhelper.rb +101 -0
  55. data/lib/rudy/routines/helpers/scripthelper.rb +91 -0
  56. data/lib/rudy/routines/release.rb +34 -0
  57. data/lib/rudy/routines/shutdown.rb +57 -0
  58. data/lib/rudy/routines/startup.rb +58 -0
  59. data/lib/rudy/scm/svn.rb +1 -1
  60. data/lib/rudy/utils.rb +322 -4
  61. data/lib/storable.rb +26 -17
  62. data/lib/sysinfo.rb +274 -0
  63. data/lib/tryouts.rb +6 -13
  64. data/rudy.gemspec +128 -42
  65. data/support/randomize-root-password +45 -0
  66. data/support/rudy-ec2-startup +9 -9
  67. data/support/update-ec2-ami-tools +20 -0
  68. data/test/05_config/00_setup_test.rb +20 -0
  69. data/test/05_config/30_machines_test.rb +69 -0
  70. data/test/20_sdb/00_setup_test.rb +16 -0
  71. data/test/20_sdb/10_domains_test.rb +115 -0
  72. data/test/25_ec2/00_setup_test.rb +29 -0
  73. data/test/25_ec2/10_keypairs_test.rb +41 -0
  74. data/test/25_ec2/20_groups_test.rb +131 -0
  75. data/test/25_ec2/30_addresses_test.rb +38 -0
  76. data/test/25_ec2/40_volumes_test.rb +49 -0
  77. data/test/25_ec2/50_snapshots_test.rb +74 -0
  78. data/test/26_ec2_instances/00_setup_test.rb +28 -0
  79. data/test/26_ec2_instances/10_instances_test.rb +83 -0
  80. data/test/26_ec2_instances/50_images_test.rb +13 -0
  81. data/test/30_sdb_metadata/00_setup_test.rb +21 -0
  82. data/test/30_sdb_metadata/10_disks_test.rb +109 -0
  83. data/test/30_sdb_metadata/20_backups_test.rb +102 -0
  84. data/test/coverage.txt +51 -0
  85. data/test/helper.rb +36 -0
  86. data/vendor/highline-1.5.1/CHANGELOG +222 -0
  87. data/vendor/highline-1.5.1/INSTALL +35 -0
  88. data/vendor/highline-1.5.1/LICENSE +7 -0
  89. data/vendor/highline-1.5.1/README +63 -0
  90. data/vendor/highline-1.5.1/Rakefile +82 -0
  91. data/vendor/highline-1.5.1/TODO +6 -0
  92. data/vendor/highline-1.5.1/examples/ansi_colors.rb +38 -0
  93. data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +18 -0
  94. data/vendor/highline-1.5.1/examples/basic_usage.rb +75 -0
  95. data/vendor/highline-1.5.1/examples/color_scheme.rb +32 -0
  96. data/vendor/highline-1.5.1/examples/limit.rb +12 -0
  97. data/vendor/highline-1.5.1/examples/menus.rb +65 -0
  98. data/vendor/highline-1.5.1/examples/overwrite.rb +19 -0
  99. data/vendor/highline-1.5.1/examples/page_and_wrap.rb +322 -0
  100. data/vendor/highline-1.5.1/examples/password.rb +7 -0
  101. data/vendor/highline-1.5.1/examples/trapping_eof.rb +22 -0
  102. data/vendor/highline-1.5.1/examples/using_readline.rb +17 -0
  103. data/vendor/highline-1.5.1/lib/highline.rb +758 -0
  104. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +120 -0
  105. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +17 -0
  106. data/vendor/highline-1.5.1/lib/highline/import.rb +43 -0
  107. data/vendor/highline-1.5.1/lib/highline/menu.rb +395 -0
  108. data/vendor/highline-1.5.1/lib/highline/question.rb +463 -0
  109. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +193 -0
  110. data/vendor/highline-1.5.1/setup.rb +1360 -0
  111. data/vendor/highline-1.5.1/test/tc_color_scheme.rb +56 -0
  112. data/vendor/highline-1.5.1/test/tc_highline.rb +823 -0
  113. data/vendor/highline-1.5.1/test/tc_import.rb +54 -0
  114. data/vendor/highline-1.5.1/test/tc_menu.rb +429 -0
  115. data/vendor/highline-1.5.1/test/ts_all.rb +15 -0
  116. metadata +141 -38
  117. data/lib/aws_sdb.rb +0 -3
  118. data/lib/aws_sdb/error.rb +0 -42
  119. data/lib/aws_sdb/service.rb +0 -215
  120. data/lib/rudy/aws/simpledb.rb +0 -53
  121. data/lib/rudy/command/addresses.rb +0 -46
  122. data/lib/rudy/command/backups.rb +0 -175
  123. data/lib/rudy/command/base.rb +0 -841
  124. data/lib/rudy/command/deploy.rb +0 -12
  125. data/lib/rudy/command/disks.rb +0 -213
  126. data/lib/rudy/command/environment.rb +0 -73
  127. data/lib/rudy/command/groups.rb +0 -61
  128. data/lib/rudy/command/images.rb +0 -91
  129. data/lib/rudy/command/instances.rb +0 -85
  130. data/lib/rudy/command/machines.rb +0 -161
  131. data/lib/rudy/command/metadata.rb +0 -41
  132. data/lib/rudy/command/release.rb +0 -174
  133. data/lib/rudy/command/volumes.rb +0 -66
  134. data/lib/rudy/metadata/disk.rb +0 -138
  135. data/tryouts/console_tryout.rb +0 -91
@@ -0,0 +1,53 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class KeyPairs < Rudy::CLI::CommandBase
7
+
8
+ def create_keypairs_valid?
9
+ raise Drydock::ArgError.new('name', @alias) unless @argv.name
10
+ true
11
+ end
12
+ def create_keypairs
13
+ rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
14
+ kp = execute_action { rkey.create(@argv.name) }
15
+ if %w[s string].member?(@@global.format)
16
+ puts "Name: #{kp.name}"
17
+ puts "Fingerprint: #{kp.fingerprint}", $/
18
+ puts "Copy the following private key data into a file."
19
+ puts "Set the permissions to 0600 and keep it safe.", $/
20
+ puts kp.private_key
21
+ else
22
+ puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
23
+ end
24
+ end
25
+
26
+ def destroy_keypairs_valid?
27
+ raise Drydock::ArgError.new('name', @alias) unless @argv.name
28
+ true
29
+ end
30
+ def destroy_keypairs
31
+ rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
32
+ raise "KeyPair #{@argv.name} does not exist" unless rkey.exists?(@argv.name)
33
+ kp = rkey.get(@argv.name)
34
+ puts "Destroying: #{kp.name}"
35
+ execute_check(:medium)
36
+ execute_action { rkey.destroy(kp.name) }
37
+ keypairs
38
+ end
39
+
40
+ def keypairs
41
+ rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
42
+ (rkey.list || []).each do |kp|
43
+ puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
44
+ end
45
+ puts "No keypairs" unless rkey.any?
46
+ end
47
+
48
+
49
+ end
50
+
51
+
52
+ end; end
53
+ end; end
@@ -0,0 +1,49 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Snapshots < Rudy::CLI::CommandBase
7
+
8
+ def create_snapshots_valid?
9
+ raise Drydock::ArgError.new('volume ID', @alias) unless @option.volume
10
+ @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
+ @volume = @rvol.get(@argv.volid)
12
+ raise "Volume #{@volume.awsid} does not exist" unless @volume
13
+ true
14
+ end
15
+ def create_snapshots
16
+ rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
+ snap = execute_action { rsnap.create(@volume.awsid) }
18
+ puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
19
+ end
20
+
21
+ def destroy_snapshots_valid?
22
+ raise Drydock::ArgError.new('snapshot ID', @alias) unless @argv.snapid
23
+ @rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
24
+ @snap = @rsnap.get(@argv.snapid)
25
+ raise "Snapshot #{@snap.awsid} does not exist" unless @snap
26
+ true
27
+ end
28
+ def destroy_snapshots
29
+ puts "Destroying: #{@snap.awsid}"
30
+ execute_check(:medium)
31
+ execute_action { @rsnap.destroy(@snap.awsid) }
32
+ snapshots
33
+ end
34
+
35
+ def snapshots
36
+ rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
37
+ snaps = rsnap.list || []
38
+ snaps.each do |snap|
39
+ puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
40
+ end
41
+ puts "No snapshots" if snaps.empty?
42
+ end
43
+
44
+
45
+ end
46
+
47
+
48
+ end; end
49
+ end; end
@@ -0,0 +1,104 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Volumes < Rudy::CLI::CommandBase
7
+
8
+
9
+ def volumes_create_valid?
10
+ raise "You must supply a volume size. See rudy volume -h" unless @option.size
11
+ raise "You must supply a zone." unless @@global.zone
12
+ true
13
+ end
14
+ def volumes_create
15
+ puts "Creating #{@option.size}GB volume in #{@@global.zone}"
16
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
+ execute_check(:low)
18
+ vol = execute_action("Create Failed") {
19
+ rvol.create(@option.size, @@global.zone, @option.snapshot)
20
+ }
21
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
22
+ end
23
+
24
+
25
+ def destroy_volumes_valid?
26
+ raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
27
+ true
28
+ end
29
+
30
+ def destroy_volumes
31
+ @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
32
+ @volume = @rvol.get(@argv.volid)
33
+ raise "Volume #{@volume.awsid} does not exist" unless @volume
34
+ raise "Volume #{@volume.awsid} is still in-use" if @volume.in_use?
35
+ raise "Volume #{@volume.awsid} is still attached" if @volume.attached?
36
+ raise "Volume #{@volume.awsid} is not available (#{@volume.state})" unless @volume.available?
37
+
38
+ puts "Destroying #{@volume.awsid}"
39
+ execute_check(:medium)
40
+ execute_action("Destroy Failed") { @rvol.destroy(@volume.awsid) }
41
+
42
+ vol = @rvol.get(@volume.awsid)
43
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
44
+ end
45
+
46
+
47
+ def volumes_attach_valid?
48
+ raise "You must supply an instance ID." unless @option.instance
49
+ raise "You must supply a volume ID." unless @argv.volid
50
+ true
51
+ end
52
+ def volumes_attach
53
+ @option.device ||= "/dev/sdh"
54
+
55
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
56
+ rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
57
+ raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
58
+ raise "Volume #{@argv.volid} is already attached" if rvol.attached?(@argv.volid)
59
+ raise "Instance #{@option.instance} does not exist" unless rinst.exists?(@option.instance)
60
+
61
+ puts "Attaching #{@argv.volid} to #{@option.instance} on #{@option.device}"
62
+ execute_check(:low)
63
+ execute_action("Attach Failed") {
64
+ rvol.attach(@argv.volid, @option.instance, @option.device)
65
+ }
66
+
67
+ vol = rvol.get(@argv.volid)
68
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
69
+ end
70
+
71
+ def volumes_detach_valid?
72
+ raise "You must supply a volume ID." unless @argv.volid
73
+ true
74
+ end
75
+
76
+ def volumes_detach
77
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
78
+ raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
79
+
80
+ vol = rvol.get(@argv.volid)
81
+ raise "Volume #{vol.awsid} is not attached" unless vol.attached?
82
+
83
+ puts "Detaching #{vol.awsid} from #{vol.instid}"
84
+ execute_check(:medium)
85
+ execute_action("Detach Failed") { rvol.detach(vol.awsid) }
86
+
87
+ vol = rvol.get(vol.awsid)
88
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
89
+ end
90
+
91
+
92
+ def volumes
93
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
94
+ volumes = rvol.list || []
95
+ volumes.each do |vol|
96
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
97
+ end
98
+ puts "No volumes" if volumes.empty?
99
+ end
100
+
101
+ end
102
+
103
+ end; end
104
+ end; end
@@ -0,0 +1,22 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Zones < Rudy::CLI::CommandBase
7
+
8
+
9
+ def zones
10
+ rzone = Rudy::AWS::EC2::Zones.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
+ rzone.list_as_hash(@argv.name).each_value do |zon|
12
+ puts zon.dump(@@global.format)
13
+ end
14
+ puts "No zones" unless rzone.any?
15
+ end
16
+
17
+
18
+ end
19
+
20
+
21
+ end; end
22
+ end; end
@@ -0,0 +1,50 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module S3;
5
+
6
+ class Buckets < Rudy::CLI::CommandBase
7
+
8
+
9
+ def buckets
10
+ raise "No bucket name supplied" if !@argv.name && @option.list
11
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
12
+ unless @option.list
13
+ (s3.list_buckets || []).each do |b|
14
+ puts b.name
15
+ end
16
+ else
17
+ puts "All objects in #{@argv.name}:"
18
+ (s3.list_bucket_objects(@argv.name) || []).each do |o|
19
+ puts o
20
+ end
21
+ end
22
+ end
23
+
24
+ def create_buckets_valid?
25
+ raise "No bucket name supplied" unless @argv.name
26
+ true
27
+ end
28
+ def create_buckets
29
+ execute_check(:low)
30
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
31
+ s3.create_bucket(@argv.name)
32
+ buckets
33
+ end
34
+
35
+ def destroy_buckets_valid?
36
+ raise "No bucket name supplied" unless @argv.name
37
+ true
38
+ end
39
+ def destroy_buckets
40
+ execute_check(:medium)
41
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
42
+ s3.destroy_bucket(@argv.name)
43
+ buckets
44
+ end
45
+
46
+
47
+ end
48
+
49
+ end; end
50
+ end; end
@@ -0,0 +1,22 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module S3;
5
+
6
+ class Store < Rudy::CLI::CommandBase
7
+
8
+ def store_valid?
9
+ raise "No path specified" unless @argv.path
10
+ raise "No bucket specified" unless @option.bucket
11
+ true
12
+ end
13
+ def store
14
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
15
+ puts "Success: %s" % s3.store(@argv.path, @option.bucket)
16
+
17
+ end
18
+
19
+ end
20
+
21
+ end;end
22
+ end;end
@@ -0,0 +1,41 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module SDB;
5
+
6
+ class Domains < Rudy::CLI::CommandBase
7
+
8
+
9
+ def domains
10
+ sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
+ domains = sdb.list_domains
12
+ puts domains
13
+ puts "No domains" if domains.nil? || domains.empty?
14
+ end
15
+
16
+ def domains_create_valid?
17
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
18
+ raise "No name specified" unless @argv.name
19
+ true
20
+ end
21
+ def domains_create
22
+ @sdb.create_domain @argv.name
23
+ execute_check(:low)
24
+ domains
25
+ end
26
+
27
+ def domains_destroy_valid?
28
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
29
+ raise "No name specified" unless @argv.name
30
+ true
31
+ end
32
+ def domains_destroy
33
+ execute_check(:medium)
34
+ @sdb.destroy_domain @argv.name
35
+ domains
36
+ end
37
+
38
+ end
39
+
40
+ end; end
41
+ end; end
@@ -0,0 +1,8 @@
1
+
2
+ module Rudy
3
+ module CLI
4
+ class Candy < Rudy::CLI::CommandBase
5
+
6
+ end
7
+ end
8
+ end
@@ -1,13 +1,13 @@
1
1
 
2
2
 
3
3
  module Rudy
4
- module Command
5
- class Config < Rudy::Command::Base
4
+ module CLI
5
+ class Config < Rudy::CLI::CommandBase
6
6
 
7
- # We force the Command::Base#print_header to be quiet
7
+ # We force the CLI::Base#print_header to be quiet
8
8
  def print_header
9
- @global.quiet = true
10
- super
9
+ #@@global.quiet = true
10
+ #super
11
11
  end
12
12
 
13
13
 
@@ -31,42 +31,52 @@ module Rudy
31
31
  # $ rudy config --all
32
32
  #
33
33
  def config
34
- return if @config.nil?
35
- puts "Config: #{@config.paths}" if @global.verbose > 0
34
+ return if @@config.nil?
36
35
 
37
- which = @option.defaults ? @global.user : machine_name
38
- puts "Machine: #{which}" if @global.verbose > 0
39
- puts "User: #{@global.user}" if @global.verbose > 0
40
36
 
41
- return if @config.empty?
37
+ @option.group ||= [@@global.environment, @@global.role].join(Rudy::DELIM)
38
+
39
+ return if @@config.empty?
42
40
 
43
41
  # We need to check whether we're running on a human's computer
44
42
  # or within EC2 (we call that running "in-situ"). The userdata
45
43
  # available when running in-situ is in a different format.
46
44
  if Rudy.in_situ?
47
-
48
-
45
+ puts "TODO: do something intelligent with config when running on EC2"
49
46
  else
50
-
51
47
  if @option.all
52
- y @config.machines.to_hash
53
- y @config.routines.to_hash
54
- elsif @option.defaults
55
- y @config.defaults.to_hash
48
+ puts "# ACCOUNTS: not displayed"
49
+ puts "# MACHINES: "
50
+ if @@config.machines?
51
+ y @@config.machines.to_hash
52
+ end
53
+ if @@config.routines?
54
+ puts "# ROUTINES: "
55
+ y @@config.routines.to_hash
56
+ end
57
+ elsif @option.defaults?
58
+ y @@config.defaults.to_hash
59
+ elsif @option.script
60
+ y fetch_script_config.to_hash
61
+ elsif @option.rudy
62
+ rf = File.join(RUDY_HOME, 'Rudyfile')
63
+ raise "Cannot find: #{rf}" unless File.exists?(rf)
64
+ puts File.read(rf)
56
65
  else
57
- env, rol, usr, att = @global.environment, @global.role, @global.user, @argv.name
58
- val = @config.machines.find_deferred(env, rol, usr, att) || ''
66
+ zon, env, rol = @@global.zone, @@global.environment, @@global.role
67
+ usr, att = @@global.user, @argv.name
68
+ val = @@config.machines.find_deferred(zon, env, rol, usr, att) || ''
59
69
  puts (val.is_a?(String)) ? val : val.to_hash.to_yaml
60
70
  end
61
71
 
62
72
  #name = @argv.first
63
- #if name && @config.userdata.has_key?(which)
64
- # value = @config.userdata[which][name.to_s]
73
+ #if name && @@config.userdata.has_key?(which)
74
+ # value = @@config.userdata[which][name.to_s]
65
75
  # puts value if value
66
76
  #elsif @option.all
67
- # puts @config.to_yaml
77
+ # puts @@config.to_yaml
68
78
  #else
69
- # value = @config.userdata[which]
79
+ # value = @@config.userdata[which]
70
80
  # puts value.to_yaml if value
71
81
  #end
72
82
  end