vgh 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +36 -46
- data/Rakefile +7 -0
- data/conf/config.yml.example +27 -6
- data/lib/vgh/apps/checkpoint.rb +55 -0
- data/lib/vgh/apps/ec2_backup.rb +21 -45
- data/lib/vgh/apps.rb +2 -1
- data/lib/vgh/cli.rb +9 -9
- data/lib/vgh/configuration.rb +60 -71
- data/lib/vgh/{extended_aws/extended_ec2 → ec2}/metadata.rb +5 -6
- data/lib/vgh/ec2/snapshot.rb +112 -0
- data/lib/vgh/ec2/volume.rb +77 -0
- data/lib/vgh/ec2.rb +15 -0
- data/lib/vgh/output.rb +0 -2
- data/lib/vgh/system/lvm.rb +38 -24
- data/lib/vgh/system/mysql.rb +16 -6
- data/lib/vgh/system.rb +50 -10
- data/lib/vgh/version.rb +1 -1
- data/lib/vgh.rb +3 -1
- data/spec/cli_spec.rb +14 -22
- data/spec/configuration_spec.rb +44 -0
- data/spec/ec2/metadata_spec.rb +14 -0
- data/spec/ec2/snapshot_spec.rb +39 -0
- data/spec/ec2/volume_spec.rb +47 -0
- data/spec/helpers/aws_mock.rb +49 -0
- data/spec/helpers/spec.rb +4 -22
- data/spec/logging_spec.rb +29 -4
- data/spec/output_spec.rb +30 -4
- data/spec/version_spec.rb +11 -0
- data/vgh.gemspec +1 -0
- metadata +41 -14
- data/conf/ec2-backup.config.yml.example +0 -12
- data/lib/vgh/extended_aws/extended_ec2/snapshot.rb +0 -87
- data/lib/vgh/extended_aws/extended_ec2/volume.rb +0 -66
- data/lib/vgh/extended_aws/extended_ec2.rb +0 -10
- data/lib/vgh/extended_aws.rb +0 -10
- data/spec/extended_aws/extended_ec2/metadata_spec.rb +0 -24
- data/spec/extended_aws/extended_ec2/snapshot_spec.rb +0 -48
- data/spec/extended_aws/extended_ec2/volume_spec.rb +0 -27
@@ -0,0 +1,49 @@
|
|
1
|
+
shared_context 'AWS Dummy' do
|
2
|
+
|
3
|
+
before(:all) do
|
4
|
+
@fqdn = 'test.example.com'
|
5
|
+
|
6
|
+
AWS.stub!
|
7
|
+
AWS.config({:access_key_id => '1234', :secret_access_key => '4321'})
|
8
|
+
@ec2 = AWS::EC2.new
|
9
|
+
|
10
|
+
# Instance
|
11
|
+
@instance = @ec2.instances['i-12345678']
|
12
|
+
|
13
|
+
# Volumes
|
14
|
+
@volume1 = @ec2.volumes['vol-11111111']
|
15
|
+
@tag1 = @volume1.tag('Name', :value => 'VolumeName')
|
16
|
+
@tag2 = @volume1.tag('Checkpoint')
|
17
|
+
|
18
|
+
@volume2 = @ec2.volumes['vol-22222222']
|
19
|
+
@tag3 = @volume2.tag('Checkpoint')
|
20
|
+
|
21
|
+
@volume3 = @ec2.volumes['vol-33333333']
|
22
|
+
|
23
|
+
# Tags
|
24
|
+
@tag_collection = AWS::EC2::TagCollection
|
25
|
+
@tag_hash = {
|
26
|
+
'Name' => 'TestTag',
|
27
|
+
'MyTAG' => 'TestValue'
|
28
|
+
}
|
29
|
+
|
30
|
+
# Attachments
|
31
|
+
@device1 = '/dev/sdz1'
|
32
|
+
@device2 = '/dev/sdz2'
|
33
|
+
@device3 = '/dev/sdz3'
|
34
|
+
@attachment1 = AWS::EC2::Attachment.new(@volume1, @instance, @device1)
|
35
|
+
@attachment2 = AWS::EC2::Attachment.new(@volume2, @instance, @device2)
|
36
|
+
@attachment3 = AWS::EC2::Attachment.new(@volume3, @instance, @device3)
|
37
|
+
@instance_mappings = {
|
38
|
+
@device1 => @attachment1,
|
39
|
+
@device2 => @attachment2,
|
40
|
+
@device3 => @attachment3
|
41
|
+
}
|
42
|
+
|
43
|
+
# Snapshots
|
44
|
+
@snapshot = @ec2.snapshots['snap-12345678']
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
data/spec/helpers/spec.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'aws-sdk'
|
3
|
+
|
1
4
|
RSpec.configure do |config|
|
2
5
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
3
6
|
config.run_all_when_everything_filtered = true
|
@@ -14,26 +17,5 @@ class Dummy
|
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
before(:each) do
|
19
|
-
AWS.stub!
|
20
|
-
AWS.config({:access_key_id => '', :secret_access_key => ''})
|
21
|
-
@ec2 = AWS::EC2.new
|
22
|
-
@instance = AWS::EC2::Instance.new('i-12345678')
|
23
|
-
@fqdn = 'test.example.com'
|
24
|
-
@volume = AWS::EC2::Volume.new('vol-12345678')
|
25
|
-
@snapshot = AWS::EC2::Snapshot.new('snap-12345678')
|
26
|
-
@device = '/dev/test'
|
27
|
-
@attachment = AWS::EC2::Attachment.new(@volume, @instance, @device)
|
28
|
-
@instance.stub(:block_device_mappings).and_return({
|
29
|
-
@device => @attachment
|
30
|
-
})
|
20
|
+
require "#{File.dirname(__FILE__)}/aws_mock.rb"
|
31
21
|
|
32
|
-
subject.stub(:ec2).and_return(@ec2)
|
33
|
-
subject.stub(:instance_id).and_return(@instance.id)
|
34
|
-
subject.stub(:fqdn).and_return(@fqdn)
|
35
|
-
subject.stub(:instance).and_return(@instance)
|
36
|
-
subject.stub(:snapshot).and_return(@snapshot)
|
37
|
-
subject.stub(:message).and_return(Dummy.new)
|
38
|
-
end
|
39
|
-
end
|
data/spec/logging_spec.rb
CHANGED
@@ -3,9 +3,34 @@ require 'vgh'
|
|
3
3
|
require 'vgh/logging'
|
4
4
|
|
5
5
|
describe VGH::Logging do
|
6
|
-
|
7
|
-
|
8
|
-
log.should_receive(:
|
9
|
-
log.
|
6
|
+
|
7
|
+
it 'Should write STDOUT messages' do
|
8
|
+
subject.log.should_receive(:stdout).with('RSpec Test')
|
9
|
+
subject.log.stdout('RSpec Test')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'Should write DEBUG messages' do
|
13
|
+
subject.log.should_receive(:debug).with('RSpec Test')
|
14
|
+
subject.log.debug('RSpec Test')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Should write INFO messages' do
|
18
|
+
subject.log.should_receive(:info).with('RSpec Test')
|
19
|
+
subject.log.info('RSpec Test')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'Should write WARN messages' do
|
23
|
+
subject.log.should_receive(:warn).with('RSpec Test')
|
24
|
+
subject.log.warn('RSpec Test')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'Should write ERROR messages' do
|
28
|
+
subject.log.should_receive(:error).with('RSpec Test')
|
29
|
+
subject.log.error('RSpec Test')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'Should write FATAL messages' do
|
33
|
+
subject.log.should_receive(:fatal).with('RSpec Test')
|
34
|
+
subject.log.fatal('RSpec Test')
|
10
35
|
end
|
11
36
|
end
|
data/spec/output_spec.rb
CHANGED
@@ -7,9 +7,35 @@ require 'vgh/logging'
|
|
7
7
|
require 'vgh/configuration'
|
8
8
|
|
9
9
|
describe VGH::Output do
|
10
|
-
|
11
|
-
it
|
12
|
-
|
13
|
-
|
10
|
+
|
11
|
+
it 'Should write STDOUT messages' do
|
12
|
+
subject.should_receive(:stdout).with('RSpec Test')
|
13
|
+
subject.stdout('RSpec Test')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Should write DEBUG messages' do
|
17
|
+
subject.should_receive(:debug).with('RSpec Test')
|
18
|
+
subject.debug('RSpec Test')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'Should write INFO messages' do
|
22
|
+
subject.should_receive(:info).with('RSpec Test')
|
23
|
+
subject.info('RSpec Test')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Should write WARN messages' do
|
27
|
+
subject.should_receive(:warn).with('RSpec Test')
|
28
|
+
subject.warn('RSpec Test')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'Should write ERROR messages' do
|
32
|
+
subject.should_receive(:error).with('RSpec Test')
|
33
|
+
subject.error('RSpec Test')
|
14
34
|
end
|
35
|
+
|
36
|
+
it 'Should write FATAL messages' do
|
37
|
+
subject.should_receive(:fatal).with('RSpec Test')
|
38
|
+
subject.fatal('RSpec Test')
|
39
|
+
end
|
40
|
+
|
15
41
|
end
|
data/vgh.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vgh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -107,6 +107,22 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: reek
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
110
126
|
description: Vlad's custom scripts
|
111
127
|
email:
|
112
128
|
- vgit@vladgh.com
|
@@ -126,17 +142,16 @@ files:
|
|
126
142
|
- Rakefile
|
127
143
|
- bin/vgh
|
128
144
|
- conf/config.yml.example
|
129
|
-
- conf/ec2-backup.config.yml.example
|
130
145
|
- lib/vgh.rb
|
131
146
|
- lib/vgh/apps.rb
|
147
|
+
- lib/vgh/apps/checkpoint.rb
|
132
148
|
- lib/vgh/apps/ec2_backup.rb
|
133
149
|
- lib/vgh/cli.rb
|
134
150
|
- lib/vgh/configuration.rb
|
135
|
-
- lib/vgh/
|
136
|
-
- lib/vgh/
|
137
|
-
- lib/vgh/
|
138
|
-
- lib/vgh/
|
139
|
-
- lib/vgh/extended_aws/extended_ec2/volume.rb
|
151
|
+
- lib/vgh/ec2.rb
|
152
|
+
- lib/vgh/ec2/metadata.rb
|
153
|
+
- lib/vgh/ec2/snapshot.rb
|
154
|
+
- lib/vgh/ec2/volume.rb
|
140
155
|
- lib/vgh/logging.rb
|
141
156
|
- lib/vgh/output.rb
|
142
157
|
- lib/vgh/system.rb
|
@@ -145,12 +160,15 @@ files:
|
|
145
160
|
- lib/vgh/version.rb
|
146
161
|
- spec/apps_spec.rb
|
147
162
|
- spec/cli_spec.rb
|
148
|
-
- spec/
|
149
|
-
- spec/
|
150
|
-
- spec/
|
163
|
+
- spec/configuration_spec.rb
|
164
|
+
- spec/ec2/metadata_spec.rb
|
165
|
+
- spec/ec2/snapshot_spec.rb
|
166
|
+
- spec/ec2/volume_spec.rb
|
167
|
+
- spec/helpers/aws_mock.rb
|
151
168
|
- spec/helpers/spec.rb
|
152
169
|
- spec/logging_spec.rb
|
153
170
|
- spec/output_spec.rb
|
171
|
+
- spec/version_spec.rb
|
154
172
|
- tasks/documentation.rake
|
155
173
|
- vgh.gemspec
|
156
174
|
homepage: https://github.com/vladgh/vgh
|
@@ -165,12 +183,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
183
|
- - ! '>='
|
166
184
|
- !ruby/object:Gem::Version
|
167
185
|
version: '0'
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
hash: -87386979
|
168
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
190
|
none: false
|
170
191
|
requirements:
|
171
192
|
- - ! '>='
|
172
193
|
- !ruby/object:Gem::Version
|
173
194
|
version: '0'
|
195
|
+
segments:
|
196
|
+
- 0
|
197
|
+
hash: -87386979
|
174
198
|
requirements: []
|
175
199
|
rubyforge_project:
|
176
200
|
rubygems_version: 1.8.23
|
@@ -180,10 +204,13 @@ summary: A collection of custom scripts used on VladGh.com
|
|
180
204
|
test_files:
|
181
205
|
- spec/apps_spec.rb
|
182
206
|
- spec/cli_spec.rb
|
183
|
-
- spec/
|
184
|
-
- spec/
|
185
|
-
- spec/
|
207
|
+
- spec/configuration_spec.rb
|
208
|
+
- spec/ec2/metadata_spec.rb
|
209
|
+
- spec/ec2/snapshot_spec.rb
|
210
|
+
- spec/ec2/volume_spec.rb
|
211
|
+
- spec/helpers/aws_mock.rb
|
186
212
|
- spec/helpers/spec.rb
|
187
213
|
- spec/logging_spec.rb
|
188
214
|
- spec/output_spec.rb
|
215
|
+
- spec/version_spec.rb
|
189
216
|
has_rdoc:
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# EC2-Backup app settings
|
2
|
-
|
3
|
-
# Expiration period
|
4
|
-
:expiration: 7 # Number of days to keep the snapshots
|
5
|
-
|
6
|
-
# MySQL Settings
|
7
|
-
:mysql_user: 'dbadmin' # The MySQL user that can flush the tables
|
8
|
-
:mysql_pwd: 'MyStrongPassword' # The password of the above MySQL user
|
9
|
-
|
10
|
-
# Remote settings
|
11
|
-
#:instance: 'i-12345678' # The id of the remote instance you want to backup
|
12
|
-
#:fqdn: 'MyServer.Example.com' # The FQDN of the remote instance you want to backup
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module VGH
|
2
|
-
module Extended_AWS
|
3
|
-
module Extended_EC2
|
4
|
-
|
5
|
-
# Creates a snapshot of the specified volume.
|
6
|
-
#
|
7
|
-
# == Usage
|
8
|
-
#
|
9
|
-
# snap = Snapshot.new.
|
10
|
-
# snap.create(id, tag)
|
11
|
-
#
|
12
|
-
class Snapshot
|
13
|
-
|
14
|
-
# @return [Object] The Snapshot object
|
15
|
-
attr_reader :snapshot
|
16
|
-
|
17
|
-
# The workflow to create a snapshot:
|
18
|
-
# - create snapshot
|
19
|
-
# - add a name tag
|
20
|
-
# - add an info tag
|
21
|
-
# @param [String] volume_id The ID of the volume to snapshot
|
22
|
-
# @param [String] volume_tag The Tag of the volume to snapshot
|
23
|
-
def create(volume_id, volume_tag)
|
24
|
-
create_snapshot(volume_id, volume_tag)
|
25
|
-
name_tag
|
26
|
-
info_tag(volume_id)
|
27
|
-
message.info "Creating and tagging snapshot \"#{snapshot.id}\""
|
28
|
-
end
|
29
|
-
|
30
|
-
# Creates a snapshot for the specified volume
|
31
|
-
# @param [String] volume_id The ID of the volume to snapshot
|
32
|
-
# @param [String] volume_tag The tag of the volume to snapshot
|
33
|
-
# @return [Object] The newly created snapshot object
|
34
|
-
def create_snapshot(volume_id, volume_tag)
|
35
|
-
@snapshot = ec2.volumes[volume_id].
|
36
|
-
create_snapshot("Backup for #{volume_id}(#{volume_tag})")
|
37
|
-
end
|
38
|
-
|
39
|
-
# Creates a name tag for the newly created snapshot.
|
40
|
-
# The name is the FQDN of the current instance.
|
41
|
-
def name_tag
|
42
|
-
ec2.snapshots[snapshot.id].tag('Name', :value => fqdn)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Creates an info tag for the newly created snapshot
|
46
|
-
def info_tag(volume_id)
|
47
|
-
ec2.snapshots[snapshot.id].tag("Backup_#{instance_id}", :value => volume_id)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Purges expired snapshots
|
51
|
-
def purge
|
52
|
-
expired.each do |snap|
|
53
|
-
message.info "Deleting expired snapshot (#{snap.id})"
|
54
|
-
snap.delete
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Creates a list of expired snapshots according to the expiration time
|
59
|
-
# specified in the app's configuration file
|
60
|
-
# @return [Array] An array of expired snapshot objects
|
61
|
-
def expired
|
62
|
-
@expired = []
|
63
|
-
all.each {|snap|
|
64
|
-
if snap.start_time < (Time.now - app_config[:expiration]*24*60*60)
|
65
|
-
@expired.push snap
|
66
|
-
end
|
67
|
-
}
|
68
|
-
return @expired
|
69
|
-
end
|
70
|
-
|
71
|
-
# Returns a list of snapshots that are named the same with the current FQDN.
|
72
|
-
def all
|
73
|
-
@all ||= ec2.snapshots.
|
74
|
-
with_owner('self').
|
75
|
-
tagged('Name').tagged_values(fqdn)
|
76
|
-
end
|
77
|
-
|
78
|
-
end # class Snapshot
|
79
|
-
|
80
|
-
end # module Extended_EC2
|
81
|
-
end # module Extended_AWS
|
82
|
-
end # module VGH
|
83
|
-
|
84
|
-
require 'vgh/system'
|
85
|
-
require 'vgh/output'
|
86
|
-
require 'vgh/configuration'
|
87
|
-
require 'vgh/extended_aws/extended_ec2/metadata'
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module VGH
|
2
|
-
module Extended_AWS
|
3
|
-
module Extended_EC2
|
4
|
-
|
5
|
-
# Collects information about the EBS volumes attached to the current instance.
|
6
|
-
# == Usage
|
7
|
-
# @volume = Volume.new
|
8
|
-
# @volume.list.map {|id, info|
|
9
|
-
# puts id
|
10
|
-
# puts info[:tag]
|
11
|
-
# puts info[:device)
|
12
|
-
# }
|
13
|
-
#
|
14
|
-
class Volume
|
15
|
-
|
16
|
-
# @return An instance object
|
17
|
-
def instance
|
18
|
-
@instance ||= ec2.instances[instance_id]
|
19
|
-
end
|
20
|
-
|
21
|
-
# Creates a Hash collection of volumes containing their id, tag and device
|
22
|
-
# @return [Hash]
|
23
|
-
def list
|
24
|
-
@list = {}
|
25
|
-
mappings.map {|device, info|
|
26
|
-
volume_id = info.volume.id
|
27
|
-
@list[volume_id] = {
|
28
|
-
:device => device,
|
29
|
-
:tag => tag(volume_id)
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return @list
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns a Hash containing the block device mappings of the current instance.
|
36
|
-
# @return [Hash]
|
37
|
-
def mappings
|
38
|
-
message.info "Creating a list of volumes..."
|
39
|
-
@mappings ||= instance.block_device_mappings
|
40
|
-
end
|
41
|
-
|
42
|
-
# Get volume's Name tag
|
43
|
-
# @return [String] The tag of the volume or (NOTAG) if a tag does not exists.
|
44
|
-
def tag(volume_id)
|
45
|
-
v_tags = tags(volume_id)
|
46
|
-
v_tags.count == 0 ? @tag = '(NOTAG)' : @tag = v_tags.first.value
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns a collection of tags for the specified volume.
|
50
|
-
# @param [String] volume_id The id of the volume to query for tags.
|
51
|
-
def tags(volume_id)
|
52
|
-
@tags = ec2.tags.
|
53
|
-
filter('resource-type', 'volume').
|
54
|
-
filter('key', 'Name').
|
55
|
-
filter('resource-id', volume_id)
|
56
|
-
end
|
57
|
-
|
58
|
-
end # class Volume
|
59
|
-
|
60
|
-
end # module Extended_EC2
|
61
|
-
end # module Extended_AWS
|
62
|
-
end # module VGH
|
63
|
-
|
64
|
-
require 'vgh/output'
|
65
|
-
require 'vgh/configuration'
|
66
|
-
require 'vgh/extended_aws/extended_ec2/metadata'
|
data/lib/vgh/extended_aws.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'helpers/spec'
|
2
|
-
|
3
|
-
require 'vgh/extended_aws/extended_ec2/metadata'
|
4
|
-
|
5
|
-
describe VGH::Extended_AWS::Extended_EC2::MetaData do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
subject.stub(:message).and_return(Dummy.new)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "Should retrieve the instance id" do
|
12
|
-
unless subject.instance_id.nil?
|
13
|
-
subject.instance_id.should match(/i\-.*/)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it "Should retrieve the root device" do
|
18
|
-
unless subject.root_device.nil?
|
19
|
-
subject.root_device.should match(/\/dev\/.*/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'helpers/spec'
|
2
|
-
|
3
|
-
require 'aws-sdk'
|
4
|
-
require 'vgh/extended_aws/extended_ec2/snapshot'
|
5
|
-
require 'vgh/system'
|
6
|
-
|
7
|
-
describe VGH::Extended_AWS::Extended_EC2::Snapshot do
|
8
|
-
|
9
|
-
include_context "Dummy Instance"
|
10
|
-
|
11
|
-
it "Should return a snapshot" do
|
12
|
-
subject.snapshot(@volume.id, 'test').should be_a(AWS::EC2::Snapshot)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "Should add a Name tag to a snapshot" do
|
16
|
-
subject.name_tag.should be_a(AWS::EC2::Tag)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "Should add an Info tag to a snapshot" do
|
20
|
-
subject.info_tag(@volume.id).should be_a(AWS::EC2::Tag)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "Should get a list of all snapshots" do
|
24
|
-
subject.all.should be_a(AWS::EC2::SnapshotCollection)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "Should create an array of expired snapshots" do
|
28
|
-
subject.expired.should be_empty
|
29
|
-
end
|
30
|
-
|
31
|
-
it "Should purge expired snapshots" do
|
32
|
-
subject.purge.should be_empty
|
33
|
-
end
|
34
|
-
|
35
|
-
#it "Should create a list of volumes" do
|
36
|
-
#subject.list.should be_a_kind_of Hash
|
37
|
-
#end
|
38
|
-
|
39
|
-
#it "Should get a collection of volume tags" do
|
40
|
-
#subject.tags(@volume.id).should be_a(AWS::EC2::TagCollection)
|
41
|
-
#end
|
42
|
-
|
43
|
-
#it "If no tags, it should return (NOTAG)" do
|
44
|
-
#subject.tag(@volume.id).should eq('(NOTAG)')
|
45
|
-
#end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'helpers/spec'
|
2
|
-
|
3
|
-
require 'aws-sdk'
|
4
|
-
require 'vgh/extended_aws/extended_ec2/volume'
|
5
|
-
|
6
|
-
describe VGH::Extended_AWS::Extended_EC2::Volume do
|
7
|
-
|
8
|
-
include_context "Dummy Instance"
|
9
|
-
|
10
|
-
it "Should create a hash with block device mappings" do
|
11
|
-
subject.mappings.should be_a_kind_of Hash
|
12
|
-
end
|
13
|
-
|
14
|
-
it "Should create a list of volumes" do
|
15
|
-
subject.list.should be_a_kind_of Hash
|
16
|
-
end
|
17
|
-
|
18
|
-
it "Should get a collection of volume tags" do
|
19
|
-
subject.tags(@volume.id).should be_a(AWS::EC2::TagCollection)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "If no tags, it should return (NOTAG)" do
|
23
|
-
subject.tag(@volume.id).should eq('(NOTAG)')
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|