Class: Rudy::AWS::EC2::Snapshots
- Inherits:
-
Object
- Object
- Rudy::AWS::EC2::Snapshots
show all
- Includes:
- Base, ObjectBase
- Defined in:
- lib/rudy/aws/ec2/snapshot.rb
Instance Attribute Summary
Attributes included from Base
#ec2
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#initialize
Methods included from Huxtable
change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Class Method Details
.from_hash(h) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 77
def Snapshots.from_hash(h)
vol = Rudy::AWS::EC2::Snapshot.new
vol.awsid = h['snapshotId']
vol.volid = h['volumeId']
vol.created = h['startTime']
vol.progress = h['progress']
vol.status = h['status']
vol
end
|
Instance Method Details
#any? ⇒ Boolean
94
95
96
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 94
def any?
!(list_as_hash || {}).empty?
end
|
#create(vol_id) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 64
def create(vol_id)
vol_id = (vol_id.is_a?(Rudy::AWS::EC2::Volume)) ? vol_id.awsid : vol_id
shash = @ec2.create_snapshot(:volume_id => vol_id)
snap = Snapshots.from_hash(shash)
snap
end
|
#destroy(snap_id) ⇒ Object
71
72
73
74
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 71
def destroy(snap_id)
ret = @ec2.delete_snapshot(:snapshot_id => snap_id)
(ret && ret['return'] == 'true')
end
|
#exists?(id) ⇒ Boolean
102
103
104
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 102
def exists?(id)
!get(snap_id).nil?
end
|
#get(snap_id) ⇒ Object
98
99
100
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 98
def get(snap_id)
list(snap_id).first || nil
end
|
#list(snap_id = []) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 45
def list(snap_id=[])
snapshots = list_as_hash(snap_id)
if snapshots
snapshots = snapshots.values.sort { |a,b| a.created <=> b.created }
end
snapshots
end
|
#list_as_hash(snap_id = []) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/rudy/aws/ec2/snapshot.rb', line 52
def list_as_hash(snap_id=[])
snap_id = [snap_id].flatten.compact
slist = @ec2.describe_snapshots(:snapshot_id => snap_id)
return unless slist['snapshotSet'].is_a?(Hash)
snapshots = {}
slist['snapshotSet']['item'].each do |snap|
kp = self.class.from_hash(snap)
snapshots[kp.awsid] = kp
end
snapshots
end
|