зеркало из https://github.com/microsoft/fog.git
add images model for ec2
This commit is contained in:
Родитель
56728c6d8f
Коммит
13b04fb4a7
4
bin/fog
4
bin/fog
|
@ -56,6 +56,10 @@ module AWS
|
|||
connections[:ec2].flavors
|
||||
end
|
||||
|
||||
def images
|
||||
connections[:ec2].images
|
||||
end
|
||||
|
||||
def servers
|
||||
connections[:ec2].servers
|
||||
end
|
||||
|
|
|
@ -24,6 +24,8 @@ module Fog
|
|||
load "fog/aws/models/ec2/addresses.rb"
|
||||
load "fog/aws/models/ec2/flavor.rb"
|
||||
load "fog/aws/models/ec2/flavors.rb"
|
||||
load "fog/aws/models/ec2/image.rb"
|
||||
load "fog/aws/models/ec2/images.rb"
|
||||
load "fog/aws/models/ec2/key_pair.rb"
|
||||
load "fog/aws/models/ec2/key_pairs.rb"
|
||||
load "fog/aws/models/ec2/security_group.rb"
|
||||
|
|
|
@ -9,7 +9,6 @@ module Fog
|
|||
attribute :bits
|
||||
attribute :cores
|
||||
attribute :disk
|
||||
attribute :id
|
||||
attribute :name
|
||||
attribute :ram
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
class Image < Fog::Model
|
||||
|
||||
identity :id, 'imageId'
|
||||
|
||||
attribute :architecture
|
||||
attribute :location, 'imageLocation'
|
||||
attribute :owner_id, 'imageOwnerId'
|
||||
attribute :state, 'imageState'
|
||||
attribute :type, 'imageType'
|
||||
attribute :is_public, 'isPublic'
|
||||
attribute :kernel_id, 'kernelId'
|
||||
attribute :platform
|
||||
attribute :product_codes, 'productCodes'
|
||||
attribute :ramdisk_id, 'ramdiskId'
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
def images
|
||||
Fog::AWS::EC2::Images.new(:connection => self)
|
||||
end
|
||||
|
||||
class Images < Fog::Collection
|
||||
|
||||
attribute :image_id
|
||||
|
||||
model Fog::AWS::EC2::Image
|
||||
|
||||
def initialize(attributes)
|
||||
@image_id ||= []
|
||||
super
|
||||
end
|
||||
|
||||
def all(image_id = @image_id)
|
||||
@image_id = image_id
|
||||
if @loaded
|
||||
clear
|
||||
end
|
||||
@loaded = true
|
||||
data = connection.describe_images('ImageId' => image_id).body
|
||||
data['imagesSet'].each do |image|
|
||||
self << new(image)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def get(image_id)
|
||||
if image_id
|
||||
all(image_id).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,7 +9,6 @@ module Fog
|
|||
attribute :bits
|
||||
attribute :cores
|
||||
attribute :disk
|
||||
attribute :id
|
||||
attribute :name
|
||||
attribute :ram
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче