mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
updated documentation for AWS compute
This commit is contained in:
parent
7ca702e46c
commit
dcb2704baa
10 changed files with 230 additions and 81 deletions
|
@ -11,12 +11,49 @@ module Fog
|
|||
attribute :server
|
||||
|
||||
model Fog::AWS::Compute::Address
|
||||
|
||||
# Used to create an IP address
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>> AWS.addresses.create
|
||||
# <Fog::AWS::Compute::Address
|
||||
# public_ip="4.88.524.95",
|
||||
# server_id=nil
|
||||
# >
|
||||
#
|
||||
# The IP address can be retreived by running AWS.addresses.get("test"). See get method below.
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
# AWS.addresses.all
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns an array of all IP addresses
|
||||
#
|
||||
#>> AWS.addresses.all
|
||||
# <Fog::AWS::Compute::Addresses
|
||||
# filters={},
|
||||
# server=nil
|
||||
# [
|
||||
# <Fog::AWS::Compute::Address
|
||||
# public_ip="76.7.46.54",
|
||||
# server_id=nil
|
||||
# >,
|
||||
# .......
|
||||
# <Fog::AWS::Compute::Address
|
||||
# public_ip="4.88.524.95",
|
||||
# server_id=nil
|
||||
# >
|
||||
# ]
|
||||
# >
|
||||
#>>
|
||||
|
||||
def all(filters = filters)
|
||||
unless filters.is_a?(Hash)
|
||||
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('public-ip' => []) instead[/] [light_black](#{caller.first})[/]")
|
||||
|
@ -35,6 +72,13 @@ module Fog
|
|||
self
|
||||
end
|
||||
|
||||
# Used to retreive an IP address
|
||||
#
|
||||
# public_ip is required to get the associated IP information.
|
||||
#
|
||||
# You can run the following command to get the details:
|
||||
# AWS.addresses.get("76.7.46.54")
|
||||
|
||||
def get(public_ip)
|
||||
if public_ip
|
||||
self.class.new(:connection => connection).all('public-ip' => public_ip).first
|
||||
|
|
|
@ -9,9 +9,9 @@ module Fog
|
|||
|
||||
model Fog::AWS::Compute::Flavor
|
||||
|
||||
# Returns an array of all key pairs that have been created
|
||||
# Returns an array of all flavors that have been created
|
||||
#
|
||||
# AWS.key_pairs.all
|
||||
# AWS.flavors.all
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
|
@ -28,78 +28,7 @@ module Fog
|
|||
# name="Micro Instance",
|
||||
# ram=613
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m1.small",
|
||||
# bits=32,
|
||||
# cores=1,
|
||||
# disk=160,
|
||||
# name="Small Instance",
|
||||
# ram=1740.8
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m1.large",
|
||||
# bits=64,
|
||||
# cores=4,
|
||||
# disk=850,
|
||||
# name="Large Instance",
|
||||
# ram=7680
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m1.xlarge",
|
||||
# bits=64,
|
||||
# cores=8,
|
||||
# disk=1690,
|
||||
# name="Extra Large Instance",
|
||||
# ram=15360
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="c1.medium",
|
||||
# bits=32,
|
||||
# cores=5,
|
||||
# disk=350,
|
||||
# name="High-CPU Medium",
|
||||
# ram=1740.8
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="c1.xlarge",
|
||||
# bits=64,
|
||||
# cores=20,
|
||||
# disk=1690,
|
||||
# name="High-CPU Extra Large",
|
||||
# ram=7168
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m2.xlarge",
|
||||
# bits=64,
|
||||
# cores=6.5,
|
||||
# disk=420,
|
||||
# name="High-Memory Extra Large",
|
||||
# ram=17510.4
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m2.2xlarge",
|
||||
# bits=64,
|
||||
# cores=13,
|
||||
# disk=850,
|
||||
# name="High Memory Double Extra Large",
|
||||
# ram=35020.8
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="m2.4xlarge",
|
||||
# bits=64,
|
||||
# cores=26,
|
||||
# disk=1690,
|
||||
# name="High Memory Quadruple Extra Large",
|
||||
# ram=70041.6
|
||||
# >,
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="cc1.4xlarge",
|
||||
# bits=64,
|
||||
# cores=33.5,
|
||||
# disk=1690,
|
||||
# name="Cluster Compute Quadruple Extra Large",
|
||||
# ram=23552
|
||||
# >,
|
||||
# ....
|
||||
# <Fog::AWS::Compute::Flavor
|
||||
# id="cg1.4xlarge",
|
||||
# bits=64,
|
||||
|
|
|
@ -10,18 +10,46 @@ module Fog
|
|||
attribute :filters
|
||||
|
||||
model Fog::AWS::Compute::Image
|
||||
|
||||
|
||||
# Creates a new Amazon machine image
|
||||
#
|
||||
# AWS.images.new
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new image
|
||||
#
|
||||
#>> AWS.images.new
|
||||
# <Fog::AWS::Compute::Image
|
||||
# id=nil,
|
||||
# architecture=nil,
|
||||
# block_device_mapping=nil,
|
||||
# location=nil,
|
||||
# owner_id=nil,
|
||||
# state=nil,
|
||||
# type=nil,
|
||||
# is_public=nil,
|
||||
# kernel_id=nil,
|
||||
# platform=nil,
|
||||
# product_codes=nil,
|
||||
# ramdisk_id=nil,
|
||||
# root_device_type=nil,
|
||||
# root_device_name=nil,
|
||||
# tags=nil
|
||||
# >
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def all(filters = @filters)
|
||||
self.filters = filters
|
||||
data = connection.describe_images(filters).body
|
||||
load(data['imagesSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(image_id)
|
||||
if image_id
|
||||
self.class.new(:connection => connection).all('image-id' => image_id).first
|
||||
|
|
|
@ -11,10 +11,49 @@ module Fog
|
|||
|
||||
model Fog::AWS::Compute::SecurityGroup
|
||||
|
||||
# Creates a new security group
|
||||
#
|
||||
# AWS.security_groups.new
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new image
|
||||
#
|
||||
#>> AWS.security_groups.new
|
||||
# <Fog::AWS::Compute::SecurityGroup
|
||||
# name=nil,
|
||||
# description=nil,
|
||||
# ip_permissions=nil,
|
||||
# owner_id=nil
|
||||
# >
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
# Returns an array of all security groups that have been created
|
||||
#
|
||||
# AWS.security_groups.all
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns an array of all security groups
|
||||
#
|
||||
#>> AWS.security_groups.all
|
||||
# <Fog::AWS::Compute::SecurityGroups
|
||||
# filters={}
|
||||
# [
|
||||
# <Fog::AWS::Compute::SecurityGroup
|
||||
# name="default",
|
||||
# description="default group",
|
||||
# ip_permissions=[{"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}],
|
||||
# owner_id="312571045469"
|
||||
# >
|
||||
# ]
|
||||
# >
|
||||
#
|
||||
|
||||
def all(filters = filters)
|
||||
unless filters.is_a?(Hash)
|
||||
|
@ -26,6 +65,23 @@ module Fog
|
|||
load(data['securityGroupInfo'])
|
||||
end
|
||||
|
||||
# Used to retreive a security group
|
||||
# group name is required to get the associated flavor information.
|
||||
#
|
||||
# You can run the following command to get the details:
|
||||
# AWS.security_groups.get("default")
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>> AWS.security_groups.get("default")
|
||||
# <Fog::AWS::Compute::SecurityGroup
|
||||
# name="default",
|
||||
# description="default group",
|
||||
# ip_permissions=[{"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}],
|
||||
# owner_id="312571045469"
|
||||
# >
|
||||
#
|
||||
|
||||
def get(group_name)
|
||||
if group_name
|
||||
self.class.new(:connection => connection).all('group-name' => group_name).first
|
||||
|
|
|
@ -11,6 +11,45 @@ module Fog
|
|||
|
||||
model Fog::AWS::Compute::Server
|
||||
|
||||
# Creates a new server
|
||||
#
|
||||
# AWS.servers.new
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new server
|
||||
#
|
||||
#>> AWS.servers.new
|
||||
# <Fog::AWS::Compute::Server
|
||||
# id=nil,
|
||||
# ami_launch_index=nil,
|
||||
# availability_zone=nil,
|
||||
# block_device_mapping=nil,
|
||||
# client_token=nil,
|
||||
# dns_name=nil,
|
||||
# groups=["default"],
|
||||
# flavor_id="m1.small",
|
||||
# image_id=nil,
|
||||
# ip_address=nil,
|
||||
# kernel_id=nil,
|
||||
# key_name=nil,
|
||||
# created_at=nil,
|
||||
# monitoring=nil,
|
||||
# product_codes=nil,
|
||||
# private_dns_name=nil,
|
||||
# private_ip_address=nil,
|
||||
# ramdisk_id=nil,
|
||||
# reason=nil,
|
||||
# root_device_name=nil,
|
||||
# root_device_type=nil,
|
||||
# state=nil,
|
||||
# state_reason=nil,
|
||||
# subnet_id=nil,
|
||||
# tags=nil,
|
||||
# user_data=nil
|
||||
# >
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
|
@ -64,6 +103,46 @@ module Fog
|
|||
server
|
||||
end
|
||||
|
||||
# Used to retreive a server
|
||||
#
|
||||
# server_id is required to get the associated server information.
|
||||
#
|
||||
# You can run the following command to get the details:
|
||||
# AWS.servers.get("i-5c973972")
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>> AWS.servers.get("i-5c973972")
|
||||
# <Fog::AWS::Compute::Server
|
||||
# id="i-5c973972",
|
||||
# ami_launch_index=0,
|
||||
# availability_zone="us-east-1b",
|
||||
# block_device_mapping=[],
|
||||
# client_token=nil,
|
||||
# dns_name="ec2-25-2-474-44.compute-1.amazonaws.com",
|
||||
# groups=["default"],
|
||||
# flavor_id="m1.small",
|
||||
# image_id="test",
|
||||
# ip_address="25.2.474.44",
|
||||
# kernel_id="aki-4e1e1da7",
|
||||
# key_name=nil,
|
||||
# created_at=Mon Nov 29 18:09:34 -0500 2010,
|
||||
# monitoring=false,
|
||||
# product_codes=[],
|
||||
# private_dns_name="ip-19-76-384-60.ec2.internal",
|
||||
# private_ip_address="19.76.384.60",
|
||||
# ramdisk_id="ari-0b3fff5c",
|
||||
# reason=nil,
|
||||
# root_device_name=nil,
|
||||
# root_device_type="instance-store",
|
||||
# state="running",
|
||||
# state_reason={},
|
||||
# subnet_id=nil,
|
||||
# tags={},
|
||||
# user_data=nil
|
||||
# >
|
||||
#
|
||||
|
||||
def get(server_id)
|
||||
if server_id
|
||||
self.class.new(:connection => connection).all('instance-id' => server_id).first
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def get(snapshot_id)
|
||||
if snapshot_id
|
||||
self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first
|
||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
|||
data = connection.describe_tags(filters).body
|
||||
load(data['tagSet'])
|
||||
end
|
||||
|
||||
|
||||
def get(key)
|
||||
if key
|
||||
self.class.new(:connection => connection).all('key' => key)
|
||||
|
|
|
@ -44,6 +44,7 @@ module Fog
|
|||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>>AWS.volumes.all
|
||||
#<Fog::AWS::Compute::Volume
|
||||
# id="vol-1e2028b9",
|
||||
# attached_at=nil,
|
||||
|
|
|
@ -18,6 +18,7 @@ module Fog
|
|||
# * body<~Hash>:
|
||||
# * 'imageId'<~String> - The ID of the created AMI.
|
||||
# * 'requestId'<~String> - Id of request.
|
||||
|
||||
def create_image(instance_id, name, description, no_reboot = false)
|
||||
request(
|
||||
'Action' => 'CreateImage',
|
||||
|
@ -31,7 +32,12 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
|
||||
|
||||
# Usage
|
||||
#
|
||||
# AWS[:compute].create_image("i-ac65ee8c", "test", "something")
|
||||
#
|
||||
|
||||
def create_image(instance_id, name, description, no_reboot = false)
|
||||
response = Excon::Response.new
|
||||
if instance_id && !name.empty?
|
||||
|
|
|
@ -31,7 +31,13 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
|
||||
|
||||
#
|
||||
# Usage
|
||||
#
|
||||
# AWS[:compute].create_snapshot("vol-f7c23423", "latest snapshot")
|
||||
#
|
||||
|
||||
def create_snapshot(volume_id, description = nil)
|
||||
response = Excon::Response.new
|
||||
if volume = @data[:volumes][volume_id]
|
||||
|
|
Loading…
Reference in a new issue