-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
808 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'fog/core/model' | ||
module Fog | ||
module Compute | ||
class Aliyun | ||
class EipAddress < Fog::Model | ||
|
||
identity :id, :aliases => 'AllocationId' | ||
|
||
attribute :allocated_at, :aliases => 'AllocationTime' | ||
attribute :bandwidth, :aliases => 'Bandwidth' | ||
attribute :server_id, :aliases => 'InstanceId' | ||
attribute :charge_type, :aliases => 'InternetChargeType' | ||
attribute :ip_address, :aliases => ['IpAddress','EipAddress'] | ||
attribute :opertion_locks,:aliases => 'OperationLocks' | ||
attribute :region_id, :aliases => 'RegionId' | ||
attribute :state, :aliases => 'Status' | ||
|
||
def destroy | ||
requires :id | ||
service.release_eip_address(id) | ||
true | ||
end | ||
|
||
def ready? | ||
requires :state | ||
state == 'Available' | ||
end | ||
|
||
def save(options={}) | ||
# raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? | ||
# requires :availability_zone | ||
options[:bandwidth] = bandwidth if bandwidth | ||
options[:internet_charge_type]=charge_type if charge_type | ||
|
||
data = Fog::JSON.decode(service.allocate_eip_address(options).body) | ||
merge_attributes(data) | ||
true | ||
end | ||
|
||
|
||
# def associate(new_server) | ||
# unless persisted? | ||
# @server = new_server | ||
# else | ||
# @server = nil | ||
# self.server_id = new_server.id | ||
# service.associate_address(server_id, public_ip, network_interface_id, allocation_id) | ||
# end | ||
# end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'fog/core/collection' | ||
require 'fog/aliyun/models/compute/eip_address' | ||
|
||
module Fog | ||
module Compute | ||
class Aliyun | ||
class EipAddresses < Fog::Collection | ||
|
||
model Fog::Compute::Aliyun::EipAddress | ||
|
||
def all(filters_arg = {}) | ||
data = Fog::JSON.decode(service.list_eip_addresses(filters_arg).body)['EipAddresses']['EipAddress'] | ||
load(data) | ||
# load(data['volumeSet']) | ||
# if server | ||
# self.replace(self.select {|volume| volume.server_id == server.id}) | ||
# end | ||
# self | ||
end | ||
|
||
def get(allocation_id) | ||
if allocation_id | ||
self.class.new(:service => service).all(:allocation_id => allocation_)[0] | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'fog/core/model' | ||
module Fog | ||
module Compute | ||
class Aliyun | ||
class RouteEntry < Fog::Model | ||
# "RouteTables"=>{"RouteTable"=>[ | ||
# {"CreationTime"=>"2015-08-03T11:23:35Z", "RouteEntrys"=>{"RouteEntry"=>[ | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.0.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.1.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.2.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"100.64.0.0/10"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"10.0.0.0/8"}]}, | ||
# "RouteTableId"=>"vtb-2504onoxh", "RouteTableType"=>"System", "VRouterId"=>"vrt-25azmd2wm"}]} | ||
identity :cidr_block, :aliases => 'DestinationCidrBlock' | ||
attribute :state, :aliases => 'Status' | ||
attribute :server_id, :aliases => 'InstanceId' | ||
attribute :type, :aliases => 'Type' | ||
attribute :route_table_id, :aliases => 'RouteTableId' | ||
|
||
# def save | ||
# requires :cidr_block,:route_table_id | ||
# if(cidr_block) | ||
|
||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'fog/core/collection' | ||
require 'fog/aliyun/models/compute/route_entry' | ||
|
||
module Fog | ||
module Compute | ||
class Aliyun | ||
class RouteEntrys < Fog::Collection | ||
attribute :route_table | ||
|
||
model Fog::Compute::Aliyun::RouteEntry | ||
|
||
def all(options={}) | ||
requires :route_table | ||
options[:routeTableId]=route_table.id | ||
data = Fog::JSON.decode(service.list_route_tables(route_table.v_router_id, options).body)['RouteTables']['RouteTable'][0]["RouteEntrys"]["RouteEntry"] | ||
load(data) | ||
end | ||
|
||
def get(cidr_block) | ||
requires :route_table | ||
data=self.class.new(:service=>service,:route_table=>route_table).all() | ||
result=nil | ||
data.each do |i| | ||
if i.cidr_block==cidr_block | ||
result=i | ||
break | ||
end | ||
end | ||
result | ||
end | ||
|
||
# def get(routeTableId) | ||
# requires :v_router | ||
# if routeTableId | ||
# self.class.new(:service => service,:v_router=>v_router).all(:routeTableId=>routeTableId)[0] | ||
# end | ||
# end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'fog/core/model' | ||
module Fog | ||
module Compute | ||
class Aliyun | ||
class RouteTable < Fog::Model | ||
# "RouteTables"=>{"RouteTable"=>[ | ||
# {"CreationTime"=>"2015-08-03T11:23:35Z", "RouteEntrys"=>{"RouteEntry"=>[ | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.0.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.1.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.2.0/24"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"100.64.0.0/10"}, | ||
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"10.0.0.0/8"}]}, | ||
# "RouteTableId"=>"vtb-2504onoxh", "RouteTableType"=>"System", "VRouterId"=>"vrt-25azmd2wm"}]} | ||
identity :id, :aliases => 'RouteTableId' | ||
attribute :created_at, :aliases => 'CreationTime' | ||
attribute :type, :aliases => 'RouteTableType' | ||
attribute :v_router_id, :aliases => 'VRouterId' | ||
# collection Fog::Compute::Aliyun::RouteEntrys | ||
def route_entrys | ||
@route_entrys ||= begin | ||
Fog::Compute::Aliyun::RouteEntrys.new( | ||
:route_table => self, | ||
:service => service | ||
) | ||
end | ||
end | ||
|
||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'fog/core/collection' | ||
require 'fog/aliyun/models/compute/route_table' | ||
|
||
module Fog | ||
module Compute | ||
class Aliyun | ||
class RouteTables < Fog::Collection | ||
attribute :v_router | ||
|
||
model Fog::Compute::Aliyun::RouteTable | ||
|
||
|
||
def all(options={}) | ||
requires :v_router | ||
data = Fog::JSON.decode(service.list_route_tables(v_router.id, options).body)['RouteTables']['RouteTable'] | ||
load(data) | ||
end | ||
|
||
# Used to retrieve a VPC | ||
# vpc_id is required to get the associated VPC information. | ||
# | ||
# You can run the following command to get the details: | ||
# Aliyun.vpcs.get("vpc-12345678") | ||
# | ||
# ==== Returns | ||
# | ||
#>> Aliyun.vpcs.get("vpc-12345678") | ||
# <Fog::Aliyun::Compute::VPC | ||
# id="vpc-12345678", | ||
# TODO | ||
# > | ||
# | ||
|
||
def get(routeTableId) | ||
requires :v_router | ||
if routeTableId | ||
self.class.new(:service => service,:v_router=>v_router).all(:routeTableId=>routeTableId)[0] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
require 'fog/core/model' | ||
|
||
module Fog | ||
module Compute | ||
class Aliyun | ||
class SecurityGroup < Fog::Model | ||
# {"SecurityGroup"=>[{"CreationTime"=>"2015-08-10T03:21:02Z", | ||
# "SecurityGroupId"=>"sg-25mexinlu", "Description"=>"", "SecurityGroupName"=>"bosh", | ||
# "VpcId"=>"vpc-25mj6mguq"}} | ||
|
||
identity :id, :aliases =>"SecurityGroupId" | ||
|
||
attribute :name, :aliases => "SecurityGroupName" | ||
attribute :description, :aliases => "Description" | ||
attribute :created_at, :aliases => "CreationTime" | ||
attribute :vpc_id, :aliases => "VpcId" | ||
|
||
def vpc | ||
requires :vpc_id | ||
$vpc=Fog::Compute::Aliyun::Vpcs.new(:service=>service).all('vpcId'=>vpc_id)[0] | ||
end | ||
|
||
def security_group_rules | ||
requires :id | ||
Fog::Compute::Aliyun::SecurityGroupRules.new(:service=>service).get(id) | ||
end | ||
|
||
def save(options={}) | ||
options[:vpcId] = vpc_id if vpc_id | ||
options[:name] = name if name | ||
options[:description] = description if description | ||
data = Fog::JSON.decode(service.create_security_group(options).body) | ||
true | ||
end | ||
|
||
|
||
def destroy | ||
requires :id | ||
service.delete_security_group(id) | ||
true | ||
end | ||
|
||
# def security_group_rules | ||
# Fog::Compute::OpenStack::SecurityGroupRules.new(:service => service).load(attributes[:security_group_rules]) | ||
# end | ||
|
||
# def rules | ||
# Fog::Logger.deprecation('#rules is deprecated. Use #security_group_rules instead') | ||
# attributes[:security_group_rules] | ||
# end | ||
|
||
# # no one should be calling this because it doesn't do anything | ||
# # useful but we deprecated the rules attribute and need to maintain the API | ||
# def rules=(new_rules) | ||
# Fog::Logger.deprecation('#rules= is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.') | ||
# attributes[:security_group_rules] = new_rules | ||
# end | ||
|
||
# def save | ||
# requires :name, :description | ||
# data = service.create_security_group(name, description) | ||
# merge_attributes(data.body['security_group']) | ||
# true | ||
# end | ||
|
||
# def destroy | ||
# requires :id | ||
# service.delete_security_group(id) | ||
# true | ||
# end | ||
|
||
# def create_security_group_rule(min, max, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil) | ||
# Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.') | ||
# requires :id | ||
# service.create_security_group_rule(id, ip_protocol, min, max, cidr, group_id) | ||
# end | ||
|
||
# def delete_security_group_rule(rule_id) | ||
# Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRule objects to destroy rules.') | ||
# service.delete_security_group_rule(rule_id) | ||
# true | ||
# end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.