fog 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -3
- data/bin/fog +0 -5
- data/changelog.txt +88 -0
- data/fog.gemspec +3 -3
- data/lib/fog.rb +1 -2
- data/lib/fog/aws/elb.rb +2 -0
- data/lib/fog/aws/iam.rb +7 -0
- data/lib/fog/aws/parsers/iam/get_group.rb +55 -0
- data/lib/fog/aws/parsers/iam/get_user_policy.rb +27 -0
- data/lib/fog/aws/parsers/iam/update_group.rb +26 -0
- data/lib/fog/aws/parsers/iam/update_user.rb +27 -0
- data/lib/fog/aws/requests/iam/create_access_key.rb +1 -1
- data/lib/fog/aws/requests/iam/get_group.rb +44 -0
- data/lib/fog/aws/requests/iam/get_user_policy.rb +36 -0
- data/lib/fog/aws/requests/iam/update_group.rb +39 -0
- data/lib/fog/aws/requests/iam/update_signing_certificate.rb +32 -0
- data/lib/fog/aws/requests/iam/update_user.rb +39 -0
- data/lib/fog/aws/ses.rb +2 -0
- data/lib/fog/aws/simpledb.rb +2 -0
- data/lib/fog/bin.rb +3 -8
- data/lib/fog/bin/aws.rb +2 -14
- data/lib/fog/bin/bluebox.rb +6 -8
- data/lib/fog/bin/dnsimple.rb +30 -0
- data/lib/fog/bin/ecloud.rb +30 -0
- data/lib/fog/bin/go_grid.rb +1 -7
- data/lib/fog/bin/linode.rb +0 -6
- data/lib/fog/bin/local.rb +1 -7
- data/lib/fog/bin/new_servers.rb +1 -7
- data/lib/fog/bin/rackspace.rb +2 -14
- data/lib/fog/bin/slicehost.rb +2 -8
- data/lib/fog/bin/terremark.rb +0 -5
- data/lib/fog/bin/voxel.rb +30 -0
- data/lib/fog/cdn/aws.rb +2 -0
- data/lib/fog/compute.rb +6 -3
- data/lib/fog/compute/aws.rb +4 -18
- data/lib/fog/compute/ecloud.rb +1306 -0
- data/lib/fog/compute/models/aws/key_pair.rb +0 -2
- data/lib/fog/compute/models/aws/security_group.rb +4 -4
- data/lib/fog/compute/models/aws/server.rb +13 -3
- data/lib/fog/compute/models/aws/snapshot.rb +0 -2
- data/lib/fog/compute/models/aws/volume.rb +0 -2
- data/lib/fog/compute/models/bluebox/server.rb +23 -11
- data/lib/fog/compute/models/brightbox/server.rb +8 -0
- data/lib/fog/compute/models/ecloud/backup_internet_service.rb +56 -0
- data/lib/fog/compute/models/ecloud/backup_internet_services.rb +33 -0
- data/lib/fog/compute/models/ecloud/catalog.rb +28 -0
- data/lib/fog/compute/models/ecloud/catalog_item.rb +29 -0
- data/lib/fog/compute/models/ecloud/firewall_acl.rb +24 -0
- data/lib/fog/compute/models/ecloud/firewall_acls.rb +31 -0
- data/lib/fog/compute/models/ecloud/internet_service.rb +117 -0
- data/lib/fog/compute/models/ecloud/internet_services.rb +33 -0
- data/lib/fog/compute/models/ecloud/ip.rb +49 -0
- data/lib/fog/compute/models/ecloud/ips.rb +32 -0
- data/lib/fog/compute/models/ecloud/network.rb +72 -0
- data/lib/fog/compute/models/ecloud/networks.rb +33 -0
- data/lib/fog/compute/models/ecloud/node.rb +43 -0
- data/lib/fog/compute/models/ecloud/nodes.rb +31 -0
- data/lib/fog/compute/models/ecloud/public_ip.rb +22 -0
- data/lib/fog/compute/models/ecloud/public_ips.rb +36 -0
- data/lib/fog/compute/models/ecloud/server.rb +209 -0
- data/lib/fog/compute/models/ecloud/servers.rb +55 -0
- data/lib/fog/compute/models/ecloud/task.rb +21 -0
- data/lib/fog/compute/models/ecloud/tasks.rb +31 -0
- data/lib/fog/compute/models/ecloud/vdc.rb +81 -0
- data/lib/fog/compute/models/ecloud/vdcs.rb +40 -0
- data/lib/fog/compute/models/go_grid/server.rb +15 -1
- data/lib/fog/compute/models/rackspace/server.rb +16 -0
- data/lib/fog/compute/models/slicehost/server.rb +16 -0
- data/lib/fog/compute/models/voxel/image.rb +12 -0
- data/lib/fog/compute/models/voxel/images.rb +30 -0
- data/lib/fog/compute/models/voxel/server.rb +77 -0
- data/lib/fog/compute/models/voxel/servers.rb +31 -0
- data/lib/fog/compute/new_servers.rb +2 -2
- data/lib/fog/compute/parsers/voxel/basic.rb +31 -0
- data/lib/fog/compute/parsers/voxel/devices_list.rb +111 -0
- data/lib/fog/compute/parsers/voxel/images_list.rb +59 -0
- data/lib/fog/compute/parsers/voxel/voxcloud_create.rb +40 -0
- data/lib/fog/compute/parsers/voxel/voxcloud_delete.rb +31 -0
- data/lib/fog/compute/parsers/voxel/voxcloud_status.rb +42 -0
- data/lib/fog/compute/rackspace.rb +0 -16
- data/lib/fog/compute/requests/aws/associate_address.rb +2 -0
- data/lib/fog/compute/requests/aws/authorize_security_group_ingress.rb +28 -8
- data/lib/fog/compute/requests/aws/create_security_group.rb +2 -0
- data/lib/fog/compute/requests/aws/create_tags.rb +2 -0
- data/lib/fog/compute/requests/aws/delete_key_pair.rb +2 -0
- data/lib/fog/compute/requests/aws/delete_security_group.rb +2 -0
- data/lib/fog/compute/requests/aws/delete_snapshot.rb +2 -0
- data/lib/fog/compute/requests/aws/delete_tags.rb +2 -0
- data/lib/fog/compute/requests/aws/delete_volume.rb +2 -0
- data/lib/fog/compute/requests/aws/disassociate_address.rb +2 -0
- data/lib/fog/compute/requests/aws/modify_image_attributes.rb +2 -0
- data/lib/fog/compute/requests/aws/modify_snapshot_attribute.rb +2 -0
- data/lib/fog/compute/requests/aws/reboot_instances.rb +2 -0
- data/lib/fog/compute/requests/aws/release_address.rb +2 -0
- data/lib/fog/compute/requests/aws/revoke_security_group_ingress.rb +2 -0
- data/lib/fog/compute/requests/ecloud/add_backup_internet_service.rb +109 -0
- data/lib/fog/compute/requests/ecloud/add_internet_service.rb +149 -0
- data/lib/fog/compute/requests/ecloud/add_node.rb +62 -0
- data/lib/fog/compute/requests/ecloud/clone_vapp.rb +40 -0
- data/lib/fog/compute/requests/ecloud/configure_internet_service.rb +112 -0
- data/lib/fog/compute/requests/ecloud/configure_network.rb +44 -0
- data/lib/fog/compute/requests/ecloud/configure_network_ip.rb +66 -0
- data/lib/fog/compute/requests/ecloud/configure_node.rb +56 -0
- data/lib/fog/compute/requests/ecloud/configure_vapp.rb +144 -0
- data/lib/fog/compute/requests/ecloud/delete_internet_service.rb +22 -0
- data/lib/fog/compute/requests/ecloud/delete_node.rb +22 -0
- data/lib/fog/compute/requests/ecloud/delete_vapp.rb +29 -0
- data/lib/fog/compute/requests/ecloud/get_catalog.rb +44 -0
- data/lib/fog/compute/requests/ecloud/get_catalog_item.rb +47 -0
- data/lib/fog/compute/requests/ecloud/get_customization_options.rb +22 -0
- data/lib/fog/compute/requests/ecloud/get_firewall_acl.rb +11 -0
- data/lib/fog/compute/requests/ecloud/get_firewall_acls.rb +11 -0
- data/lib/fog/compute/requests/ecloud/get_internet_services.rb +82 -0
- data/lib/fog/compute/requests/ecloud/get_network.rb +44 -0
- data/lib/fog/compute/requests/ecloud/get_network_extensions.rb +33 -0
- data/lib/fog/compute/requests/ecloud/get_network_ip.rb +43 -0
- data/lib/fog/compute/requests/ecloud/get_network_ips.rb +35 -0
- data/lib/fog/compute/requests/ecloud/get_node.rb +40 -0
- data/lib/fog/compute/requests/ecloud/get_nodes.rb +41 -0
- data/lib/fog/compute/requests/ecloud/get_organization.rb +49 -0
- data/lib/fog/compute/requests/ecloud/get_public_ip.rb +34 -0
- data/lib/fog/compute/requests/ecloud/get_public_ips.rb +38 -0
- data/lib/fog/compute/requests/ecloud/get_task.rb +11 -0
- data/lib/fog/compute/requests/ecloud/get_task_list.rb +11 -0
- data/lib/fog/compute/requests/ecloud/get_vapp.rb +99 -0
- data/lib/fog/compute/requests/ecloud/get_vapp_template.rb +11 -0
- data/lib/fog/compute/requests/ecloud/get_vdc.rb +84 -0
- data/lib/fog/compute/requests/ecloud/get_versions.rb +37 -0
- data/lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb +142 -0
- data/lib/fog/compute/requests/ecloud/login.rb +48 -0
- data/lib/fog/compute/requests/ecloud/power_off.rb +23 -0
- data/lib/fog/compute/requests/ecloud/power_on.rb +23 -0
- data/lib/fog/compute/requests/ecloud/power_reset.rb +11 -0
- data/lib/fog/compute/requests/ecloud/power_shutdown.rb +11 -0
- data/lib/fog/compute/requests/voxel/devices_list.rb +24 -0
- data/lib/fog/compute/requests/voxel/devices_power.rb +22 -0
- data/lib/fog/compute/requests/voxel/images_list.rb +31 -0
- data/lib/fog/compute/requests/voxel/voxcloud_create.rb +22 -0
- data/lib/fog/compute/requests/voxel/voxcloud_delete.rb +20 -0
- data/lib/fog/compute/requests/voxel/voxcloud_status.rb +29 -0
- data/lib/fog/compute/slicehost.rb +2 -0
- data/lib/fog/compute/voxel.rb +112 -0
- data/lib/fog/core.rb +1 -0
- data/lib/fog/core/credentials.rb +6 -2
- data/lib/fog/core/parser.rb +2 -0
- data/lib/fog/core/scp.rb +67 -0
- data/lib/fog/dns.rb +6 -0
- data/lib/fog/dns/aws.rb +2 -0
- data/lib/fog/dns/bluebox.rb +110 -0
- data/lib/fog/dns/dnsimple.rb +95 -0
- data/lib/fog/dns/models/bluebox/record.rb +52 -0
- data/lib/fog/dns/models/bluebox/records.rb +36 -0
- data/lib/fog/dns/models/bluebox/zone.rb +63 -0
- data/lib/fog/dns/models/bluebox/zones.rb +28 -0
- data/lib/fog/dns/models/dnsimple/record.rb +54 -0
- data/lib/fog/dns/models/dnsimple/records.rb +38 -0
- data/lib/fog/dns/models/dnsimple/zone.rb +50 -0
- data/lib/fog/dns/models/dnsimple/zones.rb +28 -0
- data/lib/fog/dns/parsers/bluebox/create_record.rb +26 -0
- data/lib/fog/dns/parsers/bluebox/create_zone.rb +26 -0
- data/lib/fog/dns/parsers/bluebox/get_record.rb +21 -0
- data/lib/fog/dns/parsers/bluebox/get_records.rb +27 -0
- data/lib/fog/{compute/parsers/terremark_ecloud/get_ip_address.rb → dns/parsers/bluebox/get_zone.rb} +6 -6
- data/lib/fog/dns/parsers/bluebox/get_zones.rb +30 -0
- data/lib/fog/dns/requests/bluebox/create_record.rb +48 -0
- data/lib/fog/dns/requests/bluebox/create_zone.rb +52 -0
- data/lib/fog/dns/requests/bluebox/delete_record.rb +31 -0
- data/lib/fog/dns/requests/bluebox/delete_zone.rb +31 -0
- data/lib/fog/dns/requests/bluebox/get_record.rb +40 -0
- data/lib/fog/dns/requests/bluebox/get_records.rb +41 -0
- data/lib/fog/dns/requests/bluebox/get_zone.rb +44 -0
- data/lib/fog/dns/requests/bluebox/get_zones.rb +43 -0
- data/lib/fog/dns/requests/bluebox/update_record.rb +34 -0
- data/lib/fog/dns/requests/bluebox/update_zone.rb +30 -0
- data/lib/fog/dns/requests/dnsimple/create_domain.rb +27 -0
- data/lib/fog/dns/requests/dnsimple/create_record.rb +48 -0
- data/lib/fog/dns/requests/dnsimple/delete_domain.rb +26 -0
- data/lib/fog/dns/requests/dnsimple/delete_record.rb +21 -0
- data/lib/fog/dns/requests/dnsimple/get_domain.rb +37 -0
- data/lib/fog/dns/requests/dnsimple/list_domains.rb +35 -0
- data/lib/fog/dns/requests/dnsimple/list_records.rb +32 -0
- data/lib/fog/dns/requests/dnsimple/update_record.rb +42 -0
- data/lib/fog/dns/slicehost.rb +2 -0
- data/lib/fog/dns/zerigo.rb +2 -0
- data/lib/fog/providers.rb +3 -1
- data/lib/fog/providers/aws.rb +0 -4
- data/lib/fog/providers/bluebox.rb +1 -8
- data/lib/fog/providers/dnsimple.rb +11 -0
- data/lib/fog/providers/ecloud.rb +11 -0
- data/lib/fog/providers/go_grid.rb +0 -8
- data/lib/fog/providers/google.rb +0 -3
- data/lib/fog/providers/linode.rb +0 -8
- data/lib/fog/providers/local.rb +0 -8
- data/lib/fog/providers/new_servers.rb +0 -11
- data/lib/fog/providers/rackspace.rb +0 -2
- data/lib/fog/providers/slicehost.rb +0 -11
- data/lib/fog/providers/voxel.rb +16 -0
- data/lib/fog/providers/zerigo.rb +0 -3
- data/lib/fog/storage/aws.rb +7 -19
- data/lib/fog/storage/google.rb +2 -2
- data/lib/fog/storage/models/aws/directory.rb +0 -3
- data/lib/fog/storage/models/aws/file.rb +0 -3
- data/lib/fog/storage/models/google/directory.rb +0 -3
- data/lib/fog/storage/models/google/file.rb +0 -3
- data/lib/fog/storage/models/local/directory.rb +0 -3
- data/lib/fog/storage/models/local/file.rb +29 -1
- data/lib/fog/storage/models/local/files.rb +8 -5
- data/lib/fog/storage/models/rackspace/directory.rb +1 -3
- data/lib/fog/storage/parsers/aws/get_bucket_website.rb +26 -0
- data/lib/fog/storage/rackspace.rb +0 -16
- data/lib/fog/storage/requests/aws/delete_bucket_website.rb +32 -0
- data/lib/fog/storage/requests/aws/get_bucket_website.rb +42 -0
- data/lib/fog/storage/requests/aws/put_bucket_website.rb +49 -0
- data/lib/fog/terremark.rb +0 -5
- data/spec/ecloud/bin_spec.rb +22 -0
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/backup_internet_service_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/backup_internet_services_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/internet_service_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/internet_services_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/ip_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/ips_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/network_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/networks_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/node_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/nodes_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/public_ip_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/public_ips_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/server_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/vdc_spec.rb +5 -5
- data/spec/{vcloud/terremark/ecloud → ecloud}/models/vdcs_spec.rb +4 -4
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/add_backup_internet_service_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/add_internet_service_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/add_node_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/configure_internet_service_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/configure_network_ip_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/configure_node_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/configure_vapp_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/delete_internet_service_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/delete_node_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/delete_vapp_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_catalog_item_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_catalog_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_customization_options_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_internet_services_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_network_ip_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_network_ips_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_network_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_node_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_nodes_spec.rb +2 -2
- data/spec/{vcloud → ecloud}/requests/get_organization_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_public_ip_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_public_ips_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_vapp_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/get_vdc_spec.rb +2 -2
- data/spec/ecloud/requests/get_versions_spec.rb +57 -0
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/instantiate_vapp_template_spec.rb +3 -3
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/login_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/power_off_spec.rb +2 -2
- data/spec/{vcloud/terremark/ecloud → ecloud}/requests/power_on_spec.rb +2 -2
- data/spec/{vcloud → ecloud}/spec_helper.rb +14 -29
- data/spec/{vcloud → ecloud}/vcloud_spec.rb +4 -4
- data/spec/spec_helper.rb +0 -1
- data/tests/compute/helper.rb +12 -1
- data/tests/compute/models/flavors_tests.rb +2 -0
- data/tests/compute/models/server_tests.rb +28 -1
- data/tests/compute/requests/voxel/image_tests.rb +46 -0
- data/tests/compute/requests/voxel/server_tests.rb +123 -0
- data/tests/dns/helper.rb +10 -1
- data/tests/dns/models/record_tests.rb +0 -1
- data/tests/dns/requests/bluebox/dns_tests.rb +271 -0
- data/tests/dns/requests/dnsimple/dns_tests.rb +130 -0
- data/tests/helper.rb +1 -1
- data/tests/helpers/mock_helper.rb +2 -0
- data/tests/storage/models/directory_test.rb +2 -1
- metadata +244 -224
- data/lib/fog/bin/terremark_ecloud.rb +0 -28
- data/lib/fog/bin/vcloud.rb +0 -59
- data/lib/fog/compute/parsers/terremark_ecloud/get_catalog.rb +0 -36
- data/lib/fog/compute/parsers/terremark_ecloud/get_catalog_item.rb +0 -43
- data/lib/fog/compute/parsers/terremark_ecloud/get_ip_addresses.rb +0 -27
- data/lib/fog/compute/parsers/terremark_ecloud/get_network.rb +0 -59
- data/lib/fog/compute/parsers/terremark_ecloud/get_organization.rb +0 -35
- data/lib/fog/compute/parsers/terremark_ecloud/get_task.rb +0 -42
- data/lib/fog/compute/parsers/terremark_ecloud/get_task_list.rb +0 -51
- data/lib/fog/compute/parsers/terremark_ecloud/get_vdc.rb +0 -110
- data/lib/fog/compute/parsers/terremark_ecloud/get_versions.rb +0 -28
- data/lib/fog/compute/parsers/terremark_ecloud/login.rb +0 -27
- data/lib/fog/compute/requests/terremark_ecloud/get_catalog.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_catalog_item.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_ip_address.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_ip_addresses.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_network.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_organization.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_task.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_task_list.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_vdc.rb +0 -19
- data/lib/fog/compute/requests/terremark_ecloud/get_versions.rb +0 -26
- data/lib/fog/compute/requests/terremark_ecloud/login.rb +0 -29
- data/lib/fog/compute/terremark_ecloud.rb +0 -93
- data/lib/fog/providers/terremark_ecloud.rb +0 -17
- data/lib/fog/terremark/ecloud.rb +0 -73
- data/lib/fog/vcloud.rb +0 -337
- data/lib/fog/vcloud/collection.rb +0 -30
- data/lib/fog/vcloud/generators.rb +0 -33
- data/lib/fog/vcloud/mock_data_classes.rb +0 -767
- data/lib/fog/vcloud/model.rb +0 -22
- data/lib/fog/vcloud/models/vdc.rb +0 -26
- data/lib/fog/vcloud/models/vdcs.rb +0 -35
- data/lib/fog/vcloud/requests/get_network.rb +0 -47
- data/lib/fog/vcloud/requests/get_organization.rb +0 -47
- data/lib/fog/vcloud/requests/get_vdc.rb +0 -82
- data/lib/fog/vcloud/requests/get_versions.rb +0 -34
- data/lib/fog/vcloud/requests/login.rb +0 -46
- data/lib/fog/vcloud/terremark/ecloud.rb +0 -187
- data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +0 -60
- data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +0 -36
- data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +0 -31
- data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +0 -31
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acl.rb +0 -28
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +0 -34
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +0 -121
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +0 -36
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +0 -51
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +0 -35
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +0 -77
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +0 -36
- data/lib/fog/vcloud/terremark/ecloud/models/node.rb +0 -47
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +0 -33
- data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +0 -25
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +0 -39
- data/lib/fog/vcloud/terremark/ecloud/models/server.rb +0 -211
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +0 -57
- data/lib/fog/vcloud/terremark/ecloud/models/task.rb +0 -23
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +0 -33
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +0 -83
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +0 -42
- data/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +0 -111
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +0 -152
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +0 -64
- data/lib/fog/vcloud/terremark/ecloud/requests/clone_vapp.rb +0 -42
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +0 -115
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +0 -46
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +0 -68
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +0 -58
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +0 -147
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +0 -25
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -24
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +0 -32
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +0 -46
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +0 -49
- data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +0 -24
- data/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acl.rb +0 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acls.rb +0 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +0 -84
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +0 -47
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +0 -35
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +0 -45
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +0 -37
- data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +0 -42
- data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +0 -43
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +0 -36
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +0 -41
- data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +0 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +0 -14
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +0 -101
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp_template.rb +0 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +0 -87
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +0 -144
- data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +0 -25
- data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +0 -25
- data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +0 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +0 -13
- data/lib/fog/vcloud/terremark/vcloud.rb +0 -39
- data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +0 -57
- data/spec/vcloud/bin_spec.rb +0 -28
- data/spec/vcloud/models/vdc_spec.rb +0 -51
- data/spec/vcloud/models/vdcs_spec.rb +0 -1
- data/spec/vcloud/requests/get_network_spec.rb +0 -44
- data/spec/vcloud/requests/get_vdc_spec.rb +0 -62
- data/spec/vcloud/requests/get_versions_spec.rb +0 -54
- data/spec/vcloud/requests/login_spec.rb +0 -24
- data/tests/compute/requests/terremark_ecloud/catalog_tests.rb +0 -47
- data/tests/compute/requests/terremark_ecloud/helper.rb +0 -45
- data/tests/compute/requests/terremark_ecloud/network_tests.rb +0 -30
- data/tests/compute/requests/terremark_ecloud/organization_tests.rb +0 -28
- data/tests/compute/requests/terremark_ecloud/task_tests.rb +0 -39
- data/tests/compute/requests/terremark_ecloud/vdc_tests.rb +0 -60
data/lib/fog/cdn/aws.rb
CHANGED
data/lib/fog/compute.rb
CHANGED
@@ -13,6 +13,9 @@ module Fog
|
|
13
13
|
when 'Brightbox'
|
14
14
|
require 'fog/compute/brightbox'
|
15
15
|
Fog::Brightbox::Compute.new(attributes)
|
16
|
+
when 'Ecloud'
|
17
|
+
require 'fog/compute/ecloud'
|
18
|
+
Fog::Ecloud::Compute.new(attributes)
|
16
19
|
when 'GoGrid'
|
17
20
|
require 'fog/compute/go_grid'
|
18
21
|
Fog::GoGrid::Compute.new(attributes)
|
@@ -25,12 +28,12 @@ module Fog
|
|
25
28
|
when 'Rackspace'
|
26
29
|
require 'fog/compute/rackspace'
|
27
30
|
Fog::Rackspace::Compute.new(attributes)
|
31
|
+
when 'Voxel'
|
32
|
+
require 'fog/compute/voxel'
|
33
|
+
Fog::Voxel::Compute.new(attributes)
|
28
34
|
when 'Slicehost'
|
29
35
|
require 'fog/compute/slicehost'
|
30
36
|
Fog::Slicehost::Compute.new(attributes)
|
31
|
-
when 'TerremarkEcloud'
|
32
|
-
require 'fog/compute/terremark_ecloud'
|
33
|
-
Fog::TerremarkEcloud::Compute.new(attributes)
|
34
37
|
else
|
35
38
|
raise ArgumentError.new("#{provider} is not a recognized compute provider")
|
36
39
|
end
|
data/lib/fog/compute/aws.rb
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
module Fog
|
2
|
-
module AWS
|
3
|
-
class EC2
|
4
|
-
|
5
|
-
def self.new(attributes = {})
|
6
|
-
location = caller.first
|
7
|
-
warning = "[yellow][WARN] Fog::AWS::EC2#new is deprecated, use Fog::AWS::Compute#new instead[/]"
|
8
|
-
warning << " [light_black](" << location << ")[/] "
|
9
|
-
Formatador.display_line(warning)
|
10
|
-
Fog::AWS::Compute.new(attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
1
|
module Fog
|
18
2
|
module AWS
|
19
3
|
class Compute < Fog::Service
|
@@ -42,8 +26,6 @@ module Fog
|
|
42
26
|
model :volume
|
43
27
|
collection :volumes
|
44
28
|
|
45
|
-
require 'fog/compute/parsers/aws/basic'
|
46
|
-
|
47
29
|
request_path 'fog/compute/requests/aws'
|
48
30
|
request :allocate_address
|
49
31
|
request :associate_address
|
@@ -154,6 +136,8 @@ module Fog
|
|
154
136
|
Formatador.display_line(warning)
|
155
137
|
end
|
156
138
|
|
139
|
+
require 'fog/compute/parsers/aws/basic'
|
140
|
+
|
157
141
|
@aws_access_key_id = options[:aws_access_key_id]
|
158
142
|
@region = options[:region] || 'us-east-1'
|
159
143
|
@data = self.class.data[@region][@aws_access_key_id]
|
@@ -190,6 +174,8 @@ module Fog
|
|
190
174
|
Formatador.display_line(warning)
|
191
175
|
end
|
192
176
|
|
177
|
+
require 'fog/core/parser'
|
178
|
+
|
193
179
|
@aws_access_key_id = options[:aws_access_key_id]
|
194
180
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
195
181
|
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
@@ -0,0 +1,1306 @@
|
|
1
|
+
require 'fog/core'
|
2
|
+
require 'ipaddr'
|
3
|
+
|
4
|
+
class IPAddr
|
5
|
+
def mask
|
6
|
+
_to_string(@mask_addr)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Fog
|
11
|
+
module Ecloud
|
12
|
+
class Collection < Fog::Collection
|
13
|
+
|
14
|
+
def load(objects)
|
15
|
+
objects = [ objects ] if objects.is_a?(Hash)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_href!(opts = {})
|
20
|
+
unless href
|
21
|
+
if opts.is_a?(String)
|
22
|
+
t = Hash.new
|
23
|
+
t[:parent] = opts
|
24
|
+
opts = t
|
25
|
+
end
|
26
|
+
msg = ":href missing, call with a :href pointing to #{if opts[:message]
|
27
|
+
opts[:message]
|
28
|
+
elsif opts[:parent]
|
29
|
+
"the #{opts[:parent]} whos #{self.class.to_s.split('::').last.downcase} you want to enumerate"
|
30
|
+
else
|
31
|
+
"the resource"
|
32
|
+
end}"
|
33
|
+
raise Fog::Errors::Error.new(msg)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module Fog
|
42
|
+
module Ecloud
|
43
|
+
module MockDataClasses
|
44
|
+
class Base < Hash
|
45
|
+
def self.base_url=(url)
|
46
|
+
@base_url = url
|
47
|
+
end
|
48
|
+
|
49
|
+
self.base_url = "http://vcloud.example.com"
|
50
|
+
|
51
|
+
def self.base_url
|
52
|
+
@base_url
|
53
|
+
end
|
54
|
+
|
55
|
+
def first
|
56
|
+
raise "Don't do this"
|
57
|
+
end
|
58
|
+
|
59
|
+
def last
|
60
|
+
raise "Don't do this"
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(data = {}, parent = nil)
|
64
|
+
@parent = parent
|
65
|
+
|
66
|
+
replace(data)
|
67
|
+
end
|
68
|
+
|
69
|
+
def _parent
|
70
|
+
@parent
|
71
|
+
end
|
72
|
+
|
73
|
+
def base_url
|
74
|
+
Base.base_url
|
75
|
+
end
|
76
|
+
|
77
|
+
def href
|
78
|
+
[base_url, self.class.name.split("::").last, object_id].join("/")
|
79
|
+
end
|
80
|
+
|
81
|
+
def inspect
|
82
|
+
"<#{self.class.name} #{object_id} data=#{super}>"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class MockData < Base
|
87
|
+
def versions
|
88
|
+
@versions ||= []
|
89
|
+
end
|
90
|
+
|
91
|
+
def organizations
|
92
|
+
@organizations ||= []
|
93
|
+
end
|
94
|
+
|
95
|
+
def organization_from_href(href)
|
96
|
+
find_href_in(href, organizations)
|
97
|
+
end
|
98
|
+
|
99
|
+
def all_vdcs
|
100
|
+
organizations.map(&:vdcs).flatten
|
101
|
+
end
|
102
|
+
|
103
|
+
def vdc_from_href(href)
|
104
|
+
find_href_in(href, all_vdcs)
|
105
|
+
end
|
106
|
+
|
107
|
+
def all_catalogs
|
108
|
+
all_vdcs.map(&:catalog).flatten
|
109
|
+
end
|
110
|
+
|
111
|
+
def catalog_from_href(href)
|
112
|
+
find_href_in(href, all_catalogs)
|
113
|
+
end
|
114
|
+
|
115
|
+
def all_catalog_items
|
116
|
+
all_catalogs.map(&:items).flatten
|
117
|
+
end
|
118
|
+
|
119
|
+
def catalog_item_from_href(href)
|
120
|
+
find_href_in(href, all_catalog_items)
|
121
|
+
end
|
122
|
+
|
123
|
+
def all_virtual_machines
|
124
|
+
all_vdcs.map(&:virtual_machines).flatten
|
125
|
+
end
|
126
|
+
|
127
|
+
def virtual_machine_from_href(href)
|
128
|
+
find_href_prefixed_in(href, all_virtual_machines)
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
def all_networks
|
133
|
+
all_vdcs.map(&:networks).flatten
|
134
|
+
end
|
135
|
+
|
136
|
+
def network_from_href(href)
|
137
|
+
find_href_in(href, all_networks)
|
138
|
+
end
|
139
|
+
|
140
|
+
def all_network_extensions
|
141
|
+
all_networks.map(&:extensions).flatten
|
142
|
+
end
|
143
|
+
|
144
|
+
def network_extension_from_href(href)
|
145
|
+
find_href_in(href, all_network_extensions)
|
146
|
+
end
|
147
|
+
|
148
|
+
def all_vdc_internet_service_collections
|
149
|
+
all_vdcs.map(&:internet_service_collection).flatten
|
150
|
+
end
|
151
|
+
|
152
|
+
def vdc_internet_service_collection_from_href(href)
|
153
|
+
find_href_in(href, all_vdc_internet_service_collections)
|
154
|
+
end
|
155
|
+
|
156
|
+
def all_backup_internet_services
|
157
|
+
all_vdc_internet_service_collections.map(&:backup_internet_services).flatten
|
158
|
+
end
|
159
|
+
|
160
|
+
def backup_internet_service_from_href(href)
|
161
|
+
find_href_in(href, all_backup_internet_services)
|
162
|
+
end
|
163
|
+
|
164
|
+
def all_public_ip_collections
|
165
|
+
all_vdcs.map {|v| v.public_ip_collection }.flatten
|
166
|
+
end
|
167
|
+
|
168
|
+
def public_ip_collection_from_href(href)
|
169
|
+
find_href_in(href, all_public_ip_collections)
|
170
|
+
end
|
171
|
+
|
172
|
+
def all_public_ips
|
173
|
+
all_public_ip_collections.map(&:items).flatten
|
174
|
+
end
|
175
|
+
|
176
|
+
def public_ip_from_href(href)
|
177
|
+
find_href_in(href, all_public_ips)
|
178
|
+
end
|
179
|
+
|
180
|
+
def all_public_ip_internet_service_collections
|
181
|
+
all_public_ips.map(&:internet_service_collection).flatten
|
182
|
+
end
|
183
|
+
|
184
|
+
def public_ip_internet_service_collection_from_href(href)
|
185
|
+
find_href_in(href, all_public_ip_internet_service_collections)
|
186
|
+
end
|
187
|
+
|
188
|
+
def all_public_ip_internet_services
|
189
|
+
all_public_ip_internet_service_collections.map(&:items).flatten
|
190
|
+
end
|
191
|
+
|
192
|
+
def public_ip_internet_service_from_href(href)
|
193
|
+
find_href_in(href, all_public_ip_internet_services)
|
194
|
+
end
|
195
|
+
|
196
|
+
def all_public_ip_internet_service_node_collections
|
197
|
+
all_public_ip_internet_services.map(&:node_collection).flatten
|
198
|
+
end
|
199
|
+
|
200
|
+
def public_ip_internet_service_node_collection_from_href(href)
|
201
|
+
find_href_in(href, all_public_ip_internet_service_node_collections)
|
202
|
+
end
|
203
|
+
|
204
|
+
def all_public_ip_internet_service_nodes
|
205
|
+
all_public_ip_internet_service_node_collections.map(&:items).flatten
|
206
|
+
end
|
207
|
+
|
208
|
+
def public_ip_internet_service_node_from_href(href)
|
209
|
+
find_href_in(href, all_public_ip_internet_service_nodes)
|
210
|
+
end
|
211
|
+
|
212
|
+
def all_network_ip_collections
|
213
|
+
all_networks.map(&:ip_collection)
|
214
|
+
end
|
215
|
+
|
216
|
+
def network_ip_collection_from_href(href)
|
217
|
+
find_href_in(href, all_network_ip_collections)
|
218
|
+
end
|
219
|
+
|
220
|
+
def all_network_ips
|
221
|
+
all_network_ip_collections.map {|c| c.items.values }.flatten
|
222
|
+
end
|
223
|
+
|
224
|
+
def network_ip_from_href(href)
|
225
|
+
find_href_in(href, all_network_ips)
|
226
|
+
end
|
227
|
+
|
228
|
+
private
|
229
|
+
|
230
|
+
def find_href_in(href, objects)
|
231
|
+
objects.detect {|o| o.href == href }
|
232
|
+
end
|
233
|
+
|
234
|
+
def find_href_prefixed_in(href, objects)
|
235
|
+
objects.detect {|o| href =~ %r{^#{o.href}($|/)} }
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
class MockVersion < Base
|
240
|
+
def version
|
241
|
+
self[:version]
|
242
|
+
end
|
243
|
+
|
244
|
+
def supported
|
245
|
+
!!self[:supported]
|
246
|
+
end
|
247
|
+
|
248
|
+
def login_url
|
249
|
+
href
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
class MockOrganization < Base
|
254
|
+
def name
|
255
|
+
self[:name]
|
256
|
+
end
|
257
|
+
|
258
|
+
def vdcs
|
259
|
+
@vdcs ||= []
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
class MockVdc < Base
|
264
|
+
def name
|
265
|
+
self[:name]
|
266
|
+
end
|
267
|
+
|
268
|
+
def storage_allocated
|
269
|
+
self[:storage_allocated] || 200
|
270
|
+
end
|
271
|
+
|
272
|
+
def storage_used
|
273
|
+
self[:storage_used] || 105
|
274
|
+
end
|
275
|
+
|
276
|
+
def cpu_allocated
|
277
|
+
self[:cpu_allocated] || 10000
|
278
|
+
end
|
279
|
+
|
280
|
+
def memory_allocated
|
281
|
+
self[:memory_allocated] || 20480
|
282
|
+
end
|
283
|
+
|
284
|
+
def catalog
|
285
|
+
@catalog ||= MockCatalog.new({}, self)
|
286
|
+
end
|
287
|
+
|
288
|
+
def networks
|
289
|
+
@networks ||= []
|
290
|
+
end
|
291
|
+
|
292
|
+
def virtual_machines
|
293
|
+
@virtual_machines ||= []
|
294
|
+
end
|
295
|
+
|
296
|
+
def task_list
|
297
|
+
@task_list ||= MockTaskList.new({}, self)
|
298
|
+
end
|
299
|
+
|
300
|
+
# for TM eCloud, should probably be subclassed
|
301
|
+
def public_ip_collection
|
302
|
+
@public_ip_collection ||= MockPublicIps.new({}, self)
|
303
|
+
end
|
304
|
+
|
305
|
+
def internet_service_collection
|
306
|
+
@internet_service_collection ||= MockVdcInternetServices.new({}, self)
|
307
|
+
end
|
308
|
+
|
309
|
+
def firewall_acls
|
310
|
+
@firewall_acls ||= MockFirewallAcls.new({}, self)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
class MockTaskList < Base
|
315
|
+
def name
|
316
|
+
self[:name] || "Tasks List"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
class MockCatalog < Base
|
321
|
+
def name
|
322
|
+
self[:name] || "Catalog"
|
323
|
+
end
|
324
|
+
|
325
|
+
def items
|
326
|
+
@items ||= []
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
class MockCatalogItem < Base
|
331
|
+
def name
|
332
|
+
self[:name]
|
333
|
+
end
|
334
|
+
|
335
|
+
def disks
|
336
|
+
@disks ||= MockVirtualMachineDisks.new(self)
|
337
|
+
end
|
338
|
+
|
339
|
+
def customization
|
340
|
+
@customization ||= MockCatalogItemCustomization.new({}, self)
|
341
|
+
end
|
342
|
+
|
343
|
+
def vapp_template
|
344
|
+
@vapp_template ||= MockCatalogItemVappTemplate.new({ :name => name }, self)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
class MockCatalogItemCustomization < Base
|
349
|
+
def name
|
350
|
+
self[:name] || "Customization Options"
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
class MockCatalogItemVappTemplate < Base
|
355
|
+
def name
|
356
|
+
self[:name]
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class MockNetwork < Base
|
361
|
+
def name
|
362
|
+
self[:name] || subnet
|
363
|
+
end
|
364
|
+
|
365
|
+
def subnet
|
366
|
+
self[:subnet]
|
367
|
+
end
|
368
|
+
|
369
|
+
def gateway
|
370
|
+
self[:gateway] || subnet_ips[1]
|
371
|
+
end
|
372
|
+
|
373
|
+
def netmask
|
374
|
+
self[:netmask] || subnet_ipaddr.mask
|
375
|
+
end
|
376
|
+
|
377
|
+
def dns
|
378
|
+
"8.8.8.8"
|
379
|
+
end
|
380
|
+
|
381
|
+
def features
|
382
|
+
[
|
383
|
+
{ :type => :FenceMode, :value => "isolated" }
|
384
|
+
]
|
385
|
+
end
|
386
|
+
|
387
|
+
def ip_collection
|
388
|
+
@ip_collection ||= MockNetworkIps.new({}, self)
|
389
|
+
end
|
390
|
+
|
391
|
+
def extensions
|
392
|
+
@extensions ||= MockNetworkExtensions.new({}, self)
|
393
|
+
end
|
394
|
+
|
395
|
+
def random_ip
|
396
|
+
usable_subnet_ips[rand(usable_subnet_ips.length)]
|
397
|
+
end
|
398
|
+
|
399
|
+
# for TM eCloud. should probably be a subclass
|
400
|
+
def rnat
|
401
|
+
self[:rnat]
|
402
|
+
end
|
403
|
+
|
404
|
+
def usable_subnet_ips
|
405
|
+
subnet_ips[3..-2]
|
406
|
+
end
|
407
|
+
|
408
|
+
def address
|
409
|
+
subnet_ips.first
|
410
|
+
end
|
411
|
+
|
412
|
+
def broadcast
|
413
|
+
subnet_ips.last
|
414
|
+
end
|
415
|
+
|
416
|
+
private
|
417
|
+
|
418
|
+
def subnet_ipaddr
|
419
|
+
@ipaddr ||= IPAddr.new(subnet)
|
420
|
+
end
|
421
|
+
|
422
|
+
def subnet_ips
|
423
|
+
subnet_ipaddr.to_range.to_a.map(&:to_s)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
class MockNetworkIps < Base
|
428
|
+
def items
|
429
|
+
@items ||= _parent.usable_subnet_ips.inject({}) do |out, subnet_ip|
|
430
|
+
out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self))
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
def ordered_ips
|
435
|
+
items.values.sort_by {|i| i.ip.split(".").map(&:to_i) }
|
436
|
+
end
|
437
|
+
|
438
|
+
def name
|
439
|
+
"IP Addresses"
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
class MockNetworkIp < Base
|
444
|
+
def name
|
445
|
+
self[:name] || ip
|
446
|
+
end
|
447
|
+
|
448
|
+
def ip
|
449
|
+
self[:ip]
|
450
|
+
end
|
451
|
+
|
452
|
+
def used_by
|
453
|
+
self[:used_by] || _parent._parent._parent.virtual_machines.detect {|v| v.ip == ip }
|
454
|
+
end
|
455
|
+
|
456
|
+
def status
|
457
|
+
if used_by
|
458
|
+
"Assigned"
|
459
|
+
else
|
460
|
+
"Available"
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
def rnat
|
465
|
+
self[:rnat] || _parent._parent.rnat
|
466
|
+
end
|
467
|
+
|
468
|
+
def rnat_set?
|
469
|
+
!!self[:rnat]
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
class MockNetworkExtensions < Base
|
474
|
+
def name
|
475
|
+
_parent.name
|
476
|
+
end
|
477
|
+
|
478
|
+
def gateway
|
479
|
+
_parent.gateway
|
480
|
+
end
|
481
|
+
|
482
|
+
def broadcast
|
483
|
+
_parent.broadcast
|
484
|
+
end
|
485
|
+
|
486
|
+
def address
|
487
|
+
_parent.address
|
488
|
+
end
|
489
|
+
|
490
|
+
def rnat
|
491
|
+
_parent.rnat
|
492
|
+
end
|
493
|
+
|
494
|
+
def type
|
495
|
+
self[:type] || "DMZ"
|
496
|
+
end
|
497
|
+
|
498
|
+
def vlan
|
499
|
+
object_id.to_s
|
500
|
+
end
|
501
|
+
|
502
|
+
def friendly_name
|
503
|
+
"#{name} (#{type}_#{object_id})"
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
class MockVirtualMachine < Base
|
508
|
+
def name
|
509
|
+
self[:name]
|
510
|
+
end
|
511
|
+
|
512
|
+
def ip
|
513
|
+
self[:ip]
|
514
|
+
end
|
515
|
+
|
516
|
+
def cpus
|
517
|
+
self[:cpus] || 1
|
518
|
+
end
|
519
|
+
|
520
|
+
def memory
|
521
|
+
self[:memory] || 1024
|
522
|
+
end
|
523
|
+
|
524
|
+
def disks
|
525
|
+
@disks ||= MockVirtualMachineDisks.new(self)
|
526
|
+
end
|
527
|
+
|
528
|
+
def status
|
529
|
+
self[:status] || 2
|
530
|
+
end
|
531
|
+
|
532
|
+
def power_off!
|
533
|
+
self[:status] = 2
|
534
|
+
end
|
535
|
+
|
536
|
+
def power_on!
|
537
|
+
self[:status] = 4
|
538
|
+
end
|
539
|
+
|
540
|
+
def size
|
541
|
+
disks.inject(0) {|s, d| s + d.vcloud_size }
|
542
|
+
end
|
543
|
+
|
544
|
+
def network_ip
|
545
|
+
if network = _parent.networks.detect {|n| n.ip_collection.items[ip] }
|
546
|
+
network.ip_collection.items[ip]
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
# from fog ecloud server's _compose_vapp_data
|
551
|
+
def to_configure_vapp_hash
|
552
|
+
{
|
553
|
+
:name => name,
|
554
|
+
:cpus => cpus,
|
555
|
+
:memory => memory,
|
556
|
+
:disks => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } }
|
557
|
+
}
|
558
|
+
end
|
559
|
+
|
560
|
+
def href(purpose = :base)
|
561
|
+
case purpose
|
562
|
+
when :base
|
563
|
+
super()
|
564
|
+
when :power_on
|
565
|
+
super() + "/power/action/powerOn"
|
566
|
+
when :power_off
|
567
|
+
super() + "/power/action/powerOff"
|
568
|
+
end
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
class MockVirtualMachineDisks < Array
|
573
|
+
def initialize(parent = nil)
|
574
|
+
@parent = parent
|
575
|
+
end
|
576
|
+
|
577
|
+
def _parent
|
578
|
+
@parent
|
579
|
+
end
|
580
|
+
|
581
|
+
def <<(disk)
|
582
|
+
next_address = 0
|
583
|
+
disk_with_max_address = max {|a, b| a[:address] <=> b[:address] }
|
584
|
+
disk_with_max_address && next_address = disk_with_max_address.address + 1
|
585
|
+
disk[:address] ||= next_address
|
586
|
+
|
587
|
+
super(disk)
|
588
|
+
|
589
|
+
if (addresses = map {|d| d.address }).uniq.size != size
|
590
|
+
raise "Duplicate disk address in: #{addresses.inspect} (#{size})"
|
591
|
+
end
|
592
|
+
|
593
|
+
sort! {|a, b| a.address <=> b.address }
|
594
|
+
self
|
595
|
+
end
|
596
|
+
|
597
|
+
def at_address(address)
|
598
|
+
detect {|d| d.address == address }
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
class MockVirtualMachineDisk < Base
|
603
|
+
def size
|
604
|
+
self[:size].to_i
|
605
|
+
end
|
606
|
+
|
607
|
+
def vcloud_size
|
608
|
+
# kilobytes
|
609
|
+
size * 1024
|
610
|
+
end
|
611
|
+
|
612
|
+
def address
|
613
|
+
self[:address].to_i
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
# for Terremark eCloud
|
618
|
+
|
619
|
+
class MockVdcInternetServices < Base
|
620
|
+
def href
|
621
|
+
_parent.href + "/internetServices"
|
622
|
+
end
|
623
|
+
|
624
|
+
def name
|
625
|
+
"Internet Services"
|
626
|
+
end
|
627
|
+
|
628
|
+
def items
|
629
|
+
public_ip_internet_services + backup_internet_services
|
630
|
+
end
|
631
|
+
|
632
|
+
def public_ip_internet_services
|
633
|
+
_parent.public_ip_collection.items.inject([]) do |services, public_ip|
|
634
|
+
services + public_ip.internet_service_collection.items
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
def backup_internet_services
|
639
|
+
@backup_internet_services ||= []
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
class MockBackupInternetService < Base
|
644
|
+
def name
|
645
|
+
self[:name] || "Backup Internet Service #{object_id}"
|
646
|
+
end
|
647
|
+
|
648
|
+
def protocol
|
649
|
+
self[:protocol]
|
650
|
+
end
|
651
|
+
|
652
|
+
def port
|
653
|
+
0
|
654
|
+
end
|
655
|
+
|
656
|
+
def enabled
|
657
|
+
self[:enabled].to_s.downcase != "false"
|
658
|
+
end
|
659
|
+
|
660
|
+
def timeout
|
661
|
+
self[:timeout] || 2
|
662
|
+
end
|
663
|
+
|
664
|
+
def description
|
665
|
+
self[:description] || "Description for Backup Service #{name}"
|
666
|
+
end
|
667
|
+
|
668
|
+
def redirect_url
|
669
|
+
nil
|
670
|
+
end
|
671
|
+
|
672
|
+
def node_collection
|
673
|
+
@node_collection ||= MockPublicIpInternetServiceNodes.new({}, self)
|
674
|
+
end
|
675
|
+
end
|
676
|
+
|
677
|
+
class MockFirewallAcls < Base
|
678
|
+
def name
|
679
|
+
"Firewall Access List"
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
class MockPublicIps < Base
|
684
|
+
def name
|
685
|
+
self[:name] || "Public IPs"
|
686
|
+
end
|
687
|
+
|
688
|
+
def items
|
689
|
+
@items ||= []
|
690
|
+
end
|
691
|
+
end
|
692
|
+
|
693
|
+
class MockPublicIp < Base
|
694
|
+
def name
|
695
|
+
self[:name]
|
696
|
+
end
|
697
|
+
|
698
|
+
def internet_service_collection
|
699
|
+
@internet_service_collection ||= MockPublicIpInternetServices.new({}, self)
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
class MockPublicIpInternetServices < Base
|
704
|
+
def href
|
705
|
+
_parent.href + "/internetServices"
|
706
|
+
end
|
707
|
+
|
708
|
+
def items
|
709
|
+
@items ||= []
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
713
|
+
class MockPublicIpInternetService < Base
|
714
|
+
def name
|
715
|
+
self[:name] || "Public IP Service #{object_id}"
|
716
|
+
end
|
717
|
+
|
718
|
+
def description
|
719
|
+
self[:description] || "Description for Public IP Service #{name}"
|
720
|
+
end
|
721
|
+
|
722
|
+
def protocol
|
723
|
+
self[:protocol]
|
724
|
+
end
|
725
|
+
|
726
|
+
def port
|
727
|
+
self[:port]
|
728
|
+
end
|
729
|
+
|
730
|
+
def enabled
|
731
|
+
!!self[:enabled]
|
732
|
+
end
|
733
|
+
|
734
|
+
def redirect_url
|
735
|
+
self[:redirect_url]
|
736
|
+
end
|
737
|
+
|
738
|
+
def timeout
|
739
|
+
self[:timeout] || 2
|
740
|
+
end
|
741
|
+
|
742
|
+
def node_collection
|
743
|
+
@node_collection ||= MockPublicIpInternetServiceNodes.new({}, self)
|
744
|
+
end
|
745
|
+
|
746
|
+
def monitor
|
747
|
+
nil
|
748
|
+
end
|
749
|
+
|
750
|
+
def backup_service
|
751
|
+
self[:backup_service]
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
755
|
+
class MockPublicIpInternetServiceNodes < Base
|
756
|
+
def href
|
757
|
+
_parent.href + "/nodeServices"
|
758
|
+
end
|
759
|
+
|
760
|
+
def items
|
761
|
+
@items ||= [].tap do |node_array|
|
762
|
+
node_array.instance_variable_set("@default_port", _parent.port)
|
763
|
+
|
764
|
+
def node_array.<<(node)
|
765
|
+
node[:port] ||= @default_port
|
766
|
+
super
|
767
|
+
end
|
768
|
+
end
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
class MockPublicIpInternetServiceNode < Base
|
773
|
+
def ip_address
|
774
|
+
self[:ip_address]
|
775
|
+
end
|
776
|
+
|
777
|
+
def name
|
778
|
+
self[:name] || "Public IP Service Node #{object_id}"
|
779
|
+
end
|
780
|
+
|
781
|
+
def description
|
782
|
+
self[:description] || "Description for Public IP Service Node #{name}"
|
783
|
+
end
|
784
|
+
|
785
|
+
def port
|
786
|
+
self[:port]
|
787
|
+
end
|
788
|
+
|
789
|
+
def enabled
|
790
|
+
self[:enabled].to_s.downcase != "false"
|
791
|
+
end
|
792
|
+
|
793
|
+
def enabled=(new_value)
|
794
|
+
self[:enabled] = new_value
|
795
|
+
end
|
796
|
+
end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
|
802
|
+
module Fog
|
803
|
+
module Ecloud
|
804
|
+
class Model < Fog::Model
|
805
|
+
|
806
|
+
attr_accessor :loaded
|
807
|
+
alias_method :loaded?, :loaded
|
808
|
+
|
809
|
+
def reload
|
810
|
+
instance = super
|
811
|
+
@loaded = true
|
812
|
+
instance
|
813
|
+
end
|
814
|
+
|
815
|
+
def load_unless_loaded!
|
816
|
+
unless @loaded
|
817
|
+
reload
|
818
|
+
end
|
819
|
+
end
|
820
|
+
|
821
|
+
end
|
822
|
+
end
|
823
|
+
end
|
824
|
+
|
825
|
+
module Fog
|
826
|
+
module Ecloud
|
827
|
+
class Compute < Fog::Service
|
828
|
+
|
829
|
+
class UnsupportedVersion < Exception ; end
|
830
|
+
|
831
|
+
requires :ecloud_username, :ecloud_password, :ecloud_versions_uri
|
832
|
+
recognizes :ecloud_version
|
833
|
+
recognizes :provider # remove post deprecation
|
834
|
+
|
835
|
+
model_path 'fog/compute/models/ecloud'
|
836
|
+
model :catalog_item
|
837
|
+
model :catalog
|
838
|
+
model :firewall_acl
|
839
|
+
collection :firewall_acls
|
840
|
+
model :internet_service
|
841
|
+
collection :internet_services
|
842
|
+
model :backup_internet_service
|
843
|
+
collection :backup_internet_services
|
844
|
+
model :ip
|
845
|
+
collection :ips
|
846
|
+
model :network
|
847
|
+
collection :networks
|
848
|
+
model :node
|
849
|
+
collection :nodes
|
850
|
+
model :public_ip
|
851
|
+
collection :public_ips
|
852
|
+
model :server
|
853
|
+
collection :servers
|
854
|
+
model :task
|
855
|
+
collection :tasks
|
856
|
+
model :vdc
|
857
|
+
collection :vdcs
|
858
|
+
|
859
|
+
request_path 'fog/compute/requests/ecloud'
|
860
|
+
request :add_internet_service
|
861
|
+
request :add_backup_internet_service
|
862
|
+
request :add_node
|
863
|
+
request :clone_vapp
|
864
|
+
request :configure_internet_service
|
865
|
+
request :configure_network
|
866
|
+
request :configure_network_ip
|
867
|
+
request :configure_node
|
868
|
+
request :configure_vapp
|
869
|
+
request :delete_internet_service
|
870
|
+
request :delete_node
|
871
|
+
request :delete_vapp
|
872
|
+
request :get_catalog
|
873
|
+
request :get_catalog_item
|
874
|
+
request :get_customization_options
|
875
|
+
request :get_firewall_acls
|
876
|
+
request :get_firewall_acl
|
877
|
+
request :get_internet_services
|
878
|
+
request :get_network
|
879
|
+
request :get_network_ip
|
880
|
+
request :get_network_ips
|
881
|
+
request :get_network_extensions
|
882
|
+
request :get_organization
|
883
|
+
request :get_node
|
884
|
+
request :get_nodes
|
885
|
+
request :get_public_ip
|
886
|
+
request :get_public_ips
|
887
|
+
request :get_task
|
888
|
+
request :get_task_list
|
889
|
+
request :get_vapp
|
890
|
+
request :get_vapp_template
|
891
|
+
request :get_vdc
|
892
|
+
request :get_versions
|
893
|
+
request :instantiate_vapp_template
|
894
|
+
request :login
|
895
|
+
request :power_off
|
896
|
+
request :power_on
|
897
|
+
request :power_reset
|
898
|
+
request :power_shutdown
|
899
|
+
|
900
|
+
module Shared
|
901
|
+
|
902
|
+
attr_reader :versions_uri
|
903
|
+
|
904
|
+
def default_organization_uri
|
905
|
+
@default_organization_uri ||= begin
|
906
|
+
unless @login_results
|
907
|
+
do_login
|
908
|
+
end
|
909
|
+
case @login_results.body[:Org]
|
910
|
+
when Array
|
911
|
+
@login_results.body[:Org].first[:href]
|
912
|
+
when Hash
|
913
|
+
@login_results.body[:Org][:href]
|
914
|
+
else
|
915
|
+
nil
|
916
|
+
end
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
920
|
+
# login handles the auth, but we just need the Set-Cookie
|
921
|
+
# header from that call.
|
922
|
+
def do_login
|
923
|
+
@login_results = login
|
924
|
+
@cookie = @login_results.headers['Set-Cookie']
|
925
|
+
end
|
926
|
+
|
927
|
+
def ecloud_xmlns
|
928
|
+
{
|
929
|
+
"xmlns" => "urn:tmrk:eCloudExtensions-2.6",
|
930
|
+
"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance"
|
931
|
+
}
|
932
|
+
end
|
933
|
+
|
934
|
+
def ensure_unparsed(uri)
|
935
|
+
if uri.is_a?(String)
|
936
|
+
uri
|
937
|
+
else
|
938
|
+
uri.to_s
|
939
|
+
end
|
940
|
+
end
|
941
|
+
|
942
|
+
def supported_versions
|
943
|
+
@supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
|
944
|
+
end
|
945
|
+
|
946
|
+
def xmlns
|
947
|
+
{ "xmlns" => "http://www.vmware.com/vcloud/v0.8",
|
948
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
949
|
+
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" }
|
950
|
+
end
|
951
|
+
|
952
|
+
end
|
953
|
+
|
954
|
+
class Mock
|
955
|
+
include Shared
|
956
|
+
include MockDataClasses
|
957
|
+
|
958
|
+
def self.base_url
|
959
|
+
"https://fakey.com/api/v0.8b-ext2.6"
|
960
|
+
end
|
961
|
+
|
962
|
+
def self.data_reset
|
963
|
+
@mock_data = nil
|
964
|
+
end
|
965
|
+
|
966
|
+
def self.data( base_url = self.base_url )
|
967
|
+
@mock_data ||= MockData.new.tap do |vcloud_mock_data|
|
968
|
+
vcloud_mock_data.versions.clear
|
969
|
+
vcloud_mock_data.versions << MockVersion.new(:version => "v0.8b-ext2.6", :supported => true)
|
970
|
+
|
971
|
+
vcloud_mock_data.organizations << MockOrganization.new(:name => "Boom Inc.").tap do |mock_organization|
|
972
|
+
mock_organization.vdcs << MockVdc.new(:name => "Boomstick").tap do |mock_vdc|
|
973
|
+
mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 0").tap do |mock_catalog_item|
|
974
|
+
mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024)
|
975
|
+
end
|
976
|
+
mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 1").tap do |mock_catalog_item|
|
977
|
+
mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024)
|
978
|
+
end
|
979
|
+
mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 2").tap do |mock_catalog_item|
|
980
|
+
mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024)
|
981
|
+
end
|
982
|
+
|
983
|
+
mock_vdc.networks << MockNetwork.new({ :subnet => "1.2.3.0/24" }, mock_vdc)
|
984
|
+
mock_vdc.networks << MockNetwork.new({ :subnet => "4.5.6.0/24" }, mock_vdc)
|
985
|
+
|
986
|
+
mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 1", :ip => "1.2.3.3" }, mock_vdc)
|
987
|
+
mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 2", :ip => "1.2.3.4" }, mock_vdc)
|
988
|
+
mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Email!", :ip => "1.2.3.10" }, mock_vdc)
|
989
|
+
end
|
990
|
+
|
991
|
+
mock_organization.vdcs << MockVdc.new(:name => "Rock-n-Roll", :storage_allocated => 150, :storage_used => 40, :cpu_allocated => 1000, :memory_allocated => 2048).tap do |mock_vdc|
|
992
|
+
mock_vdc.networks << MockNetwork.new({ :subnet => "7.8.9.0/24" }, mock_vdc)
|
993
|
+
|
994
|
+
mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Master Blaster", :ip => "7.8.9.10" }, mock_vdc)
|
995
|
+
end
|
996
|
+
end
|
997
|
+
|
998
|
+
vcloud_mock_data.organizations.detect {|o| o.name == "Boom Inc." }.tap do |mock_organization|
|
999
|
+
mock_organization.vdcs.detect {|v| v.name == "Boomstick" }.tap do |mock_vdc|
|
1000
|
+
mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.3").tap do |mock_public_ip|
|
1001
|
+
mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
|
1002
|
+
:protocol => "HTTP",
|
1003
|
+
:port => 80,
|
1004
|
+
:name => "Web Site",
|
1005
|
+
:description => "Web Servers",
|
1006
|
+
:redirect_url => "http://fakey.com"
|
1007
|
+
}, mock_public_ip.internet_service_collection
|
1008
|
+
).tap do |mock_public_ip_service|
|
1009
|
+
mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.5", :name => "Test Node 1", :description => "web 1"}, mock_public_ip_service.node_collection)
|
1010
|
+
mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.6", :name => "Test Node 2", :description => "web 2"}, mock_public_ip_service.node_collection)
|
1011
|
+
mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.7", :name => "Test Node 3", :description => "web 3"}, mock_public_ip_service.node_collection)
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
|
1015
|
+
:protocol => "TCP",
|
1016
|
+
:port => 7000,
|
1017
|
+
:name => "An SSH Map",
|
1018
|
+
:description => "SSH 1"
|
1019
|
+
}, mock_public_ip.internet_service_collection
|
1020
|
+
).tap do |mock_public_ip_service|
|
1021
|
+
mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({ :ip_address => "1.2.3.5", :port => 22, :name => "SSH", :description => "web ssh" }, mock_public_ip_service.node_collection)
|
1022
|
+
end
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.4").tap do |mock_public_ip|
|
1026
|
+
mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
|
1027
|
+
:protocol => "HTTP",
|
1028
|
+
:port => 80,
|
1029
|
+
:name => "Web Site",
|
1030
|
+
:description => "Web Servers",
|
1031
|
+
:redirect_url => "http://fakey.com"
|
1032
|
+
}, mock_public_ip.internet_service_collection
|
1033
|
+
)
|
1034
|
+
|
1035
|
+
mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
|
1036
|
+
:protocol => "TCP",
|
1037
|
+
:port => 7000,
|
1038
|
+
:name => "An SSH Map",
|
1039
|
+
:description => "SSH 2"
|
1040
|
+
}, mock_public_ip.internet_service_collection
|
1041
|
+
)
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.9.7")
|
1045
|
+
|
1046
|
+
mock_vdc.internet_service_collection.backup_internet_services << MockBackupInternetService.new({ :port => 10000, :protocol => "TCP"}, self)
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
mock_organization.vdcs.detect {|v| v.name == "Rock-n-Roll" }.tap do |mock_vdc|
|
1050
|
+
mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.99.99.99")
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
vcloud_mock_data.organizations.each do |organization|
|
1055
|
+
organization.vdcs.each do |vdc|
|
1056
|
+
vdc.networks.each do |network|
|
1057
|
+
network[:rnat] = vdc.public_ip_collection.items.first.name
|
1058
|
+
end
|
1059
|
+
vdc.virtual_machines.each do |virtual_machine|
|
1060
|
+
virtual_machine.disks << MockVirtualMachineDisk.new(:size => 25 * 1024)
|
1061
|
+
virtual_machine.disks << MockVirtualMachineDisk.new(:size => 50 * 1024)
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
end
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
def initialize(options = {})
|
1069
|
+
require 'builder'
|
1070
|
+
require 'fog/core/parser'
|
1071
|
+
|
1072
|
+
@versions_uri = URI.parse('https://vcloud.fakey.com/api/versions')
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
def mock_data
|
1076
|
+
Fog::Ecloud::Compute::Mock.data
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
def mock_error(expected, status, body='', headers={})
|
1080
|
+
raise Excon::Errors::Unauthorized.new("Expected(#{expected}) <=> Actual(#{status})")
|
1081
|
+
end
|
1082
|
+
|
1083
|
+
def mock_it(status, mock_data, mock_headers = {})
|
1084
|
+
response = Excon::Response.new
|
1085
|
+
|
1086
|
+
#Parse the response body into a hash
|
1087
|
+
if mock_data.empty?
|
1088
|
+
response.body = mock_data
|
1089
|
+
else
|
1090
|
+
document = Fog::ToHashDocument.new
|
1091
|
+
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
1092
|
+
parser << mock_data
|
1093
|
+
parser.finish
|
1094
|
+
response.body = document.body
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
response.status = status
|
1098
|
+
response.headers = mock_headers
|
1099
|
+
response
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
class Real
|
1105
|
+
include Shared
|
1106
|
+
|
1107
|
+
class << self
|
1108
|
+
|
1109
|
+
def basic_request(*args)
|
1110
|
+
self.class_eval <<-EOS, __FILE__,__LINE__
|
1111
|
+
def #{args[0]}(uri)
|
1112
|
+
request({
|
1113
|
+
:expects => #{args[1] || 200},
|
1114
|
+
:method => '#{args[2] || 'GET'}',
|
1115
|
+
:headers => #{args[3] ? args[3].inspect : '{}'},
|
1116
|
+
:body => '#{args[4] ? args[4] : ''}',
|
1117
|
+
:parse => true,
|
1118
|
+
:uri => uri })
|
1119
|
+
end
|
1120
|
+
EOS
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
def unauthenticated_basic_request(*args)
|
1124
|
+
self.class_eval <<-EOS, __FILE__,__LINE__
|
1125
|
+
def #{args[0]}(uri)
|
1126
|
+
unauthenticated_request({
|
1127
|
+
:expects => #{args[1] || 200},
|
1128
|
+
:method => '#{args[2] || 'GET'}',
|
1129
|
+
:headers => #{args[3] ? args[3].inspect : '{}'},
|
1130
|
+
:parse => true,
|
1131
|
+
:uri => uri })
|
1132
|
+
end
|
1133
|
+
EOS
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
end
|
1137
|
+
|
1138
|
+
def initialize(options = {})
|
1139
|
+
require 'builder'
|
1140
|
+
require 'fog/core/parser'
|
1141
|
+
|
1142
|
+
@connections = {}
|
1143
|
+
@versions_uri = URI.parse(options[:ecloud_versions_uri])
|
1144
|
+
@version = options[:ecloud_version]
|
1145
|
+
@username = options[:ecloud_username]
|
1146
|
+
@password = options[:ecloud_password]
|
1147
|
+
@persistent = options[:persistent]
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def default_organization_uri
|
1151
|
+
@default_organization_uri ||= begin
|
1152
|
+
unless @login_results
|
1153
|
+
do_login
|
1154
|
+
end
|
1155
|
+
case @login_results.body[:Org]
|
1156
|
+
when Array
|
1157
|
+
@login_results.body[:Org].first[:href]
|
1158
|
+
when Hash
|
1159
|
+
@login_results.body[:Org][:href]
|
1160
|
+
else
|
1161
|
+
nil
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
def reload
|
1167
|
+
@connections.each_value { |k,v| v.reset if v }
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
# If the cookie isn't set, do a get_organizations call to set it
|
1171
|
+
# and try the request.
|
1172
|
+
# If we get an Unauthorized error, we assume the token expired, re-auth and try again
|
1173
|
+
def request(params)
|
1174
|
+
unless @cookie
|
1175
|
+
do_login
|
1176
|
+
end
|
1177
|
+
begin
|
1178
|
+
do_request(params)
|
1179
|
+
rescue Excon::Errors::Unauthorized => e
|
1180
|
+
do_login
|
1181
|
+
do_request(params)
|
1182
|
+
end
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
def supporting_versions
|
1186
|
+
["v0.8b-ext2.6", "0.8b-ext2.6"]
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
private
|
1190
|
+
|
1191
|
+
def ensure_parsed(uri)
|
1192
|
+
if uri.is_a?(String)
|
1193
|
+
URI.parse(uri)
|
1194
|
+
else
|
1195
|
+
uri
|
1196
|
+
end
|
1197
|
+
end
|
1198
|
+
|
1199
|
+
def supported_version_numbers
|
1200
|
+
case supported_versions
|
1201
|
+
when Array
|
1202
|
+
supported_versions.map { |version| version[:Version] }
|
1203
|
+
when Hash
|
1204
|
+
[ supported_versions[:Version] ]
|
1205
|
+
end
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
def get_login_uri
|
1209
|
+
check_versions
|
1210
|
+
URI.parse case supported_versions
|
1211
|
+
when Array
|
1212
|
+
supported_versions.detect {|version| version[:Version] == @version }[:LoginUrl]
|
1213
|
+
when Hash
|
1214
|
+
supported_versions[:LoginUrl]
|
1215
|
+
end
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
# If we don't support any versions the service does, then raise an error.
|
1219
|
+
# If the @version that super selected isn't in our supported list, then select one that is.
|
1220
|
+
def check_versions
|
1221
|
+
if @version
|
1222
|
+
unless supported_version_numbers.include?(@version.to_s)
|
1223
|
+
raise UnsupportedVersion.new("#{@version} is not supported by the server.")
|
1224
|
+
end
|
1225
|
+
unless supporting_versions.include?(@version.to_s)
|
1226
|
+
raise UnsupportedVersion.new("#{@version} is not supported by #{self.class}")
|
1227
|
+
end
|
1228
|
+
else
|
1229
|
+
unless @version = (supported_version_numbers & supporting_versions).sort.first
|
1230
|
+
raise UnsupportedVersion.new("\nService @ #{@versions_uri} supports: #{supported_version_numbers.join(', ')}\n" +
|
1231
|
+
"#{self.class} supports: #{supporting_versions.join(', ')}")
|
1232
|
+
end
|
1233
|
+
end
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
# Don't need to set the cookie for these or retry them if the cookie timed out
|
1237
|
+
def unauthenticated_request(params)
|
1238
|
+
do_request(params)
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
# Use this to set the Authorization header for login
|
1242
|
+
def authorization_header
|
1243
|
+
"Basic #{Base64.encode64("#{@username}:#{@password}").chomp!}"
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
def login_uri
|
1247
|
+
@login_uri ||= get_login_uri
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
# login handles the auth, but we just need the Set-Cookie
|
1251
|
+
# header from that call.
|
1252
|
+
def do_login
|
1253
|
+
@login_results = login
|
1254
|
+
@cookie = @login_results.headers['Set-Cookie']
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
# Actually do the request
|
1258
|
+
def do_request(params)
|
1259
|
+
# Convert the uri to a URI if it's a string.
|
1260
|
+
if params[:uri].is_a?(String)
|
1261
|
+
params[:uri] = URI.parse(params[:uri])
|
1262
|
+
end
|
1263
|
+
host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}"
|
1264
|
+
|
1265
|
+
# Hash connections on the host_url ... There's nothing to say we won't get URI's that go to
|
1266
|
+
# different hosts.
|
1267
|
+
@connections[host_url] ||= Fog::Connection.new(host_url, @persistent)
|
1268
|
+
|
1269
|
+
# Set headers to an empty hash if none are set.
|
1270
|
+
headers = params[:headers] || {}
|
1271
|
+
|
1272
|
+
# Add our auth cookie to the headers
|
1273
|
+
if @cookie
|
1274
|
+
headers.merge!('Cookie' => @cookie)
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
# Make the request
|
1278
|
+
response = @connections[host_url].request({
|
1279
|
+
:body => params[:body] || '',
|
1280
|
+
:expects => params[:expects] || 200,
|
1281
|
+
:headers => headers,
|
1282
|
+
:method => params[:method] || 'GET',
|
1283
|
+
:path => params[:uri].path
|
1284
|
+
})
|
1285
|
+
|
1286
|
+
# Parse the response body into a hash
|
1287
|
+
#puts response.body
|
1288
|
+
unless response.body.empty?
|
1289
|
+
if params[:parse]
|
1290
|
+
document = Fog::ToHashDocument.new
|
1291
|
+
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
1292
|
+
parser << response.body
|
1293
|
+
parser.finish
|
1294
|
+
|
1295
|
+
response.body = document.body
|
1296
|
+
end
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
response
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
end
|
1305
|
+
end
|
1306
|
+
end
|