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
@@ -27,6 +27,10 @@ module Fog
|
|
27
27
|
collection :servers
|
28
28
|
model :image
|
29
29
|
collection :images
|
30
|
+
model :security_group
|
31
|
+
collection :security_groups
|
32
|
+
model :security_group_rule
|
33
|
+
collection :security_group_rules
|
30
34
|
model :volume
|
31
35
|
collection :volumes
|
32
36
|
model :zone
|
@@ -34,7 +38,9 @@ module Fog
|
|
34
38
|
|
35
39
|
request :acquire_ip_address
|
36
40
|
request :assign_to_load_balancer_rule
|
41
|
+
request :assign_virtual_machine
|
37
42
|
request :attach_volume
|
43
|
+
request :authorize_security_group_egress
|
38
44
|
request :authorize_security_group_ingress
|
39
45
|
request :change_service_for_virtual_machine
|
40
46
|
request :create_account
|
@@ -48,6 +54,7 @@ module Fog
|
|
48
54
|
request :create_snapshot_policy
|
49
55
|
request :create_user
|
50
56
|
request :create_volume
|
57
|
+
request :create_zone
|
51
58
|
request :delete_account
|
52
59
|
request :delete_domain
|
53
60
|
request :delete_load_balancer_rule
|
@@ -80,6 +87,7 @@ module Fog
|
|
80
87
|
request :list_events
|
81
88
|
request :list_external_firewalls
|
82
89
|
request :list_external_load_balancers
|
90
|
+
request :list_firewall_rules
|
83
91
|
request :list_hosts
|
84
92
|
request :list_hypervisors
|
85
93
|
request :list_instance_groups
|
@@ -115,6 +123,7 @@ module Fog
|
|
115
123
|
request :remove_from_load_balancer_rule
|
116
124
|
request :reset_password_for_virtual_machine
|
117
125
|
request :revoke_security_group_ingress
|
126
|
+
request :revoke_security_group_egress
|
118
127
|
request :start_virtual_machine
|
119
128
|
request :stop_virtual_machine
|
120
129
|
request :update_account
|
@@ -247,23 +256,20 @@ module Fog
|
|
247
256
|
|
248
257
|
def self.data
|
249
258
|
@data ||= begin
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
account_id = "8bec6f15-e2b8-44fc-a8f3-a022b2873440"
|
255
|
-
user_id = Fog::Cloudstack.uuid
|
256
|
-
domain_id = Fog::Cloudstack.uuid
|
257
|
-
network_id = (Array(rc_options[:network_ids]) || [Fog::Cloudstack.uuid]).first
|
259
|
+
zone_id = Fog.credentials[:cloudstack_zone_id] || Fog::Cloudstack.uuid
|
260
|
+
image_id = Fog.credentials[:cloudstack_template_id] || Fog::Cloudstack.uuid
|
261
|
+
flavor_id = Fog.credentials[:cloudstack_service_offering_id] || Fog::Cloudstack.uuid
|
262
|
+
network_id = (Array(Fog.credentials[:cloudstack_network_ids]) || [Fog::Cloudstack.uuid]).first
|
258
263
|
domain_name = "exampleorg"
|
264
|
+
account_id, user_id, domain_id = Fog::Cloudstack.uuid, Fog::Cloudstack.uuid, Fog::Cloudstack.uuid
|
259
265
|
domain = {
|
260
|
-
"id"
|
261
|
-
"name"
|
262
|
-
"level"
|
263
|
-
"parentdomainid"
|
266
|
+
"id" => domain_id,
|
267
|
+
"name" => domain_name,
|
268
|
+
"level" => 1,
|
269
|
+
"parentdomainid" => Fog::Cloudstack.uuid,
|
264
270
|
"parentdomainname" => "ROOT",
|
265
|
-
"haschild"
|
266
|
-
"path"
|
271
|
+
"haschild" => false,
|
272
|
+
"path" => "ROOT/accountname"
|
267
273
|
}
|
268
274
|
user = {
|
269
275
|
"id" => user_id,
|
@@ -406,10 +412,11 @@ module Fog
|
|
406
412
|
"state" => "enabled",
|
407
413
|
"user" => [user]}
|
408
414
|
},
|
409
|
-
:domains
|
410
|
-
:servers
|
411
|
-
:jobs
|
412
|
-
:volumes
|
415
|
+
:domains => {domain_id => domain},
|
416
|
+
:servers => {},
|
417
|
+
:jobs => {},
|
418
|
+
:volumes => {},
|
419
|
+
:security_groups => {},
|
413
420
|
}
|
414
421
|
end
|
415
422
|
end
|
@@ -2,60 +2,60 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Cloudstack
|
4
4
|
class Image < Fog::Model
|
5
|
-
identity :id,
|
5
|
+
identity :id, :aliases => 'id'
|
6
6
|
attribute :account
|
7
|
-
attribute :account_id,
|
7
|
+
attribute :account_id, :aliases => 'accountid'
|
8
8
|
attribute :bootable
|
9
9
|
attribute :checksum
|
10
10
|
attribute :created
|
11
|
-
attribute :cross_zones,
|
11
|
+
attribute :cross_zones, :aliases => 'crossZones'
|
12
12
|
attribute :details
|
13
|
-
attribute :display_text,
|
13
|
+
attribute :display_text, :aliases => 'displaytext'
|
14
14
|
attribute :domain
|
15
|
-
attribute :domain_id,
|
15
|
+
attribute :domain_id, :aliases => 'domainid'
|
16
16
|
attribute :format
|
17
|
-
attribute :host_id,
|
18
|
-
attribute :host_name,
|
17
|
+
attribute :host_id, :aliases => 'hostid'
|
18
|
+
attribute :host_name, :aliases => 'hostname'
|
19
19
|
attribute :hypervisor
|
20
|
-
attribute :job_id,
|
21
|
-
attribute :job_status,
|
22
|
-
attribute :is_extractable,
|
23
|
-
attribute :is_featured,
|
24
|
-
attribute :is_public,
|
25
|
-
attribute :is_ready,
|
20
|
+
attribute :job_id, :aliases => 'jobid'
|
21
|
+
attribute :job_status, :aliases => 'jobstatus'
|
22
|
+
attribute :is_extractable, :aliases => 'isextractable'
|
23
|
+
attribute :is_featured, :aliases => 'isfeatured'
|
24
|
+
attribute :is_public, :aliases => 'ispublic'
|
25
|
+
attribute :is_ready, :aliases => 'isready'
|
26
26
|
attribute :name
|
27
|
-
attribute :os_type_id,
|
28
|
-
attribute :os_type_name,
|
29
|
-
attribute :password_enabled,
|
27
|
+
attribute :os_type_id, :aliases => 'ostypeid'
|
28
|
+
attribute :os_type_name, :aliases => 'ostypename'
|
29
|
+
attribute :password_enabled, :aliases => 'ostypename'
|
30
30
|
attribute :project
|
31
|
-
attribute :project_id,
|
31
|
+
attribute :project_id, :aliases => 'projectid'
|
32
32
|
attribute :removed
|
33
33
|
attribute :size
|
34
34
|
attribute :source_template_id, :aliases => 'sourcetemplateid'
|
35
35
|
attribute :status
|
36
|
-
attribute :template_tag,
|
37
|
-
attribute :template_type,
|
38
|
-
attribute :zone_id,
|
39
|
-
attribute :zone_name,
|
36
|
+
attribute :template_tag, :aliases => 'templatetag'
|
37
|
+
attribute :template_type, :aliases => 'templatetype'
|
38
|
+
attribute :zone_id, :aliases => 'zoneid'
|
39
|
+
attribute :zone_name, :aliases => 'zonename'
|
40
40
|
|
41
41
|
attr_accessor :bits, :requires_hvm, :snapshot_id, :url, :virtual_machine_id, :volume_id
|
42
42
|
|
43
43
|
def save
|
44
44
|
options = {
|
45
|
-
'displaytext'
|
46
|
-
'name'
|
47
|
-
'ostypeid'
|
48
|
-
'bits'
|
49
|
-
'details'
|
50
|
-
'isfeatured'
|
51
|
-
'ispublic'
|
52
|
-
'passwordenabled'
|
53
|
-
'requireshvm'
|
54
|
-
'snapshotid'
|
55
|
-
'templatetag'
|
56
|
-
'url'
|
45
|
+
'displaytext' => display_text,
|
46
|
+
'name' => name,
|
47
|
+
'ostypeid' => os_type_id,
|
48
|
+
'bits' => bits,
|
49
|
+
'details' => details,
|
50
|
+
'isfeatured' => is_featured,
|
51
|
+
'ispublic' => is_public,
|
52
|
+
'passwordenabled' => password_enabled,
|
53
|
+
'requireshvm' => requires_hvm,
|
54
|
+
'snapshotid' => snapshot_id,
|
55
|
+
'templatetag' => template_tag,
|
56
|
+
'url' => url,
|
57
57
|
'virtualmachineid' => virtual_machine_id,
|
58
|
-
'volumeid'
|
58
|
+
'volumeid' => volume_id
|
59
59
|
}
|
60
60
|
data = connection.create_template(options)
|
61
61
|
merge_attributes(data['createtemplateresponse'])
|
@@ -20,9 +20,22 @@ module Fog
|
|
20
20
|
merge_attributes(connection.query_async_job_result('jobid' => self.id)['queryasyncjobresultresponse'])
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def ready?
|
24
24
|
self.job_status != 0
|
25
25
|
end
|
26
|
+
|
27
|
+
def successful?
|
28
|
+
self.job_result_code == 0
|
29
|
+
end
|
30
|
+
|
31
|
+
# so dirty
|
32
|
+
def result
|
33
|
+
if successful? && model = Fog::Compute::Cloudstack.constants.find{|c| c.to_s.downcase == self.job_result.keys.first.to_s}.to_s
|
34
|
+
collection = model.gsub(/.[A-Z]/){|w| "#{w[0]}_#{w[1].downcase}"}.downcase + "s" # cheap underscorize, assume simple pluralization
|
35
|
+
connection.send(collection).new(self.job_result.values.first)
|
36
|
+
else self.job_result
|
37
|
+
end
|
38
|
+
end
|
26
39
|
end # Job
|
27
40
|
end # Cloudstack
|
28
41
|
end # Compute
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def get(job_id)
|
18
|
-
if job = connection.query_async_job_result('jobid' => job_id)["
|
18
|
+
if job = connection.query_async_job_result('jobid' => job_id)["queryasyncjobresultresponse"]
|
19
19
|
new(job)
|
20
20
|
end
|
21
21
|
rescue Fog::Compute::Cloudstack::BadRequest
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Cloudstack
|
4
|
+
class SecurityGroup < Fog::Model
|
5
|
+
identity :id, :aliases => 'id'
|
6
|
+
attribute :name, :type => :string
|
7
|
+
attribute :description, :type => :string
|
8
|
+
attribute :account, :type => :string
|
9
|
+
attribute :domain_id, :aliases => "domainid", :type => :string
|
10
|
+
attribute :domain_name, :aliases => "domain", :type => :string
|
11
|
+
attribute :project_id, :aliases => "projectid", :type => :string
|
12
|
+
attribute :project_name, :aliases => "project", :type => :string
|
13
|
+
attribute :ingress_rules, :aliases => "ingressrule", :type => :array
|
14
|
+
attribute :egress_rules, :aliases => "egressrule", :type => :array
|
15
|
+
|
16
|
+
def destroy
|
17
|
+
requires :id
|
18
|
+
connection.delete_security_group('id' => self.id)
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def egress_rules
|
23
|
+
attributes[:egress_rules] || []
|
24
|
+
end
|
25
|
+
|
26
|
+
def ingress_rules
|
27
|
+
attributes[:ingress_rules] || []
|
28
|
+
end
|
29
|
+
|
30
|
+
def save
|
31
|
+
requires :name
|
32
|
+
|
33
|
+
options = {
|
34
|
+
'name' => self.name,
|
35
|
+
'account' => self.account,
|
36
|
+
'description' => self.description,
|
37
|
+
'projectid' => self.project_id,
|
38
|
+
'domainid' => self.domain_id,
|
39
|
+
}
|
40
|
+
data = connection.create_security_group(options)
|
41
|
+
merge_attributes(data['createsecuritygroupresponse']['securitygroup'])
|
42
|
+
end
|
43
|
+
|
44
|
+
def rules
|
45
|
+
connection.security_group_rules.all("security_group_id" => self.id)
|
46
|
+
end
|
47
|
+
end # SecurityGroup
|
48
|
+
end # Cloudstack
|
49
|
+
end # Compute
|
50
|
+
end # Fog
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Cloudstack
|
4
|
+
class SecurityGroupRule < Fog::Model
|
5
|
+
|
6
|
+
identity :id, :aliases => 'ruleid'
|
7
|
+
|
8
|
+
attribute :security_group_id, :type => :string
|
9
|
+
attribute :protocol, :type => :string
|
10
|
+
attribute :start_port, :type => :integer, :aliases => 'startport'
|
11
|
+
attribute :end_port, :type => :integer, :aliases => 'endport'
|
12
|
+
attribute :cidr, :type => :string
|
13
|
+
attribute :direction, :type => :string
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
data = connection.send("revoke_security_group_#{self.direction}", "id" => self.id)
|
17
|
+
job = connection.jobs.new(data["revokesecuritygroup#{self.direction}"])
|
18
|
+
job.wait_for { ready? }
|
19
|
+
job.successful?
|
20
|
+
end
|
21
|
+
|
22
|
+
def port_range
|
23
|
+
(self.start_port..self.end_port)
|
24
|
+
end
|
25
|
+
|
26
|
+
def save
|
27
|
+
requires :security_group_id, :cidr, :direction
|
28
|
+
|
29
|
+
data = connection.send("authorize_security_group_#{self.direction}".to_sym, params)
|
30
|
+
job = connection.jobs.new(data["authorizesecuritygroup#{self.direction}response"])
|
31
|
+
job.wait_for { ready? }
|
32
|
+
# durty
|
33
|
+
merge_attributes(job.result.send("#{self.direction}_rules").last)
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def security_group
|
38
|
+
connection.security_groups.get(self.security_group_id)
|
39
|
+
end
|
40
|
+
|
41
|
+
def reload
|
42
|
+
requires :id, :security_group_id, :cidr
|
43
|
+
|
44
|
+
merge_attributes(security_group.rules.get(self.id))
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def params
|
50
|
+
options = {
|
51
|
+
"securitygroupid" => self.security_group_id,
|
52
|
+
"protocol" => self.protocol,
|
53
|
+
"cidrlist" => self.cidr
|
54
|
+
}
|
55
|
+
options.merge!("startport" => self.start_port) unless self.start_port.nil?
|
56
|
+
options.merge("endport" => self.end_port) unless self.end_port.nil?
|
57
|
+
end
|
58
|
+
|
59
|
+
end # SecurityGroupRule
|
60
|
+
end # Cloudstack
|
61
|
+
end # Compute
|
62
|
+
end # Fog
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/cloudstack/models/compute/security_group_rule'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Cloudstack
|
7
|
+
|
8
|
+
class SecurityGroupRules < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Compute::Cloudstack::SecurityGroupRule
|
11
|
+
|
12
|
+
attribute :security_group_id, :type => :string
|
13
|
+
|
14
|
+
def security_group
|
15
|
+
connection.security_groups.get(self.security_group_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(attributes)
|
19
|
+
model = self.new(attributes.merge(:security_group_id => self.security_group_id))
|
20
|
+
model.save
|
21
|
+
end
|
22
|
+
|
23
|
+
def all(options={})
|
24
|
+
merge_attributes(options)
|
25
|
+
security_group = self.security_group
|
26
|
+
rules = security_group.ingress_rules.map{|r| r.merge("direction" => "ingress", "security_group_id" => security_group_id)}
|
27
|
+
rules += security_group.egress_rules.map{|r| r.merge("direction" => "egress", "security_group_id" => security_group_id)}
|
28
|
+
load(rules)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(rule_id)
|
32
|
+
all.find{|r| r.id == rule_id}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/cloudstack/models/compute/security_group'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Cloudstack
|
7
|
+
class SecurityGroups < Fog::Collection
|
8
|
+
|
9
|
+
model Fog::Compute::Cloudstack::SecurityGroup
|
10
|
+
|
11
|
+
def all(options={})
|
12
|
+
data = connection.list_security_groups(options)["listsecuritygroupsresponse"]["securitygroup"] || []
|
13
|
+
load(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(security_group_id)
|
17
|
+
if security_group = connection.list_security_groups('id' => security_group_id)["listsecuritygroupsresponse"]["securitygroup"].first
|
18
|
+
new(security_group)
|
19
|
+
end
|
20
|
+
rescue Fog::Compute::Cloudstack::BadRequest
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,39 +4,54 @@ module Fog
|
|
4
4
|
module Compute
|
5
5
|
class Cloudstack
|
6
6
|
class Server < Fog::Compute::Server
|
7
|
-
identity :id,
|
7
|
+
identity :id, :aliases => 'id'
|
8
8
|
attribute :name
|
9
|
-
attribute :account
|
10
|
-
attribute :domain
|
9
|
+
attribute :account_name, :aliases => 'account'
|
10
|
+
attribute :domain_name, :aliases => 'domain'
|
11
11
|
attribute :created
|
12
12
|
attribute :state
|
13
13
|
attribute :haenable
|
14
14
|
attribute :memory
|
15
|
-
attribute :display_name,
|
16
|
-
attribute :domain_id,
|
17
|
-
attribute :host_id,
|
18
|
-
attribute :host_name,
|
19
|
-
attribute :project_id,
|
20
|
-
attribute :zone_id,
|
21
|
-
attribute :zone_name,
|
22
|
-
attribute :image_id,
|
23
|
-
attribute :image_name,
|
24
|
-
attribute :templated_display_text,
|
25
|
-
attribute :password_enabled,
|
26
|
-
attribute :flavor_id,
|
27
|
-
attribute :flavor_name,
|
28
|
-
attribute :cpu_number,
|
29
|
-
attribute :cpu_speed,
|
30
|
-
attribute :cpu_used,
|
31
|
-
attribute :network_kbs_read,
|
32
|
-
attribute :network_kbs_write,
|
33
|
-
attribute :guest_os_id,
|
34
|
-
attribute :root_device_id,
|
35
|
-
attribute :root_device_type,
|
36
|
-
attribute :
|
37
|
-
attribute :nics,
|
15
|
+
attribute :display_name, :aliases => 'displayname'
|
16
|
+
attribute :domain_id, :aliases => 'domainid'
|
17
|
+
attribute :host_id, :aliases => 'hostid'
|
18
|
+
attribute :host_name, :aliases => 'hostname'
|
19
|
+
attribute :project_id, :aliases => 'projectid'
|
20
|
+
attribute :zone_id, :aliases => 'zoneid'
|
21
|
+
attribute :zone_name, :aliases => 'zonename'
|
22
|
+
attribute :image_id, :aliases => ['templateid', :template_id]
|
23
|
+
attribute :image_name, :aliases => ['templatename', :template_name]
|
24
|
+
attribute :templated_display_text, :aliases => 'templatedisplaytext'
|
25
|
+
attribute :password_enabled, :aliases => 'passwordenabled'
|
26
|
+
attribute :flavor_id, :aliases => ['serviceofferingid', :service_offering_id]
|
27
|
+
attribute :flavor_name, :aliases => ['serviceofferingname', :service_offering_name]
|
28
|
+
attribute :cpu_number, :aliases => 'cpunumber'
|
29
|
+
attribute :cpu_speed, :aliases => 'cpuspeed'
|
30
|
+
attribute :cpu_used, :aliases => 'cpuused'
|
31
|
+
attribute :network_kbs_read, :aliases => 'networkkbsread'
|
32
|
+
attribute :network_kbs_write, :aliases => 'networkkbswrite'
|
33
|
+
attribute :guest_os_id, :aliases => 'guestosid'
|
34
|
+
attribute :root_device_id, :aliases => 'rootdeviceid'
|
35
|
+
attribute :root_device_type, :aliases => 'rootdevicetype'
|
36
|
+
attribute :security_group_list, :type => :array, :aliases => 'securitygroup'
|
37
|
+
attribute :nics, :type => :array, :aliases => 'nic'
|
38
38
|
|
39
39
|
attr_accessor :network_ids, :disk_offering_id, :ip_address, :ip_to_network_list
|
40
|
+
attr_writer :security_group_ids
|
41
|
+
|
42
|
+
def addresses
|
43
|
+
nics.map{|nic| Address.new(nic)}
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
requires :id
|
48
|
+
data = connection.destroy_virtual_machine("id" => id)
|
49
|
+
connection.jobs.new(data["destroyvirtualmachineresponse"])
|
50
|
+
end
|
51
|
+
|
52
|
+
def flavor
|
53
|
+
connection.flavors.get(self.flavor_id)
|
54
|
+
end
|
40
55
|
|
41
56
|
def ready?
|
42
57
|
state == 'Running'
|
@@ -45,9 +60,19 @@ module Fog
|
|
45
60
|
def reboot
|
46
61
|
requires :id
|
47
62
|
data = connection.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail?
|
48
|
-
|
49
|
-
|
50
|
-
|
63
|
+
connection.jobs.new(data["rebootvirtualmachineresponse"])
|
64
|
+
end
|
65
|
+
|
66
|
+
def security_groups=(security_groups)
|
67
|
+
self.security_group_ids= Array(security_groups).map(&:id)
|
68
|
+
end
|
69
|
+
|
70
|
+
def security_group_ids
|
71
|
+
@security_group_ids || (self.security_group_list || []).map{|sg| sg["id"]}
|
72
|
+
end
|
73
|
+
|
74
|
+
def security_groups
|
75
|
+
security_group_ids.map{|id| self.connection.security_groups.get(id)}
|
51
76
|
end
|
52
77
|
|
53
78
|
def save
|
@@ -64,27 +89,26 @@ module Fog
|
|
64
89
|
'hostid' => host_id,
|
65
90
|
'ipaddress' => ip_address,
|
66
91
|
'iptonetworklist' => ip_to_network_list,
|
67
|
-
'projectid' => project_id
|
92
|
+
'projectid' => project_id,
|
68
93
|
}
|
69
94
|
|
70
95
|
options.merge!('networkids' => network_ids) if network_ids
|
96
|
+
options.merge!('securitygroupids' => security_group_ids) if security_group_ids
|
71
97
|
|
72
98
|
data = connection.deploy_virtual_machine(options)
|
73
99
|
merge_attributes(data['deployvirtualmachineresponse'])
|
74
100
|
end
|
75
101
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def flavor
|
81
|
-
connection.flavors.get(self.flavor_id)
|
102
|
+
def start
|
103
|
+
requires :id
|
104
|
+
data = connection.start_virtual_machine("id" => self.id)
|
105
|
+
connection.jobs.new(data["startvirtualmachineresponse"])
|
82
106
|
end
|
83
107
|
|
84
|
-
def
|
108
|
+
def stop(force=false)
|
85
109
|
requires :id
|
86
|
-
connection.
|
87
|
-
|
110
|
+
data = connection.stop_virtual_machine("id" => self.id, "force" => force)
|
111
|
+
connection.jobs.new(data["stopvirtualmachineresponse"])
|
88
112
|
end
|
89
113
|
end # Server
|
90
114
|
end # Cloudstack
|