fog 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +2 -9
- data/Rakefile +3 -2
- data/docs/_layouts/default.html +13 -13
- data/docs/about/contributing.markdown +1 -1
- data/docs/about/getting_started.markdown +28 -3
- data/docs/dns/index.markdown +4 -4
- data/docs/index.markdown +2 -10
- data/docs/public/css/fog.css +14 -1
- data/docs/storage/index.markdown +2 -2
- data/fog.gemspec +6 -5
- data/lib/fog.rb +1 -1
- data/lib/fog/aws.rb +26 -1
- data/lib/fog/aws/auto_scaling.rb +3 -1
- data/lib/fog/aws/cloud_formation.rb +3 -0
- data/lib/fog/aws/cloud_watch.rb +17 -1
- data/lib/fog/aws/compute.rb +50 -18
- data/lib/fog/aws/elb.rb +4 -2
- data/lib/fog/aws/emr.rb +133 -0
- data/lib/fog/aws/models/cloud_watch/alarm.rb +12 -0
- data/lib/fog/aws/models/cloud_watch/alarm_data.rb +39 -0
- data/lib/fog/aws/models/cloud_watch/alarm_datum.rb +66 -0
- data/lib/fog/aws/models/cloud_watch/alarm_histories.rb +18 -0
- data/lib/fog/aws/models/cloud_watch/alarm_history.rb +16 -0
- data/lib/fog/aws/models/cloud_watch/alarms.rb +30 -0
- data/lib/fog/aws/models/compute/addresses.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +1 -1
- data/lib/fog/aws/models/compute/security_groups.rb +1 -1
- data/lib/fog/aws/models/compute/server.rb +4 -2
- data/lib/fog/aws/models/compute/servers.rb +1 -1
- data/lib/fog/aws/models/compute/snapshots.rb +1 -1
- data/lib/fog/aws/models/compute/spot_request.rb +21 -4
- data/lib/fog/aws/models/compute/spot_requests.rb +45 -1
- data/lib/fog/aws/models/compute/volumes.rb +1 -1
- data/lib/fog/aws/models/elb/load_balancer.rb +2 -0
- data/lib/fog/aws/models/storage/file.rb +1 -1
- data/lib/fog/aws/parsers/cdn/get_invalidation_list.rb +0 -1
- data/lib/fog/aws/parsers/cloud_formation/update_stack.rb +19 -0
- data/lib/fog/aws/parsers/cloud_watch/delete_alarms.rb +26 -0
- data/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb +40 -0
- data/lib/fog/aws/parsers/cloud_watch/describe_alarms.rb +73 -0
- data/lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb +71 -0
- data/lib/fog/aws/parsers/cloud_watch/disable_alarm_actions.rb +26 -0
- data/lib/fog/aws/parsers/cloud_watch/enable_alarm_actions.rb +26 -0
- data/lib/fog/aws/parsers/cloud_watch/get_metric_statistics.rb +1 -0
- data/lib/fog/aws/parsers/cloud_watch/put_metric_alarm.rb +26 -0
- data/lib/fog/aws/parsers/cloud_watch/set_alarm_state.rb +26 -0
- data/lib/fog/aws/parsers/compute/spot_instance_requests.rb +2 -2
- data/lib/fog/aws/parsers/emr/add_instance_groups.rb +28 -0
- data/lib/fog/aws/parsers/emr/add_job_flow_steps.rb +17 -0
- data/lib/fog/aws/parsers/emr/describe_job_flows.rb +140 -0
- data/lib/fog/aws/parsers/emr/modify_instance_groups.rb +17 -0
- data/lib/fog/aws/parsers/emr/run_job_flow.rb +19 -0
- data/lib/fog/aws/parsers/emr/set_termination_protection.rb +17 -0
- data/lib/fog/aws/parsers/emr/terminate_job_flows.rb +17 -0
- data/lib/fog/aws/rds.rb +3 -1
- data/lib/fog/aws/requests/cloud_formation/create_stack.rb +6 -0
- data/lib/fog/aws/requests/cloud_formation/update_stack.rb +62 -0
- data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +30 -0
- data/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb +33 -0
- data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +38 -0
- data/lib/fog/aws/requests/cloud_watch/describe_alarms_for_metric.rb +39 -0
- data/lib/fog/aws/requests/cloud_watch/disable_alarm_actions.rb +30 -0
- data/lib/fog/aws/requests/cloud_watch/enable_alarm_actions.rb +30 -0
- data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +84 -0
- data/lib/fog/aws/requests/cloud_watch/set_alarm_state.rb +31 -0
- data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +141 -36
- data/lib/fog/aws/requests/compute/create_snapshot.rb +2 -3
- data/lib/fog/aws/requests/compute/create_tags.rb +5 -3
- data/lib/fog/aws/requests/compute/create_volume.rb +0 -1
- data/lib/fog/aws/requests/compute/delete_security_group.rb +25 -0
- data/lib/fog/aws/requests/compute/delete_tags.rb +3 -4
- data/lib/fog/aws/requests/compute/describe_addresses.rb +2 -2
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +5 -2
- data/lib/fog/aws/requests/compute/describe_images.rb +6 -9
- data/lib/fog/aws/requests/compute/describe_instances.rb +17 -8
- data/lib/fog/aws/requests/compute/describe_key_pairs.rb +2 -2
- data/lib/fog/aws/requests/compute/describe_regions.rb +2 -2
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -1
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -2
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +7 -5
- data/lib/fog/aws/requests/compute/describe_volumes.rb +5 -4
- data/lib/fog/aws/requests/compute/modify_image_attribute.rb +32 -0
- data/lib/fog/aws/requests/compute/modify_instance_attribute.rb +1 -1
- data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -1
- data/lib/fog/aws/requests/compute/register_image.rb +0 -1
- data/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +41 -29
- data/lib/fog/aws/requests/compute/run_instances.rb +1 -2
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
- data/lib/fog/aws/requests/elb/create_load_balancer_listeners.rb +1 -1
- data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +1 -1
- data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -2
- data/lib/fog/aws/requests/elb/describe_load_balancers.rb +3 -3
- data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -2
- data/lib/fog/aws/requests/emr/add_instance_groups.rb +46 -0
- data/lib/fog/aws/requests/emr/add_job_flow_steps.rb +49 -0
- data/lib/fog/aws/requests/emr/describe_job_flows.rb +108 -0
- data/lib/fog/aws/requests/emr/modify_instance_groups.rb +40 -0
- data/lib/fog/aws/requests/emr/run_job_flow.rb +106 -0
- data/lib/fog/aws/requests/emr/set_termination_protection.rb +39 -0
- data/lib/fog/aws/requests/emr/terminate_job_flows.rb +37 -0
- data/lib/fog/aws/requests/iam/get_server_certificate.rb +5 -7
- data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
- data/lib/fog/aws/requests/simpledb/select.rb +1 -1
- data/lib/fog/aws/requests/storage/copy_object.rb +1 -1
- data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
- data/lib/fog/aws/requests/storage/hash_to_acl.rb +35 -25
- data/lib/fog/aws/ses.rb +1 -1
- data/lib/fog/aws/simpledb.rb +2 -0
- data/lib/fog/aws/sns.rb +3 -1
- data/lib/fog/aws/sqs.rb +4 -2
- data/lib/fog/aws/storage.rb +12 -3
- data/lib/fog/bin.rb +1 -1
- data/lib/fog/bin/aws.rb +8 -4
- data/lib/fog/bin/bluebox.rb +2 -2
- data/lib/fog/bin/brightbox.rb +1 -1
- data/lib/fog/bin/dnsimple.rb +1 -1
- data/lib/fog/bin/dnsmadeeasy.rb +1 -1
- data/lib/fog/bin/ecloud.rb +1 -1
- data/lib/fog/bin/glesys.rb +1 -1
- data/lib/fog/bin/go_grid.rb +1 -1
- data/lib/fog/bin/google.rb +1 -1
- data/lib/fog/bin/libvirt.rb +1 -1
- data/lib/fog/bin/linode.rb +2 -2
- data/lib/fog/bin/local.rb +1 -1
- data/lib/fog/bin/new_servers.rb +1 -1
- data/lib/fog/bin/ninefold.rb +2 -2
- data/lib/fog/bin/openstack.rb +1 -1
- data/lib/fog/bin/rackspace.rb +3 -3
- data/lib/fog/bin/slicehost.rb +1 -1
- data/lib/fog/bin/stormondemand.rb +1 -1
- data/lib/fog/bin/virtual_box.rb +1 -1
- data/lib/fog/bin/vmfusion.rb +1 -1
- data/lib/fog/bin/voxel.rb +1 -1
- data/lib/fog/bin/zerigo.rb +1 -1
- data/lib/fog/brightbox/models/compute/account.rb +1 -1
- data/lib/fog/compute/models/server.rb +1 -2
- data/lib/fog/core/attributes.rb +5 -5
- data/lib/fog/core/connection.rb +1 -1
- data/lib/fog/core/deprecation.rb +2 -2
- data/lib/fog/core/logger.rb +8 -3
- data/lib/fog/core/mock.rb +4 -0
- data/lib/fog/core/provider.rb +7 -2
- data/lib/fog/core/service.rb +8 -2
- data/lib/fog/dnsmadeeasy/models/dns/record.rb +3 -2
- data/lib/fog/dynect/dns.rb +25 -3
- data/lib/fog/ecloud/compute.rb +2 -6
- data/lib/fog/go_grid/requests/compute/grid_server_power.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +1 -1
- data/lib/fog/google/requests/storage/get_object_url.rb +2 -2
- data/lib/fog/google/storage.rb +1 -1
- data/lib/fog/libvirt/models/compute/uri.rb +7 -3
- data/lib/fog/linode/models/compute/server.rb +10 -0
- data/lib/fog/ninefold/models/storage/file.rb +8 -6
- data/lib/fog/ninefold/models/storage/files.rb +3 -2
- data/lib/fog/ninefold/requests/storage/head_namespace.rb +20 -0
- data/lib/fog/ninefold/storage.rb +4 -2
- data/lib/fog/openstack.rb +4 -3
- data/lib/fog/openstack/compute.rb +8 -5
- data/lib/fog/openstack/models/compute/server.rb +10 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +6 -8
- data/lib/fog/rackspace/load_balancers.rb +1 -0
- data/lib/fog/rackspace/models/dns/callback.rb +1 -1
- data/lib/fog/rackspace/models/dns/record.rb +1 -1
- data/lib/fog/rackspace/models/dns/zone.rb +1 -1
- data/lib/fog/slicehost/dns.rb +1 -0
- data/lib/fog/slicehost/models/dns/record.rb +7 -3
- data/lib/fog/slicehost/models/dns/zone.rb +1 -1
- data/lib/fog/slicehost/parsers/dns/create_record.rb +8 -2
- data/lib/fog/slicehost/parsers/dns/get_record.rb +17 -5
- data/lib/fog/slicehost/parsers/dns/get_records.rb +10 -2
- data/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
- data/lib/fog/slicehost/requests/dns/get_records.rb +7 -8
- data/lib/fog/slicehost/requests/dns/update_record.rb +43 -0
- data/lib/fog/storm_on_demand/models/compute/balancers.rb +1 -1
- data/lib/fog/storm_on_demand/models/compute/configs.rb +1 -1
- data/lib/fog/storm_on_demand/models/compute/images.rb +1 -1
- data/lib/fog/storm_on_demand/models/compute/servers.rb +1 -1
- data/lib/fog/storm_on_demand/models/compute/templates.rb +1 -1
- data/lib/fog/terremark/vcloud.rb +1 -1
- data/lib/fog/vsphere/compute.rb +40 -23
- data/lib/fog/vsphere/models/compute/server.rb +1 -0
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +36 -4
- data/lib/fog/zerigo/dns.rb +14 -3
- data/lib/fog/zerigo/models/dns/record.rb +1 -1
- data/lib/fog/zerigo/models/dns/records.rb +5 -0
- data/lib/fog/zerigo/models/dns/zones.rb +2 -2
- data/lib/fog/zerigo/requests/dns/count_hosts.rb +20 -1
- data/lib/fog/zerigo/requests/dns/count_zones.rb +12 -1
- data/lib/fog/zerigo/requests/dns/create_host.rb +67 -1
- data/lib/fog/zerigo/requests/dns/create_zone.rb +44 -1
- data/lib/fog/zerigo/requests/dns/delete_host.rb +19 -0
- data/lib/fog/zerigo/requests/dns/delete_zone.rb +17 -0
- data/lib/fog/zerigo/requests/dns/find_hosts.rb +22 -1
- data/lib/fog/zerigo/requests/dns/get_host.rb +18 -1
- data/lib/fog/zerigo/requests/dns/get_zone.rb +19 -2
- data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +23 -0
- data/lib/fog/zerigo/requests/dns/list_hosts.rb +20 -1
- data/lib/fog/zerigo/requests/dns/list_zones.rb +15 -0
- data/lib/fog/zerigo/requests/dns/update_host.rb +20 -1
- data/lib/fog/zerigo/requests/dns/update_zone.rb +20 -1
- data/tests/aws/models/cloud_watch/alarm_data_tests.rb +42 -0
- data/tests/aws/models/cloud_watch/alarm_history_tests.rb +22 -0
- data/tests/aws/models/compute/security_group_tests.rb +15 -10
- data/tests/aws/models/elb/model_tests.rb +4 -4
- data/tests/aws/requests/cloud_formation/stack_tests.rb +14 -0
- data/tests/aws/requests/cloud_watch/list_metrics_test.rb +5 -5
- data/tests/aws/requests/compute/image_tests.rb +33 -2
- data/tests/aws/requests/compute/instance_tests.rb +16 -1
- data/tests/aws/requests/compute/security_group_tests.rb +251 -32
- data/tests/aws/requests/compute/tag_tests.rb +42 -2
- data/tests/aws/requests/emr/helper.rb +172 -0
- data/tests/aws/requests/emr/instance_group_tests.rb +106 -0
- data/tests/aws/requests/emr/job_flow_tests.rb +88 -0
- data/tests/aws/requests/iam/server_certificate_tests.rb +20 -7
- data/tests/aws/requests/storage/bucket_tests.rb +82 -54
- data/tests/aws/requests/storage/hash_to_acl_tests.rb +173 -0
- data/tests/aws/requests/storage/object_tests.rb +44 -24
- data/tests/brightbox/requests/compute/helper.rb +15 -6
- data/tests/core/attribute_tests.rb +29 -0
- data/tests/core/mocking_tests.rb +60 -0
- data/tests/dns/models/record_tests.rb +4 -2
- data/tests/dns/models/records_tests.rb +4 -2
- data/tests/dns/models/zone_tests.rb +3 -1
- data/tests/dns/models/zones_tests.rb +4 -2
- data/tests/helper.rb +4 -0
- data/tests/rackspace/requests/dns/dns_tests.rb +16 -12
- data/tests/rackspace/requests/dns/records_tests.rb +13 -11
- data/tests/slicehost/requests/dns/dns_tests.rb +58 -11
- data/tests/vsphere/compute_tests.rb +18 -10
- data/tests/vsphere/requests/compute/vm_clone_tests.rb +1 -1
- metadata +214 -221
|
@@ -11,9 +11,15 @@ module Fog
|
|
|
11
11
|
|
|
12
12
|
def end_element(name)
|
|
13
13
|
case name
|
|
14
|
-
when '
|
|
14
|
+
when 'zone_id'
|
|
15
|
+
@response["zone-id"] = value.to_i
|
|
16
|
+
when 'record_type'
|
|
17
|
+
@response["record-type"] = value
|
|
18
|
+
when 'ttl', 'id'
|
|
15
19
|
@response[name] = value.to_i
|
|
16
|
-
when '
|
|
20
|
+
when 'value'
|
|
21
|
+
@response["data"] = value
|
|
22
|
+
when 'name', 'data', 'active', 'aux'
|
|
17
23
|
@response[name] = value
|
|
18
24
|
end
|
|
19
25
|
end
|
|
@@ -6,15 +6,27 @@ module Fog
|
|
|
6
6
|
class GetRecord < Fog::Parsers::Base
|
|
7
7
|
|
|
8
8
|
def reset
|
|
9
|
+
@record = {}
|
|
9
10
|
@response = { }
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def end_element(name)
|
|
13
14
|
case name
|
|
14
|
-
when '
|
|
15
|
-
@
|
|
16
|
-
when '
|
|
17
|
-
@
|
|
15
|
+
when 'id'
|
|
16
|
+
@record["id"] = value.to_i
|
|
17
|
+
when 'zone-id'
|
|
18
|
+
@record["zone_id"] = value.to_i
|
|
19
|
+
when 'record-type'
|
|
20
|
+
@record["record_type"] = value
|
|
21
|
+
when 'ttl'
|
|
22
|
+
@record[name] = value.to_i
|
|
23
|
+
when 'data'
|
|
24
|
+
@record["value"] = value
|
|
25
|
+
when 'name', 'active', 'aux'
|
|
26
|
+
@record[name] = value
|
|
27
|
+
when 'record'
|
|
28
|
+
@response = @record
|
|
29
|
+
@record = {}
|
|
18
30
|
end
|
|
19
31
|
end
|
|
20
32
|
|
|
@@ -23,4 +35,4 @@ module Fog
|
|
|
23
35
|
end
|
|
24
36
|
end
|
|
25
37
|
end
|
|
26
|
-
end
|
|
38
|
+
end
|
|
@@ -12,9 +12,17 @@ module Fog
|
|
|
12
12
|
|
|
13
13
|
def end_element(name)
|
|
14
14
|
case name
|
|
15
|
-
when '
|
|
15
|
+
when 'id'
|
|
16
|
+
@record["id"] = value.to_i
|
|
17
|
+
when 'zone-id'
|
|
18
|
+
@record["zone_id"] = value.to_i
|
|
19
|
+
when 'record-type'
|
|
20
|
+
@record["record_type"] = value
|
|
21
|
+
when 'ttl'
|
|
16
22
|
@record[name] = value.to_i
|
|
17
|
-
when '
|
|
23
|
+
when 'data'
|
|
24
|
+
@record["value"] = value
|
|
25
|
+
when 'name', 'active', 'aux'
|
|
18
26
|
@record[name] = value
|
|
19
27
|
when 'record'
|
|
20
28
|
@response['records'] << @record
|
|
@@ -10,14 +10,13 @@ module Fog
|
|
|
10
10
|
# ==== Returns
|
|
11
11
|
# * response<~Excon::Response>:
|
|
12
12
|
# * body<~Array>:
|
|
13
|
-
# * '
|
|
14
|
-
# * '
|
|
15
|
-
# * '
|
|
16
|
-
# * '
|
|
17
|
-
# * '
|
|
18
|
-
# * '
|
|
19
|
-
# * '
|
|
20
|
-
# * 'status'<~String> - Current status of the slice
|
|
13
|
+
# * 'name'<~String> - Record NAME field (e.g. "example.org." or "www")
|
|
14
|
+
# * 'data'<~String> - Data contained by the record (e.g. an IP address, for A records)
|
|
15
|
+
# * 'record_type'<~String> - Type of record (A, CNAME, TXT, etc)
|
|
16
|
+
# * 'aux'<~String> - Aux data for the record, for those types which have it (e.g. TXT)
|
|
17
|
+
# * 'zone_id'<~Integer> - zone ID to which this record belongs
|
|
18
|
+
# * 'active'<~String> - whether this record is active in the Slicehost DNS (Y for yes, N for no)
|
|
19
|
+
# * 'ttl'<~Integer> - TTL in seconds
|
|
21
20
|
def get_records
|
|
22
21
|
request(
|
|
23
22
|
:expects => 200,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module DNS
|
|
3
|
+
class Slicehost
|
|
4
|
+
class Real
|
|
5
|
+
|
|
6
|
+
#require 'fog/slicehost/parsers/dns/update_record'
|
|
7
|
+
|
|
8
|
+
# Get an individual DNS record from the specified zone
|
|
9
|
+
#
|
|
10
|
+
# ==== Returns
|
|
11
|
+
# * response<~Excon::Response>:
|
|
12
|
+
# * body<~Hash>:
|
|
13
|
+
# * 'record_type'<~String> - type of DNS record to create (A, CNAME, etc)
|
|
14
|
+
# * 'zone_id'<~Integer> - ID of the zone to update
|
|
15
|
+
# * 'name'<~String> - host name this DNS record is for
|
|
16
|
+
# * 'data'<~String> - data for the DNS record (ie for an A record, the IP address)
|
|
17
|
+
# * 'ttl'<~Integer> - time to live in seconds
|
|
18
|
+
# * 'active'<~String> - whether this record is active or not ('Y' or 'N')
|
|
19
|
+
# * 'aux'<~String> - extra data required by the record
|
|
20
|
+
def update_record(record_id, record_type, zone_id, name, data, options = {})
|
|
21
|
+
optional_tags= ''
|
|
22
|
+
options.each { |option, value|
|
|
23
|
+
case option
|
|
24
|
+
when :ttl
|
|
25
|
+
optional_tags+= "<ttl type='integer'>#{value}</ttl>"
|
|
26
|
+
when :active
|
|
27
|
+
optional_tags+= "<active>#{value}</active>"
|
|
28
|
+
when :aux
|
|
29
|
+
optional_tags+= "<aux>#{value}</aux>"
|
|
30
|
+
end
|
|
31
|
+
}
|
|
32
|
+
request(
|
|
33
|
+
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><record_type>#{record_type}</record_type><zone_id type="integer">#{zone_id}</zone_id><name>#{name}</name><data>#{data}</data>#{optional_tags}</record>},
|
|
34
|
+
:expects => 200,
|
|
35
|
+
:method => 'PUT',
|
|
36
|
+
:path => "records/#{record_id}.xml"
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/fog/terremark/vcloud.rb
CHANGED
|
@@ -15,7 +15,7 @@ module Fog
|
|
|
15
15
|
extend Fog::Terremark::Shared
|
|
16
16
|
|
|
17
17
|
def self.new(options={})
|
|
18
|
-
Fog::Logger.
|
|
18
|
+
Fog::Logger.deprecation("Fog::Terremark::Vcloud is deprecated, to be replaced with Vcloud 1.0 someday/maybe [light_black](#{caller.first})[/]")
|
|
19
19
|
|
|
20
20
|
unless @required
|
|
21
21
|
shared_requires
|
data/lib/fog/vsphere/compute.rb
CHANGED
|
@@ -29,36 +29,52 @@ module Fog
|
|
|
29
29
|
attr_reader :vsphere_server
|
|
30
30
|
attr_reader :vsphere_username
|
|
31
31
|
|
|
32
|
+
ATTR_TO_PROP = {
|
|
33
|
+
:id => 'config.instanceUuid',
|
|
34
|
+
:name => 'name',
|
|
35
|
+
:uuid => 'config.uuid',
|
|
36
|
+
:instance_uuid => 'config.instanceUuid',
|
|
37
|
+
:hostname => 'summary.guest.hostName',
|
|
38
|
+
:operatingsystem => 'summary.guest.guestFullName',
|
|
39
|
+
:ipaddress => 'guest.ipAddress',
|
|
40
|
+
:power_state => 'runtime.powerState',
|
|
41
|
+
:connection_state => 'runtime.connectionState',
|
|
42
|
+
:hypervisor => 'runtime.host',
|
|
43
|
+
:tools_state => 'guest.toolsStatus',
|
|
44
|
+
:tools_version => 'guest.toolsVersionStatus',
|
|
45
|
+
:is_a_template => 'config.template',
|
|
46
|
+
}
|
|
47
|
+
|
|
32
48
|
# Utility method to convert a VMware managed object into an attribute hash.
|
|
33
49
|
# This should only really be necessary for the real class.
|
|
34
50
|
# This method is expected to be called by the request methods
|
|
35
51
|
# in order to massage VMware Managed Object References into Attribute Hashes.
|
|
36
52
|
def convert_vm_mob_ref_to_attr_hash(vm_mob_ref)
|
|
37
53
|
return nil unless vm_mob_ref
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
|
|
55
|
+
props = vm_mob_ref.collect! *ATTR_TO_PROP.values.uniq
|
|
56
|
+
# NOTE: Object.tap is in 1.8.7 and later.
|
|
57
|
+
# Here we create the hash object that this method returns, but first we need
|
|
58
|
+
# to add a few more attributes that require additional calls to the vSphere
|
|
59
|
+
# API. The hypervisor name and mac_addresses attributes may not be available
|
|
60
|
+
# so we need catch any exceptions thrown during lookup and set them to nil.
|
|
61
|
+
#
|
|
62
|
+
# The use of the "tap" method here is a convience, it allows us to update the
|
|
63
|
+
# hash object without expliclty returning the hash at the end of the method.
|
|
64
|
+
Hash[ATTR_TO_PROP.map { |k,v| [k.to_s, props[v]] }].tap do |attrs|
|
|
65
|
+
attrs['id'] ||= vm_mob_ref._ref
|
|
66
|
+
attrs['mo_ref'] = vm_mob_ref._ref
|
|
67
|
+
# The name method "magically" appears after a VM is ready and
|
|
68
|
+
# finished cloning.
|
|
69
|
+
if attrs['hypervisor'].kind_of?(RbVmomi::VIM::HostSystem) then
|
|
70
|
+
# If it's not ready, set the hypervisor to nil
|
|
71
|
+
attrs['hypervisor'] = attrs['hypervisor'].name rescue nil
|
|
72
|
+
end
|
|
73
|
+
# This inline rescue catches any standard error. While a VM is
|
|
74
|
+
# cloning, a call to the macs method will throw and NoMethodError
|
|
75
|
+
attrs['mac_addresses'] = vm_mob_ref.macs rescue nil
|
|
76
|
+
attrs['path'] = get_folder_path(vm_mob_ref.parent)
|
|
44
77
|
end
|
|
45
|
-
{
|
|
46
|
-
'id' => is_ready ? vm_mob_ref.config.instanceUuid : vm_mob_ref._ref,
|
|
47
|
-
'mo_ref' => vm_mob_ref._ref,
|
|
48
|
-
'name' => vm_mob_ref.name,
|
|
49
|
-
'uuid' => is_ready ? vm_mob_ref.config.uuid : nil,
|
|
50
|
-
'instance_uuid' => is_ready ? vm_mob_ref.config.instanceUuid : nil,
|
|
51
|
-
'hostname' => vm_mob_ref.summary.guest.hostName,
|
|
52
|
-
'operatingsystem' => vm_mob_ref.summary.guest.guestFullName,
|
|
53
|
-
'ipaddress' => vm_mob_ref.summary.guest.ipAddress,
|
|
54
|
-
'power_state' => vm_mob_ref.runtime.powerState,
|
|
55
|
-
'connection_state' => vm_mob_ref.runtime.connectionState,
|
|
56
|
-
'hypervisor' => vm_mob_ref.runtime.host ? vm_mob_ref.runtime.host.name : nil,
|
|
57
|
-
'tools_state' => vm_mob_ref.summary.guest.toolsStatus,
|
|
58
|
-
'tools_version' => vm_mob_ref.summary.guest.toolsVersionStatus,
|
|
59
|
-
'mac_addresses' => is_ready ? vm_mob_ref.macs : nil,
|
|
60
|
-
'is_a_template' => is_ready ? vm_mob_ref.config.template : nil
|
|
61
|
-
}
|
|
62
78
|
end
|
|
63
79
|
|
|
64
80
|
end
|
|
@@ -68,6 +84,7 @@ module Fog
|
|
|
68
84
|
include Shared
|
|
69
85
|
|
|
70
86
|
def initialize(options={})
|
|
87
|
+
require 'rbvmomi'
|
|
71
88
|
@vsphere_username = options[:vsphere_username]
|
|
72
89
|
@vsphere_password = 'REDACTED'
|
|
73
90
|
@vsphere_server = options[:vsphere_server]
|
|
@@ -34,6 +34,7 @@ module Fog
|
|
|
34
34
|
{ 'virtual_machines' => virtual_machines }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
# NOTE: This is a private instance method required by the vm_clone
|
|
38
39
|
# request. It's very hard to get the Managed Object Reference
|
|
39
40
|
# of a Template because we can't search for it by instance_uuid
|
|
@@ -45,19 +46,50 @@ module Fog
|
|
|
45
46
|
datacenters = @connection.rootFolder.children.find_all do |child|
|
|
46
47
|
child.kind_of? RbVmomi::VIM::Datacenter
|
|
47
48
|
end
|
|
48
|
-
# Next,
|
|
49
|
+
# Next, search the "vmFolder" inventory of each data center:
|
|
49
50
|
datacenters.each do |dc|
|
|
50
|
-
dc.vmFolder.
|
|
51
|
-
|
|
51
|
+
inventory = dc.vmFolder.inventory( 'VirtualMachine' => :all )
|
|
52
|
+
virtual_machines << find_all_in_inventory(inventory, :type => RbVmomi::VIM::VirtualMachine, :property => 'name' )
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
virtual_machines.flatten
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def find_all_in_inventory(inventory, properties = { :type => RbVmomi::VIM::VirtualMachine, :property => nil } )
|
|
59
|
+
results = Array.new
|
|
60
|
+
|
|
61
|
+
inventory.each do |k,v|
|
|
62
|
+
|
|
63
|
+
# If we have a VMware folder we need to traverse the directory
|
|
64
|
+
# to ensure we pick VMs inside folders. So we do a bit of recursion
|
|
65
|
+
# here.
|
|
66
|
+
results << find_all_in_inventory(v) if k.is_a? RbVmomi::VIM::Folder
|
|
67
|
+
|
|
68
|
+
if v[0].is_a? properties[:type]
|
|
69
|
+
if properties[:property].nil?
|
|
70
|
+
results << v[0]
|
|
71
|
+
else
|
|
72
|
+
results << v[1][properties[:property]]
|
|
73
|
+
end
|
|
52
74
|
end
|
|
53
75
|
end
|
|
54
|
-
|
|
76
|
+
results.flatten
|
|
55
77
|
end
|
|
56
78
|
|
|
79
|
+
def get_folder_path(folder, root = nil)
|
|
80
|
+
if ( not folder.methods.include?('parent') ) or ( folder == root )
|
|
81
|
+
return
|
|
82
|
+
end
|
|
83
|
+
"#{get_folder_path(folder.parent)}/#{folder.name}"
|
|
84
|
+
end
|
|
57
85
|
end
|
|
58
86
|
|
|
59
87
|
class Mock
|
|
60
88
|
|
|
89
|
+
def get_folder_path(folder, root = nil)
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
61
93
|
def list_virtual_machines(options = {})
|
|
62
94
|
case options['instance_uuid']
|
|
63
95
|
when nil
|
data/lib/fog/zerigo/dns.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Fog
|
|
|
34
34
|
|
|
35
35
|
def self.data
|
|
36
36
|
@data ||= Hash.new do |hash, key|
|
|
37
|
-
hash[key] = {}
|
|
37
|
+
hash[key] = key == :zones ? [] : {}
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -48,13 +48,24 @@ module Fog
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def data
|
|
51
|
-
self.class.data
|
|
51
|
+
self.class.data
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def reset_data
|
|
55
|
-
self.class.
|
|
55
|
+
self.class.reset
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def find_by_zone_id(zone_id)
|
|
59
|
+
self.data[:zones].find { |z| z['id'] == zone_id }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def find_by_domain(domain)
|
|
63
|
+
self.data[:zones].find { |z| z['domain'] == domain }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def find_host(host_id)
|
|
67
|
+
self.data[:zones].collect { |z| z['hosts'].find { |h| h['id'] == host_id } }.compact.first
|
|
68
|
+
end
|
|
58
69
|
end
|
|
59
70
|
|
|
60
71
|
class Real
|