awsum 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +19 -0
- data/README.rdoc +42 -0
- data/Rakefile +75 -0
- data/awsum.gemspec +199 -0
- data/lib/awsum.rb +20 -0
- data/lib/awsum/ec2.rb +741 -0
- data/lib/awsum/ec2/address.rb +67 -0
- data/lib/awsum/ec2/availability_zone.rb +16 -0
- data/lib/awsum/ec2/image.rb +62 -0
- data/lib/awsum/ec2/instance.rb +57 -0
- data/lib/awsum/ec2/keypair.rb +16 -0
- data/lib/awsum/ec2/parsers/address_parser.rb +61 -0
- data/lib/awsum/ec2/parsers/availability_zone_parser.rb +57 -0
- data/lib/awsum/ec2/parsers/image_parser.rb +74 -0
- data/lib/awsum/ec2/parsers/instance_parser.rb +90 -0
- data/lib/awsum/ec2/parsers/keypair_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/purchase_reserved_instances_offering_parser.rb +34 -0
- data/lib/awsum/ec2/parsers/region_parser.rb +56 -0
- data/lib/awsum/ec2/parsers/register_image_parser.rb +34 -0
- data/lib/awsum/ec2/parsers/reserved_instance_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/reserved_instances_offering_parser.rb +63 -0
- data/lib/awsum/ec2/parsers/security_group_parser.rb +106 -0
- data/lib/awsum/ec2/parsers/snapshot_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/volume_parser.rb +77 -0
- data/lib/awsum/ec2/region.rb +54 -0
- data/lib/awsum/ec2/reserved_instance.rb +24 -0
- data/lib/awsum/ec2/reserved_instances_offering.rb +20 -0
- data/lib/awsum/ec2/security_group.rb +74 -0
- data/lib/awsum/ec2/snapshot.rb +23 -0
- data/lib/awsum/ec2/volume.rb +65 -0
- data/lib/awsum/error.rb +53 -0
- data/lib/awsum/net_fix.rb +100 -0
- data/lib/awsum/parser.rb +18 -0
- data/lib/awsum/requestable.rb +216 -0
- data/lib/awsum/s3.rb +220 -0
- data/lib/awsum/s3/bucket.rb +28 -0
- data/lib/awsum/s3/headers.rb +24 -0
- data/lib/awsum/s3/object.rb +138 -0
- data/lib/awsum/s3/parsers/bucket_parser.rb +43 -0
- data/lib/awsum/support.rb +94 -0
- data/spec/fixtures/ec2/addresses.xml +10 -0
- data/spec/fixtures/ec2/allocate_address.xml +5 -0
- data/spec/fixtures/ec2/associate_address.xml +5 -0
- data/spec/fixtures/ec2/attach_volume.xml +9 -0
- data/spec/fixtures/ec2/authorize_ip_access.xml +5 -0
- data/spec/fixtures/ec2/authorize_owner_group_access.xml +5 -0
- data/spec/fixtures/ec2/authorize_owner_group_access_error.xml +2 -0
- data/spec/fixtures/ec2/availability_zones.xml +16 -0
- data/spec/fixtures/ec2/available_volume.xml +14 -0
- data/spec/fixtures/ec2/create_key_pair.xml +29 -0
- data/spec/fixtures/ec2/create_security_group.xml +5 -0
- data/spec/fixtures/ec2/create_snapshot.xml +9 -0
- data/spec/fixtures/ec2/create_volume.xml +10 -0
- data/spec/fixtures/ec2/delete_key_pair.xml +5 -0
- data/spec/fixtures/ec2/delete_security_group.xml +5 -0
- data/spec/fixtures/ec2/delete_snapshot.xml +5 -0
- data/spec/fixtures/ec2/delete_volume.xml +5 -0
- data/spec/fixtures/ec2/deregister_image.xml +5 -0
- data/spec/fixtures/ec2/detach_volume.xml +9 -0
- data/spec/fixtures/ec2/disassociate_address.xml +5 -0
- data/spec/fixtures/ec2/image.xml +15 -0
- data/spec/fixtures/ec2/images.xml +77 -0
- data/spec/fixtures/ec2/instance.xml +36 -0
- data/spec/fixtures/ec2/instances.xml +88 -0
- data/spec/fixtures/ec2/internal_error.xml +2 -0
- data/spec/fixtures/ec2/invalid_amiid_error.xml +2 -0
- data/spec/fixtures/ec2/invalid_request_error.xml +2 -0
- data/spec/fixtures/ec2/key_pairs.xml +10 -0
- data/spec/fixtures/ec2/purchase_reserved_instances_offering.xml +5 -0
- data/spec/fixtures/ec2/purchase_reserved_instances_offerings.xml +6 -0
- data/spec/fixtures/ec2/regions.xml +14 -0
- data/spec/fixtures/ec2/register_image.xml +5 -0
- data/spec/fixtures/ec2/release_address.xml +5 -0
- data/spec/fixtures/ec2/reserved_instances.xml +18 -0
- data/spec/fixtures/ec2/reserved_instances_offering.xml +15 -0
- data/spec/fixtures/ec2/reserved_instances_offerings.xml +276 -0
- data/spec/fixtures/ec2/revoke_ip_access.xml +5 -0
- data/spec/fixtures/ec2/revoke_owner_group_access.xml +5 -0
- data/spec/fixtures/ec2/run_instances.xml +30 -0
- data/spec/fixtures/ec2/security_groups.xml +159 -0
- data/spec/fixtures/ec2/snapshots.xml +13 -0
- data/spec/fixtures/ec2/terminate_instances.xml +17 -0
- data/spec/fixtures/ec2/unassociated_address.xml +10 -0
- data/spec/fixtures/ec2/volumes.xml +23 -0
- data/spec/fixtures/errors/invalid_parameter_value.xml +2 -0
- data/spec/fixtures/s3/buckets.xml +2 -0
- data/spec/fixtures/s3/copy_failure.xml +23 -0
- data/spec/fixtures/s3/invalid_request_signature.xml +5 -0
- data/spec/fixtures/s3/keys.xml +2 -0
- data/spec/lib/awsum/ec2/address_spec.rb +149 -0
- data/spec/lib/awsum/ec2/availability_zones_spec.rb +21 -0
- data/spec/lib/awsum/ec2/image_spec.rb +92 -0
- data/spec/lib/awsum/ec2/instance_spec.rb +125 -0
- data/spec/lib/awsum/ec2/keypair_spec.rb +55 -0
- data/spec/lib/awsum/ec2/parsers/address_parser_spec.rb +51 -0
- data/spec/lib/awsum/ec2/parsers/availability_zone_parser_spec.rb +28 -0
- data/spec/lib/awsum/ec2/parsers/image_parser_spec.rb +66 -0
- data/spec/lib/awsum/ec2/parsers/instance_parser_spec.rb +75 -0
- data/spec/lib/awsum/ec2/parsers/keypair_parser_spec.rb +74 -0
- data/spec/lib/awsum/ec2/parsers/purchase_reserved_instances_offering_parser_spec.rb +14 -0
- data/spec/lib/awsum/ec2/parsers/region_parser_spec.rb +27 -0
- data/spec/lib/awsum/ec2/parsers/register_image_parser_spec.rb +15 -0
- data/spec/lib/awsum/ec2/parsers/reserved_instance_parser_spec.rb +35 -0
- data/spec/lib/awsum/ec2/parsers/reserved_instances_offering_parser_spec.rb +32 -0
- data/spec/lib/awsum/ec2/parsers/security_group_parser_spec.rb +78 -0
- data/spec/lib/awsum/ec2/parsers/snapshot_parser_spec.rb +30 -0
- data/spec/lib/awsum/ec2/parsers/volume_parser_spec.rb +35 -0
- data/spec/lib/awsum/ec2/region_spec.rb +73 -0
- data/spec/lib/awsum/ec2/reserved_instance_spec.rb +61 -0
- data/spec/lib/awsum/ec2/reserved_instances_offering_spec.rb +33 -0
- data/spec/lib/awsum/ec2/security_group_spec.rb +179 -0
- data/spec/lib/awsum/ec2/snapshots_spec.rb +69 -0
- data/spec/lib/awsum/ec2/volume_spec.rb +107 -0
- data/spec/lib/awsum/ec2_spec.rb +6 -0
- data/spec/lib/awsum/error_spec.rb +31 -0
- data/spec/lib/awsum/requestable_spec.rb +126 -0
- data/spec/lib/awsum/s3/bucket_spec.rb +95 -0
- data/spec/lib/awsum/s3/object_spec.rb +128 -0
- data/spec/lib/awsum/s3/parsers/bucket_parser_spec.rb +41 -0
- data/spec/lib/awsum/s3/parsers/object_parser_spec.rb +41 -0
- data/spec/spec_helper.rb +16 -0
- metadata +240 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class KeyPairParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@key_pairs = []
|
7
|
+
@text = nil
|
8
|
+
@stack = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_start(tag, attributes)
|
12
|
+
#Quick hack so we can use the same parser for CreateKeyPair which doesn't use the item tag to wrap the key pair information
|
13
|
+
if tag == 'CreateKeyPairResponse'
|
14
|
+
@stack << 'keySet'
|
15
|
+
end
|
16
|
+
|
17
|
+
case tag
|
18
|
+
when 'keySet'
|
19
|
+
@stack << 'keySet'
|
20
|
+
when 'item', 'CreateKeyPairResponse'
|
21
|
+
case @stack[-1]
|
22
|
+
when 'keySet'
|
23
|
+
@current = {}
|
24
|
+
@text = ''
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def text(text)
|
30
|
+
@text << text unless @text.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def tag_end(tag)
|
34
|
+
case tag
|
35
|
+
when 'DescribeKeyPairsResponse'
|
36
|
+
#no-op
|
37
|
+
when 'keySet'
|
38
|
+
@stack.pop
|
39
|
+
when 'item', 'CreateKeyPairResponse'
|
40
|
+
case @stack[-1]
|
41
|
+
when 'keySet'
|
42
|
+
@key_pairs << KeyPair.new(
|
43
|
+
@ec2,
|
44
|
+
@current['keyName'],
|
45
|
+
@current['keyFingerprint'],
|
46
|
+
@current['keyMaterial']
|
47
|
+
)
|
48
|
+
@text = ''
|
49
|
+
end
|
50
|
+
else
|
51
|
+
unless @text.nil?
|
52
|
+
text = @text.strip
|
53
|
+
@current[tag] = (text == '' ? nil : text)
|
54
|
+
@text = ''
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def result
|
60
|
+
@key_pairs
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Awsum
|
4
|
+
class Ec2
|
5
|
+
class PurchaseReservedInstancesOfferingParser < Awsum::Parser #:nodoc:
|
6
|
+
def initialize(ec2)
|
7
|
+
@ec2 = ec2
|
8
|
+
@ids = []
|
9
|
+
@text = nil
|
10
|
+
@stack = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag_start(tag, attributes)
|
14
|
+
@text = ''
|
15
|
+
end
|
16
|
+
|
17
|
+
def text(text)
|
18
|
+
@text << text unless @text.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def tag_end(tag)
|
22
|
+
case tag
|
23
|
+
when 'reservedInstancesId'
|
24
|
+
text = @text.strip
|
25
|
+
@ids << (text == '' ? nil : text)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def result
|
30
|
+
@ids
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class RegionParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@regions = []
|
7
|
+
@text = nil
|
8
|
+
@stack = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_start(tag, attributes)
|
12
|
+
case tag
|
13
|
+
when 'regionInfo'
|
14
|
+
@stack << 'regionInfo'
|
15
|
+
when 'item'
|
16
|
+
case @stack[-1]
|
17
|
+
when 'regionInfo'
|
18
|
+
@current = {}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@text = ''
|
22
|
+
end
|
23
|
+
|
24
|
+
def text(text)
|
25
|
+
@text << text unless @text.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def tag_end(tag)
|
29
|
+
case tag
|
30
|
+
when 'DescribeRegionsResponse', 'requestId'
|
31
|
+
#no-op
|
32
|
+
when 'regionInfo'
|
33
|
+
@stack.pop
|
34
|
+
when 'item'
|
35
|
+
case @stack[-1]
|
36
|
+
when 'regionInfo'
|
37
|
+
@regions << Region.new(
|
38
|
+
@ec2,
|
39
|
+
@current['regionName'],
|
40
|
+
@current['regionEndpoint']
|
41
|
+
)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
unless @text.nil? || @current.nil?
|
45
|
+
text = @text.strip
|
46
|
+
@current[tag] = (text == '' ? nil : text)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def result
|
52
|
+
@regions
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class RegisterImageParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@image = nil
|
7
|
+
@text = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def tag_start(tag, attributes)
|
11
|
+
case tag
|
12
|
+
when 'imageId'
|
13
|
+
@text = ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def text(text)
|
18
|
+
@text << text unless @text.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def tag_end(tag)
|
22
|
+
case tag
|
23
|
+
when 'imageId'
|
24
|
+
@image = @text
|
25
|
+
@text = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def result
|
30
|
+
@image
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class ReservedInstanceParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@reserved_instances = []
|
7
|
+
@text = nil
|
8
|
+
@stack = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_start(tag, attributes)
|
12
|
+
case tag
|
13
|
+
when 'reservedInstancesSet'
|
14
|
+
@stack << 'reservedInstancesSet'
|
15
|
+
when 'item'
|
16
|
+
case @stack[-1]
|
17
|
+
when 'reservedInstancesSet'
|
18
|
+
@current = {}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@text = ''
|
22
|
+
end
|
23
|
+
|
24
|
+
def text(text)
|
25
|
+
@text << text unless @text.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def tag_end(tag)
|
29
|
+
case tag
|
30
|
+
when 'requestId'
|
31
|
+
#no-op
|
32
|
+
when 'reservedInstancesSet'
|
33
|
+
@stack.pop
|
34
|
+
when 'item'
|
35
|
+
case @stack[-1]
|
36
|
+
when 'reservedInstancesSet'
|
37
|
+
@reserved_instances << ReservedInstance.new(
|
38
|
+
@ec2,
|
39
|
+
@current['reservedInstancesId'],
|
40
|
+
@current['instanceType'],
|
41
|
+
@current['availabilityZone'],
|
42
|
+
Time.parse(@current['start']),
|
43
|
+
@current['duration'].to_i,
|
44
|
+
@current['fixedPrice'].to_f,
|
45
|
+
@current['usagePrice'].to_f,
|
46
|
+
@current['instanceCount'].to_i,
|
47
|
+
@current['productDescription'],
|
48
|
+
@current['state']
|
49
|
+
)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
unless @text.nil? || @current.nil?
|
53
|
+
text = @text.strip
|
54
|
+
@current[tag] = (text == '' ? nil : text)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def result
|
60
|
+
@reserved_instances
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Awsum
|
4
|
+
class Ec2
|
5
|
+
class ReservedInstancesOfferingParser < Awsum::Parser #:nodoc:
|
6
|
+
def initialize(ec2)
|
7
|
+
@ec2 = ec2
|
8
|
+
@offerings = []
|
9
|
+
@text = nil
|
10
|
+
@stack = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag_start(tag, attributes)
|
14
|
+
case tag
|
15
|
+
when 'reservedInstancesOfferingsSet'
|
16
|
+
@stack << 'reservedInstancesOfferingsSet'
|
17
|
+
when 'item'
|
18
|
+
case @stack[-1]
|
19
|
+
when 'reservedInstancesOfferingsSet'
|
20
|
+
@current = {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
@text = ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def text(text)
|
27
|
+
@text << text unless @text.nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
def tag_end(tag)
|
31
|
+
case tag
|
32
|
+
when 'requestId'
|
33
|
+
#no-op
|
34
|
+
when 'reservedInstancesOfferingsSet'
|
35
|
+
@stack.pop
|
36
|
+
when 'item'
|
37
|
+
case @stack[-1]
|
38
|
+
when 'reservedInstancesOfferingsSet'
|
39
|
+
@offerings << ReservedInstancesOffering.new(
|
40
|
+
@ec2,
|
41
|
+
@current['reservedInstancesOfferingId'],
|
42
|
+
@current['instanceType'],
|
43
|
+
@current['availabilityZone'],
|
44
|
+
@current['duration'].to_i,
|
45
|
+
@current['fixedPrice'].to_f,
|
46
|
+
@current['usagePrice'].to_f,
|
47
|
+
@current['productDescription']
|
48
|
+
)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
unless @text.nil? || @current.nil?
|
52
|
+
text = @text.strip
|
53
|
+
@current[tag] = (text == '' ? nil : text)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def result
|
59
|
+
@offerings
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class SecurityGroupParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@security_groups = []
|
7
|
+
@text = nil
|
8
|
+
@stack = []
|
9
|
+
@group_permissions = []
|
10
|
+
@ip_permissions = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag_start(tag, attributes)
|
14
|
+
case tag
|
15
|
+
when 'securityGroupInfo'
|
16
|
+
@stack << 'securityGroupInfo'
|
17
|
+
when 'ipPermissions'
|
18
|
+
@stack << 'ipPermissions'
|
19
|
+
when 'groups'
|
20
|
+
@stack << 'groups'
|
21
|
+
when 'ipRanges'
|
22
|
+
@stack << 'ipRanges'
|
23
|
+
when 'item'
|
24
|
+
case @stack[-1]
|
25
|
+
when 'securityGroupInfo'
|
26
|
+
@current = {}
|
27
|
+
@group_permissions = []
|
28
|
+
@ip_permissions = []
|
29
|
+
@text = ''
|
30
|
+
when 'ipPermissions'
|
31
|
+
@permissions = {}
|
32
|
+
@text = ''
|
33
|
+
when 'groups'
|
34
|
+
@group_info = {}
|
35
|
+
@text = ''
|
36
|
+
when 'ipRanges'
|
37
|
+
@ip_info = {}
|
38
|
+
@text = ''
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def text(text)
|
44
|
+
@text << text unless @text.nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def tag_end(tag)
|
48
|
+
case tag
|
49
|
+
when 'DescribeSecurityGroupsResponse', 'requestId'
|
50
|
+
#no-op
|
51
|
+
when 'securityGroupInfo', 'ipPermissions', 'groups', 'ipRanges'
|
52
|
+
@stack.pop
|
53
|
+
when 'item'
|
54
|
+
case @stack[-1]
|
55
|
+
when 'securityGroupInfo'
|
56
|
+
@security_groups << SecurityGroup.new(
|
57
|
+
@ec2,
|
58
|
+
@current['groupName'],
|
59
|
+
@current['groupDescription'],
|
60
|
+
@current['ownerId'],
|
61
|
+
@ip_permissions,
|
62
|
+
@group_permissions
|
63
|
+
)
|
64
|
+
@text = ''
|
65
|
+
when 'groups'
|
66
|
+
@group_permissions << SecurityGroup::GroupPermission.new(
|
67
|
+
@permissions['ipProtocol'],
|
68
|
+
@permissions['fromPort'],
|
69
|
+
@permissions['toPort'],
|
70
|
+
@group_info['groupName'],
|
71
|
+
@group_info['userId']
|
72
|
+
)
|
73
|
+
when 'ipRanges'
|
74
|
+
@ip_permissions << SecurityGroup::IpPermission.new(
|
75
|
+
@permissions['ipProtocol'],
|
76
|
+
@permissions['fromPort'],
|
77
|
+
@permissions['toPort'],
|
78
|
+
@ip_info['cidrIp']
|
79
|
+
)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
unless @text.nil?
|
83
|
+
text = @text.strip
|
84
|
+
text = (text == '' ? nil : text)
|
85
|
+
|
86
|
+
case @stack[-1]
|
87
|
+
when 'securityGroupInfo'
|
88
|
+
@current[tag] = text
|
89
|
+
when 'ipPermissions'
|
90
|
+
@permissions[tag] = text
|
91
|
+
when 'groups'
|
92
|
+
@group_info[tag] = text
|
93
|
+
when 'ipRanges'
|
94
|
+
@ip_info[tag] = text
|
95
|
+
end
|
96
|
+
@text = ''
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def result
|
102
|
+
@security_groups
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Awsum
|
2
|
+
class Ec2
|
3
|
+
class SnapshotParser < Awsum::Parser #:nodoc:
|
4
|
+
def initialize(ec2)
|
5
|
+
@ec2 = ec2
|
6
|
+
@snapshots = []
|
7
|
+
@text = nil
|
8
|
+
@stack = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_start(tag, attributes)
|
12
|
+
#Quick hack so we can use the same parser for CreateSnapshot which doesn't use the item tag to wrap the snapshot information
|
13
|
+
if tag == 'CreateSnapshotResponse'
|
14
|
+
@stack << 'snapshotSet'
|
15
|
+
end
|
16
|
+
|
17
|
+
case tag
|
18
|
+
when 'snapshotSet'
|
19
|
+
@stack << 'snapshotSet'
|
20
|
+
when 'item', 'CreateSnapshotResponse'
|
21
|
+
case @stack[-1]
|
22
|
+
when 'snapshotSet'
|
23
|
+
@current = {}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@text = ''
|
27
|
+
end
|
28
|
+
|
29
|
+
def text(text)
|
30
|
+
@text << text unless @text.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def tag_end(tag)
|
34
|
+
case tag
|
35
|
+
when 'DescribeSnapshotsResponts'
|
36
|
+
#no-op
|
37
|
+
when 'snapshotSet'
|
38
|
+
@stack.pop
|
39
|
+
when 'item', 'CreateSnapshotResponse'
|
40
|
+
case @stack[-1]
|
41
|
+
when 'snapshotSet'
|
42
|
+
@snapshots << Snapshot.new(
|
43
|
+
@ec2,
|
44
|
+
@current['snapshotId'],
|
45
|
+
@current['volumeId'],
|
46
|
+
@current['status'],
|
47
|
+
@current['startTime'].blank? ? nil :Time.parse(@current['startTime']),
|
48
|
+
@current['progress']
|
49
|
+
)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
unless @text.nil? || @current.nil?
|
53
|
+
text = @text.strip
|
54
|
+
@current[tag] = (text == '' ? nil : text)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def result
|
60
|
+
@snapshots
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|