зеркало из https://github.com/microsoft/fog.git
updating ec2 models to match up s3 models
This commit is contained in:
Родитель
9322e3360b
Коммит
93bcf8ca13
|
@ -4,24 +4,22 @@ module Fog
|
|||
|
||||
class Address < Fog::Model
|
||||
|
||||
attr_accessor :instance_id,
|
||||
:public_ip
|
||||
attribute :instance_id, 'instanceId'
|
||||
attribute :public_ip, 'publicIp'
|
||||
|
||||
def initialize(attributes = {})
|
||||
remap_attributes(attributes, {
|
||||
'instanceId' => :instance_id,
|
||||
'publicIp' => :public_ip
|
||||
})
|
||||
super
|
||||
end
|
||||
|
||||
def delete
|
||||
connection.release_address(@public_ip)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.allocate_address
|
||||
@public_ip = data.body['publicIp']
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
|
||||
def all(public_ip = [])
|
||||
data = connection.describe_addresses(public_ip).body
|
||||
addresses = []
|
||||
addresses = Fog::AWS::EC2::Addresses.new(:connection => connection)
|
||||
data['addressesSet'].each do |address|
|
||||
addresses << Fog::AWS::EC2::Address.new({
|
||||
:connection => connection
|
||||
|
|
|
@ -4,28 +4,24 @@ module Fog
|
|||
|
||||
class KeyPair < Fog::Model
|
||||
|
||||
attr_accessor :fingerprint,
|
||||
:material,
|
||||
:name
|
||||
attribute :fingerprint, 'keyFingerprint'
|
||||
attribute :material, 'keyMaterial'
|
||||
attribute :name, 'keyName'
|
||||
|
||||
def initialize(attributes = {})
|
||||
remap_attributes(attributes, {
|
||||
'keyFingerprint' => :fingerprint,
|
||||
'keyMaterial' => :material,
|
||||
'keyName' => :name
|
||||
})
|
||||
super
|
||||
end
|
||||
|
||||
def delete
|
||||
connection.delete_key_pair(@name)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_key_pair(@name).body
|
||||
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
||||
update_attributes(new_attributes)
|
||||
data
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
|
||||
def all(key_name = [])
|
||||
data = connection.describe_key_pairs(key_name).body
|
||||
key_pairs = []
|
||||
key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
|
||||
data['keySet'].each do |key|
|
||||
key_pairs << Fog::AWS::EC2::KeyPair.new({
|
||||
:connection => connection
|
||||
|
|
|
@ -4,40 +4,32 @@ module Fog
|
|||
|
||||
class Volume < Fog::Model
|
||||
|
||||
attr_accessor :attachment_time,
|
||||
:availability_zone,
|
||||
:device,
|
||||
:instance_id
|
||||
:size,
|
||||
:snapshot_id,
|
||||
:status,
|
||||
:volume_id
|
||||
attribute :attachment_time, 'attachmentTime'
|
||||
attribute :availability_zone, 'availabilityZone'
|
||||
attribute :device, 'createTime'
|
||||
attribute :instance_id, 'instanceId'
|
||||
attribute :size
|
||||
attribute :snapshot_id, 'snapshotId'
|
||||
attribute :status, 'status'
|
||||
attribute :volume_id, 'volumeId'
|
||||
|
||||
def initialize(attributes = {})
|
||||
if attributes['attachmentSet']
|
||||
attributes.merge!(attributes.delete('attachmentSet'))
|
||||
end
|
||||
remap_attributes(attributes, {
|
||||
'attachmentTime' => :attachment_time,
|
||||
'availabilityZone' => :availability_zone,
|
||||
'createTime' => :create_time,
|
||||
'instanceId' => :instance_id,
|
||||
'snapshotId' => :snapshot_id,
|
||||
'status' => :status
|
||||
'volumeId' => :volume_id
|
||||
})
|
||||
super
|
||||
end
|
||||
|
||||
def delete
|
||||
connection.delete_volume(@volume_id)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
update_attributes(new_attributes)
|
||||
data
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
|
||||
def all(volume_id = [])
|
||||
data = connection.describe_volumes(volume_id)
|
||||
volumes = []
|
||||
volumes = Fog::AWS::EC2::Volumes.new(:connection => connection)
|
||||
data['volumeSet'].each do |volume|
|
||||
volumes << Fog::AWS::EC2::Volume.new({
|
||||
:connection => connection
|
||||
|
|
Загрузка…
Ссылка в новой задаче