right_aws 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -2
- data/README.txt +5 -4
- data/lib/ec2/right_ec2.rb +275 -4
- data/lib/right_aws.rb +2 -2
- data/lib/s3/right_s3_interface.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
@@ -168,12 +168,20 @@ Initial release.
|
|
168
168
|
The lstat bug was causing failure of very large file uploads on Windows [ Contributed by Benjamin Allfree ]
|
169
169
|
- Fixed parsing of the ETag field for S3 objects
|
170
170
|
|
171
|
-
|
171
|
+
== 1.7.3
|
172
172
|
|
173
173
|
Release Notes:
|
174
174
|
|
175
175
|
- Removed the 1.7.2 monkey-patch of the Ruby File class on Windows. This patch broke Rails 2.0.
|
176
176
|
The patch is now included in the README for anyone to use at their own risk.
|
177
|
-
|
178
177
|
|
178
|
+
== 1.8.0
|
179
|
+
|
180
|
+
Release Notes:
|
181
|
+
|
182
|
+
This release adds major new features to RightAws to support Amazon's new
|
183
|
+
Elastic Block Store (EBS). Via the RightAws::Ec2 module, users can create
|
184
|
+
and delete EBS volumes, attach and detach them from instances, snapshot
|
185
|
+
volumes, and list the available volumes and snapshots.
|
179
186
|
|
187
|
+
Bug fixes include correction of RightAws::S3 copy's failure to url-encode the source key.
|
data/README.txt
CHANGED
@@ -5,9 +5,10 @@ For information about RightScale, see http://www.rightscale.com
|
|
5
5
|
|
6
6
|
== DESCRIPTION:
|
7
7
|
|
8
|
-
The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2,
|
8
|
+
The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, and SDB. These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon. The RightScale AWS gems comprise:
|
9
9
|
|
10
|
-
- RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud)
|
10
|
+
- RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud) and the
|
11
|
+
associated EBS (Elastic Block Store)
|
11
12
|
- RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service)
|
12
13
|
- RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service) (API version 2007-05-01)
|
13
14
|
- RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service) (API version 2008-01-01)
|
@@ -15,7 +16,7 @@ The RightScale AWS gems have been designed to provide a robust, fast, and secure
|
|
15
16
|
|
16
17
|
== FEATURES:
|
17
18
|
|
18
|
-
- Full programmmatic access to EC2, S3, SQS, and SDB.
|
19
|
+
- Full programmmatic access to EC2, EBS, S3, SQS, and SDB.
|
19
20
|
- Complete error handling: all operations check for errors and report complete
|
20
21
|
error information by raising an AwsError.
|
21
22
|
- Persistent HTTP connections with robust network-level retry layer using
|
@@ -123,7 +124,7 @@ multithreaded mode.
|
|
123
124
|
|
124
125
|
== REQUIREMENTS:
|
125
126
|
|
126
|
-
RightAws requires REXML and the
|
127
|
+
RightAws requires REXML and the right_http_connection gem.
|
127
128
|
If libxml and its Ruby bindings (distributed in the libxml-ruby gem) are
|
128
129
|
present, RightAws can be configured to use them:
|
129
130
|
RightAws::RightAWSParser.xml_lib = 'libxml'
|
data/lib/ec2/right_ec2.rb
CHANGED
@@ -25,7 +25,8 @@ module RightAws
|
|
25
25
|
|
26
26
|
# = RightAWS::EC2 -- RightScale Amazon EC2 interface
|
27
27
|
# The RightAws::EC2 class provides a complete interface to Amazon's
|
28
|
-
# Elastic Compute Cloud service
|
28
|
+
# Elastic Compute Cloud service, as well as the associated EBS (Elastic Block
|
29
|
+
# Store).
|
29
30
|
# For explanations of the semantics
|
30
31
|
# of each call, please refer to Amazon's documentation at
|
31
32
|
# http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=87
|
@@ -67,7 +68,7 @@ module RightAws
|
|
67
68
|
include RightAwsBaseInterface
|
68
69
|
|
69
70
|
# Amazon EC2 API version being used
|
70
|
-
API_VERSION = "2008-
|
71
|
+
API_VERSION = "2008-05-05"
|
71
72
|
DEFAULT_HOST = "ec2.amazonaws.com"
|
72
73
|
DEFAULT_PATH = '/'
|
73
74
|
DEFAULT_PROTOCOL = 'https'
|
@@ -859,7 +860,168 @@ module RightAws
|
|
859
860
|
on_exception
|
860
861
|
end
|
861
862
|
|
862
|
-
|
863
|
+
#-----------------------------------------------------------------
|
864
|
+
# EBS: Volumes
|
865
|
+
#-----------------------------------------------------------------
|
866
|
+
|
867
|
+
# Describe all EBS volumes.
|
868
|
+
#
|
869
|
+
# ec2.describe_volumes #=>
|
870
|
+
# [{:aws_size => 94,
|
871
|
+
# :aws_device => "/dev/sdc",
|
872
|
+
# :aws_attachment_status => "attached",
|
873
|
+
# :zone => "merlot",
|
874
|
+
# :snapshot_id => nil,
|
875
|
+
# :aws_attached_at => Wed Jun 18 08:19:28 UTC 2008,
|
876
|
+
# :aws_status => "in-use",
|
877
|
+
# :aws_id => "vol-60957009",
|
878
|
+
# :aws_created_at => Wed Jun 18 08:19:20s UTC 2008,
|
879
|
+
# :aws_instance_id => "i-c014c0a9"},
|
880
|
+
# {:aws_size => 1,
|
881
|
+
# :zone => "merlot",
|
882
|
+
# :snapshot_id => nil,
|
883
|
+
# :aws_status => "available",
|
884
|
+
# :aws_id => "vol-58957031",
|
885
|
+
# :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
|
886
|
+
#
|
887
|
+
def describe_volumes(list=[])
|
888
|
+
link = generate_request("DescribeVolumes",
|
889
|
+
hash_params('VolumeId',list.to_a))
|
890
|
+
request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, list.blank?
|
891
|
+
rescue Exception
|
892
|
+
on_exception
|
893
|
+
end
|
894
|
+
|
895
|
+
# Create new EBS volume based on previously created snapshot.
|
896
|
+
# +Size+ in Gigabytes.
|
897
|
+
#
|
898
|
+
# ec2.create_volume('snap-000000', 10, zone) #=>
|
899
|
+
# {:snapshot_id => "snap-e21df98b",
|
900
|
+
# :aws_status => "creating",
|
901
|
+
# :aws_id => "vol-fc9f7a95",
|
902
|
+
# :zone => "merlot",
|
903
|
+
# :aws_created_at => Tue Jun 24 18:13:32 UTC 2008,
|
904
|
+
# :aws_size => 94}
|
905
|
+
#
|
906
|
+
def create_volume(snapshot_id, size, zone)
|
907
|
+
link = generate_request("CreateVolume",
|
908
|
+
"SnapshotId" => snapshot_id.to_s,
|
909
|
+
"Size" => size.to_s,
|
910
|
+
"AvailabilityZone" => zone.to_s )
|
911
|
+
request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
|
912
|
+
rescue Exception
|
913
|
+
on_exception
|
914
|
+
end
|
915
|
+
|
916
|
+
# Delete the specified EBS volume.
|
917
|
+
# This does not deletes any snapshots created from this volume.
|
918
|
+
#
|
919
|
+
# ec2.delete_volume('vol-b48a6fdd') #=> true
|
920
|
+
#
|
921
|
+
def delete_volume(volume_id)
|
922
|
+
link = generate_request("DeleteVolume",
|
923
|
+
"VolumeId" => volume_id.to_s)
|
924
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
925
|
+
rescue Exception
|
926
|
+
on_exception
|
927
|
+
end
|
928
|
+
|
929
|
+
# Attach the specified EBS volume to a specified instance, exposing the
|
930
|
+
# volume using the specified device name.
|
931
|
+
#
|
932
|
+
# ec2.attach_volume('vol-898a6fe0', 'i-7c905415', '/dev/sdh') #=>
|
933
|
+
# { :aws_instance_id => "i-7c905415",
|
934
|
+
# :aws_device => "/dev/sdh",
|
935
|
+
# :aws_status => "attaching",
|
936
|
+
# :aws_attached_at => "2008-03-28T14:14:39.000Z",
|
937
|
+
# :aws_id => "vol-898a6fe0" }
|
938
|
+
#
|
939
|
+
def attach_volume(volume_id, instance_id, device)
|
940
|
+
link = generate_request("AttachVolume",
|
941
|
+
"VolumeId" => volume_id.to_s,
|
942
|
+
"InstanceId" => instance_id.to_s,
|
943
|
+
"Device" => device.to_s)
|
944
|
+
request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
|
945
|
+
rescue Exception
|
946
|
+
on_exception
|
947
|
+
end
|
948
|
+
|
949
|
+
# Detach the specified EBS volume from the instance to which it is attached.
|
950
|
+
#
|
951
|
+
# ec2.detach_volume('vol-898a6fe0') #=>
|
952
|
+
# { :aws_instance_id => "i-7c905415",
|
953
|
+
# :aws_device => "/dev/sdh",
|
954
|
+
# :aws_status => "detaching",
|
955
|
+
# :aws_attached_at => "2008-03-28T14:38:34.000Z",
|
956
|
+
# :aws_id => "vol-898a6fe0"}
|
957
|
+
#
|
958
|
+
def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
|
959
|
+
hash = { "VolumeId" => volume_id.to_s }
|
960
|
+
hash["InstanceId"] = instance_id.to_s unless instance_id.blank?
|
961
|
+
hash["Device"] = device.to_s unless device.blank?
|
962
|
+
hash["Force"] = 'true' if force
|
963
|
+
#
|
964
|
+
link = generate_request("DetachVolume", hash)
|
965
|
+
request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
|
966
|
+
rescue Exception
|
967
|
+
on_exception
|
968
|
+
end
|
969
|
+
|
970
|
+
|
971
|
+
#-----------------------------------------------------------------
|
972
|
+
# EBS: Snapshots
|
973
|
+
#-----------------------------------------------------------------
|
974
|
+
|
975
|
+
# Describe all EBS snapshots.
|
976
|
+
#
|
977
|
+
# ec2.describe_snapshots #=>
|
978
|
+
# [ { :aws_progress => "100%",
|
979
|
+
# :aws_status => "completed",
|
980
|
+
# :aws_id => "snap-72a5401b",
|
981
|
+
# :aws_volume_id => "vol-5582673c",
|
982
|
+
# :aws_started_at => "2008-02-23T02:50:48.000Z"},
|
983
|
+
# { :aws_progress => "100%",
|
984
|
+
# :aws_status => "completed",
|
985
|
+
# :aws_id => "snap-75a5401c",
|
986
|
+
# :aws_volume_id => "vol-5582673c",
|
987
|
+
# :aws_started_at => "2008-02-23T16:23:19.000Z" },...]
|
988
|
+
#
|
989
|
+
def describe_snapshots(list=[])
|
990
|
+
link = generate_request("DescribeSnapshots",
|
991
|
+
hash_params('SnapshotId',list.to_a))
|
992
|
+
request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, list.blank?
|
993
|
+
rescue Exception
|
994
|
+
on_exception
|
995
|
+
end
|
996
|
+
|
997
|
+
# Create a snapshot of specified volume.
|
998
|
+
#
|
999
|
+
# ec2.create_snapshot('vol-898a6fe0') #=>
|
1000
|
+
# {:aws_volume_id => "vol-fd9f7a94",
|
1001
|
+
# :aws_started_at => Tue Jun 24 18:40:40 UTC 2008,
|
1002
|
+
# :aws_progress => "",
|
1003
|
+
# :aws_status => "pending",
|
1004
|
+
# :aws_id => "snap-d56783bc"}
|
1005
|
+
#
|
1006
|
+
def create_snapshot(volume_id)
|
1007
|
+
link = generate_request("CreateSnapshot",
|
1008
|
+
"VolumeId" => volume_id.to_s)
|
1009
|
+
request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
|
1010
|
+
rescue Exception
|
1011
|
+
on_exception
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
# Delete the specified snapshot.
|
1015
|
+
#
|
1016
|
+
# ec2.delete_snapshot('snap-55a5403c') #=> true
|
1017
|
+
#
|
1018
|
+
def delete_snapshot(snapshot_id)
|
1019
|
+
link = generate_request("DeleteSnapshot",
|
1020
|
+
"SnapshotId" => snapshot_id.to_s)
|
1021
|
+
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
1022
|
+
rescue Exception
|
1023
|
+
on_exception
|
1024
|
+
end
|
863
1025
|
|
864
1026
|
#-----------------------------------------------------------------
|
865
1027
|
# PARSERS: Boolean Response Parser
|
@@ -1215,7 +1377,116 @@ module RightAws
|
|
1215
1377
|
end
|
1216
1378
|
end
|
1217
1379
|
|
1218
|
-
|
1380
|
+
#-----------------------------------------------------------------
|
1381
|
+
# PARSERS: EBS - Volumes
|
1382
|
+
#-----------------------------------------------------------------
|
1383
|
+
|
1384
|
+
class QEc2CreateVolumeParser < RightAWSParser #:nodoc:
|
1385
|
+
def tagend(name)
|
1386
|
+
case name
|
1387
|
+
when 'volumeId' then @result[:aws_id] = @text
|
1388
|
+
when 'status' then @result[:aws_status] = @text
|
1389
|
+
when 'createTime' then @result[:aws_created_at] = Time.parse(@text)
|
1390
|
+
when 'size' then @result[:aws_size] = @text.to_i ###
|
1391
|
+
when 'snapshotId' then @result[:snapshot_id] = @text.blank? ? nil : @text ###
|
1392
|
+
when 'availabilityZone' then @result[:zone] = @text ###
|
1393
|
+
end
|
1394
|
+
end
|
1395
|
+
def reset
|
1396
|
+
@result = {}
|
1397
|
+
end
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
class QEc2AttachAndDetachVolumeParser < RightAWSParser #:nodoc:
|
1401
|
+
def tagend(name)
|
1402
|
+
case name
|
1403
|
+
when 'volumeId' then @result[:aws_id] = @text
|
1404
|
+
when 'instanceId' then @result[:aws_instance_id] = @text
|
1405
|
+
when 'device' then @result[:aws_device] = @text
|
1406
|
+
when 'status' then @result[:aws_attachment_status] = @text
|
1407
|
+
when 'attachTime' then @result[:aws_attached_at] = Time.parse(@text)
|
1408
|
+
end
|
1409
|
+
end
|
1410
|
+
def reset
|
1411
|
+
@result = {}
|
1412
|
+
end
|
1413
|
+
end
|
1414
|
+
|
1415
|
+
class QEc2DescribeVolumesParser < RightAWSParser #:nodoc:
|
1416
|
+
def tagstart(name, attributes)
|
1417
|
+
case name
|
1418
|
+
when 'item'
|
1419
|
+
case @xmlpath
|
1420
|
+
when 'DescribeVolumesResponse/volumeSet' then @volume = {}
|
1421
|
+
end
|
1422
|
+
end
|
1423
|
+
end
|
1424
|
+
def tagend(name)
|
1425
|
+
case name
|
1426
|
+
when 'volumeId'
|
1427
|
+
case @xmlpath
|
1428
|
+
when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_id] = @text
|
1429
|
+
end
|
1430
|
+
when 'status'
|
1431
|
+
case @xmlpath
|
1432
|
+
when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_status] = @text
|
1433
|
+
when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' then @volume[:aws_attachment_status] = @text
|
1434
|
+
end
|
1435
|
+
when 'size' then @volume[:aws_size] = @text.to_i
|
1436
|
+
when 'createTime' then @volume[:aws_created_at] = Time.parse(@text)
|
1437
|
+
when 'instanceId' then @volume[:aws_instance_id] = @text
|
1438
|
+
when 'device' then @volume[:aws_device] = @text
|
1439
|
+
when 'attachTime' then @volume[:aws_attached_at] = Time.parse(@text)
|
1440
|
+
when 'snapshotId' then @volume[:snapshot_id] = @text.blank? ? nil : @text
|
1441
|
+
when 'availabilityZone' then @volume[:zone] = @text
|
1442
|
+
when 'item'
|
1443
|
+
case @xmlpath
|
1444
|
+
when 'DescribeVolumesResponse/volumeSet' then @result << @volume
|
1445
|
+
end
|
1446
|
+
end
|
1447
|
+
end
|
1448
|
+
def reset
|
1449
|
+
@result = []
|
1450
|
+
end
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
#-----------------------------------------------------------------
|
1454
|
+
# PARSERS: EBS - Snapshots
|
1455
|
+
#-----------------------------------------------------------------
|
1456
|
+
|
1457
|
+
class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
|
1458
|
+
def tagstart(name, attributes)
|
1459
|
+
@snapshot = {} if name == 'item'
|
1460
|
+
end
|
1461
|
+
def tagend(name)
|
1462
|
+
case name
|
1463
|
+
when 'volumeId' then @snapshot[:aws_volume_id] = @text
|
1464
|
+
when 'snapshotId' then @snapshot[:aws_id] = @text
|
1465
|
+
when 'status' then @snapshot[:aws_status] = @text
|
1466
|
+
when 'startTime' then @snapshot[:aws_started_at] = Time.parse(@text)
|
1467
|
+
when 'progress' then @snapshot[:aws_progress] = @text
|
1468
|
+
when 'item' then @result << @snapshot
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
def reset
|
1472
|
+
@result = []
|
1473
|
+
end
|
1474
|
+
end
|
1475
|
+
|
1476
|
+
class QEc2CreateSnapshotParser < RightAWSParser #:nodoc:
|
1477
|
+
def tagend(name)
|
1478
|
+
case name
|
1479
|
+
when 'volumeId' then @result[:aws_volume_id] = @text
|
1480
|
+
when 'snapshotId' then @result[:aws_id] = @text
|
1481
|
+
when 'status' then @result[:aws_status] = @text
|
1482
|
+
when 'startTime' then @result[:aws_started_at] = Time.parse(@text)
|
1483
|
+
when 'progress' then @result[:aws_progress] = @text
|
1484
|
+
end
|
1485
|
+
end
|
1486
|
+
def reset
|
1487
|
+
@result = {}
|
1488
|
+
end
|
1489
|
+
end
|
1219
1490
|
|
1220
1491
|
end
|
1221
1492
|
|
data/lib/right_aws.rb
CHANGED
@@ -446,7 +446,7 @@ module RightAws
|
|
446
446
|
def copy(src_bucket, src_key, dest_bucket, dest_key=nil, directive=:copy, headers={})
|
447
447
|
dest_key ||= src_key
|
448
448
|
headers['x-amz-metadata-directive'] = directive.to_s.upcase
|
449
|
-
headers['x-amz-copy-source'] = "#{src_bucket}/#{src_key}"
|
449
|
+
headers['x-amz-copy-source'] = "#{src_bucket}/#{CGI::escape src_key}"
|
450
450
|
req_hash = generate_rest_request('PUT', headers.merge(:url=>"#{dest_bucket}/#{CGI::escape dest_key}"))
|
451
451
|
request_info(req_hash, S3CopyParser.new)
|
452
452
|
rescue
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RightScale, Inc.
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-22 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.2.1
|
23
23
|
version:
|
24
|
-
description: "== DESCRIPTION: The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2,
|
24
|
+
description: "== DESCRIPTION: The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, and SDB. These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon. The RightScale AWS gems comprise: - RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud) and the associated EBS (Elastic Block Store) - RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service) - RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service) (API version 2007-05-01) - RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service) (API version 2008-01-01) - RightAws::SdbInterface and RightAws::ActiveSdb -- interface to Amazon SDB (SimpleDB) == FEATURES:"
|
25
25
|
email: support@rightscale.com
|
26
26
|
executables: []
|
27
27
|
|