solutious-rudy 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGES.txt +55 -14
  2. data/README.rdoc +26 -34
  3. data/Rudyfile +27 -32
  4. data/bin/rudy +47 -27
  5. data/bin/rudy-ec2 +2 -16
  6. data/bin/rudy-s3 +0 -10
  7. data/bin/rudy-sdb +11 -12
  8. data/lib/rudy.rb +49 -89
  9. data/lib/rudy/aws.rb +2 -43
  10. data/lib/rudy/aws/ec2.rb +57 -20
  11. data/lib/rudy/aws/ec2/address.rb +10 -11
  12. data/lib/rudy/aws/ec2/group.rb +10 -9
  13. data/lib/rudy/aws/ec2/image.rb +8 -8
  14. data/lib/rudy/aws/ec2/instance.rb +15 -16
  15. data/lib/rudy/aws/ec2/keypair.rb +14 -19
  16. data/lib/rudy/aws/ec2/snapshot.rb +16 -9
  17. data/lib/rudy/aws/ec2/volume.rb +37 -24
  18. data/lib/rudy/aws/ec2/zone.rb +5 -4
  19. data/lib/rudy/aws/s3.rb +2 -1
  20. data/lib/rudy/aws/sdb.rb +35 -86
  21. data/lib/rudy/backups.rb +24 -0
  22. data/lib/rudy/cli.rb +5 -131
  23. data/lib/rudy/cli/aws/ec2/addresses.rb +19 -27
  24. data/lib/rudy/cli/aws/ec2/candy.rb +32 -7
  25. data/lib/rudy/cli/aws/ec2/groups.rb +9 -13
  26. data/lib/rudy/cli/aws/ec2/images.rb +5 -133
  27. data/lib/rudy/cli/aws/ec2/instances.rb +25 -25
  28. data/lib/rudy/cli/aws/ec2/keypairs.rb +7 -11
  29. data/lib/rudy/cli/aws/ec2/snapshots.rb +5 -9
  30. data/lib/rudy/cli/aws/ec2/volumes.rb +22 -23
  31. data/lib/rudy/cli/aws/ec2/zones.rb +2 -3
  32. data/lib/rudy/cli/aws/sdb/domains.rb +5 -6
  33. data/lib/rudy/cli/aws/sdb/objects.rb +33 -0
  34. data/lib/rudy/cli/aws/sdb/select.rb +23 -0
  35. data/lib/rudy/cli/backups.rb +38 -0
  36. data/lib/rudy/cli/base.rb +98 -0
  37. data/lib/rudy/cli/candy.rb +1 -2
  38. data/lib/rudy/cli/config.rb +7 -4
  39. data/lib/rudy/cli/disks.rb +6 -8
  40. data/lib/rudy/cli/execbase.rb +53 -0
  41. data/lib/rudy/cli/machines.rb +14 -18
  42. data/lib/rudy/cli/metadata.rb +24 -10
  43. data/lib/rudy/cli/routines.rb +31 -5
  44. data/lib/rudy/config.rb +17 -22
  45. data/lib/rudy/config/objects.rb +44 -30
  46. data/lib/rudy/disks.rb +25 -0
  47. data/lib/rudy/exceptions.rb +95 -0
  48. data/lib/rudy/global.rb +46 -23
  49. data/lib/rudy/guidelines.rb +3 -2
  50. data/lib/rudy/huxtable.rb +66 -57
  51. data/lib/rudy/machines.rb +41 -263
  52. data/lib/rudy/metadata.rb +212 -38
  53. data/lib/rudy/metadata/backup.rb +123 -78
  54. data/lib/rudy/metadata/disk.rb +152 -170
  55. data/lib/rudy/metadata/machine.rb +179 -0
  56. data/lib/rudy/mixins.rb +2 -1
  57. data/lib/rudy/mixins/hash.rb +3 -1
  58. data/lib/rudy/mixins/symbol.rb +8 -0
  59. data/lib/rudy/routines.rb +127 -344
  60. data/lib/rudy/routines/base.rb +226 -0
  61. data/lib/rudy/routines/handlers/base.rb +48 -0
  62. data/lib/rudy/routines/handlers/depends.rb +49 -0
  63. data/lib/rudy/routines/handlers/disks.rb +239 -0
  64. data/lib/rudy/routines/handlers/group.rb +42 -0
  65. data/lib/rudy/routines/handlers/host.rb +72 -0
  66. data/lib/rudy/routines/handlers/keypair.rb +70 -0
  67. data/lib/rudy/routines/handlers/machines.rb +15 -0
  68. data/lib/rudy/routines/handlers/script.rb +85 -0
  69. data/lib/rudy/routines/handlers/user.rb +41 -0
  70. data/lib/rudy/routines/passthrough.rb +19 -23
  71. data/lib/rudy/routines/reboot.rb +82 -51
  72. data/lib/rudy/routines/shutdown.rb +61 -14
  73. data/lib/rudy/routines/startup.rb +111 -17
  74. data/lib/rudy/utils.rb +12 -59
  75. data/rudy.gemspec +85 -25
  76. data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
  77. data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
  78. data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
  79. data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
  80. data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
  81. data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
  82. data/tryouts/12_config/40_machines_tryouts.rb +53 -0
  83. data/tryouts/12_config/50_commands_tryouts.rb +17 -0
  84. data/tryouts/12_config/60_routines_tryouts.rb +16 -0
  85. data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
  86. data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
  87. data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
  88. data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
  89. data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
  90. data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
  91. data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
  92. data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
  93. data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
  94. data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
  95. data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
  96. data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
  97. data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
  98. data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
  99. data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
  100. data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
  101. data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
  102. data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
  103. data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
  104. data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
  105. data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
  106. data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
  107. data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
  108. data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
  109. data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
  110. data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
  111. data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
  112. data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
  113. data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
  114. data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
  115. data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
  116. data/tryouts/failer +6 -0
  117. data/tryouts/misc/console_tryout.rb +91 -0
  118. data/tryouts/misc/disks_tryout.rb +48 -0
  119. data/tryouts/misc/drydock_tryout.rb +48 -0
  120. data/tryouts/misc/nested_methods.rb +103 -0
  121. data/tryouts/misc/session_tryout.rb +46 -0
  122. data/tryouts/misc/tryouts.rb +33 -0
  123. data/tryouts/misc/usage_tryout.rb +23 -0
  124. metadata +119 -31
  125. data/bin/ird +0 -153
  126. data/lib/rudy/metadata/backups.rb +0 -67
  127. data/lib/rudy/metadata/debug.rb +0 -38
  128. data/lib/rudy/metadata/disks.rb +0 -67
  129. data/lib/rudy/metadata/objectbase.rb +0 -108
  130. data/lib/rudy/routines/helper.rb +0 -76
  131. data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
  132. data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
  133. data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
  134. data/lib/rudy/routines/helpers/userhelper.rb +0 -37
  135. data/support/rudy-ec2-startup +0 -200
@@ -6,16 +6,14 @@ module Rudy
6
6
 
7
7
 
8
8
  def disks
9
- rdisk = Rudy::Disks.new
10
- rback = Rudy::Backups.new
11
- more, less = [], []
9
+ more, less = {}, []
12
10
  less = [:environment, :role] if @option.all
13
11
  # We first get the disk metadata
14
- disk_list = rdisk.list(more, less) || []
12
+ disk_list = Rudy::Disks.list(more, less) || []
15
13
  # If there are no disks currently, there could be backups
16
14
  # so we grab those to create a list of disks.
17
15
  if @option.backups
18
- backups = rback.list(more, less) || []
16
+ backups = Rudy::Backups.list(more, less) || []
19
17
  backups.each_with_index do |b, index|
20
18
  disk_list << b.disk
21
19
  end
@@ -36,15 +34,15 @@ module Rudy
36
34
  end
37
35
 
38
36
  def disks_wash
39
- rdisk = Rudy::Disks.new
40
- dirt = (rdisk.list || [])#.select { |d| d.available? }
37
+ dirt = (Rudy::Disks.list || []).select { |d| !d.volume_exists? }
41
38
  if dirt.empty?
42
- puts "Nothing to wash in #{rdisk.current_machine_group}"
39
+ puts "Nothing to wash in #{current_machine_group}"
43
40
  return
44
41
  end
45
42
 
46
43
  puts "The following disk metadata will be deleted:"
47
44
  puts dirt.collect {|d| d.name }
45
+
48
46
  execute_check(:medium)
49
47
 
50
48
  dirt.each do |d|
@@ -0,0 +1,53 @@
1
+
2
+
3
+ module Rudy::CLI
4
+
5
+ # A base for all Drydock executables (bin/rudy etc...).
6
+ class Base
7
+ extend Drydock
8
+
9
+ debug :off
10
+
11
+ before do |obj|
12
+ # Don't print Rudy header unless requested to
13
+ obj.global.print_header = false if (obj.global.verbose == 0)
14
+ @start = Time.now
15
+ end
16
+
17
+ after do |obj|
18
+ if obj.global.verbose > 0
19
+ puts
20
+ @elapsed = Time.now - @start
21
+ puts "Elapsed: %.2f seconds" % @elapsed.to_f if @elapsed > 0.1
22
+ end
23
+ end
24
+
25
+ # These globals are used by all bin/ executables
26
+ global :A, :accesskey, String, "AWS Access Key"
27
+ global :S, :secretkey, String, "AWS Secret Access Key"
28
+ global :R, :region, String, "Amazon service region (e.g. #{Rudy::DEFAULT_REGION})"
29
+ global :z, :zone, String, "Amazon Availability zone (e.g. #{Rudy::DEFAULT_ZONE})"
30
+ global :u, :user, String, "Provide a username (ie: #{Rudy.sysinfo.user})"
31
+ global :l, :localhost, String, "Provide a localhost (e.g. #{Rudy.sysinfo.hostname})"
32
+ global :i, :identity, String, "Path to SSH identity (private key) for RSA or DSA authentication"
33
+ global :k, :pkey, String, "AWS Private Encryption Key (pk-****.pem)"
34
+ global :c, :cert, String, "AWS Private Certificate (cert-****.pem)"
35
+ global :f, :format, String, "Output format"
36
+ global :n, :nocolor, "Disable output colors"
37
+ global :C, :config, String, "Specify another configuration file to read (e.g. #{Rudy::CONFIG_FILE})"
38
+ global :Y, :yes, "Assume a correct answer to confirmation questions"
39
+ global :q, :quiet, "Run with less output"
40
+ global :O, :offline, "Be cool about the internet being down"
41
+ global :v, :verbose, "Increase verbosity of output (e.g. -v or -vv or -vvv)" do
42
+ @verbose ||= 0
43
+ @verbose += 1
44
+ end
45
+ global :V, :version, "Display version number" do
46
+ puts "Rudy version: #{Rudy::VERSION}"
47
+ exit 0
48
+ end
49
+
50
+
51
+ end
52
+
53
+ end
@@ -4,18 +4,16 @@ module Rudy
4
4
  module CLI
5
5
  class Machines < Rudy::CLI::CommandBase
6
6
 
7
-
8
7
  def machines
9
8
  # Rudy::Machines.list takes two optional args for adding or
10
9
  # removing metadata attributes to modify the select query.
11
10
  # When all is specified we want to find machines in every
12
11
  # environment and role to we remove these attributes from
13
12
  # the select.
14
- more, less = nil, nil
15
- less = [:environment, :role] if @option.all
13
+ fields, less = {}, []
14
+ less = Rudy::Metadata::COMMON_FIELDS if @option.all
16
15
 
17
- rmach = Rudy::Machines.new
18
- mlist = rmach.list(more, less) || []
16
+ mlist = Rudy::Machines.list(fields, less) || []
19
17
  if mlist.empty?
20
18
  if @option.all
21
19
  puts "No machines running"
@@ -30,10 +28,9 @@ module Rudy
30
28
  end
31
29
 
32
30
  def machines_wash
33
- rmach = Rudy::Machines.new
34
- dirt = (rmach.list || []).select { |m| !m.running? }
31
+ dirt = (Rudy::Machines.list || []).select { |m| !m.instance_running? }
35
32
  if dirt.empty?
36
- puts "Nothing to wash in #{rmach.current_machine_group}"
33
+ puts "Nothing to wash in #{current_machine_group}"
37
34
  return
38
35
  end
39
36
 
@@ -49,14 +46,14 @@ module Rudy
49
46
 
50
47
 
51
48
  def ssh
52
- # TODO: Give this methos a good look over
53
- pkey = user_keypairpath(@@global.user)
49
+ # TODO: Give this method a good look over
50
+ pkey = current_user_keypairpath
54
51
  unless pkey
55
- puts "No private key configured for #{@@global.user} in #{current_machine_group}"
52
+ puts "No private key configured for #{current_machine_user} in #{current_machine_group}"
56
53
  end
57
54
 
58
55
  # Options to be sent to Net::SSH
59
- ssh_opts = { :user => @@global.user || Rudy.sysinfo.user, :debug => nil }
56
+ ssh_opts = { :user => current_machine_user, :debug => nil }
60
57
  if pkey
61
58
  raise "Cannot find file #{pkey}" unless File.exists?(pkey)
62
59
  raise InsecureKeyPermissions, @pkey unless File.stat(pkey).mode == 33152
@@ -68,7 +65,7 @@ module Rudy
68
65
  # session so we need to prepare the command and its arguments
69
66
  if @argv.first
70
67
  command, command_args = @argv.shift, @argv || []
71
- puts "#{command} #{command_args.join(' ')}" if @@global.verbose > 1
68
+ Rudy::Huxtable.ld "COMMAND: #{command} #{command_args.join(' ')}" if @@global.verbose > 1
72
69
 
73
70
  # otherwise, we'll open an ssh session or print command
74
71
  else
@@ -77,14 +74,13 @@ module Rudy
77
74
 
78
75
 
79
76
  checked = false
80
- rudy = Rudy::Machines.new
81
- lt = rudy.list
77
+ lt = Rudy::Machines.list
82
78
  unless lt
83
- puts "No machines running in #{rudy.current_machine_group}"
79
+ puts "No machines running in #{current_machine_group}"
84
80
  exit
85
81
  end
86
82
  lt.each do |machine|
87
- machine.update # make sure we have the latest DNS info
83
+ machine.refresh! # make sure we have the latest DNS info
88
84
 
89
85
  # mount -t ext3 /dev/sdr /rudy/disk1
90
86
 
@@ -92,7 +88,7 @@ module Rudy
92
88
  if @@global.quiet
93
89
  print "You are #{ssh_opts[:user].to_s.bright}. " if !checked # only the 1st
94
90
  else
95
- puts machine_separator(machine.name, machine.awsid)
91
+ puts machine_separator(machine.name, machine.instid)
96
92
  puts "Connecting #{ssh_opts[:user].to_s.bright}@#{machine.dns_public} "
97
93
  puts
98
94
  end
@@ -2,34 +2,48 @@
2
2
 
3
3
  module Rudy
4
4
  module CLI
5
- class MetaData < Rudy::CLI::CommandBase
5
+ class Metadata < Rudy::CLI::CommandBase
6
6
 
7
+ def metadata_valid?
8
+ @option.rtype ||= 'm'
9
+ @metaobj = Rudy::Metadata.get_rclass @option.rtype
10
+ true
11
+ end
7
12
 
8
13
  def metadata
9
- more, less = [], []
10
- less = [:environment, :role, :zone, :region] if @option.all
11
- more += [:rtype, @option.otype] if @option.otype
14
+ unless @argv.empty?
15
+ h = Rudy::Metadata.get(@argv.first)
16
+ return if h.nil?
17
+ @metaobj = Rudy::Metadata.get_rclass h['rtype'].first
18
+ objlist = Hash[@argv.first => @metaobj.from_hash(h)]
19
+ else
20
+ more, less = {}, []
21
+ less = [:environment, :role, :zone, :region, :position] if @option.all
22
+ objlist = @metaobj.list_as_hash(more, less) || {}
23
+ end
12
24
 
13
- rdebug = Rudy::MetaData::Debug.new
14
- objlist = rdebug.list(more, less) || []
15
- objlist.each do |o|
16
- p o
25
+ objlist.each_pair do |k,o|
26
+ puts "#{k}: " << o.inspect
17
27
  end
18
28
  end
19
29
 
20
30
  def metadata_delete_valid?
21
31
  raise "Must supply object ID" unless @argv.oid
32
+ raise Rudy::Metadata::UnknownObject, @argv.oid unless Rudy::Metadata.exists? @argv.oid
22
33
  true
23
34
  end
24
35
 
25
36
  def metadata_delete
26
- rdebug = Rudy::MetaData::Debug.new
37
+
27
38
  unless @@global.quiet
28
39
  msg = "NOTE: This will delete only the metadata and "
29
40
  msg << "not the EC2 object (volume, instance, etc...)"
30
41
  puts msg
31
42
  end
32
- p rdebug.get( @argv.oid)
43
+
44
+ execute_check(:medium)
45
+
46
+ Rudy::Metadata.destroy @argv.oid
33
47
  end
34
48
 
35
49
  end
@@ -3,6 +3,30 @@
3
3
  module Rudy; module CLI;
4
4
  class Routines < Rudy::CLI::CommandBase
5
5
 
6
+ def routines_valid?
7
+ raise Rudy::NoRoutinesConfig unless @@config.routines
8
+ true
9
+ end
10
+
11
+ def routines
12
+ if @@config.nil? || @@config.empty?
13
+ return if @@global.quiet
14
+ raise Rudy::NoConfig
15
+ end
16
+
17
+ if @option.all
18
+ routine = @@config.routines
19
+ else
20
+ routine = {}
21
+ routine.merge! @@config.routines.find_deferred(@@global.environment, @@global.role) || {}
22
+ routine.merge! @@config.routines.find(@@global.role) || {}
23
+ end
24
+
25
+ outform = @@global.format == :json ? :to_json : :to_yaml
26
+
27
+ puts routine.to_hash.send(outform)
28
+ end
29
+
6
30
  def startup_valid?
7
31
  @rr = Rudy::Routines::Startup.new(@alias, @option, @argv)
8
32
  @rr.raise_early_exceptions
@@ -12,7 +36,7 @@ module Rudy; module CLI;
12
36
  machines = @rr.execute || []
13
37
  puts $/, "The following machines are now available:" unless machines.empty?
14
38
  machines.each do |machine|
15
- puts @@global.verbose > 2 ? machine.inspect : machine.dump(@@global.format)
39
+ puts machine
16
40
  end
17
41
  end
18
42
 
@@ -25,7 +49,7 @@ module Rudy; module CLI;
25
49
  machines = @rr.execute
26
50
  puts $/, "The following machines have been restarted:"
27
51
  machines.each do |machine|
28
- puts @@global.verbose > 2 ? machine.inspect : machine.dump(@@global.format)
52
+ puts machine
29
53
  end
30
54
  end
31
55
 
@@ -48,12 +72,13 @@ module Rudy; module CLI;
48
72
  # raise an exception.
49
73
  #
50
74
  def passthrough
75
+
51
76
  machines = @rr.execute
52
77
 
53
- unless machines.empty?
78
+ if @global.verbose > 1 && !machines.empty?
54
79
  puts $/, "The following machines were processed:"
55
80
  machines.each do |machine|
56
- puts @@global.verbose > 2 ? machine.inspect : machine.dump(@@global.format)
81
+ puts machine
57
82
  end
58
83
  end
59
84
 
@@ -78,9 +103,10 @@ module Rudy; module CLI;
78
103
  execute_check :medium
79
104
 
80
105
  machines = @rr.execute
106
+
81
107
  puts $/, "The following instances have been destroyed:"
82
108
  machines.each do |machine|
83
- puts '%s %s ' % [machine.name.bright, machine.awsid]
109
+ puts '%s %s ' % [machine.name.bright, machine.instid]
84
110
  end
85
111
 
86
112
 
@@ -10,19 +10,13 @@ module Rudy
10
10
  dsl Rudy::Config::Routines::DSL # Organized processes
11
11
  dsl Rudy::Config::Machines::DSL # Organized instances
12
12
  dsl Rudy::Config::Commands::DSL # Custom SSH commands
13
- #dsl Rudy::Config::Networks::DSL # Network design
14
- #dsl Rudy::Config::Controls::DSL # Network access
15
- #dsl Rudy::Config::Services::DSL # Stuff running on ports
16
-
17
- def accounts?; self.respond_to?(:accounts) && !self[:accounts].nil?; end #a
18
- def defaults?; self.respond_to?(:defaults) && !self[:defaults].nil?; end #u
19
- def machines?; self.respond_to?(:machines) && !self[:machines].nil?; end #t
20
- def commands?; self.respond_to?(:commands) && !self[:commands].nil?; end #o
21
- def routines?; self.respond_to?(:routines) && !self[:routines].nil?; end #g
22
- #def networks?; self.respond_to?(:networks) && !self[:networks].nil?; end #e
23
- #def controls?; self.respond_to?(:controls) && !self[:controls].nil?; end #n
24
- #def services?; self.respond_to?(:services) && !self[:services].nil?; end #!
25
13
 
14
+ def accounts?; self.respond_to?(:accounts) && !self[:accounts].nil?; end
15
+ def defaults?; self.respond_to?(:defaults) && !self[:defaults].nil?; end
16
+ def machines?; self.respond_to?(:machines) && !self[:machines].nil?; end
17
+ def commands?; self.respond_to?(:commands) && !self[:commands].nil?; end
18
+ def routines?; self.respond_to?(:routines) && !self[:routines].nil?; end
19
+
26
20
  # This method is called by Caesars::Config.refresh for every DSL
27
21
  # file that is loaded and parsed. If we want to run processing
28
22
  # for a particular config (machines, @routines, etc...) we can
@@ -65,6 +59,7 @@ module Rudy
65
59
  break
66
60
  end
67
61
 
62
+ # self.keys returns the current config types (machines, routines, etc...)
68
63
  typelist = self.keys.collect { |g| "#{g}.rb" }.join(',')
69
64
 
70
65
  # Rudy then looks for the rest of the config in these locations
@@ -89,18 +84,18 @@ module Rudy
89
84
 
90
85
  unless File.exists?(Rudy::CONFIG_FILE)
91
86
  puts "Creating #{Rudy::CONFIG_FILE}"
92
- rudy_config = Rudy::Utils.without_indent %Q{
93
- accounts do # Account Access Indentifiers
94
- aws do # amazon web services
87
+ rudy_config = Rudy::Utils.without_indent %Q`
88
+ accounts { # Account Access Indentifiers
89
+ aws { # amazon web services
95
90
  name "Rudy Default"
96
- accountnum ""
97
- accesskey ""
98
- secretkey ""
99
- privatekey "~/path/2/pk-xxxx.pem"
91
+ accountnum "012345678912"
92
+ accesskey "ACCESSACCESS"
93
+ secretkey "SECRETSECRET"
94
+ pkey "~/path/2/pk-xxxx.pem"
100
95
  cert "~/path/2/cert-xxxx.pem"
101
- end
102
- end
103
- }
96
+ }
97
+ }
98
+ `
104
99
  Rudy::Utils.write_to_file(Rudy::CONFIG_FILE, rudy_config, 'w', 0600)
105
100
  end
106
101
  end
@@ -9,6 +9,8 @@ class Rudy::Config
9
9
  end
10
10
 
11
11
  class Accounts < Caesars
12
+ include Gibbler::Complex
13
+
12
14
  def valid?
13
15
  (!aws.nil? && !aws.accesskey.nil? && !aws.secretkey.nil?) &&
14
16
  (!aws.account.empty? && !aws.accesskey.empty? && !aws.secretkey.empty?)
@@ -18,6 +20,8 @@ class Rudy::Config
18
20
  # Default configuration. All of the defaults can be overridden
19
21
  # on the command line with global options.
20
22
  class Defaults < Caesars
23
+ include Gibbler::Complex
24
+
21
25
  class DoubleDefined < Rudy::Config::Error
22
26
  def message; "Check your defaults config. '#{@obj}' has been defined twice"; end
23
27
  end
@@ -29,10 +33,14 @@ class Rudy::Config
29
33
  next unless self[k].is_a?(Array)
30
34
  raise Defaults::DoubleDefined.new(:defaults, k)
31
35
  end
36
+ self.keydir &&= File.expand_path(self.keydir)
32
37
  end
33
38
  end
34
39
 
35
- class Machines < Caesars; end
40
+ class Machines < Caesars
41
+ include Gibbler::Complex
42
+
43
+ end
36
44
 
37
45
  # Modify the SSH command available in routines. The default
38
46
  # set of commands is defined by Rye::Cmd (Rudy executes all
@@ -42,6 +50,8 @@ class Rudy::Config
42
50
  # important that new keywords do not conflict with existing
43
51
  # Rudy keywords. Strange things may happen!
44
52
  class Commands < Caesars
53
+ include Gibbler::Complex
54
+
45
55
  class AlreadyDefined < Rudy::Config::Error
46
56
  def message; "The command '#{@obj}' has already been defined for this project"; end
47
57
  end
@@ -102,12 +112,12 @@ class Rudy::Config
102
112
  # We can allow existing commands to be overridden but we
103
113
  # print a message to STDERR so the user knows what's up.
104
114
  if Rye::Cmd.can?(cmd)
105
- STDERR.puts "Redefining #{cmd}" #if @@global.verbose > 0
115
+ STDERR.puts "Redefining #{cmd}" if Rudy::Huxtable.global.verbose > 2
106
116
  end
107
117
 
108
118
  if args.last.is_a?(Proc)
109
119
  block = args.pop
110
- Rye::Cmd.add_command(cmd, nil, args, &block)
120
+ Rye::Cmd.add_command(cmd, nil, *args, &block)
111
121
  else
112
122
  # If no path was specified, we can assume cmd is in the remote path so
113
123
  # when we add the method to Rye::Cmd, we'll it the path is "cmd".
@@ -115,7 +125,7 @@ class Rudy::Config
115
125
 
116
126
  raise PathNotString.new(:commands, cmd) if path && !path.is_a?(String)
117
127
 
118
- Rye::Cmd.add_command cmd, path, args
128
+ Rye::Cmd.add_command cmd, path, *args
119
129
 
120
130
  end
121
131
 
@@ -137,6 +147,11 @@ class Rudy::Config
137
147
  end
138
148
 
139
149
  class Routines < Caesars
150
+ include Gibbler::Complex
151
+
152
+ # All routines
153
+ forced_array :before
154
+ forced_array :after
140
155
 
141
156
  # Disk routines
142
157
  forced_hash :create
@@ -147,37 +162,36 @@ class Rudy::Config
147
162
  forced_hash :mount
148
163
  forced_hash :attach
149
164
  forced_hash :detach
150
- forced_hash :snapshot
165
+ forced_hash :archive
151
166
  forced_hash :restore
167
+ forced_hash :format
152
168
 
153
- # Script blocks
154
- forced_hash :before
155
- forced_hash :after
156
- forced_hash :script_local
157
- forced_hash :before_local
158
- forced_hash :after_local # We force hash the script keywords b/c
159
- forced_hash :script # we want them to store the usernames
160
- chill :before # as hash keys.
161
- chill :after # We also chill them b/c we want to execute
162
- chill :before_local # the command blocks with an instance_eval
163
- chill :after_local # inside a Rye::Box object.
164
- chill :script
165
- chill :script_local
166
-
167
- # Version control systems
168
- forced_hash :git
169
- forced_hash :svn
170
-
169
+ # Passthrough routines
170
+ forced_hash :local # Force hash b/c we want to
171
+ forced_hash :remote # store the usernames.
172
+ chill :local # Chill b/c we want to execute
173
+ chill :remote # the blocks with Rye::Box#batch
174
+ forced_hash :xlocal
175
+ forced_hash :xremote
176
+ chill :xlocal
177
+ chill :xremote
178
+
179
+ forced_hash :network
180
+ chill :network
181
+
182
+ # Startup, Shutdown, Reboot routines
183
+ forced_hash :before_local
184
+ forced_hash :before_remote
185
+ forced_hash :after_local
186
+ forced_hash :after_remote
187
+ chill :before_local
188
+ chill :before_remote
189
+ chill :after_local
190
+ chill :after_remote
191
+
171
192
  def init
172
193
  end
173
194
 
174
195
  end
175
196
 
176
-
177
- class Networks < Caesars #:nodoc:all
178
- end
179
- class Controls < Caesars #:nodoc:all
180
- end
181
- class Services < Caesars #:nodoc:all
182
- end
183
197
  end