Skip to content

Commit

Permalink
refs #6442, Revise Time conversions in XML parsing in right_aws . Mak…
Browse files Browse the repository at this point in the history
…e them ALL Time or String, but not mixed
  • Loading branch information
Konstantin committed Apr 19, 2010
1 parent 23b6772 commit 1b365c1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
25 changes: 25 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,29 @@ the source key.
- Dynamic attribute accessors
- "Columns" support
- Simple Type Casting support
- ELB:
- API '2009-11-25' support (stickiness policies)
- ACF:
- API '2010-03-01' support (origin access policy and streaming distributions)
- Bunch of small issues were fixed
- Time objects were replaced by Strings (as Amazon returns them) to make the gem more consistent:
- :last_modified_time in:
RightAws::AcfInterface#incrementally_list_distributions,
RightAws::AcfInterface#create_distribution_by_config,
RightAws::AcfInterface#get_distribution,
RightAws::AcfInterface#get_distribution_config
- :timestamp in:
RightAws::AcwInterface#get_metric_statistics
- :aws_created_at in:
RightAws::Ec2#create_volume,
RightAws::Ec2#describe_volumes
- :aws_attached_at in:
RightAws::Ec2#attach_volume,
RightAws::Ec2#detach_volume,
RightAws::Ec2#describe_volumes
- :aws_started_at in:
RightAws::Ec2#describe_snapshots,
RightAws::Ec2#create_snapshot,
RightAws::Ec2#try_create_snapshot
- :describe_load_balancers in:
RightAws::ElbInterface#describe_load_balancers
15 changes: 8 additions & 7 deletions lib/acf/right_acf_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module RightAws
# :origin => "my-bucket.s3.amazonaws.com",
# :cnames => ["x1.my-awesome-site.net", "x1.my-awesome-site.net"]
# :comment => "My comments",
# :last_modified_time => Wed Sep 10 17:00:04 UTC 2008 }, ..., {...} ]
# :last_modified_time => "2008-09-10T17:00:04.000Z" }, ..., {...} ]
#
# distibution = list.first
#
Expand All @@ -55,7 +55,7 @@ module RightAws
# :aws_id => "E2REJM3VUN5RSI",
# :comment => "Woo-Hoo!",
# :origin => "my-bucket.s3.amazonaws.com",
# :last_modified_time => Wed Sep 10 17:00:54 UTC 2008 }
# :last_modified_time => "2008-09-10T17:00:54.000Z" }
#
# config = acf.get_distribution_config(distibution[:aws_id]) #=>
# {:enabled => true,
Expand Down Expand Up @@ -262,8 +262,9 @@ def list_distributions
# :origin=>"my-bucket.s3.amazonaws.com",
# :domain_name=>"d1s5gmdtmafnre.6hops.net",
# :comment=>"ONE LINE OF COMMENT",
# :last_modified_time=>Wed Oct 22 19:31:23 UTC 2008,
# :enabled=>true}],
# :last_modified_time=>"2008-10-22T19:31:23.000Z",
# :enabled=>true,
# :cnames=>[]}],
# :is_truncated=>true,
# :max_items=>1,
# :marker=>"",
Expand Down Expand Up @@ -307,7 +308,7 @@ def incrementally_list_distributions(params={}, &block)
# :cnames => ["web1.my-awesome-site.net"],
# :logging => { :prefix => "log/",
# :bucket => "my-logs.s3.amazonaws.com"},
# :last_modified_time => Wed Sep 10 17:00:54 UTC 2008,
# :last_modified_time => "2008-10-22T19:31:23.000Z",
# :caller_reference => "200809102100536497863003"}
#
def create_distribution(origin, comment='', enabled=true, cnames=[], caller_reference=nil, logging={})
Expand Down Expand Up @@ -339,7 +340,7 @@ def create_distribution_by_config(config)
# :aws_id => "E2REJM3VUN5RSI",
# :comment => "Woo-Hoo!",
# :origin => "my-bucket.s3.amazonaws.com",
# :last_modified_time => Wed Sep 10 17:00:54 UTC 2008 }
# :last_modified_time => "2008-09-10T17:00:54.000Z" }
#
# acf.get_distribution('E2FNSBHNVVF11E') #=>
# {:e_tag=>"E1Q2DJEPTQOLJD",
Expand Down Expand Up @@ -455,7 +456,7 @@ def tagend(name)
when 'IsTruncated' then @result[:is_truncated] = (@text == 'true')
when 'Id' then @distribution[:aws_id] = @text
when 'Status' then @distribution[:status] = @text
when 'LastModifiedTime' then @distribution[:last_modified_time] = Time.parse(@text)
when 'LastModifiedTime' then @distribution[:last_modified_time] = @text
when 'DomainName' then @distribution[:domain_name] = @text
when 'Origin' then @distribution[:origin] = @text
when 'Comment' then @distribution[:comment] = AcfInterface::unescape(@text)
Expand Down
2 changes: 1 addition & 1 deletion lib/acw/right_acw_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
when 'Timestamp' then @item[:timestamp] = Time.parse(@text)
when 'Timestamp' then @item[:timestamp] = @text
when 'Unit' then @item[:unit] = @text
when 'CustomUnit' then @item[:custom_unit] = @text
when 'Samples' then @item[:samples] = @text.to_f
Expand Down
24 changes: 12 additions & 12 deletions lib/ec2/right_ec2_ebs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class Ec2
# :aws_attachment_status => "attached",
# :zone => "merlot",
# :snapshot_id => nil,
# :aws_attached_at => Wed Jun 18 08:19:28 UTC 2008,
# :aws_attached_at => "2008-06-18T08:19:28.000Z",
# :aws_status => "in-use",
# :aws_id => "vol-60957009",
# :aws_created_at => Wed Jun 18 08:19:20s UTC 2008,
# :aws_created_at => "2008-06-18T08:19:20.000Z",
# :aws_instance_id => "i-c014c0a9"},
# {:aws_size => 1,
# :zone => "merlot",
Expand All @@ -65,7 +65,7 @@ def describe_volumes(*volumes)
# :aws_status => "creating",
# :aws_id => "vol-fc9f7a95",
# :zone => "merlot",
# :aws_created_at => Tue Jun 24 18:13:32 UTC 2008,
# :aws_created_at => "2008-06-24T18:13:32.000Z",
# :aws_size => 94}
#
def create_volume(snapshot_id, size, zone)
Expand Down Expand Up @@ -144,15 +144,15 @@ def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
# [ {:aws_volume_id=>"vol-545fac3d",
# :aws_description=>"Wikipedia XML Backups (Linux)",
# :aws_progress=>"100%",
# :aws_started_at=>Mon Sep 28 23:49:50 UTC 2009,
# :aws_started_at=>"2009-09-28T23:49:50.000Z",
# :aws_owner=>"amazon",
# :aws_id=>"snap-8041f2e9",
# :aws_volume_size=>500,
# :aws_status=>"completed"},
# {:aws_volume_id=>"vol-185fac71",
# :aws_description=>"Sloan Digital Sky Survey DR6 Subset (Linux)",
# :aws_progress=>"100%",
# :aws_started_at=>Mon Sep 28 23:56:10 UTC 2009,
# :aws_started_at=>"2009-09-28T23:56:10.000Z",
# :aws_owner=>"amazon",
# :aws_id=>"snap-3740f35e",
# :aws_volume_size=>180,
Expand All @@ -170,7 +170,7 @@ def describe_snapshots(*snapshots)
#
# ec2.create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
# {:aws_volume_id=>"vol-e429db8d",
# :aws_started_at=>Thu Oct 01 09:23:38 UTC 2009,
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
# :aws_description=>"KD: WooHoo!!",
# :aws_owner=>"648770000000",
# :aws_progress=>"",
Expand All @@ -194,7 +194,7 @@ def create_snapshot(volume_id, description='')
#
# ec2.try_create_snapshot('vol-898a6fe0', 'KD: WooHoo!!') #=>
# {:aws_volume_id=>"vol-e429db8d",
# :aws_started_at=>Thu Oct 01 09:23:38 UTC 2009,
# :aws_started_at=>"2009-10-01T09:23:38.000Z",
# :aws_description=>"KD: WooHoo!!",
# :aws_owner=>"648770000000",
# :aws_progress=>"",
Expand Down Expand Up @@ -335,7 +335,7 @@ def tagend(name)
case name
when 'volumeId' then @result[:aws_id] = @text
when 'status' then @result[:aws_status] = @text
when 'createTime' then @result[:aws_created_at] = Time.parse(@text)
when 'createTime' then @result[:aws_created_at] = @text
when 'size' then @result[:aws_size] = @text.to_i ###
when 'snapshotId' then @result[:snapshot_id] = @text.blank? ? nil : @text ###
when 'availabilityZone' then @result[:zone] = @text ###
Expand All @@ -353,7 +353,7 @@ def tagend(name)
when 'instanceId' then @result[:aws_instance_id] = @text
when 'device' then @result[:aws_device] = @text
when 'status' then @result[:aws_attachment_status] = @text
when 'attachTime' then @result[:aws_attached_at] = Time.parse(@text)
when 'attachTime' then @result[:aws_attached_at] = @text
end
end
def reset
Expand Down Expand Up @@ -382,10 +382,10 @@ def tagend(name)
when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' then @volume[:aws_attachment_status] = @text
end
when 'size' then @volume[:aws_size] = @text.to_i
when 'createTime' then @volume[:aws_created_at] = Time.parse(@text)
when 'createTime' then @volume[:aws_created_at] = @text
when 'instanceId' then @volume[:aws_instance_id] = @text
when 'device' then @volume[:aws_device] = @text
when 'attachTime' then @volume[:aws_attached_at] = Time.parse(@text)
when 'attachTime' then @volume[:aws_attached_at] = @text
when 'snapshotId' then @volume[:snapshot_id] = @text.blank? ? nil : @text
when 'availabilityZone' then @volume[:zone] = @text
when 'deleteOnTermination' then @volume[:delete_on_termination] = (@text == 'true')
Expand Down Expand Up @@ -415,7 +415,7 @@ def tagend(name)
when 'volumeId' then @snapshot[:aws_volume_id] = @text
when 'snapshotId' then @snapshot[:aws_id] = @text
when 'status' then @snapshot[:aws_status] = @text
when 'startTime' then @snapshot[:aws_started_at] = Time.parse(@text)
when 'startTime' then @snapshot[:aws_started_at] = @text
when 'progress' then @snapshot[:aws_progress] = @text
when 'description' then @snapshot[:aws_description] = @text
when 'ownerId' then @snapshot[:aws_owner] = @text
Expand Down
6 changes: 3 additions & 3 deletions lib/elb/right_elb_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def request_info(request, parser) #:nodoc:
# :listeners =>
# [ { :protocol => "HTTP", :load_balancer_port => "80", :instance_port => "80" },
# { :protocol => "TCP", :load_balancer_port => "443", :instance_port => "443" } ],
# :created_time => Wed May 27 11:59:11 UTC 2009,
# :created_time => "2009-05-27T11:59:11.000Z",
# :dns_name => "test-kd1-1519253964.us-east-1.elb.amazonaws.com",
# :instances => [] } ]
#
Expand All @@ -155,7 +155,7 @@ def request_info(request, parser) #:nodoc:
# :policy_names=>[],
# :instance_port=>"443",
# :protocol=>"TCP"}],
# :created_time=>Thu Apr 15 12:04:49 UTC 2010,
# :created_time=>"2010-04-15T12:04:49.000Z",
# :availability_zones=>["us-east-1a", "us-east-1b"],
# :app_cookie_stickiness_policies=>
# [{:policy_name=>"my-policy-1", :cookie_name=>"my-cookie-1"}],
Expand Down Expand Up @@ -376,7 +376,7 @@ def tagend(name)
case name
when 'LoadBalancerName' then @item[:load_balancer_name] = @text
when 'DNSName' then @item[:dns_name] = @text
when 'CreatedTime' then @item[:created_time] = Time::parse(@text)
when 'CreatedTime' then @item[:created_time] = @text
when 'Interval' then @item[:health_check][:interval] = @text.to_i
when 'Target' then @item[:health_check][:target] = @text
when 'HealthyThreshold' then @item[:health_check][:healthy_threshold] = @text.to_i
Expand Down

0 comments on commit 1b365c1

Please sign in to comment.