rudy 0.8.5 → 0.9.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.
- data/CHANGES.txt +110 -18
- data/README.rdoc +40 -44
- data/Rudyfile +35 -50
- data/bin/rudy +88 -57
- data/bin/rudy-ec2 +2 -16
- data/bin/rudy-s3 +0 -10
- data/bin/rudy-sdb +11 -12
- data/lib/rudy.rb +59 -91
- data/lib/rudy/aws.rb +4 -45
- data/lib/rudy/aws/ec2.rb +57 -20
- data/lib/rudy/aws/ec2/address.rb +10 -11
- data/lib/rudy/aws/ec2/group.rb +10 -9
- data/lib/rudy/aws/ec2/image.rb +8 -8
- data/lib/rudy/aws/ec2/instance.rb +18 -19
- data/lib/rudy/aws/ec2/keypair.rb +14 -19
- data/lib/rudy/aws/ec2/snapshot.rb +16 -9
- data/lib/rudy/aws/ec2/volume.rb +39 -26
- data/lib/rudy/aws/ec2/zone.rb +5 -4
- data/lib/rudy/aws/s3.rb +2 -1
- data/lib/rudy/aws/sdb.rb +35 -86
- data/lib/rudy/backups.rb +24 -0
- data/lib/rudy/cli.rb +5 -131
- data/lib/rudy/cli/aws/ec2/addresses.rb +19 -27
- data/lib/rudy/cli/aws/ec2/candy.rb +45 -20
- data/lib/rudy/cli/aws/ec2/groups.rb +9 -13
- data/lib/rudy/cli/aws/ec2/images.rb +5 -133
- data/lib/rudy/cli/aws/ec2/instances.rb +25 -25
- data/lib/rudy/cli/aws/ec2/keypairs.rb +7 -11
- data/lib/rudy/cli/aws/ec2/snapshots.rb +5 -9
- data/lib/rudy/cli/aws/ec2/volumes.rb +22 -23
- data/lib/rudy/cli/aws/ec2/zones.rb +2 -3
- data/lib/rudy/cli/aws/sdb/domains.rb +5 -6
- data/lib/rudy/cli/aws/sdb/objects.rb +33 -0
- data/lib/rudy/cli/aws/sdb/select.rb +23 -0
- data/lib/rudy/cli/backups.rb +38 -0
- data/lib/rudy/cli/base.rb +104 -0
- data/lib/rudy/cli/candy.rb +1 -2
- data/lib/rudy/cli/config.rb +20 -7
- data/lib/rudy/cli/disks.rb +7 -9
- data/lib/rudy/cli/execbase.rb +56 -0
- data/lib/rudy/cli/machines.rb +242 -45
- data/lib/rudy/cli/metadata.rb +24 -10
- data/lib/rudy/cli/networks.rb +34 -0
- data/lib/rudy/cli/routines.rb +32 -6
- data/lib/rudy/cli/status.rb +60 -0
- data/lib/rudy/config.rb +55 -32
- data/lib/rudy/config/objects.rb +44 -30
- data/lib/rudy/disks.rb +25 -0
- data/lib/rudy/exceptions.rb +99 -0
- data/lib/rudy/global.rb +67 -28
- data/lib/rudy/guidelines.rb +3 -2
- data/lib/rudy/huxtable.rb +67 -58
- data/lib/rudy/machines.rb +41 -263
- data/lib/rudy/metadata.rb +212 -38
- data/lib/rudy/metadata/backup.rb +123 -78
- data/lib/rudy/metadata/disk.rb +153 -170
- data/lib/rudy/metadata/machine.rb +179 -0
- data/lib/rudy/mixins.rb +2 -1
- data/lib/rudy/mixins/hash.rb +3 -1
- data/lib/rudy/mixins/symbol.rb +8 -0
- data/lib/rudy/routines.rb +127 -344
- data/lib/rudy/routines/base.rb +229 -0
- data/lib/rudy/routines/handlers/base.rb +48 -0
- data/lib/rudy/routines/handlers/depends.rb +49 -0
- data/lib/rudy/routines/handlers/disks.rb +249 -0
- data/lib/rudy/routines/handlers/group.rb +44 -0
- data/lib/rudy/routines/handlers/host.rb +70 -0
- data/lib/rudy/routines/handlers/keypair.rb +70 -0
- data/lib/rudy/routines/handlers/machines.rb +15 -0
- data/lib/rudy/routines/handlers/script.rb +85 -0
- data/lib/rudy/routines/handlers/user.rb +45 -0
- data/lib/rudy/routines/passthrough.rb +19 -23
- data/lib/rudy/routines/reboot.rb +98 -50
- data/lib/rudy/routines/shutdown.rb +65 -14
- data/lib/rudy/routines/startup.rb +112 -17
- data/lib/rudy/utils.rb +35 -68
- data/rudy.gemspec +82 -25
- data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
- data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
- data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
- data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
- data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
- data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
- data/tryouts/12_config/40_machines_tryouts.rb +53 -0
- data/tryouts/12_config/50_commands_tryouts.rb +17 -0
- data/tryouts/12_config/60_routines_tryouts.rb +16 -0
- data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
- data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
- data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
- data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
- data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
- data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
- data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
- data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
- data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
- data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
- data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
- data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
- data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
- data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
- data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
- data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
- data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
- data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
- data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
- data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
- data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
- data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
- data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
- data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
- data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
- data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
- data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
- data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
- data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
- data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
- data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
- data/tryouts/exploration/console.rb +91 -0
- data/tryouts/exploration/machine.rb +23 -0
- data/tryouts/failer +6 -0
- metadata +116 -32
- data/bin/ird +0 -153
- data/lib/rudy/metadata/backups.rb +0 -67
- data/lib/rudy/metadata/debug.rb +0 -38
- data/lib/rudy/metadata/disks.rb +0 -67
- data/lib/rudy/metadata/objectbase.rb +0 -108
- data/lib/rudy/routines/helper.rb +0 -76
- data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
- data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
- data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
- data/lib/rudy/routines/helpers/userhelper.rb +0 -37
- data/support/rudy-ec2-startup +0 -200
data/bin/ird
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
# = Interactive Rudy (experimental)
|
4
|
-
#
|
5
|
-
# === Not your granparent's deployment tool
|
6
|
-
#
|
7
|
-
# See ird -h for usage
|
8
|
-
#
|
9
|
-
|
10
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
|
11
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'highline-1.5.1', 'lib')
|
12
|
-
%w{drydock caesars rye}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
|
13
|
-
require 'rubygems'
|
14
|
-
|
15
|
-
# SEE: http://github.com/rubyspec/matzruby/blob/a34130eb7c4ecc164115a59aa1b76c643bd98202/lib/irb/xmp.rb
|
16
|
-
# SEE: http://github.com/blackwinter/wirble/tree/master
|
17
|
-
require "irb"
|
18
|
-
require 'irb/completion'
|
19
|
-
|
20
|
-
require 'rudy'
|
21
|
-
require 'drydock'
|
22
|
-
require 'rudy/cli'
|
23
|
-
|
24
|
-
|
25
|
-
class RudyCLI_Interactive < Rudy::CLI::Base # :nodoc:all
|
26
|
-
|
27
|
-
include Readline
|
28
|
-
|
29
|
-
default :interactive
|
30
|
-
debug :off
|
31
|
-
about "An interactive REPL for Rudy."
|
32
|
-
usage "#{$0} [global options]"
|
33
|
-
command :interactive do |obj|
|
34
|
-
|
35
|
-
@@rmach = Rudy::Machines.new(:global => obj.global)
|
36
|
-
@@rkey = Rudy::KeyPairs.new(:global => obj.global)
|
37
|
-
@@rgrp = Rudy::Groups.new(:global => obj.global)
|
38
|
-
@@rvol = Rudy::Volumes.new(:global => obj.global)
|
39
|
-
@@radd = Rudy::Addresses.new(:global => obj.global)
|
40
|
-
|
41
|
-
puts Rudy::CLI.generate_header(@@rmach.global, @@rmach.config)
|
42
|
-
puts Rudy::Utils.without_indent(%Q`
|
43
|
-
------------------------------------------------------------
|
44
|
-
Welcome Interactive Rudy! (EXPERIMENTAL)
|
45
|
-
------------------------------------------------------------
|
46
|
-
|
47
|
-
`)
|
48
|
-
h
|
49
|
-
|
50
|
-
# What's the deal with this error message when defining a help method?
|
51
|
-
# => rb: warn: can't alias help from irb_help
|
52
|
-
if __FILE__ == $0
|
53
|
-
IRB.start(__FILE__)
|
54
|
-
else
|
55
|
-
# check -e option
|
56
|
-
if /^-e$/ =~ $0
|
57
|
-
IRB.start(__FILE__)
|
58
|
-
else
|
59
|
-
IRB.start(__FILE__)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def h;
|
69
|
-
puts (%Q`
|
70
|
-
HELP
|
71
|
-
|
72
|
-
h Help (this screen)
|
73
|
-
m Rudy::Machines instance
|
74
|
-
g Rudy::Groups instance
|
75
|
-
k Rudy::KeyPairs instance
|
76
|
-
v Rudy::Volumes instance
|
77
|
-
a Rudy::Addresses instance
|
78
|
-
ssh [GROUP] Connect to a machine
|
79
|
-
example Start an EC2 instance from scratch.
|
80
|
-
`)
|
81
|
-
end
|
82
|
-
def example
|
83
|
-
puts (%Q`
|
84
|
-
EXAMPLE
|
85
|
-
Start an EC2 instance from scratch.
|
86
|
-
|
87
|
-
# Create a security group
|
88
|
-
>> g.create
|
89
|
-
=> #<Rudy::AWS::EC2::Group @name="stage-app" ...>
|
90
|
-
|
91
|
-
# Create a keypair (used to login as root)
|
92
|
-
>> k.create
|
93
|
-
=> #<Rudy::AWS::EC2::KeyPair @name="key-stage-app" ...>
|
94
|
-
|
95
|
-
# Start an EC2 machine instance:
|
96
|
-
>> m.create
|
97
|
-
Instance: i-228def51
|
98
|
-
Waiting for the instance to startup
|
99
|
-
........It's up!
|
100
|
-
|
101
|
-
# Login to the new instance
|
102
|
-
>> ssh
|
103
|
-
|
104
|
-
All commands in Rudy refer to the global defaults unless
|
105
|
-
otherwise specified. "stage" is the default environment and
|
106
|
-
"app" is the default role. You can change these with command
|
107
|
-
line arguments or by modifying the defaults in your Rudy
|
108
|
-
config file: #{@@rmach.config_dirname}
|
109
|
-
|
110
|
-
You can also specify your own names by providing
|
111
|
-
one as the first argument: g.create 'group5000'.
|
112
|
-
|
113
|
-
# List instances in stage-app
|
114
|
-
>> m.list :running
|
115
|
-
=> [#<Rudy::AWS::EC2::Instance:0x18c5888 ...>]
|
116
|
-
|
117
|
-
# Print the instance in a human readable way
|
118
|
-
>> puts m.list.first.to_s
|
119
|
-
|
120
|
-
# Print instance system console output
|
121
|
-
>> puts m.console
|
122
|
-
|
123
|
-
# Destroy ALL INSTANCES in stage-app
|
124
|
-
>> m.destroy
|
125
|
-
`)
|
126
|
-
end
|
127
|
-
|
128
|
-
def m; @@rmach; end
|
129
|
-
def k; @@rkey; end
|
130
|
-
def g; @@rgrp; end
|
131
|
-
def v; @@rvol; end
|
132
|
-
def a; @@radd; end
|
133
|
-
|
134
|
-
# Change Group
|
135
|
-
#def cg(name); end
|
136
|
-
|
137
|
-
def ssh(*args)
|
138
|
-
@@rmach.switch_user :root
|
139
|
-
@@rmach.connect(*args)
|
140
|
-
@@rmach.switch_user # back to previous user
|
141
|
-
nil
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
#include RudyCLI_Interactive # So we don't have to say CLI.example in the REPL.
|
148
|
-
|
149
|
-
|
150
|
-
__END__
|
151
|
-
#@rbox = Rye::Box.new('ec2-174-129-173-3.compute-1.amazonaws.com', 'root')
|
152
|
-
#@rbox2 = Rye::Box.new('ec2-174-129-173-3.compute-1.amazonaws.com', 'root')
|
153
|
-
#@rbox.add_keys('/Users/delano/Projects/git/rudy/.rudy/key-test-app.private')
|
@@ -1,67 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
class Backups
|
5
|
-
include Rudy::MetaData
|
6
|
-
|
7
|
-
def init
|
8
|
-
now = Time.now.utc
|
9
|
-
datetime = Rudy::MetaData::Backup.format_timestamp(now).split(Rudy::DELIM)
|
10
|
-
@created = now.to_i
|
11
|
-
@date, @time, @second = datetime
|
12
|
-
end
|
13
|
-
|
14
|
-
#def create(&each_mach)
|
15
|
-
|
16
|
-
#end
|
17
|
-
|
18
|
-
|
19
|
-
def destroy(&each_mach)
|
20
|
-
list do |backup|
|
21
|
-
puts "Destroying #{backup.name}"
|
22
|
-
backup.destroy
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def list(more=[], less=[], local={}, &each_backup)
|
27
|
-
backups = list_as_hash(more, less, local, &each_backup)
|
28
|
-
backups &&= backups.values
|
29
|
-
backups
|
30
|
-
end
|
31
|
-
|
32
|
-
def list_as_hash(more=[], less=[], local={}, &each_backup)
|
33
|
-
more ||= []
|
34
|
-
more += [:rtype, 'back']
|
35
|
-
query = to_select(more, less, local)
|
36
|
-
list = @sdb.select(query) || {}
|
37
|
-
backups = {}
|
38
|
-
list.each_pair do |n,d|
|
39
|
-
backups[n] = Rudy::MetaData::Backup.from_hash(d)
|
40
|
-
end
|
41
|
-
backups.each_pair { |n,backup| each_backup.call(backup) } if each_backup
|
42
|
-
backups = nil if backups.empty?
|
43
|
-
backups
|
44
|
-
end
|
45
|
-
|
46
|
-
def get(rname=nil)
|
47
|
-
dhash = @sdb.get(Rudy::DOMAIN, rname)
|
48
|
-
return nil if dhash.nil? || dhash.empty?
|
49
|
-
d = Rudy::MetaData::Backup.from_hash(dhash)
|
50
|
-
d.update if d
|
51
|
-
d
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def running?
|
56
|
-
!list.nil?
|
57
|
-
# TODO: add logic that checks whether the instances are running.
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_select(*args)
|
61
|
-
query = super(*args)
|
62
|
-
query << " and created != '0' order by created desc"
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
data/lib/rudy/metadata/debug.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy; module MetaData
|
4
|
-
class Debug
|
5
|
-
include Rudy::MetaData
|
6
|
-
|
7
|
-
def init
|
8
|
-
end
|
9
|
-
|
10
|
-
def list(more=[], less=[], local={}, &block)
|
11
|
-
objects = list_as_hash(more, less, local, &block)
|
12
|
-
objects &&= objects.values
|
13
|
-
objects
|
14
|
-
end
|
15
|
-
|
16
|
-
def list_as_hash(more=[], less=[], local={}, &block)
|
17
|
-
query = to_select(more, less, local)
|
18
|
-
list = @sdb.select(query) || {}
|
19
|
-
objects = {}
|
20
|
-
list.each_pair do |n,d|
|
21
|
-
objects[n] = d
|
22
|
-
end
|
23
|
-
objects.each_pair { |n,obj| block.call(obj) } if block
|
24
|
-
objects = nil if objects.empty?
|
25
|
-
objects
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def to_select(more, less, local)
|
30
|
-
query = super(more, less, local)
|
31
|
-
# query << " order by created desc"
|
32
|
-
puts query if @@global.verbose > 0
|
33
|
-
query
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end; end
|
38
|
-
|
data/lib/rudy/metadata/disks.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
class Disks
|
5
|
-
include Rudy::MetaData
|
6
|
-
|
7
|
-
|
8
|
-
def init
|
9
|
-
@rback = Rudy::Backups.new
|
10
|
-
end
|
11
|
-
|
12
|
-
#def create(&each_mach)
|
13
|
-
|
14
|
-
#end
|
15
|
-
|
16
|
-
|
17
|
-
def destroy(&each_mach)
|
18
|
-
#raise MachineGroupNotRunning, current_machine_group unless running?
|
19
|
-
#raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
|
20
|
-
list do |disk|
|
21
|
-
puts "Destroying #{disk.name}"
|
22
|
-
disk.destroy
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def backups
|
27
|
-
@rback.list()
|
28
|
-
end
|
29
|
-
|
30
|
-
def list(more=[], less=[], &each_disk)
|
31
|
-
disks = list_as_hash(&each_disk)
|
32
|
-
disks &&= disks.values
|
33
|
-
disks
|
34
|
-
end
|
35
|
-
|
36
|
-
def list_as_hash(more=[], less=[], &each_disk)
|
37
|
-
query = to_select([:rtype, 'disk'], less)
|
38
|
-
list = @sdb.select(query) || {}
|
39
|
-
disks = {}
|
40
|
-
list.each_pair do |n,d|
|
41
|
-
disks[n] = Rudy::MetaData::Disk.from_hash(d)
|
42
|
-
end
|
43
|
-
disks.each_pair { |n,disk| each_disk.call(disk) } if each_disk
|
44
|
-
disks = nil if disks.empty?
|
45
|
-
disks
|
46
|
-
end
|
47
|
-
|
48
|
-
def get(rname=nil)
|
49
|
-
dhash = @sdb.get(Rudy::DOMAIN, rname)
|
50
|
-
return nil if dhash.nil? || dhash.empty?
|
51
|
-
d = Rudy::MetaData::Disk.from_hash(dhash)
|
52
|
-
d.update if d
|
53
|
-
d
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def running?
|
58
|
-
!list.nil?
|
59
|
-
# TODO: add logic that checks whether the instances are running.
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
@@ -1,108 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
module MetaData
|
5
|
-
module ObjectBase
|
6
|
-
include Rudy::Huxtable
|
7
|
-
|
8
|
-
attr_accessor :sdb_domain
|
9
|
-
|
10
|
-
def initialize(*args)
|
11
|
-
a, s, r = @@global.accesskey, @@global.secretkey, @@global.region
|
12
|
-
@sdb = Rudy::AWS::SDB.new(a, s, r)
|
13
|
-
@ec2inst = Rudy::AWS::EC2::Instances.new(a, s, r)
|
14
|
-
@rvol = Rudy::AWS::EC2::Volumes.new(a, s, r)
|
15
|
-
@radd = Rudy::AWS::EC2::Addresses.new(a, s, r)
|
16
|
-
@rsnap = Rudy::AWS::EC2::Snapshots.new(a, s, r)
|
17
|
-
@sdb_domain = Rudy::DOMAIN
|
18
|
-
init(*args)
|
19
|
-
end
|
20
|
-
|
21
|
-
def init(*args); raise "Must override init"; end
|
22
|
-
|
23
|
-
def valid?; raise "#{self.class} must override 'valid?'"; end
|
24
|
-
|
25
|
-
def to_query(more=[], less=[])
|
26
|
-
Rudy::AWS::SDB.generate_query build_criteria(more, less)
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_select(more=[], less=[])
|
30
|
-
s = Rudy::AWS::SDB.generate_select ['*'], @sdb_domain, build_criteria(more, less)
|
31
|
-
s
|
32
|
-
end
|
33
|
-
|
34
|
-
def name(identifier, zon, env, rol, pos, *other)
|
35
|
-
pos = pos.to_s.rjust 2, '0'
|
36
|
-
[identifier, zon, env, rol, pos, *other].flatten.compact.join(Rudy::DELIM)
|
37
|
-
end
|
38
|
-
|
39
|
-
def save(replace=true)
|
40
|
-
replace = true if replace.nil?
|
41
|
-
@sdb ||= Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
42
|
-
@sdb.put(@sdb_domain, name, self.to_hash, replace) # Always returns nil
|
43
|
-
true
|
44
|
-
end
|
45
|
-
|
46
|
-
def destroy
|
47
|
-
@sdb ||= Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
48
|
-
@sdb.destroy(@sdb_domain, name)
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
def refresh
|
53
|
-
@sdb ||= Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
|
54
|
-
h = @sdb.get(@sdb_domain, name) || {}
|
55
|
-
from_hash(h)
|
56
|
-
end
|
57
|
-
|
58
|
-
def ==(other)
|
59
|
-
return false unless other.is_a?(self.class)
|
60
|
-
self.name == other.name
|
61
|
-
end
|
62
|
-
|
63
|
-
# A generic default
|
64
|
-
def to_s
|
65
|
-
str = ""
|
66
|
-
field_names.each do |key|
|
67
|
-
str << sprintf(" %22s: %s#{$/}", key, self.send(key.to_sym))
|
68
|
-
end
|
69
|
-
str
|
70
|
-
end
|
71
|
-
|
72
|
-
def liner_note
|
73
|
-
info = @awsid && !@awsid.empty? ? @awsid : "[no aws object]"
|
74
|
-
"%s %s" % [self.name.bright, info]
|
75
|
-
end
|
76
|
-
|
77
|
-
def inspect
|
78
|
-
lines = []
|
79
|
-
lines << liner_note
|
80
|
-
field_names.each do |key|
|
81
|
-
next unless self.respond_to?(key)
|
82
|
-
val = self.send(key)
|
83
|
-
lines << sprintf(" %22s: %s", key, (val.is_a?(Array) ? val.join(', ') : val))
|
84
|
-
end
|
85
|
-
lines.join($/)
|
86
|
-
end
|
87
|
-
|
88
|
-
protected
|
89
|
-
|
90
|
-
# Builds a zipped Array from a list of criteria.
|
91
|
-
# The list of criteria is made up of metadata object attributes.
|
92
|
-
# The list is constructed by taking the adding +more+, and
|
93
|
-
# subtracting +less+ from <tt>:rtype, :region, :zone, :environment, :role, :position</tt>
|
94
|
-
#
|
95
|
-
# Returns [[:rtype, value], [:zone, value], ...]
|
96
|
-
def build_criteria(more=[], less=[])
|
97
|
-
criteria = [:rtype, :region, :zone, :environment, :role, :position, *more].compact
|
98
|
-
criteria -= [*less].flatten.uniq.compact
|
99
|
-
values = criteria.collect do |n|
|
100
|
-
self.send(n.to_sym)
|
101
|
-
end
|
102
|
-
criteria.zip(values)
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
data/lib/rudy/routines/helper.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
module Routines
|
5
|
-
module HelperBase
|
6
|
-
include Rudy::Huxtable
|
7
|
-
|
8
|
-
def trap_rbox_errors(ret=nil, &command)
|
9
|
-
begin
|
10
|
-
ret = command.call if command
|
11
|
-
return unless ret.is_a?(Rye::Rap)
|
12
|
-
puts ' ' << ret.stdout.join("#{$/} ") if !ret.stdout.empty?
|
13
|
-
print_response(ret)
|
14
|
-
rescue IOError => ex
|
15
|
-
STDERR.puts " Connection Error (#{ex.message})".color(:red)
|
16
|
-
choice = Annoy.get_user_input('(S)kip (R)etry (A)bort: ') || ''
|
17
|
-
if choice.match(/\AS/i)
|
18
|
-
return
|
19
|
-
elsif choice.match(/\AR/i)
|
20
|
-
retry
|
21
|
-
else
|
22
|
-
exit 12
|
23
|
-
end
|
24
|
-
rescue Rye::CommandError => ex
|
25
|
-
print_response(ex)
|
26
|
-
choice = Annoy.get_user_input('(S)kip (R)etry (A)bort: ') || ''
|
27
|
-
if choice.match(/\AS/i)
|
28
|
-
return
|
29
|
-
elsif choice.match(/\AR/i)
|
30
|
-
retry
|
31
|
-
else
|
32
|
-
exit 12
|
33
|
-
end
|
34
|
-
rescue Rye::CommandNotFound => ex
|
35
|
-
STDERR.puts " CommandNotFound: #{ex.message}".color(:red)
|
36
|
-
STDERR.puts ex.backtrace if Rudy.debug?
|
37
|
-
choice = Annoy.get_user_input('(S)kip (R)etry (A)bort: ') || ''
|
38
|
-
if choice.match(/\AS/i)
|
39
|
-
return
|
40
|
-
elsif choice.match(/\AR/i)
|
41
|
-
retry
|
42
|
-
else
|
43
|
-
exit 12
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
ret
|
48
|
-
end
|
49
|
-
|
50
|
-
def keep_going?
|
51
|
-
Annoy.pose_question(" Keep going?\a ", /yes|y|ya|sure|you bet!/i, STDERR)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns a formatted string for printing command info
|
55
|
-
def command_separator(cmd, user, host)
|
56
|
-
cmd ||= ""
|
57
|
-
cmd, user = cmd.to_s, user.to_s
|
58
|
-
prompt = user == "root" ? "#" : "$"
|
59
|
-
("%s@%s%s %s" % [user, host, prompt, cmd.bright])
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
def print_response(rap)
|
64
|
-
colour = rap.exit_code != 0 ? :red : :normal
|
65
|
-
[:stderr].each do |sumpin|
|
66
|
-
next if rap.send(sumpin).empty?
|
67
|
-
STDERR.puts
|
68
|
-
STDERR.puts((" #{sumpin.to_s.upcase} " << '-'*38).color(colour).bright)
|
69
|
-
STDERR.puts " " << rap.send(sumpin).join("#{$/} ").color(colour)
|
70
|
-
end
|
71
|
-
STDERR.puts " Exit code: #{rap.exit_code}".color(colour) if rap.exit_code != 0
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|