fog-aliyun 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/fog-aliyun.gemspec +1 -1
- data/lib/fog/aliyun.rb +0 -0
- data/lib/fog/aliyun/compute.rb +31 -0
- data/lib/fog/aliyun/models/compute/eip_address.rb +63 -0
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +30 -0
- data/lib/fog/aliyun/models/compute/image.rb +68 -0
- data/lib/fog/aliyun/models/compute/images.rb +29 -0
- data/lib/fog/aliyun/models/compute/route_entry.rb +28 -0
- data/lib/fog/aliyun/models/compute/route_entrys.rb +41 -0
- data/lib/fog/aliyun/models/compute/route_table.rb +31 -0
- data/lib/fog/aliyun/models/compute/route_tables.rb +27 -0
- data/lib/fog/aliyun/models/compute/security_group.rb +81 -0
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +47 -0
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +23 -0
- data/lib/fog/aliyun/models/compute/security_groups.rb +33 -0
- data/lib/fog/aliyun/models/compute/server.rb +71 -0
- data/lib/fog/aliyun/models/compute/servers.rb +44 -0
- data/lib/fog/aliyun/models/compute/snapshot.rb +52 -0
- data/lib/fog/aliyun/models/compute/snapshots.rb +42 -0
- data/lib/fog/aliyun/models/compute/volume.rb +105 -0
- data/lib/fog/aliyun/models/compute/volumes.rb +139 -0
- data/lib/fog/aliyun/models/compute/vpc.rb +20 -11
- data/lib/fog/aliyun/models/compute/vpcs.rb +2 -10
- data/lib/fog/aliyun/models/compute/vrouter.rb +35 -0
- data/lib/fog/aliyun/models/compute/vrouters.rb +62 -0
- data/lib/fog/aliyun/models/compute/vswitch.rb +3 -1
- data/lib/fog/aliyun/models/compute/vswitches.rb +1 -8
- data/lib/fog/aliyun/models/storage/directories.rb +0 -0
- data/lib/fog/aliyun/models/storage/directory.rb +0 -0
- data/lib/fog/aliyun/models/storage/file.rb +11 -10
- data/lib/fog/aliyun/models/storage/files.rb +50 -24
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +6 -5
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +0 -0
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +9 -2
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +0 -0
- data/lib/fog/aliyun/requests/compute/create_disk.rb +40 -8
- data/lib/fog/aliyun/requests/compute/create_image.rb +0 -0
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +2 -2
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +104 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +109 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +19 -1
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +26 -3
- data/lib/fog/aliyun/requests/compute/create_server.rb +0 -0
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +1 -1
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +12 -12
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +14 -14
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +12 -2
- data/lib/fog/aliyun/requests/compute/delete_image.rb +0 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +104 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +109 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -4
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +26 -3
- data/lib/fog/aliyun/requests/compute/delete_server.rb +0 -0
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +1 -1
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +13 -13
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +13 -13
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +6 -1
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +0 -0
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +0 -0
- data/lib/fog/aliyun/requests/compute/list_disks.rb +95 -1
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +6 -6
- data/lib/fog/aliyun/requests/compute/list_images.rb +1 -1
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +67 -0
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +0 -0
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +1 -1
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +0 -0
- data/lib/fog/aliyun/requests/compute/list_servers.rb +5 -5
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +30 -2
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +0 -0
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +64 -0
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +0 -0
- data/lib/fog/aliyun/requests/compute/list_zones.rb +0 -0
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +12 -12
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +12 -12
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +0 -0
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +1 -1
- data/lib/fog/aliyun/requests/compute/start_server.rb +1 -1
- data/lib/fog/aliyun/requests/compute/stop_server.rb +1 -1
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +20 -2
- data/lib/fog/aliyun/requests/storage/copy_object.rb +0 -0
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +0 -0
- data/lib/fog/aliyun/requests/storage/delete_container.rb +0 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +0 -0
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +2 -2
- data/lib/fog/aliyun/requests/storage/get_container.rb +0 -0
- data/lib/fog/aliyun/requests/storage/get_containers.rb +0 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +0 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +0 -0
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +0 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +0 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +0 -0
- data/lib/fog/aliyun/requests/storage/list_objects.rb +0 -0
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +0 -0
- data/lib/fog/aliyun/requests/storage/put_container.rb +0 -0
- data/lib/fog/aliyun/requests/storage/put_object.rb +1 -1
- data/lib/fog/aliyun/storage.rb +0 -0
- data/lib/fog/aliyun/version.rb +1 -1
- data/lib/fog/bin/aliyun.rb +0 -0
- metadata +29 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f039d826c1b8f347bd39065fca8d8c8d1a3a513
|
4
|
+
data.tar.gz: 883c955e643d7d333571a41ce98f30ce16706a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a315a64cbbd5ae803e0064ac3b063dcab53b7970cf4e6aa0c0ee70abddf0273cc7e9cfde587f627f6bcf5ddc931a9153b883e2f4b6e5ae86f78d0170181cc362
|
7
|
+
data.tar.gz: e700199fed03abeeec6cd02f7c313ce6fee29c7f72ac6d5aca366ea83621c474f286ce313c4ba3a32ba0b5a75b7170ee798057e3ee0d120ba63fdc3a1d746480
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/fog-aliyun.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Fog provider for Aliyun Web Services.}
|
13
13
|
spec.description = %q{As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/fog/fog-aliyun"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/fog/aliyun.rb
CHANGED
File without changes
|
data/lib/fog/aliyun/compute.rb
CHANGED
@@ -10,10 +10,30 @@ module Fog
|
|
10
10
|
## MODELS
|
11
11
|
#
|
12
12
|
model_path 'fog/aliyun/models/compute'
|
13
|
+
model :server
|
14
|
+
collection :servers
|
15
|
+
model :image
|
16
|
+
collection :images
|
17
|
+
model :eip_address
|
18
|
+
collection :eip_addresses
|
19
|
+
model :security_group
|
20
|
+
collection :security_groups
|
21
|
+
model :security_group_rule
|
22
|
+
collection :security_group_rules
|
23
|
+
model :volume
|
24
|
+
collection :volumes
|
25
|
+
model :snapshot
|
26
|
+
collection :snapshots
|
13
27
|
model :vpc
|
14
28
|
collection :vpcs
|
15
29
|
model :vswitch
|
16
30
|
collection :vswitches
|
31
|
+
model :vrouter
|
32
|
+
collection :vrouters
|
33
|
+
model :route_table
|
34
|
+
collection :route_tables
|
35
|
+
model :route_entry
|
36
|
+
collection :route_entrys
|
17
37
|
|
18
38
|
## REQUESTS
|
19
39
|
#
|
@@ -59,9 +79,13 @@ module Fog
|
|
59
79
|
request :create_security_group
|
60
80
|
request :create_security_group_ip_rule
|
61
81
|
request :create_security_group_sg_rule
|
82
|
+
request :create_security_group_egress_ip_rule
|
83
|
+
request :create_security_group_egress_sg_rule
|
62
84
|
request :delete_security_group
|
63
85
|
request :delete_security_group_ip_rule
|
64
86
|
request :delete_security_group_sg_rule
|
87
|
+
request :delete_security_group_egress_ip_rule
|
88
|
+
request :delete_security_group_egress_sg_rule
|
65
89
|
request :join_security_group
|
66
90
|
request :leave_security_group
|
67
91
|
|
@@ -78,6 +102,13 @@ module Fog
|
|
78
102
|
request :delete_vswitch
|
79
103
|
request :list_vswitchs
|
80
104
|
request :modify_vpc
|
105
|
+
request :modify_vswitch
|
106
|
+
|
107
|
+
#VRouter
|
108
|
+
request :list_vrouters
|
109
|
+
|
110
|
+
#RouteTable
|
111
|
+
request :list_route_tables
|
81
112
|
|
82
113
|
|
83
114
|
#clouddisk
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Aliyun
|
5
|
+
class EipAddress < Fog::Model
|
6
|
+
|
7
|
+
identity :id, :aliases => 'AllocationId'
|
8
|
+
|
9
|
+
attribute :allocated_at, :aliases => 'AllocationTime'
|
10
|
+
attribute :bandwidth, :aliases => 'Bandwidth'
|
11
|
+
attribute :server_id, :aliases => 'InstanceId'
|
12
|
+
attribute :charge_type, :aliases => 'InternetChargeType'
|
13
|
+
attribute :ip_address, :aliases => ['IpAddress','EipAddress']
|
14
|
+
attribute :opertion_locks,:aliases => 'OperationLocks'
|
15
|
+
attribute :region_id, :aliases => 'RegionId'
|
16
|
+
attribute :state, :aliases => 'Status'
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
requires :id
|
20
|
+
service.release_eip_address(id)
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def ready?
|
25
|
+
requires :state
|
26
|
+
state == 'Available'
|
27
|
+
end
|
28
|
+
|
29
|
+
def save(options={})
|
30
|
+
# raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
31
|
+
# requires :availability_zone
|
32
|
+
options[:bandwidth] = bandwidth if bandwidth
|
33
|
+
options[:internet_charge_type]=charge_type if charge_type
|
34
|
+
|
35
|
+
data = Fog::JSON.decode(service.allocate_eip_address(options).body)
|
36
|
+
merge_attributes(data)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def associate(new_server,options={})
|
42
|
+
unless persisted?
|
43
|
+
@server = new_server
|
44
|
+
else
|
45
|
+
@server = nil
|
46
|
+
self.server_id = new_server.id
|
47
|
+
service.associate_eip_address(server_id,id,options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def disassociate(new_server,options={})
|
52
|
+
@server = nil
|
53
|
+
self.server_id = new_server.id
|
54
|
+
if persisted?
|
55
|
+
service.unassociate_eip_address(server_id,id,options)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/aliyun/models/compute/eip_address'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Aliyun
|
7
|
+
class EipAddresses < Fog::Collection
|
8
|
+
|
9
|
+
model Fog::Compute::Aliyun::EipAddress
|
10
|
+
|
11
|
+
def all(filters_arg = {})
|
12
|
+
data = Fog::JSON.decode(service.list_eip_addresses(filters_arg).body)['EipAddresses']['EipAddress']
|
13
|
+
load(data)
|
14
|
+
# load(data['volumeSet'])
|
15
|
+
# if server
|
16
|
+
# self.replace(self.select {|volume| volume.server_id == server.id})
|
17
|
+
# end
|
18
|
+
# self
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(allocation_id)
|
22
|
+
if allocation_id
|
23
|
+
self.class.new(:service => service).all(:allocation_id => allocation_id)[0]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Aliyun
|
5
|
+
class Image < Fog::Model
|
6
|
+
|
7
|
+
identity :id, :aliases => 'ImageId'
|
8
|
+
|
9
|
+
attribute :description, :aliases => 'Description'
|
10
|
+
attribute :product_code, :aliases => 'ProductCode'
|
11
|
+
attribute :os_type, :aliases => 'OSType'
|
12
|
+
attribute :architecture, :aliases => 'Architecture'
|
13
|
+
attribute :os_name, :aliases => 'OSName'
|
14
|
+
attribute :disk_device_mappings, :aliases => 'DiskDeviceMappings'
|
15
|
+
attribute :owner_alias, :aliases => 'ImageOwnerAlias'
|
16
|
+
attribute :progress, :aliases => 'Progress'
|
17
|
+
attribute :usage, :aliases => 'Usage'
|
18
|
+
attribute :created_at, :aliases => 'CreationTime'
|
19
|
+
attribute :tags, :aliases => 'Tags'
|
20
|
+
attribute :version, :aliases => 'ImageVersion'
|
21
|
+
attribute :state, :aliases => 'Status'
|
22
|
+
attribute :name, :aliases => 'ImageName'
|
23
|
+
attribute :is_self_shared, :aliases => 'IsSelfShared'
|
24
|
+
attribute :is_copied, :aliases => 'IsCopied'
|
25
|
+
attribute :is_subscribed, :aliases => 'IsSubscribed'
|
26
|
+
attribute :platform, :aliases => 'Platform'
|
27
|
+
attribute :size, :aliases => 'Size'
|
28
|
+
attribute :snapshot_id, :aliases => 'SnapshotId'
|
29
|
+
|
30
|
+
def initialize(attributes)
|
31
|
+
self.snapshot_id=attributes["DiskDeviceMappings"]["DiskDeviceMapping"][0]["SnapshotId"]
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def save (options={})
|
36
|
+
requires :snapshot_id
|
37
|
+
options[:name] = name if name
|
38
|
+
options[:description]=description if description
|
39
|
+
data=Fog::JSON.decode(service.create_image(snapshot_id,options).body)
|
40
|
+
merge_attributes(data)
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
requires :id
|
46
|
+
service.delete_image(id)
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def ready?
|
51
|
+
state == 'Available'
|
52
|
+
end
|
53
|
+
|
54
|
+
def snapshot
|
55
|
+
requires :snapshot_id
|
56
|
+
Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:snapshotIds=>[snapshot_id])[0]
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def snapshot=(new_snapshot)
|
62
|
+
self.snapshot_id = new_snapshot.id
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/aliyun/models/compute/image'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Aliyun
|
7
|
+
class Images < Fog::Collection
|
8
|
+
|
9
|
+
model Fog::Compute::Aliyun::Image
|
10
|
+
|
11
|
+
|
12
|
+
def all(filters_arg = {})
|
13
|
+
unless filters_arg.is_a?(Hash)
|
14
|
+
Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('diskIds' => []) instead [light_black](#{caller.first})[/]")
|
15
|
+
filters_arg = {:imageId => filters_arg}
|
16
|
+
end
|
17
|
+
data = Fog::JSON.decode(service.list_images(filters_arg).body)['Images']['Image']
|
18
|
+
load(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(image_id)
|
22
|
+
if image_id
|
23
|
+
self.class.new(:service => service).all(:imageId => image_id)[0]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Aliyun
|
5
|
+
class RouteEntry < Fog::Model
|
6
|
+
|
7
|
+
# "RouteTables"=>{"RouteTable"=>[
|
8
|
+
# {"CreationTime"=>"2015-08-03T11:23:35Z", "RouteEntrys"=>{"RouteEntry"=>[
|
9
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.0.0/24"},
|
10
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.1.0/24"},
|
11
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.2.0/24"},
|
12
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"100.64.0.0/10"},
|
13
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"10.0.0.0/8"}]},
|
14
|
+
# "RouteTableId"=>"vtb-2504onoxh", "RouteTableType"=>"System", "VRouterId"=>"vrt-25azmd2wm"}]}
|
15
|
+
identity :cidr_block, :aliases => 'DestinationCidrBlock'
|
16
|
+
attribute :state, :aliases => 'Status'
|
17
|
+
attribute :server_id, :aliases => 'InstanceId'
|
18
|
+
attribute :type, :aliases => 'Type'
|
19
|
+
attribute :route_table_id, :aliases => 'RouteTableId'
|
20
|
+
|
21
|
+
# def save
|
22
|
+
# requires :cidr_block,:route_table_id
|
23
|
+
# if(cidr_block)
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/aliyun/models/compute/route_entry'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Aliyun
|
7
|
+
class RouteEntrys < Fog::Collection
|
8
|
+
attribute :route_table
|
9
|
+
|
10
|
+
model Fog::Compute::Aliyun::RouteEntry
|
11
|
+
|
12
|
+
def all(options={})
|
13
|
+
requires :route_table
|
14
|
+
options[:routeTableId]=route_table.id
|
15
|
+
data = Fog::JSON.decode(service.list_route_tables(route_table.v_router_id, options).body)['RouteTables']['RouteTable'][0]["RouteEntrys"]["RouteEntry"]
|
16
|
+
load(data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(cidr_block)
|
20
|
+
requires :route_table
|
21
|
+
data=self.class.new(:service=>service,:route_table=>route_table).all()
|
22
|
+
result=nil
|
23
|
+
data.each do |i|
|
24
|
+
if i.cidr_block==cidr_block
|
25
|
+
result=i
|
26
|
+
break
|
27
|
+
end
|
28
|
+
end
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
# def get(routeTableId)
|
33
|
+
# requires :v_router
|
34
|
+
# if routeTableId
|
35
|
+
# self.class.new(:service => service,:v_router=>v_router).all(:routeTableId=>routeTableId)[0]
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Aliyun
|
5
|
+
class RouteTable < Fog::Model
|
6
|
+
|
7
|
+
# "RouteTables"=>{"RouteTable"=>[
|
8
|
+
# {"CreationTime"=>"2015-08-03T11:23:35Z", "RouteEntrys"=>{"RouteEntry"=>[
|
9
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.0.0/24"},
|
10
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.1.0/24"},
|
11
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"172.16.2.0/24"},
|
12
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"100.64.0.0/10"},
|
13
|
+
# {"Status"=>"Available", "Type"=>"System", "InstanceId"=>"", "RouteTableId"=>"vtb-2504onoxh", "DestinationCidrBlock"=>"10.0.0.0/8"}]},
|
14
|
+
# "RouteTableId"=>"vtb-2504onoxh", "RouteTableType"=>"System", "VRouterId"=>"vrt-25azmd2wm"}]}
|
15
|
+
identity :id, :aliases => 'RouteTableId'
|
16
|
+
attribute :created_at, :aliases => 'CreationTime'
|
17
|
+
attribute :type, :aliases => 'RouteTableType'
|
18
|
+
attribute :v_router_id, :aliases => 'VRouterId'
|
19
|
+
# collection Fog::Compute::Aliyun::RouteEntrys
|
20
|
+
def route_entrys
|
21
|
+
@route_entrys ||= begin
|
22
|
+
Fog::Compute::Aliyun::RouteEntrys.new(
|
23
|
+
:route_table => self,
|
24
|
+
:service => service
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/aliyun/models/compute/route_table'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Aliyun
|
7
|
+
class RouteTables < Fog::Collection
|
8
|
+
attribute :v_router
|
9
|
+
|
10
|
+
model Fog::Compute::Aliyun::RouteTable
|
11
|
+
|
12
|
+
def all(options={})
|
13
|
+
requires :v_router
|
14
|
+
data = Fog::JSON.decode(service.list_route_tables(v_router.id, options).body)['RouteTables']['RouteTable']
|
15
|
+
load(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(routeTableId)
|
19
|
+
requires :v_router
|
20
|
+
if routeTableId
|
21
|
+
self.class.new(:service => service,:v_router=>v_router).all(:routeTableId=>routeTableId)[0]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Aliyun
|
6
|
+
class SecurityGroup < Fog::Model
|
7
|
+
identity :id, :aliases =>"SecurityGroupId"
|
8
|
+
attribute :name, :aliases => "SecurityGroupName"
|
9
|
+
attribute :description, :aliases => "Description"
|
10
|
+
attribute :created_at, :aliases => "CreationTime"
|
11
|
+
attribute :vpc_id, :aliases => "VpcId"
|
12
|
+
|
13
|
+
def vpc
|
14
|
+
requires :vpc_id
|
15
|
+
service.vpcs.get(vpc_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def security_group_rules
|
19
|
+
requires :id
|
20
|
+
service.security_group_rules.get(id)
|
21
|
+
end
|
22
|
+
|
23
|
+
def save(options={})
|
24
|
+
options[:vpcId] = vpc_id if vpc_id
|
25
|
+
options[:name] = name if name
|
26
|
+
options[:description] = description if description
|
27
|
+
Fog::JSON.decode(service.create_security_group(options).body)
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def destroy
|
32
|
+
requires :id
|
33
|
+
service.delete_security_group(id)
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def authorize_security_group_sg_rule(group_id,direction="ingress",options={})
|
38
|
+
requires :id
|
39
|
+
if direction=="egress"
|
40
|
+
service.create_security_group_egress_sg_rule(id,group_id,options)
|
41
|
+
else
|
42
|
+
service.create_security_group_sg_rule(id,group_id,options)
|
43
|
+
end
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize_security_group_ip_rule(cidr_ip,direction="ingress",options={})
|
48
|
+
requires :id
|
49
|
+
nic_type = options.fetch(:nic_type, "internet")
|
50
|
+
if direction=="egress"
|
51
|
+
service.create_security_group_egress_ip_rule(id,cidr_ip,nic_type,options)
|
52
|
+
else
|
53
|
+
service.create_security_group_ip_rule(id,cidr_ip,nic_type,options)
|
54
|
+
end
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def revoke_seurity_group_sg_rule(group_id,direction="ingress",options={})
|
59
|
+
requires :id
|
60
|
+
if direction=="egress"
|
61
|
+
service.delete_security_group_egress_sg_rule(id,group_id,options)
|
62
|
+
else
|
63
|
+
service.delete_security_group_sg_rule(id,group_id,options)
|
64
|
+
end
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def revoke_security_group_ip_rule(cidr_ip,direction="ingress",options={})
|
69
|
+
requires :id
|
70
|
+
nic_type = options.fetch(:nic_type, "internet")
|
71
|
+
if direction=="egress"
|
72
|
+
service.delete_security_group_egress_ip_rule(id,cidr_ip,nic_type,options)
|
73
|
+
else
|
74
|
+
service.delete_security_group_ip_rule(id,cidr_ip,nic_type,options)
|
75
|
+
end
|
76
|
+
true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|