fog 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -1
- data/.irbrc +5 -10
- data/{README.rdoc → README.md} +66 -61
- data/Rakefile +4 -6
- data/changelog.txt +491 -0
- data/docs/about/users.markdown +1 -0
- data/fog.gemspec +4 -4
- data/lib/fog.rb +1 -1
- data/lib/fog/aws.rb +4 -0
- data/lib/fog/aws/auto_scaling.rb +3 -0
- data/lib/fog/aws/cloud_watch.rb +28 -0
- data/lib/fog/aws/compute.rb +7 -1
- data/lib/fog/aws/elasticache.rb +64 -6
- data/lib/fog/aws/models/auto_scaling/configuration.rb +3 -1
- data/lib/fog/aws/models/auto_scaling/group.rb +10 -9
- data/lib/fog/aws/models/auto_scaling/policies.rb +33 -0
- data/lib/fog/aws/models/auto_scaling/policy.rb +46 -0
- data/lib/fog/aws/models/cloud_watch/alarm.rb +50 -2
- data/lib/fog/aws/models/cloud_watch/alarms.rb +18 -1
- data/lib/fog/aws/models/compute/address.rb +2 -2
- data/lib/fog/aws/models/dns/records.rb +5 -0
- data/lib/fog/aws/models/elasticache/cluster.rb +1 -1
- data/lib/fog/aws/models/iam/users.rb +26 -4
- data/lib/fog/aws/parsers/auto_scaling/describe_policies.rb +7 -5
- data/lib/fog/aws/parsers/elb/describe_load_balancers.rb +1 -1
- data/lib/fog/aws/rds.rb +1 -1
- data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
- data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +1 -2
- data/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +10 -2
- data/lib/fog/aws/requests/auto_scaling/delete_launch_configuration.rb +1 -1
- data/lib/fog/aws/requests/auto_scaling/delete_policy.rb +10 -1
- data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +0 -1
- data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +13 -1
- data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +20 -1
- data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +1 -1
- data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +19 -1
- data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +20 -2
- data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +9 -0
- data/lib/fog/aws/requests/compute/allocate_address.rb +4 -5
- data/lib/fog/aws/requests/compute/create_dhcp_options.rb +6 -5
- data/lib/fog/aws/requests/compute/create_internet_gateway.rb +7 -6
- data/lib/fog/aws/requests/compute/create_subnet.rb +11 -10
- data/lib/fog/aws/requests/compute/create_vpc.rb +8 -7
- data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +1 -0
- data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +1 -0
- data/lib/fog/aws/requests/compute/delete_subnet.rb +1 -0
- data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -1
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +1 -0
- data/lib/fog/aws/requests/compute/describe_dhcp_options.rb +1 -8
- data/lib/fog/aws/requests/compute/describe_instances.rb +3 -1
- data/lib/fog/aws/requests/compute/describe_internet_gateways.rb +1 -8
- data/lib/fog/aws/requests/compute/describe_subnets.rb +1 -9
- data/lib/fog/aws/requests/compute/describe_vpcs.rb +1 -8
- data/lib/fog/aws/requests/compute/release_address.rb +12 -4
- data/lib/fog/aws/requests/compute/start_instances.rb +1 -0
- data/lib/fog/aws/requests/compute/stop_instances.rb +1 -0
- data/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +26 -2
- data/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb +10 -1
- data/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb +16 -1
- data/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb +35 -3
- data/lib/fog/aws/requests/elasticache/reboot_cache_cluster.rb +10 -2
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
- data/lib/fog/aws/requests/rds/describe_db_instances.rb +3 -3
- data/lib/fog/aws/sqs.rb +1 -1
- data/lib/fog/aws/storage.rb +1 -1
- data/lib/fog/bin/rackspace.rb +4 -0
- data/lib/fog/cloudstack/compute.rb +25 -18
- data/lib/fog/cloudstack/models/compute/image.rb +34 -34
- data/lib/fog/cloudstack/models/compute/job.rb +14 -1
- data/lib/fog/cloudstack/models/compute/jobs.rb +1 -1
- data/lib/fog/cloudstack/models/compute/security_group.rb +50 -0
- data/lib/fog/cloudstack/models/compute/security_group_rule.rb +62 -0
- data/lib/fog/cloudstack/models/compute/security_group_rules.rb +37 -0
- data/lib/fog/cloudstack/models/compute/security_groups.rb +27 -0
- data/lib/fog/cloudstack/models/compute/server.rb +63 -39
- data/lib/fog/cloudstack/models/compute/volume.rb +3 -7
- data/lib/fog/cloudstack/models/compute/zone.rb +1 -2
- data/lib/fog/cloudstack/requests/compute/assign_virtual_machine.rb +18 -0
- data/lib/fog/cloudstack/requests/compute/authorize_security_group_egress.rb +68 -0
- data/lib/fog/cloudstack/requests/compute/authorize_security_group_ingress.rb +55 -4
- data/lib/fog/cloudstack/requests/compute/create_security_group.rb +12 -4
- data/lib/fog/cloudstack/requests/compute/create_zone.rb +20 -0
- data/lib/fog/cloudstack/requests/compute/delete_security_group.rb +17 -0
- data/lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb +23 -1
- data/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb +15 -0
- data/lib/fog/cloudstack/requests/compute/list_security_groups.rb +22 -4
- data/lib/fog/cloudstack/requests/compute/query_async_job_result.rb +15 -3
- data/lib/fog/cloudstack/requests/compute/revoke_security_group_egress.rb +42 -0
- data/lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb +29 -3
- data/lib/fog/core.rb +1 -0
- data/lib/fog/core/attributes.rb +1 -1
- data/lib/fog/core/current_machine.rb +2 -2
- data/lib/fog/core/scp.rb +8 -0
- data/lib/fog/core/ssh.rb +8 -0
- data/lib/fog/dynect/dns.rb +14 -5
- data/lib/fog/ibm/requests/compute/create_instance.rb +1 -1
- data/lib/fog/libvirt/requests/compute/create_volume.rb +1 -1
- data/lib/fog/libvirt/requests/compute/list_volumes.rb +1 -1
- data/lib/fog/local/models/storage/file.rb +12 -1
- data/lib/fog/local/storage.rb +25 -1
- data/lib/fog/ninefold/compute.rb +1 -0
- data/lib/fog/openstack.rb +3 -1
- data/lib/fog/openstack/compute.rb +13 -2
- data/lib/fog/openstack/models/compute/servers.rb +10 -2
- data/lib/fog/openstack/requests/compute/create_flavor.rb +2 -2
- data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_volume.rb +1 -1
- data/lib/fog/openstack/requests/compute/get_flavor_details.rb +7 -7
- data/lib/fog/openstack/requests/compute/get_quota.rb +1 -12
- data/lib/fog/openstack/requests/compute/get_quota_defaults.rb +1 -12
- data/lib/fog/openstack/requests/compute/get_volume_details.rb +1 -1
- data/lib/fog/openstack/requests/compute/list_flavors.rb +7 -7
- data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +7 -7
- data/lib/fog/openstack/requests/compute/list_security_groups.rb +7 -7
- data/lib/fog/openstack/requests/compute/list_servers_detail.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_volumes.rb +6 -8
- data/lib/fog/openstack/requests/compute/update_quota.rb +2 -15
- data/lib/fog/openstack/requests/identity/delete_role.rb +1 -1
- data/lib/fog/openstack/requests/identity/list_roles.rb +1 -1
- data/lib/fog/openstack/requests/image/create_image.rb +3 -1
- data/lib/fog/openstack/requests/image/list_public_images.rb +19 -1
- data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +20 -2
- data/lib/fog/openstack/requests/image/update_image.rb +1 -1
- data/lib/fog/rackspace.rb +2 -0
- data/lib/fog/rackspace/databases.rb +121 -0
- data/lib/fog/rackspace/identity.rb +83 -0
- data/lib/fog/rackspace/load_balancers.rb +3 -0
- data/lib/fog/rackspace/models/databases/database.rb +32 -0
- data/lib/fog/rackspace/models/databases/databases.rb +31 -0
- data/lib/fog/rackspace/models/databases/flavor.rb +15 -0
- data/lib/fog/rackspace/models/databases/flavors.rb +25 -0
- data/lib/fog/rackspace/models/databases/instance.rb +104 -0
- data/lib/fog/rackspace/models/databases/instances.rb +25 -0
- data/lib/fog/rackspace/models/databases/user.rb +32 -0
- data/lib/fog/rackspace/models/databases/users.rb +31 -0
- data/lib/fog/rackspace/models/identity/credential.rb +13 -0
- data/lib/fog/rackspace/models/identity/credentials.rb +32 -0
- data/lib/fog/rackspace/models/identity/role.rb +14 -0
- data/lib/fog/rackspace/models/identity/roles.rb +32 -0
- data/lib/fog/rackspace/models/identity/tenant.rb +15 -0
- data/lib/fog/rackspace/models/identity/tenants.rb +28 -0
- data/lib/fog/rackspace/models/identity/user.rb +53 -0
- data/lib/fog/rackspace/models/identity/users.rb +36 -0
- data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +17 -0
- data/lib/fog/rackspace/requests/databases/check_root_user.rb +15 -0
- data/lib/fog/rackspace/requests/databases/create_database.rb +24 -0
- data/lib/fog/rackspace/requests/databases/create_instance.rb +26 -0
- data/lib/fog/rackspace/requests/databases/create_user.rb +24 -0
- data/lib/fog/rackspace/requests/databases/delete_database.rb +15 -0
- data/lib/fog/rackspace/requests/databases/delete_instance.rb +15 -0
- data/lib/fog/rackspace/requests/databases/delete_user.rb +15 -0
- data/lib/fog/rackspace/requests/databases/enable_root_user.rb +15 -0
- data/lib/fog/rackspace/requests/databases/get_flavor.rb +15 -0
- data/lib/fog/rackspace/requests/databases/get_instance.rb +15 -0
- data/lib/fog/rackspace/requests/databases/list_databases.rb +15 -0
- data/lib/fog/rackspace/requests/databases/list_flavors.rb +15 -0
- data/lib/fog/rackspace/requests/databases/list_instances.rb +15 -0
- data/lib/fog/rackspace/requests/databases/list_users.rb +15 -0
- data/lib/fog/rackspace/requests/databases/resize_instance.rb +22 -0
- data/lib/fog/rackspace/requests/databases/resize_instance_volume.rb +24 -0
- data/lib/fog/rackspace/requests/databases/restart_instance.rb +20 -0
- data/lib/fog/rackspace/requests/identity/create_token.rb +25 -0
- data/lib/fog/rackspace/requests/identity/create_user.rb +25 -0
- data/lib/fog/rackspace/requests/identity/delete_user.rb +15 -0
- data/lib/fog/rackspace/requests/identity/get_credentials.rb +15 -0
- data/lib/fog/rackspace/requests/identity/get_user_by_id.rb +15 -0
- data/lib/fog/rackspace/requests/identity/get_user_by_name.rb +15 -0
- data/lib/fog/rackspace/requests/identity/list_credentials.rb +22 -0
- data/lib/fog/rackspace/requests/identity/list_tenants.rb +22 -0
- data/lib/fog/rackspace/requests/identity/list_user_roles.rb +22 -0
- data/lib/fog/rackspace/requests/identity/list_users.rb +22 -0
- data/lib/fog/rackspace/requests/identity/update_user.rb +24 -0
- data/lib/fog/rackspace/requests/load_balancers/get_ssl_termination.rb +15 -0
- data/lib/fog/rackspace/requests/load_balancers/remove_ssl_termination.rb +15 -0
- data/lib/fog/rackspace/requests/load_balancers/set_ssl_termination.rb +31 -0
- data/lib/fog/rackspace/storage.rb +1 -1
- data/lib/fog/vsphere/models/compute/server.rb +1 -0
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -2
- data/tests/aws/models/compute/address_tests.rb +2 -1
- data/tests/aws/models/compute/volume_tests.rb +1 -1
- data/tests/aws/models/dns/records_tests.rb +19 -1
- data/tests/aws/models/storage/directory_tests.rb +1 -1
- data/tests/aws/models/storage/url_tests.rb +7 -1
- data/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +4 -2
- data/tests/aws/requests/compute/address_tests.rb +19 -1
- data/tests/aws/requests/elasticache/cache_cluster_tests.rb +4 -4
- data/tests/aws/requests/elb/helper.rb +13 -2
- data/tests/aws/requests/iam/access_key_tests.rb +1 -3
- data/tests/cloudstack/compute/models/security_group_rule_tests.rb +29 -0
- data/tests/cloudstack/compute/models/security_group_tests.rb +16 -0
- data/tests/cloudstack/compute/models/security_groups_tests.rb +19 -0
- data/tests/cloudstack/compute/models/server_tests.rb +18 -0
- data/tests/cloudstack/compute/models/volume_tests.rb +34 -0
- data/tests/cloudstack/compute/models/volumes_tests.rb +17 -0
- data/tests/compute/helper.rb +10 -3
- data/tests/core/current_machine_tests.rb +32 -0
- data/tests/helper.rb +1 -1
- data/tests/helpers/mock_helper.rb +3 -0
- data/tests/hp/requests/compute/address_tests.rb +2 -1
- data/tests/joyent/requests/compute/datasets_tests.rb +12 -3
- data/tests/local/models/file_tests.rb +43 -0
- data/tests/local/storage_tests.rb +40 -0
- data/tests/openstack/requests/compute/flavor_tests.rb +1 -1
- data/tests/openstack/requests/compute/server_tests.rb +3 -3
- data/tests/openstack/requests/compute/volume_tests.rb +1 -1
- data/tests/openstack/requests/identity/role_tests.rb +1 -1
- data/tests/rackspace/databases_tests.rb +26 -0
- data/tests/rackspace/models/databases/database_tests.rb +17 -0
- data/tests/rackspace/models/databases/databases_tests.rb +17 -0
- data/tests/rackspace/models/databases/flavors_tests.rb +20 -0
- data/tests/rackspace/models/databases/instance_tests.rb +43 -0
- data/tests/rackspace/models/databases/instances_tests.rb +14 -0
- data/tests/rackspace/models/databases/user_tests.rb +21 -0
- data/tests/rackspace/models/databases/users_tests.rb +21 -0
- data/tests/rackspace/models/identity/credentials_tests.rb +16 -0
- data/tests/rackspace/models/identity/roles_tests.rb +16 -0
- data/tests/rackspace/models/identity/tenants_tests.rb +21 -0
- data/tests/rackspace/models/identity/user_tests.rb +17 -0
- data/tests/rackspace/models/identity/users_tests.rb +17 -0
- data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +20 -0
- data/tests/rackspace/requests/databases/database_tests.rb +36 -0
- data/tests/rackspace/requests/databases/flavor_tests.rb +16 -0
- data/tests/rackspace/requests/databases/helper.rb +84 -0
- data/tests/rackspace/requests/databases/instance_tests.rb +77 -0
- data/tests/rackspace/requests/databases/user_tests.rb +37 -0
- data/tests/rackspace/requests/identity/tenants_tests.rb +21 -0
- data/tests/rackspace/requests/identity/token_tests.rb +63 -0
- data/tests/rackspace/requests/identity/user_tests.rb +107 -0
- data/tests/rackspace/requests/load_balancers/helper.rb +70 -1
- data/tests/rackspace/requests/load_balancers/ssl_termination_tests.rb +38 -0
- data/tests/storage/models/file_tests.rb +1 -1
- metadata +129 -13
- data/spec/core/current_machine_spec.rb +0 -32
- data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +0 -58
- data/spec/spec_helper.rb +0 -8
data/docs/about/users.markdown
CHANGED
@@ -28,6 +28,7 @@ Thanks for following these rules to keep the quality high and and the content us
|
|
28
28
|
* [Engine Yard AppCloud](http://www.engineyard.com/cloud) = AWS => \[Compute, Storage\]
|
29
29
|
* [iSwifter](http://iswifter.youwebinc.com/) = BlueBox => Compute
|
30
30
|
* [OpenFeint](http://openfeint.com) = BlueBox => Compute
|
31
|
+
* [PeopleAdmin](http://www.peopleadmin.com) = AWS => [Compute, Storage]
|
31
32
|
* [PHPFog](https://phpfog.com) = AWS => Compute
|
32
33
|
* [RowFeeder](https://rowfeeder.com) = Blue Box Group => Compute
|
33
34
|
* [Viximo](http://viximo.com) = AWS => Compute
|
data/fog.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
## If your rubyforge_project name is different, then edit it and comment out
|
7
7
|
## the sub! line in the Rakefile
|
8
8
|
s.name = 'fog'
|
9
|
-
s.version = '1.
|
10
|
-
s.date = '2012-
|
9
|
+
s.version = '1.5.0'
|
10
|
+
s.date = '2012-07-28'
|
11
11
|
s.rubyforge_project = 'fog'
|
12
12
|
|
13
13
|
|
@@ -37,12 +37,12 @@ Gem::Specification.new do |s|
|
|
37
37
|
## Specify any RDoc options here. You'll want to add your README and
|
38
38
|
## LICENSE files to the extra_rdoc_files list.
|
39
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
-
s.extra_rdoc_files = %w[README.
|
40
|
+
s.extra_rdoc_files = %w[README.md]
|
41
41
|
|
42
42
|
## List your runtime dependencies here. Runtime dependencies are those
|
43
43
|
## that are needed for an end user to actually USE your code.
|
44
44
|
s.add_dependency('builder')
|
45
|
-
s.add_dependency('excon', '~>0.14
|
45
|
+
s.add_dependency('excon', '~>0.14')
|
46
46
|
s.add_dependency('formatador', '~>0.2.0')
|
47
47
|
s.add_dependency('multi_json', '~>1.0')
|
48
48
|
s.add_dependency('mime-types')
|
data/lib/fog.rb
CHANGED
data/lib/fog/aws.rb
CHANGED
data/lib/fog/aws/auto_scaling.rb
CHANGED
@@ -50,6 +50,8 @@ module Fog
|
|
50
50
|
collection :groups
|
51
51
|
model :instance
|
52
52
|
collection :instances
|
53
|
+
model :policy
|
54
|
+
collection :policies
|
53
55
|
|
54
56
|
class Real
|
55
57
|
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
@@ -165,6 +167,7 @@ module Fog
|
|
165
167
|
'PercentChangeInCapacity'
|
166
168
|
],
|
167
169
|
:auto_scaling_groups => {},
|
170
|
+
:scaling_policies => {},
|
168
171
|
:health_states => ['Healthy', 'Unhealthy'],
|
169
172
|
:launch_configurations => {},
|
170
173
|
:metric_collection_types => {
|
data/lib/fog/aws/cloud_watch.rb
CHANGED
@@ -36,9 +36,37 @@ module Fog
|
|
36
36
|
|
37
37
|
class Mock
|
38
38
|
|
39
|
+
def self.data
|
40
|
+
@data ||= Hash.new do |hash, region|
|
41
|
+
hash[region] = Hash.new do |region_hash, key|
|
42
|
+
region_hash[key] = {
|
43
|
+
:metric_alarms => {}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.reset
|
50
|
+
@data = nil
|
51
|
+
end
|
52
|
+
|
39
53
|
def initialize(options={})
|
54
|
+
@aws_access_key_id = options[:aws_access_key_id]
|
55
|
+
|
56
|
+
@region = options[:region] || 'us-east-1'
|
57
|
+
|
58
|
+
unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'sa-east-1', 'us-east-1', 'us-west-1', 'us-west-2'].include?(@region)
|
59
|
+
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def data
|
64
|
+
self.class.data[@region][@aws_access_key_id]
|
40
65
|
end
|
41
66
|
|
67
|
+
def reset_data
|
68
|
+
self.class.data[@region].delete(@aws_access_key_id)
|
69
|
+
end
|
42
70
|
end
|
43
71
|
|
44
72
|
class Real
|
data/lib/fog/aws/compute.rb
CHANGED
@@ -138,6 +138,7 @@ module Fog
|
|
138
138
|
end
|
139
139
|
|
140
140
|
class Mock
|
141
|
+
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
141
142
|
|
142
143
|
def self.data
|
143
144
|
@data ||= Hash.new do |hash, region|
|
@@ -197,7 +198,11 @@ module Fog
|
|
197
198
|
:tags => {},
|
198
199
|
:tag_sets => Hash.new do |tag_set_hash, resource_id|
|
199
200
|
tag_set_hash[resource_id] = {}
|
200
|
-
end
|
201
|
+
end,
|
202
|
+
:subnets => [],
|
203
|
+
:vpcs => [],
|
204
|
+
:dhcp_options => [],
|
205
|
+
:internet_gateways => []
|
201
206
|
}
|
202
207
|
end
|
203
208
|
end
|
@@ -209,6 +214,7 @@ module Fog
|
|
209
214
|
|
210
215
|
def initialize(options={})
|
211
216
|
@use_iam_profile = options[:use_iam_profile]
|
217
|
+
@aws_credentials_expire_at = Time::now + 20
|
212
218
|
setup_credentials(options)
|
213
219
|
@region = options[:region] || 'us-east-1'
|
214
220
|
|
data/lib/fog/aws/elasticache.rb
CHANGED
@@ -41,12 +41,6 @@ module Fog
|
|
41
41
|
model :parameter_group
|
42
42
|
collection :parameter_groups
|
43
43
|
|
44
|
-
class Mock
|
45
|
-
def initalize(options={})
|
46
|
-
Fog::Mock.not_implemented
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
44
|
class Real
|
51
45
|
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
52
46
|
def initialize(options={})
|
@@ -129,6 +123,70 @@ module Fog
|
|
129
123
|
end
|
130
124
|
|
131
125
|
end
|
126
|
+
|
127
|
+
class Mock
|
128
|
+
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
129
|
+
|
130
|
+
def self.data
|
131
|
+
@data ||= Hash.new do |hash, region|
|
132
|
+
hash[region] = Hash.new do |region_hash, key|
|
133
|
+
owner_id = Fog::AWS::Mock.owner_id
|
134
|
+
security_group_id = Fog::AWS::Mock.security_group_id
|
135
|
+
region_hash[key] = {
|
136
|
+
:clusters => {}, # cache cluster data, indexed by cluster ID
|
137
|
+
}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.reset
|
143
|
+
@data = nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def initialize(options={})
|
147
|
+
@aws_credentials_expire_at = Time::now + 20
|
148
|
+
setup_credentials(options)
|
149
|
+
@region = options[:region] || 'us-east-1'
|
150
|
+
unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'us-east-1',
|
151
|
+
'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
|
152
|
+
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def region_data
|
157
|
+
self.class.data[@region]
|
158
|
+
end
|
159
|
+
|
160
|
+
def data
|
161
|
+
self.region_data[@aws_access_key_id]
|
162
|
+
end
|
163
|
+
|
164
|
+
def reset_data
|
165
|
+
self.region_data.delete(@aws_access_key_id)
|
166
|
+
end
|
167
|
+
|
168
|
+
def setup_credentials(options)
|
169
|
+
@aws_access_key_id = options[:aws_access_key_id]
|
170
|
+
end
|
171
|
+
|
172
|
+
# returns an Array of (Mock) elasticache nodes, representated as Hashes
|
173
|
+
def create_cache_nodes(cluster_id, num_nodes = 1, port = '11211')
|
174
|
+
(1..num_nodes).map do |node_number|
|
175
|
+
node_id = "%04d" % node_number
|
176
|
+
{ # each hash represents a cache cluster node
|
177
|
+
"CacheNodeId" => node_id,
|
178
|
+
"Port" => port,
|
179
|
+
"ParameterGroupStatus" => "in-sync",
|
180
|
+
"CacheNodeStatus" => "available",
|
181
|
+
"CacheNodeCreateTime" => Time.now.utc.to_s,
|
182
|
+
"Address" =>
|
183
|
+
"#{cluster_id}.#{node_id}.use1.cache.amazonaws.com"
|
184
|
+
}
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
|
132
190
|
end
|
133
191
|
end
|
134
192
|
end
|
@@ -39,7 +39,9 @@ module Fog
|
|
39
39
|
requires :image_id
|
40
40
|
requires :instance_type
|
41
41
|
|
42
|
-
|
42
|
+
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
43
|
+
options.delete_if { |key, value| value.nil? }
|
44
|
+
connection.create_launch_configuration(image_id, instance_type, id, options) #, listeners.map{|l| l.to_params})
|
43
45
|
|
44
46
|
# reload instead of merge attributes b/c some attrs (like HealthCheck)
|
45
47
|
# may be set, but only the DNS name is returned in the create_load_balance
|
@@ -4,7 +4,6 @@ module Fog
|
|
4
4
|
module AWS
|
5
5
|
class AutoScaling
|
6
6
|
class Group < Fog::Model
|
7
|
-
|
8
7
|
identity :id, :aliases => 'AutoScalingGroupName'
|
9
8
|
attribute :arn, :aliases => 'AutoScalingGroupARN'
|
10
9
|
attribute :availability_zones, :aliases => 'AvailabilityZones'
|
@@ -22,6 +21,7 @@ module Fog
|
|
22
21
|
attribute :placement_group, :aliases => 'PlacementGroup'
|
23
22
|
attribute :suspended_processes, :aliases => 'SuspendedProcesses'
|
24
23
|
attribute :vpc_zone_identifier, :aliases => 'VPCZoneIdentifier'
|
24
|
+
attribute :tags, :aliases => 'Tags'
|
25
25
|
|
26
26
|
def initialize(attributes={})
|
27
27
|
attributes['DefaultCooldown'] ||= 0
|
@@ -34,6 +34,7 @@ module Fog
|
|
34
34
|
attributes['MaxSize'] ||= 0
|
35
35
|
attributes['MinSize'] ||= 0
|
36
36
|
attributes['SuspendedProcesses'] ||= []
|
37
|
+
attributes['Tags'] ||= []
|
37
38
|
super
|
38
39
|
end
|
39
40
|
|
@@ -72,10 +73,7 @@ module Fog
|
|
72
73
|
end
|
73
74
|
|
74
75
|
def instances
|
75
|
-
Fog::AWS::AutoScaling::Instances.new(
|
76
|
-
:data => attributes['Instances'],
|
77
|
-
:connection => connection
|
78
|
-
})
|
76
|
+
Fog::AWS::AutoScaling::Instances.new(:connection => connection).load(attributes[:instance])
|
79
77
|
end
|
80
78
|
|
81
79
|
def instances_in_service
|
@@ -112,7 +110,7 @@ module Fog
|
|
112
110
|
requires :max_size
|
113
111
|
requires :min_size
|
114
112
|
|
115
|
-
connection.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size)
|
113
|
+
connection.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, options)
|
116
114
|
reload
|
117
115
|
end
|
118
116
|
|
@@ -126,14 +124,17 @@ module Fog
|
|
126
124
|
connection.delete_auto_scaling_group(id)
|
127
125
|
end
|
128
126
|
|
129
|
-
|
130
|
-
|
131
|
-
def update(options)
|
127
|
+
def update
|
132
128
|
requires :id
|
133
129
|
connection.update_auto_scaling_group(id, options)
|
134
130
|
reload
|
135
131
|
end
|
136
132
|
|
133
|
+
def options
|
134
|
+
ret = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
135
|
+
ret.delete_if { |key, value| value.nil? }
|
136
|
+
ret
|
137
|
+
end
|
137
138
|
end
|
138
139
|
end
|
139
140
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fog/aws/models/auto_scaling/policy'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class AutoScaling
|
6
|
+
class Policies < Fog::Collection
|
7
|
+
model Fog::AWS::AutoScaling::Policy
|
8
|
+
|
9
|
+
# Creates a new scaling policy.
|
10
|
+
def initialize(attributes={})
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
data = []
|
16
|
+
next_token = nil
|
17
|
+
loop do
|
18
|
+
result = connection.describe_policies('NextToken' => next_token).body['DescribePoliciesResult']
|
19
|
+
data += result['ScalingPolicies']
|
20
|
+
next_token = result['NextToken']
|
21
|
+
break if next_token.nil?
|
22
|
+
end
|
23
|
+
load(data)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(identity, auto_scaling_group = nil)
|
27
|
+
data = connection.describe_policies('PolicyNames' => identity, 'AutoScalingGroupName' => auto_scaling_group).body['DescribePoliciesResult']['ScalingPolicies'].first
|
28
|
+
new(data) unless data.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class AutoScaling
|
6
|
+
class Policy < Fog::Model
|
7
|
+
identity :id, :aliases => 'PolicyName'
|
8
|
+
attribute :arn, :aliases => 'PolicyARN'
|
9
|
+
attribute :adjustment_type, :aliases => 'AdjustmentType'
|
10
|
+
attribute :alarms, :aliases => 'Alarms'
|
11
|
+
attribute :auto_scaling_group_name, :aliases => 'AutoScalingGroupName'
|
12
|
+
attribute :cooldown, :aliases => 'Cooldown'
|
13
|
+
attribute :min_adjustment_step, :aliases => 'MinAdjustmentStep'
|
14
|
+
attribute :scaling_adjustment, :aliases => 'ScalingAdjustment'
|
15
|
+
|
16
|
+
def initialize(attributes)
|
17
|
+
attributes['AdjustmentType'] ||= 'ChangeInCapacity'
|
18
|
+
attributes['ScalingAdjustment'] ||= 1
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO: implement #alarms
|
23
|
+
# TODO: implement #auto_scaling_group
|
24
|
+
|
25
|
+
def save
|
26
|
+
requires :id
|
27
|
+
requires :adjustment_type
|
28
|
+
requires :auto_scaling_group_name
|
29
|
+
requires :scaling_adjustment
|
30
|
+
|
31
|
+
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
32
|
+
options.delete_if { |key, value| value.nil? }
|
33
|
+
|
34
|
+
connection.put_scaling_policy(adjustment_type, auto_scaling_group_name, id, scaling_adjustment, options)
|
35
|
+
reload
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
requires :id
|
40
|
+
requires :auto_scaling_group_name
|
41
|
+
connection.delete_policy(auto_scaling_group_name, id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -3,9 +3,57 @@ require 'fog/core/model'
|
|
3
3
|
module Fog
|
4
4
|
module AWS
|
5
5
|
class CloudWatch
|
6
|
-
|
7
6
|
class Alarm < Fog::Model
|
8
|
-
|
7
|
+
identity :id, :aliases => 'AlarmName'
|
8
|
+
|
9
|
+
attribute :actions_enabled, :aliases => 'ActionsEnabled'
|
10
|
+
attribute :alarm_actions, :aliases => 'AlarmActions'
|
11
|
+
attribute :arn, :aliases => 'AlarmArn'
|
12
|
+
attribute :alarm_configuration_updated_timestamp, :aliases => 'AlarmConfigurationUpdatedTimestamp'
|
13
|
+
attribute :alarm_description, :aliases => 'AlarmDescription'
|
14
|
+
attribute :comparison_operator, :aliases => 'ComparisonOperator'
|
15
|
+
attribute :dimensions, :aliases => 'Dimensions'
|
16
|
+
attribute :evaluation_periods, :aliases => 'EvaluationPeriods'
|
17
|
+
attribute :insufficient_data_actions, :aliases => 'InsufficientDataActions'
|
18
|
+
attribute :metric_name, :aliases => 'MetricName'
|
19
|
+
attribute :namespace, :aliases => 'Namespace'
|
20
|
+
attribute :ok_actions, :aliases => 'OKActions'
|
21
|
+
attribute :period, :aliases => 'Period'
|
22
|
+
attribute :state_reason, :aliases => 'StateReason'
|
23
|
+
attribute :state_reason_data, :aliases => 'StateReasonData'
|
24
|
+
attribute :state_updated_timestamp, :aliases => 'StateUpdatedTimestamp'
|
25
|
+
attribute :state_value, :aliases => 'StateValue'
|
26
|
+
attribute :statistic, :aliases => 'Statistic'
|
27
|
+
attribute :threshold, :aliases => 'Threshold'
|
28
|
+
attribute :unit, :aliases => 'Unit'
|
29
|
+
|
30
|
+
def initialize(attributes)
|
31
|
+
attributes['EvaluationPeriods'] ||= 1
|
32
|
+
attributes['Namespace'] ||= 'AWS/EC2'
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
def save
|
37
|
+
requires :id
|
38
|
+
requires :comparison_operator
|
39
|
+
requires :evaluation_periods
|
40
|
+
requires :metric_name
|
41
|
+
requires :namespace
|
42
|
+
requires :period
|
43
|
+
requires :statistic
|
44
|
+
requires :threshold
|
45
|
+
|
46
|
+
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
47
|
+
options.delete_if { |key, value| value.nil? }
|
48
|
+
|
49
|
+
connection.put_metric_alarm(options)
|
50
|
+
reload
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy
|
54
|
+
requires :id
|
55
|
+
connection.delete_alarms(id)
|
56
|
+
end
|
9
57
|
end
|
10
58
|
end
|
11
59
|
end
|
@@ -7,7 +7,24 @@ module Fog
|
|
7
7
|
|
8
8
|
class Alarms < Fog::Collection
|
9
9
|
model Fog::AWS::CloudWatch::Alarm
|
10
|
-
|
10
|
+
|
11
|
+
def all
|
12
|
+
data = []
|
13
|
+
next_token = nil
|
14
|
+
loop do
|
15
|
+
result = connection.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
16
|
+
data += result['MetricAlarms']
|
17
|
+
next_token = result['NextToken']
|
18
|
+
break if next_token.nil?
|
19
|
+
end
|
20
|
+
load(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(identity)
|
24
|
+
data = connection.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
|
25
|
+
new(data) unless data.nil?
|
26
|
+
end
|
27
|
+
|
11
28
|
#alarm_names is an array of alarm names
|
12
29
|
def delete(alarm_names)
|
13
30
|
connection.delete_alarms(alarm_names)
|