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
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
group "Metadata"
|
3
|
+
library :rudy, 'lib'
|
4
|
+
|
5
|
+
Gibbler.enable_debug if Tryouts.verbose > 3
|
6
|
+
|
7
|
+
tryout "Disk Backups" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
Rudy.enable_debug
|
11
|
+
Rudy::Huxtable.update_config # Read config files
|
12
|
+
global = Rudy::Huxtable.global
|
13
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
14
|
+
Rudy::Metadata.connect akey, skey, region
|
15
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
16
|
+
Rudy::Disk.new( 1, '/any/path').save
|
17
|
+
end
|
18
|
+
|
19
|
+
clean do
|
20
|
+
Rudy::Disk.new( 1, '/any/path').destroy
|
21
|
+
if Rudy.debug?
|
22
|
+
puts $/, "Rudy Debugging:"
|
23
|
+
Rudy::Huxtable.logger.rewind
|
24
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
drill "no previous backups", false do
|
29
|
+
Rudy::Backups.any?
|
30
|
+
end
|
31
|
+
|
32
|
+
dream :class, Array
|
33
|
+
dream :size, 10
|
34
|
+
drill "create 10 backups" do
|
35
|
+
10.times do |i|
|
36
|
+
seconds = i.to_s.rjust(2, '0')
|
37
|
+
now = Time.parse("2009-01-01 00:00:#{seconds}")
|
38
|
+
Rudy::Backup.new(1, '/any/path', :created => now).save
|
39
|
+
end
|
40
|
+
sleep 1 # eventual consistency
|
41
|
+
Rudy::Backups.list
|
42
|
+
end
|
43
|
+
|
44
|
+
dream true
|
45
|
+
drill "listed backups are in chronological order" do
|
46
|
+
backups = Rudy::Backups.list
|
47
|
+
stash :backups, backups
|
48
|
+
prev = backups.shift
|
49
|
+
success = false
|
50
|
+
Rudy::Backups.list.each do |back|
|
51
|
+
success = (prev.created <= back.created)
|
52
|
+
break unless success
|
53
|
+
end
|
54
|
+
success
|
55
|
+
end
|
56
|
+
|
57
|
+
drill "destroy all backups", false do
|
58
|
+
Rudy::Backups.list.each { |b| b.destroy }
|
59
|
+
Rudy::Backups.any?
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
group "Metadata"
|
3
|
+
library :rudy, 'lib'
|
4
|
+
|
5
|
+
tryout "Backup Snapshot API" do
|
6
|
+
|
7
|
+
set :sample_time, Time.now.utc
|
8
|
+
set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
|
9
|
+
set :test_env, :stage #'env_' << Rudy::Utils.strand(4)
|
10
|
+
|
11
|
+
setup do
|
12
|
+
Rudy.enable_debug
|
13
|
+
Rudy::Huxtable.global.offline = true
|
14
|
+
Rudy::Huxtable.update_config # Read config files
|
15
|
+
global = Rudy::Huxtable.global
|
16
|
+
global.environment = test_env
|
17
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
18
|
+
Rudy::Metadata.connect akey, skey, region
|
19
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
20
|
+
end
|
21
|
+
|
22
|
+
clean do
|
23
|
+
if Rudy.debug?
|
24
|
+
puts $/, "Rudy Debugging:"
|
25
|
+
Rudy::Huxtable.logger.rewind
|
26
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
dream :class, Rudy::Disk
|
31
|
+
drill "Creates disk object with volume" do
|
32
|
+
b = Rudy::Backup.new(1, '/any/path', :created => sample_time)
|
33
|
+
b.disk.create
|
34
|
+
end
|
35
|
+
|
36
|
+
dream :class, String
|
37
|
+
dream :empty?, false
|
38
|
+
drill "refreshes associated disk object" do
|
39
|
+
b = Rudy::Backup.new(1, '/any/path', :created => sample_time)
|
40
|
+
b.disk.volid
|
41
|
+
end
|
42
|
+
|
43
|
+
dream :class, String
|
44
|
+
dream :empty?, false
|
45
|
+
drill "create backups with snapshot" do
|
46
|
+
b = Rudy::Backup.new(1, '/any/path', :created => sample_time)
|
47
|
+
b.create
|
48
|
+
b.snapid
|
49
|
+
end
|
50
|
+
|
51
|
+
dream :any?, true
|
52
|
+
drill "knows when there's at least one backup" do
|
53
|
+
Rudy::Backup.new(1, '/any/path')
|
54
|
+
end
|
55
|
+
|
56
|
+
dream :any?, false
|
57
|
+
drill "knows when there are no backups" do
|
58
|
+
Rudy::Backup.new(1, '/no/such/path')
|
59
|
+
end
|
60
|
+
|
61
|
+
drill "destroy disk", true do
|
62
|
+
back = Rudy::Backup.new(1, '/any/path', :created => sample_time)
|
63
|
+
back.disk.destroy
|
64
|
+
end
|
65
|
+
|
66
|
+
xdrill "destroy backup", true do
|
67
|
+
back = Rudy::Backup.new(1, '/any/path', :created => sample_time)
|
68
|
+
back.destroy
|
69
|
+
end
|
70
|
+
|
71
|
+
drill "destroy all backups", false do
|
72
|
+
Rudy::Backups.list.each { |b| b.destroy }
|
73
|
+
Rudy::Backups.any?
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
|
2
|
+
library :rudy, 'lib'
|
3
|
+
group "Metadata"
|
4
|
+
|
5
|
+
tryout "Rudy::Machine API" do
|
6
|
+
|
7
|
+
set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
|
8
|
+
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
|
9
|
+
|
10
|
+
setup do
|
11
|
+
Rudy.enable_debug
|
12
|
+
Rudy::Huxtable.global.offline = true
|
13
|
+
Rudy::Huxtable.update_config # Read config files
|
14
|
+
global = Rudy::Huxtable.global
|
15
|
+
global.environment = test_env
|
16
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
17
|
+
Rudy::Metadata.connect akey, skey, region
|
18
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
19
|
+
end
|
20
|
+
|
21
|
+
clean do
|
22
|
+
if Rudy.debug?
|
23
|
+
puts $/, "Rudy Debugging:"
|
24
|
+
Rudy::Huxtable.logger.rewind
|
25
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
dream :class, Rudy::Machine
|
30
|
+
dream :position, '02'
|
31
|
+
drill "create new machine instance" do
|
32
|
+
Rudy::Machine.new '02'
|
33
|
+
end
|
34
|
+
|
35
|
+
dream :class, Rudy::Machine
|
36
|
+
dream :position, '04'
|
37
|
+
drill "create new machine instance with integer position" do
|
38
|
+
Rudy::Machine.new 4
|
39
|
+
end
|
40
|
+
|
41
|
+
drill "save machine metadata", true do
|
42
|
+
Rudy::Machine.new.save
|
43
|
+
end
|
44
|
+
|
45
|
+
drill "knows when an object exists", true do
|
46
|
+
sleep 1 # eventual consistency
|
47
|
+
Rudy::Machine.new.exists?
|
48
|
+
end
|
49
|
+
|
50
|
+
drill "knows when an object doesn't exist", false do
|
51
|
+
Rudy::Machine.new('99').exists?
|
52
|
+
end
|
53
|
+
|
54
|
+
dream :exception, Rudy::Metadata::DuplicateRecord
|
55
|
+
drill "won't save over a machine with the same name" do
|
56
|
+
Rudy::Machine.new.save
|
57
|
+
end
|
58
|
+
|
59
|
+
drill "will save over a disk with the same name if forced", true do
|
60
|
+
Rudy::Machine.new.save :replace
|
61
|
+
end
|
62
|
+
|
63
|
+
dream :class, Rudy::Machine
|
64
|
+
dream :size, 'm1.small'
|
65
|
+
drill "refresh machine metadata" do
|
66
|
+
m = Rudy::Machine.new
|
67
|
+
m.save :replace
|
68
|
+
m.size = :nothing
|
69
|
+
m.refresh!
|
70
|
+
m
|
71
|
+
end
|
72
|
+
|
73
|
+
##dream :class, Rudy::Machine
|
74
|
+
##dream :zone, 'zone9000'
|
75
|
+
##xdrill "correctly saves zone" do
|
76
|
+
## Rudy::Machine.new(9, :zone => 'zone9000').save
|
77
|
+
## Rudy::Machine.new(9, :zone => 'zone9000').refresh!
|
78
|
+
##end
|
79
|
+
|
80
|
+
drill "destroy machine metadata", true do
|
81
|
+
Rudy::Machine.new.destroy
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
group "Metadata"
|
3
|
+
library :rudy, 'lib'
|
4
|
+
|
5
|
+
Gibbler.enable_debug if Tryouts.verbose > 3
|
6
|
+
|
7
|
+
tryout "List Machines" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
Rudy.enable_debug
|
11
|
+
Rudy::Huxtable.update_config # Read config files
|
12
|
+
global = Rudy::Huxtable.global
|
13
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
14
|
+
Rudy::Metadata.connect akey, skey, region
|
15
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
16
|
+
('01'..'03').each { |i| Rudy::Machine.new(i).save }
|
17
|
+
('04'..'05').each { |i| Rudy::Machine.new(i, :environment => :test).save }
|
18
|
+
sleep 1 # SimpleDB, eventual consistency
|
19
|
+
end
|
20
|
+
|
21
|
+
clean do
|
22
|
+
('01'..'03').each { |i| Rudy::Machine.new(i).destroy }
|
23
|
+
('04'..'05').each { |i| Rudy::Machine.new(i, :environment => :test).destroy }
|
24
|
+
if Rudy.debug?
|
25
|
+
puts $/, "Rudy Debugging:"
|
26
|
+
Rudy::Huxtable.logger.rewind
|
27
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
dream :class, Array
|
33
|
+
dream :empty?, false
|
34
|
+
dream :size, 3
|
35
|
+
drill "list available disks in default environment" do
|
36
|
+
ret = Rudy::Machines.list
|
37
|
+
#puts ret.to_json
|
38
|
+
ret
|
39
|
+
end
|
40
|
+
|
41
|
+
dream :size, 2
|
42
|
+
drill "list available disks in 'test' environment" do
|
43
|
+
ret = Rudy::Machines.list({:environment => :test})
|
44
|
+
#puts ret.to_json
|
45
|
+
ret
|
46
|
+
end
|
47
|
+
|
48
|
+
dream :size, 5
|
49
|
+
drill "list all available disks" do
|
50
|
+
ret = Rudy::Machines.list({}, [:environment])
|
51
|
+
#puts ret.to_json
|
52
|
+
ret
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
library :rudy, 'lib'
|
3
|
+
group "Metadata"
|
4
|
+
|
5
|
+
tryout "Rudy::Machine Instance API" do
|
6
|
+
|
7
|
+
set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
|
8
|
+
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
|
9
|
+
|
10
|
+
setup do
|
11
|
+
Rudy.enable_debug
|
12
|
+
Rudy::Huxtable.global.offline = true
|
13
|
+
Rudy::Huxtable.update_config # Read config files
|
14
|
+
global = Rudy::Huxtable.global
|
15
|
+
global.environment = test_env
|
16
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
17
|
+
Rudy::Metadata.connect akey, skey, region
|
18
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
19
|
+
end
|
20
|
+
|
21
|
+
clean do
|
22
|
+
if Rudy.debug?
|
23
|
+
puts $/, "Rudy Debugging:"
|
24
|
+
Rudy::Huxtable.logger.rewind
|
25
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
dream :instid, nil
|
30
|
+
drill "machine instid is nil by default" do
|
31
|
+
Rudy::Machine.new '02'
|
32
|
+
end
|
33
|
+
|
34
|
+
dream :nil?, false
|
35
|
+
dream :class, String
|
36
|
+
drill "create machine with instance" do
|
37
|
+
mach = Rudy::Machine.new '02'
|
38
|
+
mach.create
|
39
|
+
mach.instid
|
40
|
+
end
|
41
|
+
|
42
|
+
dream :nil?, false
|
43
|
+
drill "refresh machine" do
|
44
|
+
mach = Rudy::Machine.new '02'
|
45
|
+
mach.refresh!
|
46
|
+
mach.instid
|
47
|
+
end
|
48
|
+
|
49
|
+
dream [true, true]
|
50
|
+
drill "knows about the state of the instance" do
|
51
|
+
mach = Rudy::Machine.new '02'
|
52
|
+
mach.refresh!
|
53
|
+
[mach.instance_exists?, mach.instance_running?]
|
54
|
+
end
|
55
|
+
|
56
|
+
dream true
|
57
|
+
drill "destroy machine with instance" do
|
58
|
+
mach = Rudy::Machine.new '02'
|
59
|
+
mach.refresh!
|
60
|
+
mach.destroy
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
library :rudy, 'lib'
|
4
|
+
group "Metadata"
|
5
|
+
|
6
|
+
tryout "Rudy::Machines API" do
|
7
|
+
|
8
|
+
set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
|
9
|
+
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
|
10
|
+
|
11
|
+
setup do
|
12
|
+
Rudy.enable_debug
|
13
|
+
Rudy::Huxtable.global.offline = true
|
14
|
+
Rudy::Huxtable.update_config # Read config files
|
15
|
+
global = Rudy::Huxtable.global
|
16
|
+
global.environment = test_env
|
17
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
18
|
+
Rudy::Metadata.connect akey, skey, region
|
19
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
20
|
+
Rudy::Machine.new('07').save
|
21
|
+
Rudy::Machine.new('08').save
|
22
|
+
Rudy::Machine.new('09').save
|
23
|
+
end
|
24
|
+
|
25
|
+
clean do
|
26
|
+
Rudy::Machine.new('07').destroy
|
27
|
+
Rudy::Machine.new('08').destroy
|
28
|
+
Rudy::Machine.new('09').destroy
|
29
|
+
if Rudy.debug?
|
30
|
+
puts $/, "Rudy Debugging:"
|
31
|
+
Rudy::Huxtable.logger.rewind
|
32
|
+
puts Rudy::Huxtable.logger.read unless Rudy::Huxtable.logger.closed_read?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
dream :class, Rudy::Machine
|
37
|
+
drill "get machine metadata" do
|
38
|
+
Rudy::Machines.get '07'
|
39
|
+
end
|
40
|
+
|
41
|
+
drill "knows when the current group is not running", false do
|
42
|
+
Rudy::Machines.running?
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
group "Routines"
|
2
|
+
library :rudy, 'lib'
|
3
|
+
|
4
|
+
tryout "Keypair Handler" do
|
5
|
+
set :user, Rudy::Utils.strand(4)
|
6
|
+
set :keydir, '/tmp'
|
7
|
+
set :global, Rudy::Huxtable.global
|
8
|
+
set :config, Rudy::Huxtable.config
|
9
|
+
set :test_env, 'env_' << Rudy::Utils.strand
|
10
|
+
setup do
|
11
|
+
Rudy.enable_debug
|
12
|
+
Rudy::Huxtable.update_config # Read config files
|
13
|
+
akey, skey, region = global.accesskey, global.secretkey, global.region
|
14
|
+
Rudy::Metadata.connect akey, skey, region
|
15
|
+
Rudy::AWS::EC2.connect akey, skey, region
|
16
|
+
global.environment = test_env
|
17
|
+
config.defaults[:keydir] = keydir
|
18
|
+
end
|
19
|
+
|
20
|
+
drill "has new temporary ssh key directory", keydir do
|
21
|
+
config.defaults[:keydir]
|
22
|
+
end
|
23
|
+
|
24
|
+
drill "knows when a keypair isn't registered", false do
|
25
|
+
Rudy::Routines::Handlers::Keypair.registered? user
|
26
|
+
end
|
27
|
+
|
28
|
+
drill "knows when a private key file doesn't exist", false do
|
29
|
+
Rudy::Routines::Handlers::Keypair.pkey? '/path/2/' << user
|
30
|
+
end
|
31
|
+
|
32
|
+
dream "#{keydir}/key-us-east-1b-#{test_env}-app-#{user}"
|
33
|
+
drill "determine keypair path (#{user})" do
|
34
|
+
Rudy::Routines::Handlers::Keypair.pkey user
|
35
|
+
end
|
36
|
+
|
37
|
+
dream "#{keydir}/key-us-east-1b-#{test_env}-app"
|
38
|
+
drill "determine root keypair path" do
|
39
|
+
Rudy::Routines::Handlers::Keypair.pkey :root
|
40
|
+
end
|
41
|
+
|
42
|
+
dream :class, Rudy::AWS::EC2::Keypair
|
43
|
+
drill "create a new keypair" do
|
44
|
+
Rudy::Routines::Handlers::Keypair.create user
|
45
|
+
end
|
46
|
+
|
47
|
+
dream :class, Rudy::AWS::EC2::Keypair
|
48
|
+
drill "create a new root keypair" do
|
49
|
+
Rudy::Routines::Handlers::Keypair.create :root
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|