From e72831d99be9b01dc66ed568c56846adb84edc36 Mon Sep 17 00:00:00 2001 From: geemus Date: Thu, 17 Feb 2011 10:44:46 -0800 Subject: [PATCH] [ecloud|compute] re-namespace terremark ecloud --- bin/fog | 5 - lib/fog.rb | 1 - lib/fog/bin.rb | 8 +- lib/fog/bin/ecloud.rb | 30 + lib/fog/bin/vcloud.rb | 59 -- lib/fog/compute.rb | 3 + .../{vcloud/terremark => compute}/ecloud.rb | 922 +++++++++--------- .../models/ecloud/backup_internet_service.rb | 56 ++ .../models/ecloud/backup_internet_services.rb | 33 + lib/fog/compute/models/ecloud/catalog.rb | 28 + lib/fog/compute/models/ecloud/catalog_item.rb | 29 + lib/fog/compute/models/ecloud/firewall_acl.rb | 24 + .../compute/models/ecloud/firewall_acls.rb | 31 + .../compute/models/ecloud/internet_service.rb | 117 +++ .../models/ecloud/internet_services.rb | 33 + lib/fog/compute/models/ecloud/ip.rb | 49 + lib/fog/compute/models/ecloud/ips.rb | 32 + lib/fog/compute/models/ecloud/network.rb | 72 ++ lib/fog/compute/models/ecloud/networks.rb | 33 + lib/fog/compute/models/ecloud/node.rb | 43 + lib/fog/compute/models/ecloud/nodes.rb | 31 + lib/fog/compute/models/ecloud/public_ip.rb | 22 + lib/fog/compute/models/ecloud/public_ips.rb | 36 + lib/fog/compute/models/ecloud/server.rb | 209 ++++ lib/fog/compute/models/ecloud/servers.rb | 55 ++ lib/fog/compute/models/ecloud/task.rb | 21 + lib/fog/compute/models/ecloud/tasks.rb | 31 + lib/fog/compute/models/ecloud/vdc.rb | 81 ++ lib/fog/compute/models/ecloud/vdcs.rb | 40 + .../ecloud/add_backup_internet_service.rb | 109 +++ .../requests/ecloud/add_internet_service.rb | 149 +++ lib/fog/compute/requests/ecloud/add_node.rb | 62 ++ lib/fog/compute/requests/ecloud/clone_vapp.rb | 40 + .../ecloud/configure_internet_service.rb | 112 +++ .../requests/ecloud/configure_network.rb | 44 + .../requests/ecloud/configure_network_ip.rb | 66 ++ .../compute/requests/ecloud/configure_node.rb | 56 ++ .../compute/requests/ecloud/configure_vapp.rb | 144 +++ .../ecloud/delete_internet_service.rb | 22 + .../compute/requests/ecloud/delete_node.rb | 22 + .../compute/requests/ecloud/delete_vapp.rb | 29 + .../compute/requests/ecloud/get_catalog.rb | 44 + .../requests/ecloud/get_catalog_item.rb | 47 + .../ecloud/get_customization_options.rb | 22 + .../requests/ecloud/get_firewall_acl.rb | 11 + .../requests/ecloud/get_firewall_acls.rb | 11 + .../requests/ecloud/get_internet_services.rb | 82 ++ .../compute/requests/ecloud/get_network.rb | 44 + .../requests/ecloud/get_network_extensions.rb | 33 + .../compute/requests/ecloud/get_network_ip.rb | 43 + .../requests/ecloud/get_network_ips.rb | 35 + lib/fog/compute/requests/ecloud/get_node.rb | 40 + lib/fog/compute/requests/ecloud/get_nodes.rb | 41 + .../requests/ecloud/get_organization.rb | 49 + .../compute/requests/ecloud/get_public_ip.rb | 34 + .../compute/requests/ecloud/get_public_ips.rb | 38 + lib/fog/compute/requests/ecloud/get_task.rb | 11 + .../compute/requests/ecloud/get_task_list.rb | 11 + lib/fog/compute/requests/ecloud/get_vapp.rb | 99 ++ .../requests/ecloud/get_vapp_template.rb | 11 + lib/fog/compute/requests/ecloud/get_vdc.rb | 84 ++ .../compute/requests/ecloud/get_versions.rb | 37 + .../ecloud/instantiate_vapp_template.rb | 142 +++ lib/fog/compute/requests/ecloud/login.rb | 48 + lib/fog/compute/requests/ecloud/power_off.rb | 23 + lib/fog/compute/requests/ecloud/power_on.rb | 23 + .../compute/requests/ecloud/power_reset.rb | 11 + .../compute/requests/ecloud/power_shutdown.rb | 11 + lib/fog/providers.rb | 1 + lib/fog/providers/ecloud.rb | 11 + lib/fog/vcloud.rb | 1 - .../ecloud/models/backup_internet_service.rb | 60 -- .../ecloud/models/backup_internet_services.rb | 36 - .../vcloud/terremark/ecloud/models/catalog.rb | 31 - .../terremark/ecloud/models/catalog_item.rb | 31 - .../terremark/ecloud/models/firewall_acl.rb | 28 - .../terremark/ecloud/models/firewall_acls.rb | 34 - .../ecloud/models/internet_service.rb | 121 --- .../ecloud/models/internet_services.rb | 36 - lib/fog/vcloud/terremark/ecloud/models/ip.rb | 51 - lib/fog/vcloud/terremark/ecloud/models/ips.rb | 35 - .../vcloud/terremark/ecloud/models/network.rb | 77 -- .../terremark/ecloud/models/networks.rb | 36 - .../vcloud/terremark/ecloud/models/node.rb | 47 - .../vcloud/terremark/ecloud/models/nodes.rb | 33 - .../terremark/ecloud/models/public_ip.rb | 25 - .../terremark/ecloud/models/public_ips.rb | 39 - .../vcloud/terremark/ecloud/models/server.rb | 211 ---- .../vcloud/terremark/ecloud/models/servers.rb | 57 -- .../vcloud/terremark/ecloud/models/task.rb | 23 - .../vcloud/terremark/ecloud/models/tasks.rb | 33 - lib/fog/vcloud/terremark/ecloud/models/vdc.rb | 83 -- .../vcloud/terremark/ecloud/models/vdcs.rb | 42 - .../requests/add_backup_internet_service.rb | 111 --- .../ecloud/requests/add_internet_service.rb | 152 --- .../terremark/ecloud/requests/add_node.rb | 64 -- .../terremark/ecloud/requests/clone_vapp.rb | 42 - .../requests/configure_internet_service.rb | 115 --- .../ecloud/requests/configure_network.rb | 46 - .../ecloud/requests/configure_network_ip.rb | 68 -- .../ecloud/requests/configure_node.rb | 58 -- .../ecloud/requests/configure_vapp.rb | 147 --- .../requests/delete_internet_service.rb | 25 - .../terremark/ecloud/requests/delete_node.rb | 24 - .../terremark/ecloud/requests/delete_vapp.rb | 32 - .../terremark/ecloud/requests/get_catalog.rb | 46 - .../ecloud/requests/get_catalog_item.rb | 49 - .../requests/get_customization_options.rb | 24 - .../ecloud/requests/get_firewall_acl.rb | 13 - .../ecloud/requests/get_firewall_acls.rb | 13 - .../ecloud/requests/get_internet_services.rb | 84 -- .../terremark/ecloud/requests/get_network.rb | 47 - .../ecloud/requests/get_network_extensions.rb | 35 - .../ecloud/requests/get_network_ip.rb | 45 - .../ecloud/requests/get_network_ips.rb | 37 - .../terremark/ecloud/requests/get_node.rb | 42 - .../terremark/ecloud/requests/get_nodes.rb | 43 - .../ecloud/requests/get_organization.rb | 52 - .../ecloud/requests/get_public_ip.rb | 36 - .../ecloud/requests/get_public_ips.rb | 41 - .../terremark/ecloud/requests/get_task.rb | 13 - .../ecloud/requests/get_task_list.rb | 14 - .../terremark/ecloud/requests/get_vapp.rb | 101 -- .../ecloud/requests/get_vapp_template.rb | 13 - .../terremark/ecloud/requests/get_vdc.rb | 87 -- .../terremark/ecloud/requests/get_versions.rb | 39 - .../requests/instantiate_vapp_template.rb | 144 --- .../vcloud/terremark/ecloud/requests/login.rb | 51 - .../terremark/ecloud/requests/power_off.rb | 25 - .../terremark/ecloud/requests/power_on.rb | 25 - .../terremark/ecloud/requests/power_reset.rb | 13 - .../ecloud/requests/power_shutdown.rb | 13 - spec/ecloud/bin_spec.rb | 22 + .../models/backup_internet_service_spec.rb | 10 +- .../models/backup_internet_services_spec.rb | 8 +- .../ecloud/models/internet_service_spec.rb | 10 +- .../ecloud/models/internet_services_spec.rb | 8 +- .../terremark => }/ecloud/models/ip_spec.rb | 10 +- .../terremark => }/ecloud/models/ips_spec.rb | 8 +- .../ecloud/models/network_spec.rb | 10 +- .../ecloud/models/networks_spec.rb | 8 +- .../terremark => }/ecloud/models/node_spec.rb | 10 +- .../ecloud/models/nodes_spec.rb | 8 +- .../ecloud/models/public_ip_spec.rb | 10 +- .../ecloud/models/public_ips_spec.rb | 8 +- .../ecloud/models/server_spec.rb | 8 +- .../terremark => }/ecloud/models/vdc_spec.rb | 10 +- .../terremark => }/ecloud/models/vdcs_spec.rb | 8 +- .../add_backup_internet_service_spec.rb | 4 +- .../requests/add_internet_service_spec.rb | 4 +- .../ecloud/requests/add_node_spec.rb | 4 +- .../configure_internet_service_spec.rb | 4 +- .../requests/configure_network_ip_spec.rb | 4 +- .../ecloud/requests/configure_node_spec.rb | 4 +- .../ecloud/requests/configure_vapp_spec.rb | 4 +- .../requests/delete_internet_service_spec.rb | 4 +- .../ecloud/requests/delete_node_spec.rb | 4 +- .../ecloud/requests/delete_vapp_spec.rb | 4 +- .../ecloud/requests/get_catalog_item_spec.rb | 4 +- .../ecloud/requests/get_catalog_spec.rb | 4 +- .../get_customization_options_spec.rb | 4 +- .../requests/get_internet_services_spec.rb | 4 +- .../ecloud/requests/get_network_ip_spec.rb | 4 +- .../ecloud/requests/get_network_ips_spec.rb | 4 +- .../ecloud/requests/get_network_spec.rb | 4 +- .../ecloud/requests/get_node_spec.rb | 4 +- .../ecloud/requests/get_nodes_spec.rb | 4 +- .../ecloud/requests/get_organization_spec.rb | 4 +- .../ecloud/requests/get_public_ip_spec.rb | 4 +- .../ecloud/requests/get_public_ips_spec.rb | 4 +- .../ecloud/requests/get_vapp_spec.rb | 4 +- .../ecloud/requests/get_vdc_spec.rb | 4 +- .../ecloud/requests/get_versions_spec.rb | 6 +- .../instantiate_vapp_template_spec.rb | 6 +- .../ecloud/requests/login_spec.rb | 4 +- .../ecloud/requests/power_off_spec.rb | 4 +- .../ecloud/requests/power_on_spec.rb | 4 +- spec/{vcloud => ecloud}/spec_helper.rb | 29 +- spec/{vcloud => ecloud}/vcloud_spec.rb | 6 +- spec/spec_helper.rb | 1 - spec/vcloud/bin_spec.rb | 28 - 181 files changed, 3718 insertions(+), 3907 deletions(-) create mode 100644 lib/fog/bin/ecloud.rb delete mode 100644 lib/fog/bin/vcloud.rb rename lib/fog/{vcloud/terremark => compute}/ecloud.rb (53%) create mode 100644 lib/fog/compute/models/ecloud/backup_internet_service.rb create mode 100644 lib/fog/compute/models/ecloud/backup_internet_services.rb create mode 100644 lib/fog/compute/models/ecloud/catalog.rb create mode 100644 lib/fog/compute/models/ecloud/catalog_item.rb create mode 100644 lib/fog/compute/models/ecloud/firewall_acl.rb create mode 100644 lib/fog/compute/models/ecloud/firewall_acls.rb create mode 100644 lib/fog/compute/models/ecloud/internet_service.rb create mode 100644 lib/fog/compute/models/ecloud/internet_services.rb create mode 100644 lib/fog/compute/models/ecloud/ip.rb create mode 100644 lib/fog/compute/models/ecloud/ips.rb create mode 100644 lib/fog/compute/models/ecloud/network.rb create mode 100644 lib/fog/compute/models/ecloud/networks.rb create mode 100644 lib/fog/compute/models/ecloud/node.rb create mode 100644 lib/fog/compute/models/ecloud/nodes.rb create mode 100644 lib/fog/compute/models/ecloud/public_ip.rb create mode 100644 lib/fog/compute/models/ecloud/public_ips.rb create mode 100644 lib/fog/compute/models/ecloud/server.rb create mode 100644 lib/fog/compute/models/ecloud/servers.rb create mode 100644 lib/fog/compute/models/ecloud/task.rb create mode 100644 lib/fog/compute/models/ecloud/tasks.rb create mode 100644 lib/fog/compute/models/ecloud/vdc.rb create mode 100644 lib/fog/compute/models/ecloud/vdcs.rb create mode 100644 lib/fog/compute/requests/ecloud/add_backup_internet_service.rb create mode 100644 lib/fog/compute/requests/ecloud/add_internet_service.rb create mode 100644 lib/fog/compute/requests/ecloud/add_node.rb create mode 100644 lib/fog/compute/requests/ecloud/clone_vapp.rb create mode 100644 lib/fog/compute/requests/ecloud/configure_internet_service.rb create mode 100644 lib/fog/compute/requests/ecloud/configure_network.rb create mode 100644 lib/fog/compute/requests/ecloud/configure_network_ip.rb create mode 100644 lib/fog/compute/requests/ecloud/configure_node.rb create mode 100644 lib/fog/compute/requests/ecloud/configure_vapp.rb create mode 100644 lib/fog/compute/requests/ecloud/delete_internet_service.rb create mode 100644 lib/fog/compute/requests/ecloud/delete_node.rb create mode 100644 lib/fog/compute/requests/ecloud/delete_vapp.rb create mode 100644 lib/fog/compute/requests/ecloud/get_catalog.rb create mode 100644 lib/fog/compute/requests/ecloud/get_catalog_item.rb create mode 100644 lib/fog/compute/requests/ecloud/get_customization_options.rb create mode 100644 lib/fog/compute/requests/ecloud/get_firewall_acl.rb create mode 100644 lib/fog/compute/requests/ecloud/get_firewall_acls.rb create mode 100644 lib/fog/compute/requests/ecloud/get_internet_services.rb create mode 100644 lib/fog/compute/requests/ecloud/get_network.rb create mode 100644 lib/fog/compute/requests/ecloud/get_network_extensions.rb create mode 100644 lib/fog/compute/requests/ecloud/get_network_ip.rb create mode 100644 lib/fog/compute/requests/ecloud/get_network_ips.rb create mode 100644 lib/fog/compute/requests/ecloud/get_node.rb create mode 100644 lib/fog/compute/requests/ecloud/get_nodes.rb create mode 100644 lib/fog/compute/requests/ecloud/get_organization.rb create mode 100644 lib/fog/compute/requests/ecloud/get_public_ip.rb create mode 100644 lib/fog/compute/requests/ecloud/get_public_ips.rb create mode 100644 lib/fog/compute/requests/ecloud/get_task.rb create mode 100644 lib/fog/compute/requests/ecloud/get_task_list.rb create mode 100644 lib/fog/compute/requests/ecloud/get_vapp.rb create mode 100644 lib/fog/compute/requests/ecloud/get_vapp_template.rb create mode 100644 lib/fog/compute/requests/ecloud/get_vdc.rb create mode 100644 lib/fog/compute/requests/ecloud/get_versions.rb create mode 100644 lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb create mode 100644 lib/fog/compute/requests/ecloud/login.rb create mode 100644 lib/fog/compute/requests/ecloud/power_off.rb create mode 100644 lib/fog/compute/requests/ecloud/power_on.rb create mode 100644 lib/fog/compute/requests/ecloud/power_reset.rb create mode 100644 lib/fog/compute/requests/ecloud/power_shutdown.rb create mode 100644 lib/fog/providers/ecloud.rb delete mode 100644 lib/fog/vcloud.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/catalog.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/firewall_acl.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/internet_services.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/ip.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/ips.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/network.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/networks.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/node.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/nodes.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/public_ip.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/public_ips.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/server.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/servers.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/task.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/tasks.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/vdc.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/models/vdcs.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/add_node.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/clone_vapp.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acl.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acls.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_network.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_node.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_organization.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_task.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_vapp_template.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/get_versions.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/login.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/power_off.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/power_on.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb delete mode 100644 lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb create mode 100644 spec/ecloud/bin_spec.rb rename spec/{vcloud/terremark => }/ecloud/models/backup_internet_service_spec.rb (83%) rename spec/{vcloud/terremark => }/ecloud/models/backup_internet_services_spec.rb (62%) rename spec/{vcloud/terremark => }/ecloud/models/internet_service_spec.rb (92%) rename spec/{vcloud/terremark => }/ecloud/models/internet_services_spec.rb (62%) rename spec/{vcloud/terremark => }/ecloud/models/ip_spec.rb (69%) rename spec/{vcloud/terremark => }/ecloud/models/ips_spec.rb (60%) rename spec/{vcloud/terremark => }/ecloud/models/network_spec.rb (88%) rename spec/{vcloud/terremark => }/ecloud/models/networks_spec.rb (57%) rename spec/{vcloud/terremark => }/ecloud/models/node_spec.rb (76%) rename spec/{vcloud/terremark => }/ecloud/models/nodes_spec.rb (67%) rename spec/{vcloud/terremark => }/ecloud/models/public_ip_spec.rb (70%) rename spec/{vcloud/terremark => }/ecloud/models/public_ips_spec.rb (58%) rename spec/{vcloud/terremark => }/ecloud/models/server_spec.rb (88%) rename spec/{vcloud/terremark => }/ecloud/models/vdc_spec.rb (90%) rename spec/{vcloud/terremark => }/ecloud/models/vdcs_spec.rb (61%) rename spec/{vcloud/terremark => }/ecloud/requests/add_backup_internet_service_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/add_internet_service_spec.rb (96%) rename spec/{vcloud/terremark => }/ecloud/requests/add_node_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/configure_internet_service_spec.rb (96%) rename spec/{vcloud/terremark => }/ecloud/requests/configure_network_ip_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/configure_node_spec.rb (94%) rename spec/{vcloud/terremark => }/ecloud/requests/configure_vapp_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/delete_internet_service_spec.rb (90%) rename spec/{vcloud/terremark => }/ecloud/requests/delete_node_spec.rb (89%) rename spec/{vcloud/terremark => }/ecloud/requests/delete_vapp_spec.rb (96%) rename spec/{vcloud/terremark => }/ecloud/requests/get_catalog_item_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/get_catalog_spec.rb (92%) rename spec/{vcloud/terremark => }/ecloud/requests/get_customization_options_spec.rb (93%) rename spec/{vcloud/terremark => }/ecloud/requests/get_internet_services_spec.rb (98%) rename spec/{vcloud/terremark => }/ecloud/requests/get_network_ip_spec.rb (92%) rename spec/{vcloud/terremark => }/ecloud/requests/get_network_ips_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/get_network_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/get_node_spec.rb (92%) rename spec/{vcloud/terremark => }/ecloud/requests/get_nodes_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/get_organization_spec.rb (96%) rename spec/{vcloud/terremark => }/ecloud/requests/get_public_ip_spec.rb (91%) rename spec/{vcloud/terremark => }/ecloud/requests/get_public_ips_spec.rb (94%) rename spec/{vcloud/terremark => }/ecloud/requests/get_vapp_spec.rb (98%) rename spec/{vcloud/terremark => }/ecloud/requests/get_vdc_spec.rb (98%) rename spec/{vcloud/terremark => }/ecloud/requests/get_versions_spec.rb (90%) rename spec/{vcloud/terremark => }/ecloud/requests/instantiate_vapp_template_spec.rb (95%) rename spec/{vcloud/terremark => }/ecloud/requests/login_spec.rb (53%) rename spec/{vcloud/terremark => }/ecloud/requests/power_off_spec.rb (91%) rename spec/{vcloud/terremark => }/ecloud/requests/power_on_spec.rb (91%) rename spec/{vcloud => ecloud}/spec_helper.rb (93%) rename spec/{vcloud => ecloud}/vcloud_spec.rb (63%) delete mode 100644 spec/vcloud/bin_spec.rb diff --git a/bin/fog b/bin/fog index 064410a33..34dfc45f9 100755 --- a/bin/fog +++ b/bin/fog @@ -35,11 +35,6 @@ else Formatador.display_line('Welcome to fog interactive!') Formatador.display_line(":#{Fog.credential} provides #{providers}") providers = Fog.providers - Fog.modules.each do |_module_| - if _module_.respond_to?(:startup_notice) - _module_.send(:startup_notice) - end - end catch(:IRB_EXIT) { @irb.eval_input } diff --git a/lib/fog.rb b/lib/fog.rb index 0fe2aedf1..234e1d8c2 100644 --- a/lib/fog.rb +++ b/lib/fog.rb @@ -11,7 +11,6 @@ end # FIXME: these should go away (force usage of Fog::[Compute, CDN, DNS, Storage] etc) require 'fog/providers' require 'fog/terremark' -require 'fog/vcloud' require 'fog/compute' require 'fog/cdn' diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index 168e35929..e71f8afaa 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -7,12 +7,6 @@ module Fog @providers.select {|provider| eval("::#{provider.to_s.split('::').last}").available?} end - def modules - [ - ::Vcloud - ].select {|_module_| _module_.initialized?} - end - end class Bin @@ -62,6 +56,7 @@ end require 'fog/bin/aws' require 'fog/bin/bluebox' require 'fog/bin/brightbox' +require 'fog/bin/ecloud' require 'fog/bin/go_grid' require 'fog/bin/google' require 'fog/bin/linode' @@ -70,5 +65,4 @@ require 'fog/bin/new_servers' require 'fog/bin/rackspace' require 'fog/bin/slicehost' require 'fog/bin/terremark' -require 'fog/bin/vcloud' require 'fog/bin/zerigo' diff --git a/lib/fog/bin/ecloud.rb b/lib/fog/bin/ecloud.rb new file mode 100644 index 000000000..31bd9934e --- /dev/null +++ b/lib/fog/bin/ecloud.rb @@ -0,0 +1,30 @@ +class Ecloud < Fog::Bin + class << self + + def class_for(key) + case key + when :compute + Fog::Ecloud::Compute + else + raise ArgumentError, "Unrecognized service: #{key}" + end + end + + def [](service) + @@connections ||= Hash.new do |hash, key| + hash[key] = case key + when :compute + Fog::Compute.new(:provider => 'Ecloud') + else + raise ArgumentError, "Unrecognized service: #{key.inspect}" + end + end + @@connections[service] + end + + def services + Fog::Ecloud.services + end + + end +end diff --git a/lib/fog/bin/vcloud.rb b/lib/fog/bin/vcloud.rb deleted file mode 100644 index bf03bfbd7..000000000 --- a/lib/fog/bin/vcloud.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Vcloud - class << self - - def services - if Fog.credentials.has_key?(:vcloud) - Fog.credentials[:vcloud].keys.sort { |a,b| a.to_s <=> b.to_s } - else - [] - end - end - - def registered_services - Vcloud.services.map { |service| ":" << service.to_s }.join(", ") - end - - def complete_service_options?(service) - if Fog.credentials.has_key?(:vcloud) - if Fog.credentials[:vcloud].has_key?(service) - service = Fog.credentials[:vcloud][service] - if Fog::Vcloud.requirements.all? { |option| service.has_key?(option) } - return true - end - end - end - false - end - - if Vcloud.services.any? && Vcloud.services.all? { |service| Vcloud.complete_service_options?(service) } - - def initialized? - true - end - - def startup_notice - Formatador.display_line("You have access to the following Vcloud services: #{Vcloud.registered_services}.") - end - - def [](service) - @@connections ||= Hash.new do |hash, key| - if credentials = Fog.credentials[:vcloud][key] - credentials = credentials.dup - _module_ = eval(credentials.delete(:module)) - hash[key] = _module_.new(credentials) - else - raise ArgumentError.new("Unregistered service: #{key.inspect}. Registered services are: #{Vcloud.registered_services}") - end - end - @@connections[service] - end - - else - - def initialized? - false - end - - end - end -end diff --git a/lib/fog/compute.rb b/lib/fog/compute.rb index 2fe797f6e..8ec5e5556 100644 --- a/lib/fog/compute.rb +++ b/lib/fog/compute.rb @@ -13,6 +13,9 @@ module Fog when 'Brightbox' require 'fog/compute/brightbox' Fog::Brightbox::Compute.new(attributes) + when 'Ecloud' + require 'fog/compute/ecloud' + Fog::Ecloud::Compute.new(attributes) when 'GoGrid' require 'fog/compute/go_grid' Fog::GoGrid::Compute.new(attributes) diff --git a/lib/fog/vcloud/terremark/ecloud.rb b/lib/fog/compute/ecloud.rb similarity index 53% rename from lib/fog/vcloud/terremark/ecloud.rb rename to lib/fog/compute/ecloud.rb index a86c0fe71..ad811048b 100644 --- a/lib/fog/vcloud/terremark/ecloud.rb +++ b/lib/fog/compute/ecloud.rb @@ -8,7 +8,7 @@ class IPAddr end module Fog - class Vcloud < Fog::Service + module Ecloud class Collection < Fog::Collection def load(objects) @@ -39,7 +39,7 @@ module Fog end module Fog - class Vcloud + module Ecloud module MockDataClasses class Base < Hash def self.base_url=(url) @@ -800,7 +800,7 @@ end module Fog - class Vcloud < Fog::Service + module Ecloud class Model < Fog::Model attr_accessor :loaded @@ -823,486 +823,484 @@ module Fog end module Fog - class Vcloud - module Terremark - class Ecloud < Fog::Service + module Ecloud + class Compute < Fog::Service - class UnsupportedVersion < Exception ; end + class UnsupportedVersion < Exception ; end - requires :username, :password, :versions_uri - recognizes :module, :version + requires :ecloud_username, :ecloud_password, :ecloud_versions_uri + recognizes :ecloud_version + recognizes :provider # remove post deprecation - model_path 'fog/vcloud/terremark/ecloud/models' - model :catalog_item - model :catalog - model :firewall_acl - collection :firewall_acls - model :internet_service - collection :internet_services - model :backup_internet_service - collection :backup_internet_services - model :ip - collection :ips - model :network - collection :networks - model :node - collection :nodes - model :public_ip - collection :public_ips - model :server - collection :servers - model :task - collection :tasks - model :vdc - collection :vdcs + model_path 'fog/compute/models/ecloud' + model :catalog_item + model :catalog + model :firewall_acl + collection :firewall_acls + model :internet_service + collection :internet_services + model :backup_internet_service + collection :backup_internet_services + model :ip + collection :ips + model :network + collection :networks + model :node + collection :nodes + model :public_ip + collection :public_ips + model :server + collection :servers + model :task + collection :tasks + model :vdc + collection :vdcs - request_path 'fog/vcloud/terremark/ecloud/requests' - request :add_internet_service - request :add_backup_internet_service - request :add_node - request :clone_vapp - request :configure_internet_service - request :configure_network - request :configure_network_ip - request :configure_node - request :configure_vapp - request :delete_internet_service - request :delete_node - request :delete_vapp - request :get_catalog - request :get_catalog_item - request :get_customization_options - request :get_firewall_acls - request :get_firewall_acl - request :get_internet_services - request :get_network - request :get_network_ip - request :get_network_ips - request :get_network_extensions - request :get_organization - request :get_node - request :get_nodes - request :get_public_ip - request :get_public_ips - request :get_task - request :get_task_list - request :get_vapp - request :get_vapp_template - request :get_vdc - request :get_versions - request :instantiate_vapp_template - request :login - request :power_off - request :power_on - request :power_reset - request :power_shutdown + request_path 'fog/compute/requests/ecloud' + request :add_internet_service + request :add_backup_internet_service + request :add_node + request :clone_vapp + request :configure_internet_service + request :configure_network + request :configure_network_ip + request :configure_node + request :configure_vapp + request :delete_internet_service + request :delete_node + request :delete_vapp + request :get_catalog + request :get_catalog_item + request :get_customization_options + request :get_firewall_acls + request :get_firewall_acl + request :get_internet_services + request :get_network + request :get_network_ip + request :get_network_ips + request :get_network_extensions + request :get_organization + request :get_node + request :get_nodes + request :get_public_ip + request :get_public_ips + request :get_task + request :get_task_list + request :get_vapp + request :get_vapp_template + request :get_vdc + request :get_versions + request :instantiate_vapp_template + request :login + request :power_off + request :power_on + request :power_reset + request :power_shutdown - module Shared + module Shared - attr_reader :versions_uri + attr_reader :versions_uri - def default_organization_uri - @default_organization_uri ||= begin - unless @login_results - do_login - end - case @login_results.body[:Org] - when Array - @login_results.body[:Org].first[:href] - when Hash - @login_results.body[:Org][:href] - else - nil - end - end - end - - # login handles the auth, but we just need the Set-Cookie - # header from that call. - def do_login - @login_results = login - @cookie = @login_results.headers['Set-Cookie'] - end - - def ecloud_xmlns - { - "xmlns" => "urn:tmrk:eCloudExtensions-2.6", - "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" - } - end - - def ensure_unparsed(uri) - if uri.is_a?(String) - uri - else - uri.to_s - end - end - - def supported_versions - @supported_versions ||= get_versions(@versions_uri).body[:VersionInfo] - end - - def xmlns - { "xmlns" => "http://www.vmware.com/vcloud/v0.8", - "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", - "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" } - end - - end - - class Mock - include Shared - include MockDataClasses - - def self.base_url - "https://fakey.com/api/v0.8b-ext2.6" - end - - def self.data_reset - @mock_data = nil - end - - def self.data( base_url = self.base_url ) - @mock_data ||= MockData.new.tap do |vcloud_mock_data| - vcloud_mock_data.versions.clear - vcloud_mock_data.versions << MockVersion.new(:version => "v0.8b-ext2.6", :supported => true) - - vcloud_mock_data.organizations << MockOrganization.new(:name => "Boom Inc.").tap do |mock_organization| - mock_organization.vdcs << MockVdc.new(:name => "Boomstick").tap do |mock_vdc| - mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 0").tap do |mock_catalog_item| - mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) - end - mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 1").tap do |mock_catalog_item| - mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) - end - mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 2").tap do |mock_catalog_item| - mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) - end - - mock_vdc.networks << MockNetwork.new({ :subnet => "1.2.3.0/24" }, mock_vdc) - mock_vdc.networks << MockNetwork.new({ :subnet => "4.5.6.0/24" }, mock_vdc) - - mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 1", :ip => "1.2.3.3" }, mock_vdc) - mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 2", :ip => "1.2.3.4" }, mock_vdc) - mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Email!", :ip => "1.2.3.10" }, mock_vdc) - end - - 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| - mock_vdc.networks << MockNetwork.new({ :subnet => "7.8.9.0/24" }, mock_vdc) - - mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Master Blaster", :ip => "7.8.9.10" }, mock_vdc) - end - end - - vcloud_mock_data.organizations.detect {|o| o.name == "Boom Inc." }.tap do |mock_organization| - mock_organization.vdcs.detect {|v| v.name == "Boomstick" }.tap do |mock_vdc| - mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.3").tap do |mock_public_ip| - mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ - :protocol => "HTTP", - :port => 80, - :name => "Web Site", - :description => "Web Servers", - :redirect_url => "http://fakey.com" - }, mock_public_ip.internet_service_collection - ).tap do |mock_public_ip_service| - 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) - 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) - 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) - end - - mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ - :protocol => "TCP", - :port => 7000, - :name => "An SSH Map", - :description => "SSH 1" - }, mock_public_ip.internet_service_collection - ).tap do |mock_public_ip_service| - 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) - end - end - - mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.4").tap do |mock_public_ip| - mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ - :protocol => "HTTP", - :port => 80, - :name => "Web Site", - :description => "Web Servers", - :redirect_url => "http://fakey.com" - }, mock_public_ip.internet_service_collection - ) - - mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ - :protocol => "TCP", - :port => 7000, - :name => "An SSH Map", - :description => "SSH 2" - }, mock_public_ip.internet_service_collection - ) - end - - mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.9.7") - - mock_vdc.internet_service_collection.backup_internet_services << MockBackupInternetService.new({ :port => 10000, :protocol => "TCP"}, self) - end - - mock_organization.vdcs.detect {|v| v.name == "Rock-n-Roll" }.tap do |mock_vdc| - mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.99.99.99") - end - end - - vcloud_mock_data.organizations.each do |organization| - organization.vdcs.each do |vdc| - vdc.networks.each do |network| - network[:rnat] = vdc.public_ip_collection.items.first.name - end - vdc.virtual_machines.each do |virtual_machine| - virtual_machine.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) - virtual_machine.disks << MockVirtualMachineDisk.new(:size => 50 * 1024) - end - end - end - end - end - - def initialize(options = {}) - require 'builder' - require 'fog/core/parser' - - @versions_uri = URI.parse('https://vcloud.fakey.com/api/versions') - end - - def mock_data - Fog::Vcloud::Terremark::Ecloud::Mock.data - end - - def mock_error(expected, status, body='', headers={}) - raise Excon::Errors::Unauthorized.new("Expected(#{expected}) <=> Actual(#{status})") - end - - def mock_it(status, mock_data, mock_headers = {}) - response = Excon::Response.new - - #Parse the response body into a hash - if mock_data.empty? - response.body = mock_data - else - document = Fog::ToHashDocument.new - parser = Nokogiri::XML::SAX::PushParser.new(document) - parser << mock_data - parser.finish - response.body = document.body - end - - response.status = status - response.headers = mock_headers - response - end - - end - - class Real - include Shared - - class << self - - def basic_request(*args) - self.class_eval <<-EOS, __FILE__,__LINE__ - def #{args[0]}(uri) - request({ - :expects => #{args[1] || 200}, - :method => '#{args[2] || 'GET'}', - :headers => #{args[3] ? args[3].inspect : '{}'}, - :body => '#{args[4] ? args[4] : ''}', - :parse => true, - :uri => uri }) - end - EOS - end - - def unauthenticated_basic_request(*args) - self.class_eval <<-EOS, __FILE__,__LINE__ - def #{args[0]}(uri) - unauthenticated_request({ - :expects => #{args[1] || 200}, - :method => '#{args[2] || 'GET'}', - :headers => #{args[3] ? args[3].inspect : '{}'}, - :parse => true, - :uri => uri }) - end - EOS - end - - end - - def initialize(options = {}) - require 'builder' - require 'fog/core/parser' - - @connections = {} - @versions_uri = URI.parse(options[:versions_uri]) - @module = options[:module] - @version = options[:version] - @username = options[:username] - @password = options[:password] - @persistent = options[:persistent] - end - - def default_organization_uri - @default_organization_uri ||= begin - unless @login_results - do_login - end - case @login_results.body[:Org] - when Array - @login_results.body[:Org].first[:href] - when Hash - @login_results.body[:Org][:href] - else - nil - end - end - end - - def reload - @connections.each_value { |k,v| v.reset if v } - end - - # If the cookie isn't set, do a get_organizations call to set it - # and try the request. - # If we get an Unauthorized error, we assume the token expired, re-auth and try again - def request(params) - unless @cookie + def default_organization_uri + @default_organization_uri ||= begin + unless @login_results do_login end - begin - do_request(params) - rescue Excon::Errors::Unauthorized => e - do_login - do_request(params) - end - end - - def supporting_versions - ["v0.8b-ext2.6", "0.8b-ext2.6"] - end - - private - - def ensure_parsed(uri) - if uri.is_a?(String) - URI.parse(uri) - else - uri - end - end - - def supported_version_numbers - case supported_versions + case @login_results.body[:Org] when Array - supported_versions.map { |version| version[:Version] } + @login_results.body[:Org].first[:href] when Hash - [ supported_versions[:Version] ] - end - end - - def get_login_uri - check_versions - URI.parse case supported_versions - when Array - supported_versions.detect {|version| version[:Version] == @version }[:LoginUrl] - when Hash - supported_versions[:LoginUrl] - end - end - - # If we don't support any versions the service does, then raise an error. - # If the @version that super selected isn't in our supported list, then select one that is. - def check_versions - if @version - unless supported_version_numbers.include?(@version.to_s) - raise UnsupportedVersion.new("#{@version} is not supported by the server.") - end - unless supporting_versions.include?(@version.to_s) - raise UnsupportedVersion.new("#{@version} is not supported by #{self.class}") - end + @login_results.body[:Org][:href] else - unless @version = (supported_version_numbers & supporting_versions).sort.first - raise UnsupportedVersion.new("\nService @ #{@versions_uri} supports: #{supported_version_numbers.join(', ')}\n" + - "#{self.class} supports: #{supporting_versions.join(', ')}") - end + nil end end + end - # Don't need to set the cookie for these or retry them if the cookie timed out - def unauthenticated_request(params) - do_request(params) + # login handles the auth, but we just need the Set-Cookie + # header from that call. + def do_login + @login_results = login + @cookie = @login_results.headers['Set-Cookie'] + end + + def ecloud_xmlns + { + "xmlns" => "urn:tmrk:eCloudExtensions-2.6", + "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" + } + end + + def ensure_unparsed(uri) + if uri.is_a?(String) + uri + else + uri.to_s end + end - # Use this to set the Authorization header for login - def authorization_header - "Basic #{Base64.encode64("#{@username}:#{@password}").chomp!}" - end - - def login_uri - @login_uri ||= get_login_uri - end - - # login handles the auth, but we just need the Set-Cookie - # header from that call. - def do_login - @login_results = login - @cookie = @login_results.headers['Set-Cookie'] - end - - # Actually do the request - def do_request(params) - # Convert the uri to a URI if it's a string. - if params[:uri].is_a?(String) - params[:uri] = URI.parse(params[:uri]) - end - host_url = "#{self.scheme}://#{self.host}#{self.port ? ":#{self.port}" : ''}" - - # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to - # different hosts. - @connections[host_url] ||= Fog::Connection.new(host_url, @persistent) - - # Set headers to an empty hash if none are set. - headers = params[:headers] || {} - - # Add our auth cookie to the headers - if @cookie - headers.merge!('Cookie' => @cookie) - end - - # Make the request - response = @connections[host_url].request({ - :body => params[:body] || '', - :expects => params[:expects] || 200, - :headers => headers, - :method => params[:method] || 'GET', - :path => params[:uri].path - }) - - # Parse the response body into a hash - #puts response.body - unless response.body.empty? - if params[:parse] - document = Fog::ToHashDocument.new - parser = Nokogiri::XML::SAX::PushParser.new(document) - parser << response.body - parser.finish - - response.body = document.body - end - end - - response - end + def supported_versions + @supported_versions ||= get_versions(@versions_uri).body[:VersionInfo] + end + def xmlns + { "xmlns" => "http://www.vmware.com/vcloud/v0.8", + "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", + "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" } end end + + class Mock + include Shared + include MockDataClasses + + def self.base_url + "https://fakey.com/api/v0.8b-ext2.6" + end + + def self.data_reset + @mock_data = nil + end + + def self.data( base_url = self.base_url ) + @mock_data ||= MockData.new.tap do |vcloud_mock_data| + vcloud_mock_data.versions.clear + vcloud_mock_data.versions << MockVersion.new(:version => "v0.8b-ext2.6", :supported => true) + + vcloud_mock_data.organizations << MockOrganization.new(:name => "Boom Inc.").tap do |mock_organization| + mock_organization.vdcs << MockVdc.new(:name => "Boomstick").tap do |mock_vdc| + mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 0").tap do |mock_catalog_item| + mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) + end + mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 1").tap do |mock_catalog_item| + mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) + end + mock_vdc.catalog.items << MockCatalogItem.new(:name => "Item 2").tap do |mock_catalog_item| + mock_catalog_item.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) + end + + mock_vdc.networks << MockNetwork.new({ :subnet => "1.2.3.0/24" }, mock_vdc) + mock_vdc.networks << MockNetwork.new({ :subnet => "4.5.6.0/24" }, mock_vdc) + + mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 1", :ip => "1.2.3.3" }, mock_vdc) + mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Broom 2", :ip => "1.2.3.4" }, mock_vdc) + mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Email!", :ip => "1.2.3.10" }, mock_vdc) + end + + 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| + mock_vdc.networks << MockNetwork.new({ :subnet => "7.8.9.0/24" }, mock_vdc) + + mock_vdc.virtual_machines << MockVirtualMachine.new({ :name => "Master Blaster", :ip => "7.8.9.10" }, mock_vdc) + end + end + + vcloud_mock_data.organizations.detect {|o| o.name == "Boom Inc." }.tap do |mock_organization| + mock_organization.vdcs.detect {|v| v.name == "Boomstick" }.tap do |mock_vdc| + mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.3").tap do |mock_public_ip| + mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ + :protocol => "HTTP", + :port => 80, + :name => "Web Site", + :description => "Web Servers", + :redirect_url => "http://fakey.com" + }, mock_public_ip.internet_service_collection + ).tap do |mock_public_ip_service| + 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) + 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) + 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) + end + + mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ + :protocol => "TCP", + :port => 7000, + :name => "An SSH Map", + :description => "SSH 1" + }, mock_public_ip.internet_service_collection + ).tap do |mock_public_ip_service| + 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) + end + end + + mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.4").tap do |mock_public_ip| + mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ + :protocol => "HTTP", + :port => 80, + :name => "Web Site", + :description => "Web Servers", + :redirect_url => "http://fakey.com" + }, mock_public_ip.internet_service_collection + ) + + mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({ + :protocol => "TCP", + :port => 7000, + :name => "An SSH Map", + :description => "SSH 2" + }, mock_public_ip.internet_service_collection + ) + end + + mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.9.7") + + mock_vdc.internet_service_collection.backup_internet_services << MockBackupInternetService.new({ :port => 10000, :protocol => "TCP"}, self) + end + + mock_organization.vdcs.detect {|v| v.name == "Rock-n-Roll" }.tap do |mock_vdc| + mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.99.99.99") + end + end + + vcloud_mock_data.organizations.each do |organization| + organization.vdcs.each do |vdc| + vdc.networks.each do |network| + network[:rnat] = vdc.public_ip_collection.items.first.name + end + vdc.virtual_machines.each do |virtual_machine| + virtual_machine.disks << MockVirtualMachineDisk.new(:size => 25 * 1024) + virtual_machine.disks << MockVirtualMachineDisk.new(:size => 50 * 1024) + end + end + end + end + end + + def initialize(options = {}) + require 'builder' + require 'fog/core/parser' + + @versions_uri = URI.parse('https://vcloud.fakey.com/api/versions') + end + + def mock_data + Fog::Ecloud::Compute::Mock.data + end + + def mock_error(expected, status, body='', headers={}) + raise Excon::Errors::Unauthorized.new("Expected(#{expected}) <=> Actual(#{status})") + end + + def mock_it(status, mock_data, mock_headers = {}) + response = Excon::Response.new + + #Parse the response body into a hash + if mock_data.empty? + response.body = mock_data + else + document = Fog::ToHashDocument.new + parser = Nokogiri::XML::SAX::PushParser.new(document) + parser << mock_data + parser.finish + response.body = document.body + end + + response.status = status + response.headers = mock_headers + response + end + + end + + class Real + include Shared + + class << self + + def basic_request(*args) + self.class_eval <<-EOS, __FILE__,__LINE__ + def #{args[0]}(uri) + request({ + :expects => #{args[1] || 200}, + :method => '#{args[2] || 'GET'}', + :headers => #{args[3] ? args[3].inspect : '{}'}, + :body => '#{args[4] ? args[4] : ''}', + :parse => true, + :uri => uri }) + end + EOS + end + + def unauthenticated_basic_request(*args) + self.class_eval <<-EOS, __FILE__,__LINE__ + def #{args[0]}(uri) + unauthenticated_request({ + :expects => #{args[1] || 200}, + :method => '#{args[2] || 'GET'}', + :headers => #{args[3] ? args[3].inspect : '{}'}, + :parse => true, + :uri => uri }) + end + EOS + end + + end + + def initialize(options = {}) + require 'builder' + require 'fog/core/parser' + + @connections = {} + @versions_uri = URI.parse(options[:ecloud_versions_uri]) + @version = options[:ecloud_version] + @username = options[:ecloud_username] + @password = options[:ecloud_password] + @persistent = options[:persistent] + end + + def default_organization_uri + @default_organization_uri ||= begin + unless @login_results + do_login + end + case @login_results.body[:Org] + when Array + @login_results.body[:Org].first[:href] + when Hash + @login_results.body[:Org][:href] + else + nil + end + end + end + + def reload + @connections.each_value { |k,v| v.reset if v } + end + + # If the cookie isn't set, do a get_organizations call to set it + # and try the request. + # If we get an Unauthorized error, we assume the token expired, re-auth and try again + def request(params) + unless @cookie + do_login + end + begin + do_request(params) + rescue Excon::Errors::Unauthorized => e + do_login + do_request(params) + end + end + + def supporting_versions + ["v0.8b-ext2.6", "0.8b-ext2.6"] + end + + private + + def ensure_parsed(uri) + if uri.is_a?(String) + URI.parse(uri) + else + uri + end + end + + def supported_version_numbers + case supported_versions + when Array + supported_versions.map { |version| version[:Version] } + when Hash + [ supported_versions[:Version] ] + end + end + + def get_login_uri + check_versions + URI.parse case supported_versions + when Array + supported_versions.detect {|version| version[:Version] == @version }[:LoginUrl] + when Hash + supported_versions[:LoginUrl] + end + end + + # If we don't support any versions the service does, then raise an error. + # If the @version that super selected isn't in our supported list, then select one that is. + def check_versions + if @version + unless supported_version_numbers.include?(@version.to_s) + raise UnsupportedVersion.new("#{@version} is not supported by the server.") + end + unless supporting_versions.include?(@version.to_s) + raise UnsupportedVersion.new("#{@version} is not supported by #{self.class}") + end + else + unless @version = (supported_version_numbers & supporting_versions).sort.first + raise UnsupportedVersion.new("\nService @ #{@versions_uri} supports: #{supported_version_numbers.join(', ')}\n" + + "#{self.class} supports: #{supporting_versions.join(', ')}") + end + end + end + + # Don't need to set the cookie for these or retry them if the cookie timed out + def unauthenticated_request(params) + do_request(params) + end + + # Use this to set the Authorization header for login + def authorization_header + "Basic #{Base64.encode64("#{@username}:#{@password}").chomp!}" + end + + def login_uri + @login_uri ||= get_login_uri + end + + # login handles the auth, but we just need the Set-Cookie + # header from that call. + def do_login + @login_results = login + @cookie = @login_results.headers['Set-Cookie'] + end + + # Actually do the request + def do_request(params) + # Convert the uri to a URI if it's a string. + if params[:uri].is_a?(String) + params[:uri] = URI.parse(params[:uri]) + end + host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}" + + # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to + # different hosts. + @connections[host_url] ||= Fog::Connection.new(host_url, @persistent) + + # Set headers to an empty hash if none are set. + headers = params[:headers] || {} + + # Add our auth cookie to the headers + if @cookie + headers.merge!('Cookie' => @cookie) + end + + # Make the request + response = @connections[host_url].request({ + :body => params[:body] || '', + :expects => params[:expects] || 200, + :headers => headers, + :method => params[:method] || 'GET', + :path => params[:uri].path + }) + + # Parse the response body into a hash + #puts response.body + unless response.body.empty? + if params[:parse] + document = Fog::ToHashDocument.new + parser = Nokogiri::XML::SAX::PushParser.new(document) + parser << response.body + parser.finish + + response.body = document.body + end + end + + response + end + + end + end end end diff --git a/lib/fog/compute/models/ecloud/backup_internet_service.rb b/lib/fog/compute/models/ecloud/backup_internet_service.rb new file mode 100644 index 000000000..dad08d5fe --- /dev/null +++ b/lib/fog/compute/models/ecloud/backup_internet_service.rb @@ -0,0 +1,56 @@ +module Fog + module Ecloud + class Compute + class BackupInternetService < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i + + attribute :name, :aliases => :Name + attribute :id, :aliases => :Id + attribute :protocol, :aliases => :Protocol + attribute :enabled, :aliases => :Enabled + attribute :description, :aliases => :Description + attribute :timeout, :aliases => :Timeout + attribute :redirect_url, :aliases => :RedirectURL + attribute :monitor, :aliases => :Monitor + + def delete + requires :href + + connection.delete_internet_service( href ) + end + + def monitor=(new_monitor = {}) + if new_monitor.nil? || new_monitor.empty? + attributes[:monitor] = nil + end + end + + def save + if new_record? + result = connection.add_backup_internet_service( collection.href, _compose_service_data ) + merge_attributes(result.body) + else + connection.configure_backup_internet_service( href, _compose_service_data ) + end + end + + def nodes + @nodes ||= Fog::Ecloud::Compute::Nodes.new( :connection => connection, :href => href + "/nodeServices" ) + end + + private + + def _compose_service_data + #For some reason inject didn't work + service_data = {} + self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| service_data[attribute] = send(attribute) } + service_data + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/backup_internet_services.rb b/lib/fog/compute/models/ecloud/backup_internet_services.rb new file mode 100644 index 000000000..3bea2c836 --- /dev/null +++ b/lib/fog/compute/models/ecloud/backup_internet_services.rb @@ -0,0 +1,33 @@ +require 'fog/compute/models/ecloud/backup_internet_service' + +module Fog + module Ecloud + class Compute + class BackupInternetServices < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::BackupInternetService + + attribute :href, :aliases => :Href + + def all + check_href! :message => "the Internet Services for the Vdc you want to enumerate" + if data = connection.get_internet_services(href).body[:InternetService].find_all {|i| i[:IsBackupService] == "true" } + load(data) + end + end + + # Optimize later, no need to get_internet_services again? + def get(uri) + internet_services = connection.get_internet_services(href).body[:InternetService] + internet_services = [ internet_services ] if internet_services.is_a?(Hash) + if data = internet_services.detect { |service| service[:Href] == uri } + new(data) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/catalog.rb b/lib/fog/compute/models/ecloud/catalog.rb new file mode 100644 index 000000000..96970f927 --- /dev/null +++ b/lib/fog/compute/models/ecloud/catalog.rb @@ -0,0 +1,28 @@ +module Fog + module Ecloud + class Compute + class Catalog < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::CatalogItem + + attribute :href, :aliases => :Href + + def all + check_href! + if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem] + load(data) + end + end + + def get(uri) + if data = connection.get_catalog_item(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/catalog_item.rb b/lib/fog/compute/models/ecloud/catalog_item.rb new file mode 100644 index 000000000..adc31e7c3 --- /dev/null +++ b/lib/fog/compute/models/ecloud/catalog_item.rb @@ -0,0 +1,29 @@ +module Fog + module Ecloud + class Compute + class CatalogItem < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd + + attribute :type + attribute :name + attribute :entity, :aliases => :Entity + attribute :link, :aliases => :Link + attribute :property, :aliases => :Property + + def customization_options + load_unless_loaded! + if data = connection.get_customization_options( link[:href] ).body + data.delete_if { |key, value| [:xmlns_i, :xmlns].include?(key) } + data + else + nil + end + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/firewall_acl.rb b/lib/fog/compute/models/ecloud/firewall_acl.rb new file mode 100644 index 000000000..428c9e23a --- /dev/null +++ b/lib/fog/compute/models/ecloud/firewall_acl.rb @@ -0,0 +1,24 @@ +module Fog + module Ecloud + class Compute + class FirewallAcl < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i + + attribute :name, :aliases => :Name + attribute :id, :aliases => :Id + attribute :protocol, :aliases => :Protocol + attribute :source, :aliases => :Source + attribute :destination, :aliases => :Destination + attribute :permission, :aliases => :Permission + attribute :port_start, :aliases => :PortStart + attribute :port_end, :aliases => :PortEnd + attribute :port_type, :aliases => :PortType + attribute :type, :aliases => :Type + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/firewall_acls.rb b/lib/fog/compute/models/ecloud/firewall_acls.rb new file mode 100644 index 000000000..3adb8d29c --- /dev/null +++ b/lib/fog/compute/models/ecloud/firewall_acls.rb @@ -0,0 +1,31 @@ +require 'fog/compute/models/ecloud/firewall_acl' + +module Fog + module Ecloud + class Compute + class FirewallAcls < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::FirewallAcl + + attribute :href, :aliases => :Href + + def all + check_href! :message => "the Firewall ACL href for the network you want to enumerate" + if data = connection.get_firewall_acls(href).body[:FirewallAcl] + data = [ data ] if data.is_a?(Hash) + load(data) + end + end + + def get(uri) + if data = connection.get_firewall_acl(uri).body + new(data) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/internet_service.rb b/lib/fog/compute/models/ecloud/internet_service.rb new file mode 100644 index 000000000..8fe7c5640 --- /dev/null +++ b/lib/fog/compute/models/ecloud/internet_service.rb @@ -0,0 +1,117 @@ +module Fog + module Ecloud + class Compute + class InternetService < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i + + attribute :name, :aliases => :Name + attribute :id, :aliases => :Id + attribute :protocol, :aliases => :Protocol + attribute :port, :aliases => :Port + attribute :enabled, :aliases => :Enabled + attribute :description, :aliases => :Description + attribute :public_ip, :aliases => :PublicIpAddress + attribute :timeout, :aliases => :Timeout + attribute :redirect_url, :aliases => :RedirectURL + attribute :monitor, :aliases => :Monitor + attribute :backup_service_data, :aliases => :BackupService + + def delete + requires :href + + connection.delete_internet_service( href ) + end + + def save + if new_record? + result = connection.add_internet_service( collection.href, _compose_service_data ) + merge_attributes(result.body) + else + connection.configure_internet_service( href, _compose_service_data, _compose_ip_data ) + end + end + + # disables monitoring for this service + def disable_monitor + if self.monitor and self.monitor[:type] == "Disabled" + raise RuntimeError.new("Monitoring already disabled") + else + self.monitor = {:type => "Disabled", :is_enabled => "true"} + self.save + end + end + + # enable default ping monitoring, use monitor= for more exotic forms (ECV & HTTP) + def enable_ping_monitor + self.monitor = nil + self.save + end + + def monitor=(new_monitor = {}) + if new_monitor.nil? || new_monitor.empty? + attributes[:monitor] = nil + elsif new_monitor.is_a?(Hash) + attributes[:monitor] = {} + attributes[:monitor][:type] = new_monitor[:MonitorType] || new_monitor[:type] + attributes[:monitor][:url_send_string] = new_monitor[:UrlSendString] || new_monitor[:url_send_string] + attributes[:monitor][:http_headers] = new_monitor[:HttpHeader] || new_monitor[:http_headers] + if attributes[:monitor][:http_headers] + if attributes[:monitor][:http_headers].is_a?(String) + attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n") + else + attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers] + end + end + attributes[:monitor][:receive_string] = new_monitor[:ReceiveString] || new_monitor[:receive_string] + attributes[:monitor][:interval] = new_monitor[:Interval] || new_monitor[:interval] + attributes[:monitor][:response_timeout] = new_monitor[:ResponseTimeOut] || new_monitor[:response_timeout] + attributes[:monitor][:downtime] = new_monitor[:DownTime] || new_monitor[:downtime] + attributes[:monitor][:retries] = new_monitor[:Retries] || new_monitor[:retries] + attributes[:monitor][:is_enabled] = new_monitor[:IsEnabled] || new_monitor[:is_enabled] + else + raise RuntimeError.new("monitor needs to either be nil or a Hash") + end + end + + def nodes + @nodes ||= Fog::Ecloud::Compute::Nodes.new( :connection => connection, :href => href + "/nodeServices" ) + end + + def backup_service_uri + if backup_service_data + backup_service_data[:Href] + end + end + + def backup_service_uri=(new_value) + self.backup_service_data = { + :Href => new_value + } + end + + private + + def _compose_service_data + #For some reason inject didn't work + service_data = {} + self.class.attributes.select{ |attribute| attribute != :backup_service_data }.each { |attribute| service_data[attribute] = send(attribute) } + service_data[:backup_service_uri] = backup_service_uri + service_data.reject! {|k, v| v.nil? } + service_data + end + + def _compose_ip_data + if public_ip.nil? + {} + else + { :id => public_ip[:Id], :href => public_ip[:Href], :name => public_ip[:Name] } + end + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/internet_services.rb b/lib/fog/compute/models/ecloud/internet_services.rb new file mode 100644 index 000000000..df2a4140b --- /dev/null +++ b/lib/fog/compute/models/ecloud/internet_services.rb @@ -0,0 +1,33 @@ +require 'fog/compute/models/ecloud/internet_service' + +module Fog + module Ecloud + class Compute + class InternetServices < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::InternetService + + attribute :href, :aliases => :Href + + def all + check_href! :message => "the Internet Services for the Vdc you want to enumerate" + if internet_service_data = connection.get_internet_services(href).body[:InternetService] + load(Array[internet_service_data].flatten.find_all {|i| i[:IsBackupService] == "false" }) + end + end + + # Optimize later, no need to get_internet_services again? + def get(uri) + internet_services = connection.get_internet_services(href).body[:InternetService] + internet_services = [ internet_services ] if internet_services.is_a?(Hash) + if data = internet_services.detect { |service| service[:Href] == uri } + new(data) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/ip.rb b/lib/fog/compute/models/ecloud/ip.rb new file mode 100644 index 000000000..7e156fb05 --- /dev/null +++ b/lib/fog/compute/models/ecloud/ip.rb @@ -0,0 +1,49 @@ +module Fog + module Ecloud + class Compute + class Ip < Fog::Ecloud::Model + + ignore_attributes :xmlns_i, :xmlns + + identity :href, :aliases => :Href + + attribute :name, :aliases => :Name + attribute :status, :aliases => :Status + attribute :server, :aliases => :Server + attribute :rnat, :aliases => :RnatAddress + attribute :id, :aliases => :Id, :type => :integer + + def rnat=(new_rnat) + attributes[:rnat] = new_rnat + @changed = true + end + + def save + if @changed + connection.configure_network_ip( href, _compose_network_ip_data ) + end + true + end + + def reload + super + @changed = false + self + end + + private + def _compose_network_ip_data + { + :id => id, + :href => href, + :name => name, + :status => status, + :server => server, + :rnat => rnat + } + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/ips.rb b/lib/fog/compute/models/ecloud/ips.rb new file mode 100644 index 000000000..2563f67ee --- /dev/null +++ b/lib/fog/compute/models/ecloud/ips.rb @@ -0,0 +1,32 @@ +require 'fog/compute/models/ecloud/ip' + +module Fog + module Ecloud + class Compute + class Ips < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::Ip + + undef_method :create + + attribute :href + + def all + check_href!( :messages => "Ips href of a Network you want to enumerate" ) + if data = connection.get_network_ips(href).body[:IpAddress] + load(data) + end + end + + def get(uri) + if data = connection.get_network_ip(uri).body + new(data) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/network.rb b/lib/fog/compute/models/ecloud/network.rb new file mode 100644 index 000000000..047266d39 --- /dev/null +++ b/lib/fog/compute/models/ecloud/network.rb @@ -0,0 +1,72 @@ +module Fog + module Ecloud + class Compute + class Network < Fog::Ecloud::Model + + identity :href + + ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id + + attribute :name, :aliases => :Name + #attribute :id, :aliases => :Id + attribute :features, :aliases => :Features, :type => :array + attribute :links, :aliases => :Link, :type => :array + attribute :type + attribute :gateway, :aliases => :GatewayAddress + attribute :broadcast, :aliases => :BroadcastAddress + attribute :address, :aliases => :Address + attribute :rnat, :aliases => :RnatAddress + attribute :extension_href, :aliases => :Href + attribute :network_type, :aliases => :NetworkType + attribute :vlan, :aliases => :Vlan + attribute :friendly_name, :aliases => :FriendlyName + + def ips + load_unless_loaded! + Fog::Ecloud::Compute::Ips.new( :connection => connection, + :href => links.detect { |link| link[:name] == "IP Addresses" }[:href] ) + end + + def rnat=(new_rnat) + attributes[:rnat] = new_rnat + @changed = true + end + + def save + if @changed + connection.configure_network( extension_href, _compose_network_data ) + end + true + end + + def reload + super + merge_attributes(extension_data.body) + self + end + + private + + def extension_data + connection.get_network_extensions( extensions_link[:href] ) + end + + def extensions_link + links.detect { |link| link[:name] == name } + end + + def _compose_network_data + { + :id => id, + :href => extension_href, + :name => name, + :rnat => rnat, + :address => address, + :broadcast => broadcast, + :gateway => gateway + } + end + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/networks.rb b/lib/fog/compute/models/ecloud/networks.rb new file mode 100644 index 000000000..50c456a8e --- /dev/null +++ b/lib/fog/compute/models/ecloud/networks.rb @@ -0,0 +1,33 @@ +require 'fog/compute/models/ecloud/network' + +module Fog + module Ecloud + class Compute + + class Networks < Fog::Ecloud::Collection + + undef_method :create + + model Fog::Ecloud::Compute::Network + + attribute :href + + def all + check_href!("Vdc") + if data = connection.get_vdc(href).body[:AvailableNetworks][:Network] + load(data) + end + end + + def get(uri) + if data = connection.get_network(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/node.rb b/lib/fog/compute/models/ecloud/node.rb new file mode 100644 index 000000000..eae3a3782 --- /dev/null +++ b/lib/fog/compute/models/ecloud/node.rb @@ -0,0 +1,43 @@ +module Fog + module Ecloud + class Compute + class Node < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i + + attribute :ip_address, :aliases => :IpAddress + attribute :description, :aliases => :Description + attribute :name, :aliases => :Name + attribute :port, :aliases => :Port + attribute :enabled, :aliases => :Enabled + attribute :id, :aliases => :Id + + def delete + requires :href + + connection.delete_node( href ) + end + + def save + if new_record? + result = connection.add_node( collection.href, _compose_node_data ) + merge_attributes(result.body) + else + connection.configure_node( href, _compose_node_data ) + end + end + + private + + def _compose_node_data + node_data = {} + self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| node_data[attribute] = send(attribute).to_s } + node_data + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/nodes.rb b/lib/fog/compute/models/ecloud/nodes.rb new file mode 100644 index 000000000..9a17829d7 --- /dev/null +++ b/lib/fog/compute/models/ecloud/nodes.rb @@ -0,0 +1,31 @@ +require 'fog/compute/models/ecloud/node' + +module Fog + module Ecloud + class Compute + + class Nodes < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::Node + + attribute :href, :aliases => :Href + + def all + check_href!( :messages => "the Nodes href of the Internet Service you want to enumerate" ) + if data = connection.get_nodes(href).body[:NodeService] + load(data) + end + end + + def get(uri) + if data = connection.get_node(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/public_ip.rb b/lib/fog/compute/models/ecloud/public_ip.rb new file mode 100644 index 000000000..8d205efd8 --- /dev/null +++ b/lib/fog/compute/models/ecloud/public_ip.rb @@ -0,0 +1,22 @@ +module Fog + module Ecloud + class Compute + class PublicIp < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i + + attribute :name, :aliases => :Name + attribute :id, :aliases => :Id + + def internet_services + load_unless_loaded! + @internet_services ||= Fog::Ecloud::Compute::InternetServices. + new( :connection => connection, + :href => href.to_s + "/internetServices" ) + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/compute/models/ecloud/public_ips.rb b/lib/fog/compute/models/ecloud/public_ips.rb new file mode 100644 index 000000000..e0c1b35cf --- /dev/null +++ b/lib/fog/compute/models/ecloud/public_ips.rb @@ -0,0 +1,36 @@ +require 'fog/compute/models/ecloud/public_ip' + +module Fog + module Ecloud + class Compute + class PublicIps < Fog::Ecloud::Collection + + undef_method :create + + attribute :href, :aliases => :Href + + model Fog::Ecloud::Compute::PublicIp + + #get_request :get_public_ip + #vcloud_type "application/vnd.tmrk.ecloud.publicIp+xml" + #all_request lambda { |public_ips| public_ips.connection.get_public_ips(public_ips.href) } + + def all + check_href!(:message => "the Public Ips href of the Vdc you want to enumerate") + if data = connection.get_public_ips(href).body[:PublicIPAddress] + load(data) + end + end + + def get(uri) + if data = connection.get_public_ip(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/server.rb b/lib/fog/compute/models/ecloud/server.rb new file mode 100644 index 000000000..040acba3d --- /dev/null +++ b/lib/fog/compute/models/ecloud/server.rb @@ -0,0 +1,209 @@ +module Fog + module Ecloud + class Compute + class Server < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd + + attribute :type + attribute :name + attribute :status + attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection + attribute :os, :aliases => :OperatingSystemSection + attribute :virtual_hardware, :aliases => :VirtualHardwareSection + attribute :storage_size, :aliases => :size + attribute :links, :aliases => :Link, :type => :array + + def friendly_status + load_unless_loaded! + case status + when '0' + 'creating' + when '2' + 'off' + when '4' + 'on' + else + 'unkown' + end + end + + def ready? + load_unless_loaded! + status == '2' + end + + def on? + load_unless_loaded! + status == '4' + end + + def off? + load_unless_loaded! + status == '2' + end + + def power_on + power_operation( :power_on => :powerOn ) + end + + def power_off + power_operation( :power_off => :powerOff ) + end + + def shutdown + power_operation( :power_shutdown => :shutdown ) + end + + def power_reset + power_operation( :power_reset => :reset ) + end + + def graceful_restart + requires :href + shutdown + wait_for { off? } + power_on + end + + def delete + requires :href + connection.delete_vapp( href) + end + + def name=(new_name) + attributes[:name] = new_name + @changed = true + end + + def cpus + if cpu_mess + { :count => cpu_mess[:VirtualQuantity].to_i, + :units => cpu_mess[:AllocationUnits] } + end + end + + def cpus=(qty) + @changed = true + cpu_mess[:VirtualQuantity] = qty.to_s + end + + def memory + if memory_mess + { :amount => memory_mess[:VirtualQuantity].to_i, + :units => memory_mess[:AllocationUnits] } + end + end + + def memory=(amount) + @changed = true + memory_mess[:VirtualQuantity] = amount.to_s + end + + def disks + disk_mess.map do |dm| + { :number => dm[:AddressOnParent], :size => dm[:VirtualQuantity].to_i, :resource => dm[:HostResource] } + end + end + + def add_disk(size) + if @disk_change == :deleted + raise RuntimeError, "Can't add a disk w/o saving changes or reloading" + else + @disk_change = :added + load_unless_loaded! + virtual_hardware[:Item] << { :ResourceType => '17', + :AddressOnParent => (disk_mess.map { |dm| dm[:AddressOnParent] }.sort.last.to_i + 1).to_s, + :VirtualQuantity => size.to_s } + end + true + end + + def delete_disk(number) + if @disk_change == :added + raise RuntimeError, "Can't delete a disk w/o saving changes or reloading" + else + @disk_change = :deleted + load_unless_loaded! + unless number == 0 + virtual_hardware[:Item].delete_if { |vh| vh[:ResourceType] == '17' && vh[:AddressOnParent].to_i == number } + end + end + true + end + + def reload + reset_tracking + super + end + + def save + if new_record? + #Lame ... + raise RuntimeError, "Should not be here" + else + if on? + if @changed + raise RuntimeError, "Can't save cpu, name or memory changes while the VM is on." + end + end + connection.configure_vapp( href, _compose_vapp_data ) + end + reset_tracking + end + + private + + def reset_tracking + @disk_change = false + @changed = false + end + + def _compose_vapp_data + { :name => name, + :cpus => cpus[:count], + :memory => memory[:amount], + :disks => disks + } + end + + def memory_mess + load_unless_loaded! + if virtual_hardware && virtual_hardware[:Item] + virtual_hardware[:Item].detect { |item| item[:ResourceType] == "4" } + end + end + + def cpu_mess + load_unless_loaded! + if virtual_hardware && virtual_hardware[:Item] + virtual_hardware[:Item].detect { |item| item[:ResourceType] == "3" } + end + end + + def disk_mess + load_unless_loaded! + if virtual_hardware && virtual_hardware[:Item] + virtual_hardware[:Item].select { |item| item[:ResourceType] == "17" } + else + [] + end + end + + def power_operation(op) + requires :href + begin + connection.send(op.keys.first, href + "/power/action/#{op.values.first}" ) + rescue Excon::Errors::InternalServerError => e + #Frankly we shouldn't get here ... + raise e unless e.to_s =~ /because it is already powered o(n|ff)/ + end + true + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/servers.rb b/lib/fog/compute/models/ecloud/servers.rb new file mode 100644 index 000000000..16f537a58 --- /dev/null +++ b/lib/fog/compute/models/ecloud/servers.rb @@ -0,0 +1,55 @@ +require 'fog/compute/models/ecloud/server' + +module Fog + module Ecloud + class Compute + + class Servers < Fog::Ecloud::Collection + + undef_method :create + + model Fog::Ecloud::Compute::Server + + attribute :href, :aliases => :Href + + def all + check_href!(:parent => "Vdc") + load(_vapps) + end + + def get(uri) + if data = connection.get_vapp(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + def create( catalog_item_uri, options ) + options[:vdc_uri] = href + options[:cpus] ||= 1 + options[:memory] ||= 512 + data = connection.instantiate_vapp_template( catalog_item_uri, options ).body + object = new(data) + object + end + + private + + def _resource_entities + connection.get_vdc(href).body[:ResourceEntities][:ResourceEntity] + end + + def _vapps + resource_entities = _resource_entities + if resource_entities.nil? + [] + else + resource_entities + end + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/task.rb b/lib/fog/compute/models/ecloud/task.rb new file mode 100644 index 000000000..6210bae44 --- /dev/null +++ b/lib/fog/compute/models/ecloud/task.rb @@ -0,0 +1,21 @@ +module Fog + module Ecloud + class Compute + class Task < Fog::Ecloud::Model + + identity :href, :aliases => :Href + + ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd + + attribute :status + attribute :type + attribute :result, :aliases => :Result + attribute :owner, :aliases => :Owner + attribute :start_time, :aliases => :startTime, :type => :time + attribute :end_time, :aliases => :endTime, :type => :time + attribute :error, :aliases => :Error + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/tasks.rb b/lib/fog/compute/models/ecloud/tasks.rb new file mode 100644 index 000000000..c33375462 --- /dev/null +++ b/lib/fog/compute/models/ecloud/tasks.rb @@ -0,0 +1,31 @@ +require 'fog/compute/models/ecloud/task' + +module Fog + module Ecloud + class Compute + + class Tasks < Fog::Ecloud::Collection + + model Fog::Ecloud::Compute::Task + + attribute :href, :aliases => :Href + + def all + check_href! + if data = connection.get_task_list(href).body[:Task] + load(data) + end + end + + def get(uri) + if data = connection.get_task(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/vdc.rb b/lib/fog/compute/models/ecloud/vdc.rb new file mode 100644 index 000000000..fce01de90 --- /dev/null +++ b/lib/fog/compute/models/ecloud/vdc.rb @@ -0,0 +1,81 @@ +module Fog + module Ecloud + class Compute + class Vdc < Fog::Ecloud::Model + + identity :href + + ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd + + attribute :name + attribute :type + attribute :description, :aliases => :Description + attribute :other_links, :aliases => :Link + attribute :compute_capacity, :aliases => :ComputeCapacity + attribute :storage_capacity, :aliases => :StorageCapacity + attribute :available_networks, :aliases => :AvailableNetworks, :squash => :Network + attribute :resource_entities, :aliases => :ResourceEntities, :squash => :ResourceEntity + attribute :deployed_vm_quota + attribute :instantiated_vm_quota + + def public_ips + @public_ips ||= collection_based_on_type("application/vnd.tmrk.ecloud.publicIpsList+xml") + end + + def internet_services + @internet_services ||= collection_based_on_type("application/vnd.tmrk.ecloud.internetServicesList+xml") + end + + def backup_internet_services + @backup_internet_services ||= collection_based_on_type("application/vnd.tmrk.ecloud.internetServicesList+xml", BackupInternetServices) + end + + def networks + @networks ||= Fog::Ecloud::Compute::Networks. + new( :connection => connection, + :href => href ) + end + + def servers + @servers ||= Fog::Ecloud::Compute::Servers. + new( :connection => connection, + :href => href ) + end + + def tasks + @tasks ||= Fog::Ecloud::Compute::Tasks. + new( :connection => connection, + :href => href + "/tasksList" ) + end + + def catalog + @catalog ||= collection_based_on_type("application/vnd.vmware.vcloud.catalog+xml") + end + + def firewall_acls + @firewall_acls ||= collection_based_on_type("application/vnd.tmrk.ecloud.firewallAclsList+xml") + end + + private + + def collection_based_on_type(type, klass = nil) + load_unless_loaded! + if link = other_links.detect { |link| link[:type] == type } + case type + when "application/vnd.tmrk.ecloud.publicIpsList+xml" + Fog::Ecloud::Compute::PublicIps + when "application/vnd.tmrk.ecloud.internetServicesList+xml" + klass || Fog::Ecloud::Compute::InternetServices + when "application/vnd.vmware.vcloud.catalog+xml" + Fog::Ecloud::Compute::Catalog + when "application/vnd.tmrk.ecloud.firewallAclsList+xml" + Fog::Ecloud::Compute::FirewallAcls + end.new( :connection => connection, :href => link[:href] ) + else + [ ] + end + end + end + end + end +end diff --git a/lib/fog/compute/models/ecloud/vdcs.rb b/lib/fog/compute/models/ecloud/vdcs.rb new file mode 100644 index 000000000..55d3fd37f --- /dev/null +++ b/lib/fog/compute/models/ecloud/vdcs.rb @@ -0,0 +1,40 @@ +require 'fog/compute/models/ecloud/vdc' + +module Fog + module Ecloud + class Compute + + class Vdcs < Collection + + model Fog::Ecloud::Compute::Vdc + + undef_method :create + + def all + data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" } + data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } } + load(data) + end + + def get(uri) + if data = connection.get_vdc(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + def organization_uri + @organizatio_uri ||= connection.default_organization_uri + end + + private + + def organization_uri=(new_organization_uri) + @organization_uri = new_organization_uri + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/add_backup_internet_service.rb b/lib/fog/compute/requests/ecloud/add_backup_internet_service.rb new file mode 100644 index 000000000..279940374 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/add_backup_internet_service.rb @@ -0,0 +1,109 @@ +module Fog + module Ecloud + class Compute + module Shared + def validate_backup_internet_service_data(service_data, configure=false) + required_opts = [:name, :protocol, :description, :enabled] + if configure + required_opts + [ :id, :href, :timeout ] + end + unless required_opts.all? { |opt| service_data.keys.include?(opt) } + raise ArgumentError.new("Required Backup Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def add_backup_internet_service(internet_services_uri, service_data) + validate_backup_internet_service_data(service_data) + if monitor = service_data[:monitor] + validate_internet_service_monitor(monitor) + ensure_monitor_defaults!(monitor) + end + + request( + :body => generate_backup_internet_service_request(service_data), + :expects => 200, + :headers => {'Content-Type' => 'application/xml'}, + :method => 'POST', + :uri => internet_services_uri, + :parse => true + ) + end + + private + + def generate_backup_internet_service_request(service_data) + builder = Builder::XmlMarkup.new + builder.CreateBackupInternetServiceRequest("xmlns" => "urn:tmrk:eCloudExtensions-2.5") { + builder.Name(service_data[:name]) + builder.Protocol(service_data[:protocol]) + builder.Enabled(service_data[:enabled]) + builder.Description(service_data[:description]) + builder.RedirectURL(service_data[:redirect_url]) + if monitor = service_data[:monitor] + generate_monitor_section(builder,monitor) + end + } + end + end + + class Mock + include Shared + + # + # Based on + # http://support.theenterprisecloud.com/kb/default.asp?id=729&Lang=1&SID= + # and many tears shed. + # + + def add_backup_internet_service(internet_services_uri, service_data) + validate_backup_internet_service_data(service_data) + + internet_services_uri = ensure_unparsed(internet_services_uri) + + if vdc_internet_service_collection = mock_data.vdc_internet_service_collection_from_href(internet_services_uri) + new_backup_internet_service = MockBackupInternetService.new(service_data, vdc_internet_service_collection.backup_internet_services) + vdc_internet_service_collection.backup_internet_services << new_backup_internet_service + xml = generate_backup_internet_service_added_response(new_backup_internet_service) + + mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + + private + + def generate_backup_internet_service_added_response(new_backup_internet_service) + builder = Builder::XmlMarkup.new + builder.InternetService("xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") { + builder.Id new_backup_internet_service.object_id + builder.Href new_backup_internet_service.href + builder.Name new_backup_internet_service.name + # so broken + builder.PublicIpAddress do + builder.Id -2147483648 + builder.Id "http://totally.invalid/1234" + builder.Name + end + builder.Port new_backup_internet_service.port + builder.Protocol new_backup_internet_service.protocol + builder.Enabled new_backup_internet_service.enabled + builder.Timeout new_backup_internet_service.timeout + builder.Description new_backup_internet_service.description + builder.RedirectURL new_backup_internet_service.redirect_url + builder.Monitor "i:nil" => true + # so broken + builder.IsBackupService false + builder.BackupService "i:nil" => true + builder.BackupOf "i:nil" => true + } + end + end + end + end +end + diff --git a/lib/fog/compute/requests/ecloud/add_internet_service.rb b/lib/fog/compute/requests/ecloud/add_internet_service.rb new file mode 100644 index 000000000..7b51aff38 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/add_internet_service.rb @@ -0,0 +1,149 @@ +module Fog + module Ecloud + class Compute + module Shared + def validate_internet_service_monitor(monitor) + #FIXME: Refactor this type of function into something generic + unless ['Disabled','HTTP','ECV'].include?(monitor[:type]) + raise ArgumentError.new("Supported monitor types are: ECV & HTTP") + end + + required_opts = case monitor[:type] + when "Disabled" + [:type, :is_enabled] + else + [:type, :url_send_string, :http_headers, :receive_string, :is_enabled] + end + + unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] } + raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}") + end + + case monitor[:type] + when "HTTP", "ECV" + unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String) + raise ArgumentError.new("Monitor :http_headers must be a String or Array") + end + end + + unless [true, false, "true", "false"].include?(monitor[:is_enabled]) + raise ArgumentError.new("Monitor :is_enabled must be true or false") + end + end + + def validate_internet_service_data(service_data, configure=false) + required_opts = [:name, :protocol, :port, :description, :enabled] + if configure + required_opts + [ :id, :href, :timeout ] + end + unless required_opts.all? { |opt| service_data.keys.include?(opt) } + raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") + end + end + + def ensure_monitor_defaults!(monitor) + if monitor[:http_headers].is_a?(String) + monitor[:http_headers] = [ monitor[:http_headers] ] + end + + unless monitor[:retries] + monitor[:retries] = 3 + end + + unless monitor[:response_timeout] + monitor[:response_timeout] = 2 + end + + unless monitor[:down_time] + monitor[:down_time] = 30 + end + + unless monitor[:interval] + monitor[:interval] = 5 + end + end + end + + class Real + include Shared + + def add_internet_service(internet_services_uri, service_data) + validate_internet_service_data(service_data) + if monitor = service_data[:monitor] + validate_internet_service_monitor(monitor) + ensure_monitor_defaults!(monitor) + end + + request( + :body => generate_internet_service_request(service_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}, + :method => 'POST', + :uri => internet_services_uri, + :parse => true + ) + end + + private + + def generate_internet_service_request(service_data) + builder = Builder::XmlMarkup.new + builder.CreateInternetServiceRequest(ecloud_xmlns) { + builder.Name(service_data[:name]) + builder.Protocol(service_data[:protocol]) + builder.Port(service_data[:port]) + builder.Enabled(service_data[:enabled]) + builder.Description(service_data[:description]) + builder.RedirectURL(service_data[:redirect_url]) + if monitor = service_data[:monitor] + generate_monitor_section(builder,monitor) + end + } + end + + def generate_monitor_section(builder, monitor) + builder.Monitor { + builder.MonitorType(monitor[:type]) + case monitor[:type] + when "ECV","HTTP" + builder.UrlSendString(monitor[:url_send_string]) + builder.HttpHeader(monitor[:http_headers].join("\n")) + builder.ReceiveString(monitor[:receive_string]) + builder.Interval(monitor[:interval]) + builder.ResponseTimeOut(monitor[:response_timeout]) + builder.DownTime(monitor[:downtime]) + builder.Retries(monitor[:retries]) + end + builder.IsEnabled(monitor[:is_enabled]) + } + end + + end + + class Mock + include Shared + + # + # Based on + # http://support.theenterprisecloud.com/kb/default.asp?id=561&Lang=1&SID= + # + + def add_internet_service(internet_services_uri, service_data) + validate_internet_service_data(service_data) + + internet_services_uri = ensure_unparsed(internet_services_uri) + + if public_ip_internet_service_collection = mock_data.public_ip_internet_service_collection_from_href(internet_services_uri) + new_public_ip_internet_service = MockPublicIpInternetService.new(service_data, public_ip_internet_service_collection) + public_ip_internet_service_collection.items << new_public_ip_internet_service + xml = generate_internet_service(Builder::XmlMarkup.new, new_public_ip_internet_service, true) + + mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/add_node.rb b/lib/fog/compute/requests/ecloud/add_node.rb new file mode 100644 index 000000000..833919079 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/add_node.rb @@ -0,0 +1,62 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def generate_node_request(node_data) + builder = Builder::XmlMarkup.new + builder.CreateNodeServiceRequest(ecloud_xmlns) { + builder.IpAddress(node_data[:ip_address]) + builder.Name(node_data[:name]) + builder.Port(node_data[:port]) + builder.Enabled(node_data[:enabled]) + builder.Description(node_data[:description]) + } + end + + def validate_node_data(node_data, configure=false) + valid_opts = [:name, :port, :enabled, :description, :ip_address] + if configure + valid_opts.delete_if { |opt| ![:name, :enabled, :description].include?(opt) } + end + unless valid_opts.all? { |opt| node_data.keys.include?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - node_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def add_node(nodes_uri, node_data) + validate_node_data(node_data) + + request( + :body => generate_node_request(node_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'}, + :method => 'POST', + :uri => nodes_uri, + :parse => true + ) + end + end + + class Mock + include Shared + + def add_node(nodes_uri, node_data) + validate_node_data(node_data) + if node_collection = mock_data.public_ip_internet_service_node_collection_from_href(ensure_unparsed(nodes_uri)) + new_node = MockPublicIpInternetServiceNode.new(node_data, node_collection) + node_collection.items << new_node + mock_it 200, mock_node_service_response(new_node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/clone_vapp.rb b/lib/fog/compute/requests/ecloud/clone_vapp.rb new file mode 100644 index 000000000..b070a97f7 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/clone_vapp.rb @@ -0,0 +1,40 @@ +module Fog + module Ecloud + class Compute + class Real + + def validate_clone_vapp_options(options) + valid_opts = [:name, :poweron] + unless valid_opts.all? { |opt| options.keys.include?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}") + end + end + + def generate_clone_vapp_request(uri, options) + xml = Builder::XmlMarkup.new + xml.CloneVAppParams(xmlns.merge!(:name => options[:name], :deploy => "true", :powerOn => options[:poweron])) { + xml.VApp( :href => uri, :type => "application/vnd.vmware.vcloud.vApp+xml", + :xmlns => "http://www.vmware.com/vcloud/v0.8") + } + end + + def clone_vapp(vdc_uri, vapp_uri, options = {}) + unless options.has_key?(:poweron) + options[:poweron] = "false" + end + + validate_clone_vapp_options(options) + + request( + :body => generate_clone_vapp_request(vapp_uri, options), + :expects => 202, + :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneVAppParams+xml'}, + :method => 'POST', + :uri => vdc_uri + '/action/clonevapp', + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/configure_internet_service.rb b/lib/fog/compute/requests/ecloud/configure_internet_service.rb new file mode 100644 index 000000000..48147e7a6 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/configure_internet_service.rb @@ -0,0 +1,112 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def validate_public_ip_address_data(ip_address_data) + valid_opts = [:name, :href, :id] + unless valid_opts.all? { |opt| ip_address_data.keys.include?(opt) } + raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - ip_address_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def configure_internet_service(internet_service_uri, service_data, ip_address_data) + validate_internet_service_data(service_data, true) + + validate_public_ip_address_data(ip_address_data) + + if monitor = service_data[:monitor] + validate_internet_service_monitor(monitor) + ensure_monitor_defaults!(monitor) + end + + request( + :body => generate_configure_internet_service_request(service_data, ip_address_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}, + :method => 'PUT', + :uri => internet_service_uri, + :parse => true + ) + end + + private + + def generate_configure_internet_service_request(service_data, ip_address_data) + builder = Builder::XmlMarkup.new + builder.InternetService(ecloud_xmlns) { + builder.Id(service_data[:id]) + builder.Href(service_data[:href]) + builder.Name(service_data[:name]) + builder.Protocol(service_data[:protocol]) + builder.Port(service_data[:port]) + builder.Enabled(service_data[:enabled]) + builder.Description(service_data[:description]) + builder.Timeout(service_data[:timeout]) + builder.RedirectURL(service_data[:redirect_url]) + builder.PublicIpAddress { + builder.Id(ip_address_data[:id]) + builder.Href(ip_address_data[:href]) + builder.Name(ip_address_data[:name]) + } + if monitor = service_data[:monitor] + generate_monitor_section(builder, monitor) + end + if service_data[:backup_service_uri] + builder.BackupService do + builder.Href(service_data[:backup_service_uri]) + end + end + } + end + end + + class Mock + include Shared + + # + # Based on + # http://support.theenterprisecloud.com/kb/default.asp?id=583&Lang=1&SID= + # + + def configure_internet_service(internet_service_uri, service_data, ip_address_data) + service_data = service_data.dup + + validate_internet_service_data(service_data, true) + + if monitor = service_data[:monitor] + validate_internet_service_monitor(monitor) + ensure_monitor_defaults!(monitor) + end + + validate_public_ip_address_data(ip_address_data) + + internet_service_uri = ensure_unparsed(internet_service_uri) + + backup_service_uri = service_data.delete(:backup_service_uri) + backup_service = backup_service_uri && mock_data.backup_internet_service_from_href(backup_service_uri) + + xml = nil + + if (public_ip_internet_service = mock_data.public_ip_internet_service_from_href(internet_service_uri)) && + (backup_service_uri.nil? || backup_service) + public_ip_internet_service.update(service_data.reject {|k, v| [:id, :href].include?(k) }) + public_ip_internet_service[:backup_service] = backup_service + xml = generate_internet_service(Builder::XmlMarkup.new, public_ip_internet_service, true) + end + + if xml + mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/configure_network.rb b/lib/fog/compute/requests/ecloud/configure_network.rb new file mode 100644 index 000000000..b9993825b --- /dev/null +++ b/lib/fog/compute/requests/ecloud/configure_network.rb @@ -0,0 +1,44 @@ +module Fog + module Ecloud + class Compute + class Real + + def validate_network_data(network_data, configure=false) + valid_opts = [:id, :href, :name, :rnat, :address, :broadcast, :gateway] + unless valid_opts.all? { |opt| network_data.keys.include?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - network_data.keys).map(&:inspect).join(", ")}") + end + end + + def configure_network(network_uri, network_data) + validate_network_data(network_data) + + request( + :body => generate_configure_network_request(network_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.networkService+xml'}, + :method => 'PUT', + :uri => network_uri, + :parse => true + ) + end + + private + + def generate_configure_network_request(network_data) + builder = Builder::XmlMarkup.new + builder.Network(ecloud_xmlns) { + builder.Id(network_data[:id]) + builder.Href(network_data[:href]) + builder.Name(network_data[:name]) + builder.RnatAddress(network_data[:rnat]) + builder.Address(network_data[:address]) + builder.BroadcastAddress(network_data[:broadcast]) + builder.GatewayAddress(network_data[:gateway]) + } + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/configure_network_ip.rb b/lib/fog/compute/requests/ecloud/configure_network_ip.rb new file mode 100644 index 000000000..ee4f3df71 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/configure_network_ip.rb @@ -0,0 +1,66 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def validate_network_ip_data(network_ip_data) + valid_opts = [:id, :href, :name, :status, :server, :rnat] + unless valid_opts.all? { |opt| network_ip_data.keys.include?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - network_ip_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def configure_network_ip(network_ip_uri, network_ip_data) + validate_network_ip_data(network_ip_data) + + request( + :body => generate_configure_network_ip_request(network_ip_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' }, + :method => 'PUT', + :uri => network_ip_uri, + :parse => true + ) + end + + private + + def generate_configure_network_ip_request(network_ip_data) + builder = Builder::XmlMarkup.new + builder.IpAddress(ecloud_xmlns) { + builder.Id(network_ip_data[:id]) + builder.Href(network_ip_data[:href]) + builder.Name(network_ip_data[:name]) + builder.Status(network_ip_data[:status]) + builder.Server(network_ip_data[:server]) + builder.RnatAddress(network_ip_data[:rnat]) + } + end + end + + class Mock + include Shared + + def configure_network_ip(network_ip_uri, network_ip_data) + validate_network_ip_data(network_ip_data) + + if network_ip = mock_data.network_ip_from_href(network_ip_uri) + network_ip[:rnat] = network_ip_data[:rnat] + + builder = Builder::XmlMarkup.new + xml = network_ip_response(builder, network_ip, ecloud_xmlns) + + mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/configure_node.rb b/lib/fog/compute/requests/ecloud/configure_node.rb new file mode 100644 index 000000000..44b525412 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/configure_node.rb @@ -0,0 +1,56 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def generate_configure_node_request(node_data) + builder = Builder::XmlMarkup.new + builder.NodeService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance", + :xmlns => "urn:tmrk:eCloudExtensions-2.0") { + builder.Name(node_data[:name]) + builder.Enabled(node_data[:enabled].to_s) + builder.Description(node_data[:description]) + } + end + + end + + class Real + include Shared + + def configure_node(node_uri, node_data) + validate_node_data(node_data, true) + + request( + :body => generate_configure_node_request(node_data), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'}, + :method => 'PUT', + :uri => node_uri, + :parse => true + ) + end + + end + + class Mock + include Shared + + def configure_node(node_uri, node_data) + validate_node_data(node_data, true) + + if node = mock_data.public_ip_internet_service_node_from_href(ensure_unparsed(node_uri)) + node.update(node_data) + #if node_data[:enabled] + # node.enabled = (node_data[:enabled] == "true") ? true : false + #end + mock_it 200, mock_node_service_response(node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/configure_vapp.rb b/lib/fog/compute/requests/ecloud/configure_vapp.rb new file mode 100644 index 000000000..53b744af5 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/configure_vapp.rb @@ -0,0 +1,144 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def validate_vapp_data(vapp_data) + valid_opts = [:name, :cpus, :memory, :disks] + unless valid_opts.all? { |opt| vapp_data.keys.include?(opt) } + raise ArgumentError.new("Required Vapp data missing: #{(valid_opts - vapp_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def generate_configure_vapp_request(vapp_uri, vapp_data) + rasd_xmlns = { "xmlns" => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" } + + xml = Nokogiri::XML(request( :uri => vapp_uri).body) + xml.root['name'] = vapp_data[:name] + + #cpu + xml.at("//xmlns:ResourceType[.='3']/..", rasd_xmlns).at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:cpus] + + #memory + xml.at("//xmlns:ResourceType[.='4']/..", rasd_xmlns).at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:memory] + + #disks + real_disks = xml.xpath("//xmlns:ResourceType[ .='17']/..", rasd_xmlns) + real_disk_numbers = real_disks.map { |disk| disk.at('.//xmlns:AddressOnParent', rasd_xmlns).content } + disk_numbers = vapp_data[:disks].map { |vdisk| vdisk[:number].to_s } + + if vapp_data[:disks].length < real_disks.length + #Assume we're removing a disk + remove_disk_numbers = real_disk_numbers - disk_numbers + remove_disk_numbers.each do |number| + if result = xml.at("//xmlns:ResourceType[ .='17']/../xmlns:AddressOnParent[.='#{number}']/..", rasd_xmlns) + result.remove + end + end + elsif vapp_data[:disks].length > real_disks.length + add_disk_numbers = disk_numbers - real_disk_numbers + + add_disk_numbers.each do |number| + new_disk = real_disks.first.dup + new_disk.at('.//xmlns:AddressOnParent', rasd_xmlns).content = -1 + new_disk.at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:disks].detect { |disk| disk[:number].to_s == number.to_s }[:size] + real_disks.first.parent << new_disk + end + end + + #puts xml.root.to_s + xml.root.to_s + + #builder = Builder::XmlMarkup.new + #builder.Vapp(:href => vapp_uri.to_s, + # :type => 'application/vnd.vmware.vcloud.vApp+xml', + # :name => vapp_data[:name], + # :status => 2, + # :size => 0, + # :xmlns => 'http://www.vmware.com/vcloud/v0.8', + # :"xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance', + # :"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema') { + # #builder.VirtualHardwareSection(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { + # builder.Section(:"xsi:type" => "q2:VirtualHardwareSection_Type", :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"xmlns:q2" => "http://www.vmware.com/vcloud/v0.8") { + # builder.Info('Virtual Hardware') + # builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { + # #builder.Item { + # builder.InstanceID(1, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.ResourceType(3, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.VirtualQuantity(vapp_data[:cpus], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # } + # builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { + # #builder.Item { + # builder.InstanceID(2, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.ResourceType(4, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.VirtualQuantity(vapp_data[:memory], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # } + # vapp_data[:disks].each do |disk_data| + # #builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { + # builder.Item { + # builder.AddressOnParent(disk_data[:number], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.HostResource(disk_data[:resource], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.InstanceID(9, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.ResourceType(17, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # builder.VirtualQuantity(disk_data[:size], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') + # } + # end + # + # } + #} + end + + def configure_vapp(vapp_uri, vapp_data) + validate_vapp_data(vapp_data) + + request( + :body => generate_configure_vapp_request(vapp_uri, vapp_data), + :expects => 202, + :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vApp+xml' }, + :method => 'PUT', + :uri => vapp_uri, + :parse => true + ) + end + + end + + class Mock + include Shared + + def configure_vapp(vapp_uri, vapp_data) + validate_vapp_data(vapp_data) + + if vapp = mock_data.virtual_machine_from_href(vapp_uri) + vapp_data.each do |key, value| + case key + when :cpus, :memory + vapp[key] = value + when :disks + addresses_to_delete = vapp.disks.map {|d| d.address } - value.map {|d| d[:number] } + addresses_to_delete.each do |address_to_delete| + vapp.disks.delete(vapp.disks.at_address(address_to_delete)) + end + + current_addresses = vapp.disks.map {|d| d.address } + disks_to_add = value.find_all {|d| !current_addresses.include?(d[:number]) } + disks_to_add.each do |disk_to_add| + vapp.disks << MockVirtualMachineDisk.new(:size => disk_to_add[:size] / 1024, :address => disk_to_add[:number]) + end + end + end + + mock_it 200, '', { "Location" => mock_data.base_url + "/some_tasks/1234" } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/delete_internet_service.rb b/lib/fog/compute/requests/ecloud/delete_internet_service.rb new file mode 100644 index 000000000..cfee21ea0 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/delete_internet_service.rb @@ -0,0 +1,22 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :delete_internet_service, 200, 'DELETE', {}, "" + end + + class Mock + def delete_internet_service(service_uri) + if public_ip_internet_service = mock_data.public_ip_internet_service_from_href(service_uri) + public_ip_internet_service._parent.items.delete(public_ip_internet_service) + + mock_it 200, '', { } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/delete_node.rb b/lib/fog/compute/requests/ecloud/delete_node.rb new file mode 100644 index 000000000..05883d42f --- /dev/null +++ b/lib/fog/compute/requests/ecloud/delete_node.rb @@ -0,0 +1,22 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :delete_node, 200, 'DELETE', {}, "" + end + + class Mock + + def delete_node(node_uri) + if node = mock_data.public_ip_internet_service_node_from_href(ensure_unparsed(node_uri)) + node._parent.items.delete(node) + mock_it 200, '', {} + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/delete_vapp.rb b/lib/fog/compute/requests/ecloud/delete_vapp.rb new file mode 100644 index 000000000..764c8ca83 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/delete_vapp.rb @@ -0,0 +1,29 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :delete_vapp, 202, "DELETE" + end + + class Mock + def delete_vapp(vapp_uri) + if virtual_machine = mock_data.virtual_machine_from_href(vapp_uri) + vdc = virtual_machine._parent + + if vdc.internet_service_collection.items.detect {|is| is.node_collection.items.any? {|isn| isn.ip_address == virtual_machine.ip } } || + virtual_machine.status != 2 || + virtual_machine.network_ip.rnat_set? + mock_it 202, '', {} + else + vdc.virtual_machines.delete(virtual_machine) + mock_it 202, '', { "Location" => mock_data.base_url + "/some_tasks/1234" } + end + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/compute/requests/ecloud/get_catalog.rb b/lib/fog/compute/requests/ecloud/get_catalog.rb new file mode 100644 index 000000000..42662e0a2 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_catalog.rb @@ -0,0 +1,44 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_catalog + end + + class Mock + def get_catalog(catalog_uri) + catalog_uri = ensure_unparsed(catalog_uri) + xml = nil + + if catalog = mock_data.catalog_from_href(catalog_uri) + builder = Builder::XmlMarkup.new + + xml = builder.Catalog(xmlns.merge( + :type => "application/vnd.vmware.vcloud.catalog+xml", + :href => catalog.href, + :name => catalog.name + )) do |xml| + xml.CatalogItems do |xml| + catalog.items.each do |catalog_item| + xml.CatalogItem( + :type => "application/vnd.vmware.vcloud.catalogItem+xml", + :href => catalog_item.href, + :name => catalog_item.name + ) + end + end + end + end + + if xml + mock_it 200, + xml, { 'Content-Type' => 'application/vnd.vmware.vcloud.catalog+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_catalog_item.rb b/lib/fog/compute/requests/ecloud/get_catalog_item.rb new file mode 100644 index 000000000..6b8fb7d69 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_catalog_item.rb @@ -0,0 +1,47 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_catalog_item + end + + class Mock + + # + # Based on + # http://support.theenterprisecloud.com/kb/default.asp?id=542&Lang=1&SID= + # + + def get_catalog_item(catalog_item_uri) + if catalog_item = mock_data.catalog_item_from_href(catalog_item_uri) + builder = Builder::XmlMarkup.new + + xml = builder.CatalogItem(xmlns.merge(:href => catalog_item.href, :name => catalog_item.name)) do + builder.Link( + :rel => "down", + :href => catalog_item.customization.href, + :type => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml", + :name => catalog_item.customization.name + ) + + builder.Entity( + :href => catalog_item.vapp_template.href, + :type => "application/vnd.vmware.vcloud.vAppTemplate+xml", + :name => catalog_item.vapp_template.name + ) + + builder.Property(0, :key => "LicensingCost") + end + end + + if xml + mock_it 200, xml, {'Content-Type' => 'application/vnd.vmware.vcloud.catalogItem+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_customization_options.rb b/lib/fog/compute/requests/ecloud/get_customization_options.rb new file mode 100644 index 000000000..eb2b4ff49 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_customization_options.rb @@ -0,0 +1,22 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_customization_options + end + + class Mock + def get_customization_options(options_uri) + builder = Builder::XmlMarkup.new + xml = builder.CustomizationParameters(xmlns) do + builder.CustomizeNetwork "true" + builder.CustomizePassword "false" + end + + mock_it 200, xml, "Content-Type" => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_firewall_acl.rb b/lib/fog/compute/requests/ecloud/get_firewall_acl.rb new file mode 100644 index 000000000..d0aa0bded --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_firewall_acl.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_firewall_acl + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_firewall_acls.rb b/lib/fog/compute/requests/ecloud/get_firewall_acls.rb new file mode 100644 index 000000000..5668f0487 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_firewall_acls.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_firewall_acls + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_internet_services.rb b/lib/fog/compute/requests/ecloud/get_internet_services.rb new file mode 100644 index 000000000..f75183981 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_internet_services.rb @@ -0,0 +1,82 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_internet_services + end + + class Mock + # + #Based off of: + #http://support.theenterprisecloud.com/kb/default.asp?id=580&Lang=1&SID= + #http://support.theenterprisecloud.com/kb/default.asp?id=560&Lang=1&SID= + # + # + + def get_internet_services(internet_services_uri) + internet_services_uri = ensure_unparsed(internet_services_uri) + xml = nil + + if vdc_internet_service_collection = mock_data.vdc_internet_service_collection_from_href(internet_services_uri) + xml = generate_internet_services(vdc_internet_service_collection.items) + elsif public_ip_internet_service_collection = mock_data.public_ip_internet_service_collection_from_href(internet_services_uri) + xml = generate_internet_services(public_ip_internet_service_collection.items) + end + + if xml + mock_it 200, + xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.internetServicesList+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + + private + + def generate_internet_services(services) + builder = Builder::XmlMarkup.new + + builder.InternetServices("xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {|xml| + services.each do |service| + generate_internet_service(xml, service) + end + } + end + + def generate_internet_service(xml, service, by_itself = false) + xml.InternetService(by_itself ? { "xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" } : {}) { + xml.Id service.object_id + xml.Href service.href + xml.Name service.name + if MockDataClasses::MockBackupInternetService === service + xml.PublicIpAddress "i:nil" => true + else + xml.PublicIpAddress { + xml.Id service._parent._parent.object_id + xml.Href service._parent._parent.href + xml.Name service._parent._parent.name + } + end + xml.Port service.port + xml.Protocol service.protocol + xml.Enabled service.enabled + xml.Timeout service.timeout + xml.Description service.description + xml.RedirectURL service.redirect_url + xml.Monitor "i:nil" => true + xml.IsBackupService MockDataClasses::MockBackupInternetService === service + if MockDataClasses::MockPublicIpInternetService === service && service.backup_service + xml.BackupService do + xml.Href service.backup_service.href + end + else + xml.BackupService "i:nil" => true + end + xml.BackupOf + } + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_network.rb b/lib/fog/compute/requests/ecloud/get_network.rb new file mode 100644 index 000000000..045098564 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_network.rb @@ -0,0 +1,44 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_network + end + + class Mock + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=546&Lang=1&SID= + # + + def get_network(network_uri) + network_uri = ensure_unparsed(network_uri) + + if network = mock_data.network_from_href(network_uri) + builder = Builder::XmlMarkup.new + xml = builder.Network(xmlns.merge(:href => network.href, :name => network.name, :type => "application/vnd.vmware.vcloud.network+xml")) { + builder.Link(:rel => "down", :href => network.ip_collection.href, :type => "application/xml", :name => network.ip_collection.name) + builder.Link(:rel => "down", :href => network.extensions.href, :type => "application/xml", :name => network.name) + builder.Configuration { + builder.Gateway(network.gateway) + builder.Netmask(network.netmask) + } + if network.features + builder.Features { + network.features.each do |feature| + builder.tag!(feature[:type], feature[:value]) + end + } + end + } + + mock_it 200, xml, { "Content-Type" => "application/vnd.vmware.vcloud.network+xml" } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/compute/requests/ecloud/get_network_extensions.rb b/lib/fog/compute/requests/ecloud/get_network_extensions.rb new file mode 100644 index 000000000..fa5033636 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_network_extensions.rb @@ -0,0 +1,33 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_network_extensions + end + + class Mock + + def get_network_extensions(network_extension_uri) + if network_extension = mock_data.network_extension_from_href(ensure_unparsed(network_extension_uri)) + xml = Builder::XmlMarkup.new + mock_it 200, xml.Network(ecloud_xmlns) { + xml.Address network_extension.address + xml.RnatAddress network_extension.rnat + xml.Href network_extension.href + xml.Id network_extension.object_id + xml.Name network_extension.name + xml.GatewayAddress network_extension.gateway + xml.BroadcastAddress network_extension.broadcast + xml.NetworkType network_extension.type + xml.Vlan network_extension.vlan + xml.FriendlyName network_extension.friendly_name + }, { 'Content-Type' => "application/vnd.tmrk.ecloud.network+xml" } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_network_ip.rb b/lib/fog/compute/requests/ecloud/get_network_ip.rb new file mode 100644 index 000000000..8c2f9889c --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_network_ip.rb @@ -0,0 +1,43 @@ +# +# AFAICT this is basically undocumented ATM - 6/18/2010 - freeformz +# + +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_network_ip + end + + class Mock + + def get_network_ip(network_ip_uri) + if network_ip = mock_data.network_ip_from_href(network_ip_uri) + builder = Builder::XmlMarkup.new + xml = network_ip_response(builder, network_ip, ecloud_xmlns) + + mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + + def network_ip_response(builder, network_ip, xmlns = {}) + builder.IpAddress(xmlns) do + builder.Id network_ip.object_id + builder.Href network_ip.href + builder.Name network_ip.name + + builder.Status network_ip.status + if network_ip.used_by + builder.Server network_ip.used_by.name + end + + builder.RnatAddress(network_ip.rnat) + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_network_ips.rb b/lib/fog/compute/requests/ecloud/get_network_ips.rb new file mode 100644 index 000000000..ed54685ac --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_network_ips.rb @@ -0,0 +1,35 @@ +# +# AFAICT - This is basically undocumented - 6/18/2010 - freeformz +# + +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_network_ips + end + + class Mock + + def get_network_ips(network_ips_uri) + network_ips_uri = ensure_unparsed(network_ips_uri) + + if network_ip_collection = mock_data.network_ip_collection_from_href(network_ips_uri) + builder = Builder::XmlMarkup.new + xml = builder.IpAddresses do + network_ip_collection.ordered_ips.each do |network_ip| + network_ip_response(builder, network_ip) + end + end + + mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ipAddressesList+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_node.rb b/lib/fog/compute/requests/ecloud/get_node.rb new file mode 100644 index 000000000..f1b305d37 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_node.rb @@ -0,0 +1,40 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_node + end + + class Mock + # + # Based on http://support.theenterprisecloud.com/kb/default.asp?id=641&Lang=1&SID= + # + + def mock_node_service_response(node) + xml = Builder::XmlMarkup.new + xml.NodeService(ecloud_xmlns) { + xml.Id(node.object_id) + xml.Href(node.href) + xml.Name(node.name) + xml.IpAddress(node.ip_address) + xml.Port(node.port) + xml.Enabled(node.enabled) + xml.Description(node.description) + } + end + + def get_node(node_uri) + node_uri = ensure_unparsed(node_uri) + + if public_ip_internet_service_node = mock_data.public_ip_internet_service_node_from_href(node_uri) + xml = Builder::XmlMarkup.new + mock_it 200, mock_node_service_response(public_ip_internet_service_node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_nodes.rb b/lib/fog/compute/requests/ecloud/get_nodes.rb new file mode 100644 index 000000000..31f438b87 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_nodes.rb @@ -0,0 +1,41 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_nodes + end + + class Mock + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=637&Lang=1&SID= + # + + def get_nodes(nodes_uri) + nodes_uri = ensure_unparsed(nodes_uri) + + if public_ip_internet_service_node_collection = mock_data.public_ip_internet_service_node_collection_from_href(nodes_uri) + xml = Builder::XmlMarkup.new + mock_it 200, + xml.NodeServices(ecloud_xmlns) { + public_ip_internet_service_node_collection.items.each do |node| + xml.NodeService { + xml.Id node.object_id + xml.Href node.href + xml.Name node.name + xml.IpAddress node.ip_address + xml.Port node.port + xml.Enabled node.enabled + xml.Description node.description + } + end + }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_organization.rb b/lib/fog/compute/requests/ecloud/get_organization.rb new file mode 100644 index 000000000..78d3057af --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_organization.rb @@ -0,0 +1,49 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_organization + end + + class Mock + + def get_organization(organization_uri) + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=540&Lang=1&SID= + # + # vCloud API Guide v0.9 - Page 26 + # + organization_uri = ensure_unparsed(organization_uri) + if organization = mock_data.organization_from_href(organization_uri) + xml = Builder::XmlMarkup.new + + mock_it 200, + xml.Org(xmlns.merge(:href => organization.href, :name => organization.name)) { + + organization.vdcs.each do |vdc| + xml.Link(:rel => "down", + :href => vdc.href, + :type => "application/vnd.vmware.vcloud.vdc+xml", + :name => vdc.name) + xml.Link(:rel => "down", + :href => vdc.catalog.href, + :type => "application/vnd.vmware.vcloud.catalog+xml", + :name => vdc.catalog.name) + xml.Link(:rel => "down", + :href => vdc.task_list.href, + :type => "application/vnd.vmware.vcloud.tasksList+xml", + :name => vdc.task_list.name) + end + }, + {'Content-Type' => "application/vnd.vmware.vcloud.org+xml" } + else + mock_error 200, "401 Unauthorized" + end + end + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_public_ip.rb b/lib/fog/compute/requests/ecloud/get_public_ip.rb new file mode 100644 index 000000000..9d858b353 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_public_ip.rb @@ -0,0 +1,34 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_public_ip + end + + class Mock + # + #Based off of: + #http://support.theenterprisecloud.com/kb/default.asp?id=567&Lang=1&SID= + # + + def get_public_ip(public_ip_uri) + public_ip_uri = ensure_unparsed(public_ip_uri) + + if public_ip = mock_data.public_ip_from_href(public_ip_uri) + xml = Builder::XmlMarkup.new + mock_it 200, + xml.PublicIp(:xmlns => "urn:tmrk:eCloudExtensions-2.0", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") { + xml.Id public_ip.object_id + xml.Href public_ip.href + xml.Name public_ip.name + }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.publicIp+xml' } + else + mock_error 200, "401 Unauthorized" + end + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_public_ips.rb b/lib/fog/compute/requests/ecloud/get_public_ips.rb new file mode 100644 index 000000000..fef50b530 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_public_ips.rb @@ -0,0 +1,38 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_public_ips + end + + class Mock + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=577&Lang=1&SID= + # + + def get_public_ips(public_ips_uri) + public_ips_uri = ensure_unparsed(public_ips_uri) + + if public_ip_collection = mock_data.public_ip_collection_from_href(public_ips_uri) + xml = Builder::XmlMarkup.new + mock_it 200, + xml.PublicIPAddresses { + public_ip_collection.items.each do |ip| + xml.PublicIPAddress { + xml.Id ip.object_id + xml.Href ip.href + xml.Name ip.name + } + end + }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.publicIpsList+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_task.rb b/lib/fog/compute/requests/ecloud/get_task.rb new file mode 100644 index 000000000..652ec0238 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_task.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_task + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_task_list.rb b/lib/fog/compute/requests/ecloud/get_task_list.rb new file mode 100644 index 000000000..685dce08c --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_task_list.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_task_list + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_vapp.rb b/lib/fog/compute/requests/ecloud/get_vapp.rb new file mode 100644 index 000000000..d595f1211 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_vapp.rb @@ -0,0 +1,99 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_vapp + end + + class Mock + def return_vapp_as_creating!(name) + vapps_to_return_as_creating[name] = true + end + + def vapps_to_return_as_creating + @vapps_to_return_as_creating ||= {} + end + + def get_vapp(vapp_uri) + xml = nil + + if vapp = mock_data.virtual_machine_from_href(vapp_uri) + if vapps_to_return_as_creating[vapp.name] + xml = generate_instantiate_vapp_template_response(vapp) + else + xml = generate_get_vapp_response(vapp) + end + end + + if xml + mock_it 200, xml, "Content-Type" => "application/vnd.vmware.vcloud.vApp+xml" + else + mock_error 200, "401 Unauthorized" + end + end + + private + + def generate_get_vapp_response(vapp) + builder = Builder::XmlMarkup.new + builder.VApp(xmlns.merge( + :href => vapp.href, + :type => "application/vnd.vmware.vcloud.vApp+xml", + :name => vapp.name, + :status => vapp.status, + :size => vapp.size + )) do + builder.Link(:rel => "up", :href => vapp._parent.href, :type => "application/vnd.vmware.vcloud.vdc+xml") + + builder.NetworkConnectionSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do + builder.NetworkConnection(:Network => "Internal", :xmlns => "http://www.vmware.com/vcloud/v0.8") do + builder.IpAddress vapp.ip + end + end + + builder.OperatingSystemSection( + "d2p1:id" => 4, + :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", + "xmlns:d2p1" => "http://schemas.dmtf.org/ovf/envelope/1") do + builder.Info "The kind of installed guest operating system" + builder.Description "Red Hat Enterprise Linux 5 (64-bit)" + end + + builder.VirtualHardwareSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do + builder.Info + builder.System + builder.Item do + # CPUs + builder.VirtualQuantity vapp.cpus + builder.ResourceType 3 + end + builder.Item do + # memory + builder.VirtualQuantity vapp.memory + builder.ResourceType 4 + end + builder.Item do + # SCSI controller + builder.Address 0 + builder.ResourceType 6 + builder.InstanceId 3 + end + + # Hard Disks + vapp.disks.each do |disk| + builder.Item do + builder.Parent 3 + builder.VirtualQuantity disk.vcloud_size + builder.HostResource disk.vcloud_size + builder.ResourceType 17 + builder.AddressOnParent disk.address + end + end + end + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_vapp_template.rb b/lib/fog/compute/requests/ecloud/get_vapp_template.rb new file mode 100644 index 000000000..0574bb8d2 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_vapp_template.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_vapp_template + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_vdc.rb b/lib/fog/compute/requests/ecloud/get_vdc.rb new file mode 100644 index 000000000..cf10adeb0 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_vdc.rb @@ -0,0 +1,84 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :get_vdc + end + + class Mock + # + #Based off of: + #http://support.theenterprisecloud.com/kb/default.asp?id=545&Lang=1&SID= + + def get_vdc(vdc_uri) + vdc_uri = ensure_unparsed(vdc_uri) + + if vdc = mock_data.vdc_from_href(vdc_uri) + xml = Builder::XmlMarkup.new + mock_it 200, + xml.Vdc(xmlns.merge(:href => vdc.href, :name => vdc.name)) { + xml.Link(:rel => "down", + :href => vdc.catalog.href, + :type => "application/vnd.vmware.vcloud.catalog+xml", + :name => vdc.catalog.name) + xml.Link(:rel => "down", + :href => vdc.public_ip_collection.href, + :type => "application/vnd.tmrk.ecloud.publicIpsList+xml", + :name => vdc.public_ip_collection.name) + xml.Link(:rel => "down", + :href => vdc.internet_service_collection.href, + :type => "application/vnd.tmrk.ecloud.internetServicesList+xml", + :name => vdc.internet_service_collection.name) + xml.Link(:rel => "down", + :href => vdc.firewall_acls.href, + :type => "application/vnd.tmrk.ecloud.firewallAclsList+xml", + :name => vdc.firewall_acls.name) + xml.Description("") + xml.StorageCapacity { + xml.Units("bytes * 10^9") + xml.Allocated(vdc.storage_allocated) + xml.Used(vdc.storage_used) + } + xml.ComputeCapacity { + xml.Cpu { + xml.Units("hz * 10^6") + xml.Allocated(vdc.cpu_allocated) + } + xml.Memory { + xml.Units("bytes * 2^20") + xml.Allocated(vdc.memory_allocated) + } + xml.DeployedVmsQuota { + xml.Limit("-1") + xml.Used("-1") + } + xml.InstantiatedVmsQuota { + xml.Limit("-1") + xml.Used("-1") + } + } + xml.ResourceEntities { + vdc.virtual_machines.each do |virtual_machine| + xml.ResourceEntity(:href => virtual_machine.href, + :type => "application/vnd.vmware.vcloud.vApp+xml", + :name => virtual_machine.name) + end + } + xml.AvailableNetworks { + vdc.networks.each do |network| + xml.Network(:href => network.href, + :type => "application/vnd.vmware.vcloud.network+xml", + :name => network.name) + end + } + }, { 'Content-Type' => 'application/vnd.vmware.vcloud.vdc+xml'} + else + mock_error 200, "401 Unauthorized" + end + end + + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/get_versions.rb b/lib/fog/compute/requests/ecloud/get_versions.rb new file mode 100644 index 000000000..f643ff686 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/get_versions.rb @@ -0,0 +1,37 @@ +module Fog + module Ecloud + class Compute + + class Real + unauthenticated_basic_request :get_versions + end + + class Mock + + def get_versions(versions_uri) + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=535&Lang=1&SID= + # https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/02-get-versions.aspx + # vCloud API Guide v0.9 - Page 89 + # + xml = Builder::XmlMarkup.new + + mock_it 200, + xml.SupportedVersions( xmlns.merge("xmlns" => "http://www.vmware.com/vcloud/versions")) { + + mock_data.versions.select {|version| version.supported }.each do |version| + xml.VersionInfo { + xml.Version(version.version) + xml.LoginUrl(version.login_url) + } + end + } + + end + + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb b/lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb new file mode 100644 index 000000000..170d9e0d0 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb @@ -0,0 +1,142 @@ +module Fog + module Ecloud + class Compute + module Shared + private + + def validate_instantiate_vapp_template_options(catalog_item_uri, options) + valid_opts = [:name, :vdc_uri, :network_uri, :cpus, :memory, :row, :group] + unless valid_opts.all? { |opt| options.keys.include?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}") + end + + # Figure out the template_uri + catalog_item = get_catalog_item( catalog_item_uri ).body + catalog_item[:Entity] = [ catalog_item[:Entity] ] if catalog_item[:Entity].is_a?(Hash) + catalog_item[:Link] = [ catalog_item[:Link] ] if catalog_item[:Link].is_a?(Hash) + + options[:template_uri] = begin + catalog_item[:Entity].detect { |entity| entity[:type] == "application/vnd.vmware.vcloud.vAppTemplate+xml" }[:href] + rescue + raise RuntimeError.new("Unable to locate template uri for #{catalog_item_uri}") + end + + customization_options = begin + customization_href = catalog_item[:Link].detect { |link| link[:type] == "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" }[:href] + get_customization_options( customization_href ).body + rescue + raise RuntimeError.new("Unable to get customization options for #{catalog_item_uri}") + end + + # Check to see if we can set the password + if options[:password] and customization_options[:CustomizePassword] == "false" + raise ArgumentError.new("This catalog item (#{catalog_item_uri}) does not allow setting a password.") + end + + # According to the docs if CustomizePassword is "true" then we NEED to set a password + if customization_options[:CustomizePassword] == "true" and ( options[:password].nil? or options[:password].empty? ) + raise ArgumentError.new("This catalog item (#{catalog_item_uri}) requires a :password to instantiate.") + end + end + + def generate_instantiate_vapp_template_request(options) + xml = Builder::XmlMarkup.new + xml.InstantiateVAppTemplateParams(xmlns.merge!(:name => options[:name], :"xml:lang" => "en")) { + xml.VAppTemplate(:href => options[:template_uri]) + xml.InstantiationParams { + xml.ProductSection( :"xmlns:q1" => "http://www.vmware.com/vcloud/v0.8", :"xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { + if options[:password] + xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "password", :"ovf:value" => options[:password] ) + end + xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "row", :"ovf:value" => options[:row] ) + xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "group", :"ovf:value" => options[:group] ) + } + xml.VirtualHardwareSection( :"xmlns:q1" => "http://www.vmware.com/vcloud/v0.8" ) { + # # of CPUS + xml.Item( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1" ) { + xml.InstanceID(1, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + xml.ResourceType(3, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + xml.VirtualQuantity(options[:cpus], :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + } + # Memory + xml.Item( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1" ) { + xml.InstanceID(2, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + xml.ResourceType(4, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + xml.VirtualQuantity(options[:memory], :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") + } + } + xml.NetworkConfigSection { + xml.NetworkConfig { + xml.NetworkAssociation( :href => options[:network_uri] ) + } + } + } + } + end + end + + class Real + include Shared + + def instantiate_vapp_template(catalog_item_uri, options = {}) + validate_instantiate_vapp_template_options(catalog_item_uri, options) + + request( + :body => generate_instantiate_vapp_template_request(options), + :expects => 200, + :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'}, + :method => 'POST', + :uri => options[:vdc_uri] + '/action/instantiatevAppTemplate', + :parse => true + ) + end + end + + class Mock + include Shared + + # + # Based on + # http://support.theenterprisecloud.com/kb/default.asp?id=554&Lang=1&SID= + # + + def instantiate_vapp_template(catalog_item_uri, options = {}) + validate_instantiate_vapp_template_options(catalog_item_uri, options) + catalog_item = mock_data.catalog_item_from_href(catalog_item_uri) + + xml = nil + if vdc = mock_data.vdc_from_href(options[:vdc_uri]) + if network = mock_data.network_from_href(options[:network_uri]) + new_vm = MockVirtualMachine.new({ :name => options[:name], :ip => network.random_ip, :cpus => options[:cpus], :memory => options[:memory] }, vdc) + new_vm.disks.push(*catalog_item.disks.dup) + vdc.virtual_machines << new_vm + + xml = generate_instantiate_vapp_template_response(new_vm) + end + end + + if xml + mock_it 200, xml, {'Content-Type' => 'application/xml'} + else + mock_error 200, "401 Unauthorized" + end + end + + private + + def generate_instantiate_vapp_template_response(vapp) + builder = Builder::XmlMarkup.new + builder.VApp(xmlns.merge( + :href => vapp.href, + :type => "application/vnd.vmware.vcloud.vApp+xml", + :name => vapp.name, + :status => 0, + :size => 4 + )) { + builder.Link(:rel => "up", :href => vapp._parent.href, :type => "application/vnd.vmware.vcloud.vdc+xml") + } + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/login.rb b/lib/fog/compute/requests/ecloud/login.rb new file mode 100644 index 000000000..be67aab92 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/login.rb @@ -0,0 +1,48 @@ +module Fog + module Ecloud + class Compute + + class Real + + + def login + unauthenticated_request({ + :expects => 200, + :headers => { + 'Authorization' => authorization_header + }, + :method => 'POST', + :parse => true, + :uri => login_uri + }) + end + + end + + class Mock + + def login + # + # Based off of: + # http://support.theenterprisecloud.com/kb/default.asp?id=536&Lang=1&SID= + # https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/01-get-login-token.aspx + # vCloud API Guide v0.9 - Page 17 + # + xml = Builder::XmlMarkup.new + + mock_it 200, + xml.OrgList(xmlns) { + mock_data.organizations.each do |organization| + xml.Org( :type => "application/vnd.vmware.vcloud.org+xml", :href => organization.href, :name => organization.name ) + end + }, + { 'Set-Cookie' => 'vcloud-token=fc020a05-21d7-4f33-9b2a-25d8cd05a44e; path=/', + 'Content-Type' => 'application/vnd.vmware.vcloud.orgslist+xml' } + + end + + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/power_off.rb b/lib/fog/compute/requests/ecloud/power_off.rb new file mode 100644 index 000000000..514ef585d --- /dev/null +++ b/lib/fog/compute/requests/ecloud/power_off.rb @@ -0,0 +1,23 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :power_off, 202, 'POST' + end + + class Mock + def power_off(vapp_uri) + if vapp = mock_data.virtual_machine_from_href(vapp_uri) + vapp.power_off! + + builder = Builder::XmlMarkup.new + mock_it 200, builder.Task(xmlns) + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/power_on.rb b/lib/fog/compute/requests/ecloud/power_on.rb new file mode 100644 index 000000000..2f1393ac8 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/power_on.rb @@ -0,0 +1,23 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :power_on, 202, 'POST' + end + + class Mock + def power_on(vapp_uri) + if vapp = mock_data.virtual_machine_from_href(vapp_uri) + vapp.power_on! + + builder = Builder::XmlMarkup.new + mock_it 200, builder.Task(xmlns) + else + mock_error 200, "401 Unauthorized" + end + end + end + end + end +end diff --git a/lib/fog/compute/requests/ecloud/power_reset.rb b/lib/fog/compute/requests/ecloud/power_reset.rb new file mode 100644 index 000000000..9426edbea --- /dev/null +++ b/lib/fog/compute/requests/ecloud/power_reset.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :power_reset, 202, 'POST' + end + + end + end +end diff --git a/lib/fog/compute/requests/ecloud/power_shutdown.rb b/lib/fog/compute/requests/ecloud/power_shutdown.rb new file mode 100644 index 000000000..91e79dfa9 --- /dev/null +++ b/lib/fog/compute/requests/ecloud/power_shutdown.rb @@ -0,0 +1,11 @@ +module Fog + module Ecloud + class Compute + + class Real + basic_request :power_shutdown, 204, 'POST' + end + + end + end +end diff --git a/lib/fog/providers.rb b/lib/fog/providers.rb index 2e0d5c274..6c447c5b9 100644 --- a/lib/fog/providers.rb +++ b/lib/fog/providers.rb @@ -9,6 +9,7 @@ end require 'fog/providers/aws' require 'fog/providers/bluebox' require 'fog/providers/brightbox' +require 'fog/providers/ecloud' require 'fog/providers/go_grid' require 'fog/providers/google' require 'fog/providers/linode' diff --git a/lib/fog/providers/ecloud.rb b/lib/fog/providers/ecloud.rb new file mode 100644 index 000000000..212de9ff4 --- /dev/null +++ b/lib/fog/providers/ecloud.rb @@ -0,0 +1,11 @@ +require 'fog/core' + +module Fog + module Ecloud + + extend Fog::Provider + + service(:compute, 'compute/ecloud') + + end +end diff --git a/lib/fog/vcloud.rb b/lib/fog/vcloud.rb deleted file mode 100644 index eca6c85e1..000000000 --- a/lib/fog/vcloud.rb +++ /dev/null @@ -1 +0,0 @@ -require 'fog/vcloud/terremark/ecloud' \ No newline at end of file diff --git a/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb deleted file mode 100644 index dd91a33fa..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +++ /dev/null @@ -1,60 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class BackupInternetService < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id - attribute :protocol, :aliases => :Protocol - attribute :enabled, :aliases => :Enabled - attribute :description, :aliases => :Description - attribute :timeout, :aliases => :Timeout - attribute :redirect_url, :aliases => :RedirectURL - attribute :monitor, :aliases => :Monitor - - def delete - requires :href - - connection.delete_internet_service( href ) - end - - def monitor=(new_monitor = {}) - if new_monitor.nil? || new_monitor.empty? - attributes[:monitor] = nil - end - end - - def save - if new_record? - result = connection.add_backup_internet_service( collection.href, _compose_service_data ) - merge_attributes(result.body) - else - connection.configure_backup_internet_service( href, _compose_service_data ) - end - end - - def nodes - @nodes ||= Fog::Vcloud::Terremark::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" ) - end - - private - - def _compose_service_data - #For some reason inject didn't work - service_data = {} - self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| service_data[attribute] = send(attribute) } - service_data - end - - end - end - end - end -end - - diff --git a/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb b/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb deleted file mode 100644 index f7f3d4df7..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/backup_internet_service' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class BackupInternetServices < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::BackupInternetService - - attribute :href, :aliases => :Href - - def all - check_href! :message => "the Internet Services for the Vdc you want to enumerate" - if data = connection.get_internet_services(href).body[:InternetService].find_all {|i| i[:IsBackupService] == "true" } - load(data) - end - end - - # Optimize later, no need to get_internet_services again? - def get(uri) - internet_services = connection.get_internet_services(href).body[:InternetService] - internet_services = [ internet_services ] if internet_services.is_a?(Hash) - if data = internet_services.detect { |service| service[:Href] == uri } - new(data) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/catalog.rb b/lib/fog/vcloud/terremark/ecloud/models/catalog.rb deleted file mode 100644 index 357d55162..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Catalog < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::CatalogItem - - attribute :href, :aliases => :Href - - def all - check_href! - if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem] - load(data) - end - end - - def get(uri) - if data = connection.get_catalog_item(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb b/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb deleted file mode 100644 index 23145658c..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class CatalogItem < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd - - attribute :type - attribute :name - attribute :entity, :aliases => :Entity - attribute :link, :aliases => :Link - attribute :property, :aliases => :Property - - def customization_options - load_unless_loaded! - if data = connection.get_customization_options( link[:href] ).body - data.delete_if { |key, value| [:xmlns_i, :xmlns].include?(key) } - data - else - nil - end - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/firewall_acl.rb b/lib/fog/vcloud/terremark/ecloud/models/firewall_acl.rb deleted file mode 100644 index d75e02769..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/firewall_acl.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class FirewallAcl < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id - attribute :protocol, :aliases => :Protocol - attribute :source, :aliases => :Source - attribute :destination, :aliases => :Destination - attribute :permission, :aliases => :Permission - attribute :port_start, :aliases => :PortStart - attribute :port_end, :aliases => :PortEnd - attribute :port_type, :aliases => :PortType - attribute :type, :aliases => :Type - - end - end - end - end -end - - diff --git a/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb b/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb deleted file mode 100644 index 3c8a831ef..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/firewall_acl' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class FirewallAcls < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::FirewallAcl - - attribute :href, :aliases => :Href - - def all - check_href! :message => "the Firewall ACL href for the network you want to enumerate" - if data = connection.get_firewall_acls(href).body[:FirewallAcl] - data = [ data ] if data.is_a?(Hash) - load(data) - end - end - - def get(uri) - if data = connection.get_firewall_acl(uri).body - new(data) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb b/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb deleted file mode 100644 index b39507526..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +++ /dev/null @@ -1,121 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class InternetService < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id - attribute :protocol, :aliases => :Protocol - attribute :port, :aliases => :Port - attribute :enabled, :aliases => :Enabled - attribute :description, :aliases => :Description - attribute :public_ip, :aliases => :PublicIpAddress - attribute :timeout, :aliases => :Timeout - attribute :redirect_url, :aliases => :RedirectURL - attribute :monitor, :aliases => :Monitor - attribute :backup_service_data, :aliases => :BackupService - - def delete - requires :href - - connection.delete_internet_service( href ) - end - - def save - if new_record? - result = connection.add_internet_service( collection.href, _compose_service_data ) - merge_attributes(result.body) - else - connection.configure_internet_service( href, _compose_service_data, _compose_ip_data ) - end - end - - # disables monitoring for this service - def disable_monitor - if self.monitor and self.monitor[:type] == "Disabled" - raise RuntimeError.new("Monitoring already disabled") - else - self.monitor = {:type => "Disabled", :is_enabled => "true"} - self.save - end - end - - # enable default ping monitoring, use monitor= for more exotic forms (ECV & HTTP) - def enable_ping_monitor - self.monitor = nil - self.save - end - - def monitor=(new_monitor = {}) - if new_monitor.nil? || new_monitor.empty? - attributes[:monitor] = nil - elsif new_monitor.is_a?(Hash) - attributes[:monitor] = {} - attributes[:monitor][:type] = new_monitor[:MonitorType] || new_monitor[:type] - attributes[:monitor][:url_send_string] = new_monitor[:UrlSendString] || new_monitor[:url_send_string] - attributes[:monitor][:http_headers] = new_monitor[:HttpHeader] || new_monitor[:http_headers] - if attributes[:monitor][:http_headers] - if attributes[:monitor][:http_headers].is_a?(String) - attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n") - else - attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers] - end - end - attributes[:monitor][:receive_string] = new_monitor[:ReceiveString] || new_monitor[:receive_string] - attributes[:monitor][:interval] = new_monitor[:Interval] || new_monitor[:interval] - attributes[:monitor][:response_timeout] = new_monitor[:ResponseTimeOut] || new_monitor[:response_timeout] - attributes[:monitor][:downtime] = new_monitor[:DownTime] || new_monitor[:downtime] - attributes[:monitor][:retries] = new_monitor[:Retries] || new_monitor[:retries] - attributes[:monitor][:is_enabled] = new_monitor[:IsEnabled] || new_monitor[:is_enabled] - else - raise RuntimeError.new("monitor needs to either be nil or a Hash") - end - end - - def nodes - @nodes ||= Fog::Vcloud::Terremark::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" ) - end - - def backup_service_uri - if backup_service_data - backup_service_data[:Href] - end - end - - def backup_service_uri=(new_value) - self.backup_service_data = { - :Href => new_value - } - end - - private - - def _compose_service_data - #For some reason inject didn't work - service_data = {} - self.class.attributes.select{ |attribute| attribute != :backup_service_data }.each { |attribute| service_data[attribute] = send(attribute) } - service_data[:backup_service_uri] = backup_service_uri - service_data.reject! {|k, v| v.nil? } - service_data - end - - def _compose_ip_data - if public_ip.nil? - {} - else - { :id => public_ip[:Id], :href => public_ip[:Href], :name => public_ip[:Name] } - end - end - - end - end - end - end -end - - diff --git a/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb b/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb deleted file mode 100644 index b302b4ab5..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/internet_service' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class InternetServices < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::InternetService - - attribute :href, :aliases => :Href - - def all - check_href! :message => "the Internet Services for the Vdc you want to enumerate" - if internet_service_data = connection.get_internet_services(href).body[:InternetService] - load(Array[internet_service_data].flatten.find_all {|i| i[:IsBackupService] == "false" }) - end - end - - # Optimize later, no need to get_internet_services again? - def get(uri) - internet_services = connection.get_internet_services(href).body[:InternetService] - internet_services = [ internet_services ] if internet_services.is_a?(Hash) - if data = internet_services.detect { |service| service[:Href] == uri } - new(data) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/ip.rb b/lib/fog/vcloud/terremark/ecloud/models/ip.rb deleted file mode 100644 index 395e8dea0..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/ip.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Ip < Fog::Vcloud::Model - - ignore_attributes :xmlns_i, :xmlns - - identity :href, :aliases => :Href - - attribute :name, :aliases => :Name - attribute :status, :aliases => :Status - attribute :server, :aliases => :Server - attribute :rnat, :aliases => :RnatAddress - attribute :id, :aliases => :Id, :type => :integer - - def rnat=(new_rnat) - attributes[:rnat] = new_rnat - @changed = true - end - - def save - if @changed - connection.configure_network_ip( href, _compose_network_ip_data ) - end - true - end - - def reload - super - @changed = false - self - end - - private - def _compose_network_ip_data - { - :id => id, - :href => href, - :name => name, - :status => status, - :server => server, - :rnat => rnat - } - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/ips.rb b/lib/fog/vcloud/terremark/ecloud/models/ips.rb deleted file mode 100644 index c686eedeb..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/ips.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/ip' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Ips < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::Ip - - undef_method :create - - attribute :href - - def all - check_href!( :messages => "Ips href of a Network you want to enumerate" ) - if data = connection.get_network_ips(href).body[:IpAddress] - load(data) - end - end - - def get(uri) - if data = connection.get_network_ip(uri).body - new(data) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/network.rb b/lib/fog/vcloud/terremark/ecloud/models/network.rb deleted file mode 100644 index ee9be57f2..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/network.rb +++ /dev/null @@ -1,77 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Network < Fog::Vcloud::Model - - identity :href - - ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id - - attribute :name, :aliases => :Name - #attribute :id, :aliases => :Id - attribute :features, :aliases => :Features, :type => :array - attribute :links, :aliases => :Link, :type => :array - attribute :type - attribute :gateway, :aliases => :GatewayAddress - attribute :broadcast, :aliases => :BroadcastAddress - attribute :address, :aliases => :Address - attribute :rnat, :aliases => :RnatAddress - attribute :extension_href, :aliases => :Href - attribute :network_type, :aliases => :NetworkType - attribute :vlan, :aliases => :Vlan - attribute :friendly_name, :aliases => :FriendlyName - - def ips - load_unless_loaded! - @ips ||= Fog::Vcloud::Terremark::Ecloud::Ips. - new( :connection => connection, - :href => links.detect { |link| link[:name] == "IP Addresses" }[:href] ) - end - - def rnat=(new_rnat) - attributes[:rnat] = new_rnat - @changed = true - end - - def save - if @changed - connection.configure_network( extension_href, _compose_network_data ) - end - true - end - - def reload - super - merge_attributes(extension_data.body) - self - end - - private - - def extension_data - connection.get_network_extensions( extensions_link[:href] ) - end - - def extensions_link - links.detect { |link| link[:name] == name } - end - - def _compose_network_data - { - :id => id, - :href => extension_href, - :name => name, - :rnat => rnat, - :address => address, - :broadcast => broadcast, - :gateway => gateway - } - end - end - end - end - end -end - - diff --git a/lib/fog/vcloud/terremark/ecloud/models/networks.rb b/lib/fog/vcloud/terremark/ecloud/models/networks.rb deleted file mode 100644 index ccd901c88..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/networks.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/network' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Networks < Fog::Vcloud::Collection - - undef_method :create - - model Fog::Vcloud::Terremark::Ecloud::Network - - attribute :href - - def all - check_href!("Vdc") - if data = connection.get_vdc(href).body[:AvailableNetworks][:Network] - load(data) - end - end - - def get(uri) - if data = connection.get_network(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/models/node.rb b/lib/fog/vcloud/terremark/ecloud/models/node.rb deleted file mode 100644 index c69911766..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/node.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Node < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :ip_address, :aliases => :IpAddress - attribute :description, :aliases => :Description - attribute :name, :aliases => :Name - attribute :port, :aliases => :Port - attribute :enabled, :aliases => :Enabled - attribute :id, :aliases => :Id - - def delete - requires :href - - connection.delete_node( href ) - end - - def save - if new_record? - result = connection.add_node( collection.href, _compose_node_data ) - merge_attributes(result.body) - else - connection.configure_node( href, _compose_node_data ) - end - end - - private - - def _compose_node_data - node_data = {} - self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| node_data[attribute] = send(attribute).to_s } - node_data - end - - end - end - end - end -end - - diff --git a/lib/fog/vcloud/terremark/ecloud/models/nodes.rb b/lib/fog/vcloud/terremark/ecloud/models/nodes.rb deleted file mode 100644 index e02c38de7..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/node' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Nodes < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::Node - - attribute :href, :aliases => :Href - - def all - check_href!( :messages => "the Nodes href of the Internet Service you want to enumerate" ) - if data = connection.get_nodes(href).body[:NodeService] - load(data) - end - end - - def get(uri) - if data = connection.get_node(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb b/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb deleted file mode 100644 index d042af825..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class PublicIp < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id - - def internet_services - load_unless_loaded! - @internet_services ||= Fog::Vcloud::Terremark::Ecloud::InternetServices. - new( :connection => connection, - :href => href.to_s + "/internetServices" ) - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb b/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb deleted file mode 100644 index 7c10a2756..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/public_ip' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class PublicIps < Fog::Vcloud::Collection - - undef_method :create - - attribute :href, :aliases => :Href - - model Fog::Vcloud::Terremark::Ecloud::PublicIp - - #get_request :get_public_ip - #vcloud_type "application/vnd.tmrk.ecloud.publicIp+xml" - #all_request lambda { |public_ips| public_ips.connection.get_public_ips(public_ips.href) } - - def all - check_href!(:message => "the Public Ips href of the Vdc you want to enumerate") - if data = connection.get_public_ips(href).body[:PublicIPAddress] - load(data) - end - end - - def get(uri) - if data = connection.get_public_ip(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/server.rb b/lib/fog/vcloud/terremark/ecloud/models/server.rb deleted file mode 100644 index 5eae70b37..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/server.rb +++ /dev/null @@ -1,211 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Server < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd - - attribute :type - attribute :name - attribute :status - attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection - attribute :os, :aliases => :OperatingSystemSection - attribute :virtual_hardware, :aliases => :VirtualHardwareSection - attribute :storage_size, :aliases => :size - attribute :links, :aliases => :Link, :type => :array - - def friendly_status - load_unless_loaded! - case status - when '0' - 'creating' - when '2' - 'off' - when '4' - 'on' - else - 'unkown' - end - end - - def ready? - load_unless_loaded! - status == '2' - end - - def on? - load_unless_loaded! - status == '4' - end - - def off? - load_unless_loaded! - status == '2' - end - - def power_on - power_operation( :power_on => :powerOn ) - end - - def power_off - power_operation( :power_off => :powerOff ) - end - - def shutdown - power_operation( :power_shutdown => :shutdown ) - end - - def power_reset - power_operation( :power_reset => :reset ) - end - - def graceful_restart - requires :href - shutdown - wait_for { off? } - power_on - end - - def delete - requires :href - connection.delete_vapp( href) - end - - def name=(new_name) - attributes[:name] = new_name - @changed = true - end - - def cpus - if cpu_mess - { :count => cpu_mess[:VirtualQuantity].to_i, - :units => cpu_mess[:AllocationUnits] } - end - end - - def cpus=(qty) - @changed = true - cpu_mess[:VirtualQuantity] = qty.to_s - end - - def memory - if memory_mess - { :amount => memory_mess[:VirtualQuantity].to_i, - :units => memory_mess[:AllocationUnits] } - end - end - - def memory=(amount) - @changed = true - memory_mess[:VirtualQuantity] = amount.to_s - end - - def disks - disk_mess.map do |dm| - { :number => dm[:AddressOnParent], :size => dm[:VirtualQuantity].to_i, :resource => dm[:HostResource] } - end - end - - def add_disk(size) - if @disk_change == :deleted - raise RuntimeError, "Can't add a disk w/o saving changes or reloading" - else - @disk_change = :added - load_unless_loaded! - virtual_hardware[:Item] << { :ResourceType => '17', - :AddressOnParent => (disk_mess.map { |dm| dm[:AddressOnParent] }.sort.last.to_i + 1).to_s, - :VirtualQuantity => size.to_s } - end - true - end - - def delete_disk(number) - if @disk_change == :added - raise RuntimeError, "Can't delete a disk w/o saving changes or reloading" - else - @disk_change = :deleted - load_unless_loaded! - unless number == 0 - virtual_hardware[:Item].delete_if { |vh| vh[:ResourceType] == '17' && vh[:AddressOnParent].to_i == number } - end - end - true - end - - def reload - reset_tracking - super - end - - def save - if new_record? - #Lame ... - raise RuntimeError, "Should not be here" - else - if on? - if @changed - raise RuntimeError, "Can't save cpu, name or memory changes while the VM is on." - end - end - connection.configure_vapp( href, _compose_vapp_data ) - end - reset_tracking - end - - private - - def reset_tracking - @disk_change = false - @changed = false - end - - def _compose_vapp_data - { :name => name, - :cpus => cpus[:count], - :memory => memory[:amount], - :disks => disks - } - end - - def memory_mess - load_unless_loaded! - if virtual_hardware && virtual_hardware[:Item] - virtual_hardware[:Item].detect { |item| item[:ResourceType] == "4" } - end - end - - def cpu_mess - load_unless_loaded! - if virtual_hardware && virtual_hardware[:Item] - virtual_hardware[:Item].detect { |item| item[:ResourceType] == "3" } - end - end - - def disk_mess - load_unless_loaded! - if virtual_hardware && virtual_hardware[:Item] - virtual_hardware[:Item].select { |item| item[:ResourceType] == "17" } - else - [] - end - end - - def power_operation(op) - requires :href - begin - connection.send(op.keys.first, href + "/power/action/#{op.values.first}" ) - rescue Excon::Errors::InternalServerError => e - #Frankly we shouldn't get here ... - raise e unless e.to_s =~ /because it is already powered o(n|ff)/ - end - true - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/servers.rb b/lib/fog/vcloud/terremark/ecloud/models/servers.rb deleted file mode 100644 index b79f2e7f6..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/servers.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/server' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Servers < Fog::Vcloud::Collection - - undef_method :create - - model Fog::Vcloud::Terremark::Ecloud::Server - - attribute :href, :aliases => :Href - - def all - check_href!(:parent => "Vdc") - load(_vapps) - end - - def get(uri) - if data = connection.get_vapp(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - def create( catalog_item_uri, options ) - options[:vdc_uri] = href - options[:cpus] ||= 1 - options[:memory] ||= 512 - data = connection.instantiate_vapp_template( catalog_item_uri, options ).body - object = new(data) - object - end - - private - - def _resource_entities - connection.get_vdc(href).body[:ResourceEntities][:ResourceEntity] - end - - def _vapps - resource_entities = _resource_entities - if resource_entities.nil? - [] - else - resource_entities - end - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/task.rb b/lib/fog/vcloud/terremark/ecloud/models/task.rb deleted file mode 100644 index a063c8431..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/task.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Task < Fog::Vcloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd - - attribute :status - attribute :type - attribute :result, :aliases => :Result - attribute :owner, :aliases => :Owner - attribute :start_time, :aliases => :startTime, :type => :time - attribute :end_time, :aliases => :endTime, :type => :time - attribute :error, :aliases => :Error - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/tasks.rb b/lib/fog/vcloud/terremark/ecloud/models/tasks.rb deleted file mode 100644 index 775baf744..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/task' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Tasks < Fog::Vcloud::Collection - - model Fog::Vcloud::Terremark::Ecloud::Task - - attribute :href, :aliases => :Href - - def all - check_href! - if data = connection.get_task_list(href).body[:Task] - load(data) - end - end - - def get(uri) - if data = connection.get_task(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/vdc.rb b/lib/fog/vcloud/terremark/ecloud/models/vdc.rb deleted file mode 100644 index 3436d380b..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +++ /dev/null @@ -1,83 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Vdc < Fog::Vcloud::Model - - identity :href - - ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd - - attribute :name - attribute :type - attribute :description, :aliases => :Description - attribute :other_links, :aliases => :Link - attribute :compute_capacity, :aliases => :ComputeCapacity - attribute :storage_capacity, :aliases => :StorageCapacity - attribute :available_networks, :aliases => :AvailableNetworks, :squash => :Network - attribute :resource_entities, :aliases => :ResourceEntities, :squash => :ResourceEntity - attribute :deployed_vm_quota - attribute :instantiated_vm_quota - - def public_ips - @public_ips ||= collection_based_on_type("application/vnd.tmrk.ecloud.publicIpsList+xml") - end - - def internet_services - @internet_services ||= collection_based_on_type("application/vnd.tmrk.ecloud.internetServicesList+xml") - end - - def backup_internet_services - @backup_internet_services ||= collection_based_on_type("application/vnd.tmrk.ecloud.internetServicesList+xml", BackupInternetServices) - end - - def networks - @networks ||= Fog::Vcloud::Terremark::Ecloud::Networks. - new( :connection => connection, - :href => href ) - end - - def servers - @servers ||= Fog::Vcloud::Terremark::Ecloud::Servers. - new( :connection => connection, - :href => href ) - end - - def tasks - @tasks ||= Fog::Vcloud::Terremark::Ecloud::Tasks. - new( :connection => connection, - :href => href + "/tasksList" ) - end - - def catalog - @catalog ||= collection_based_on_type("application/vnd.vmware.vcloud.catalog+xml") - end - - def firewall_acls - @firewall_acls ||= collection_based_on_type("application/vnd.tmrk.ecloud.firewallAclsList+xml") - end - - private - - def collection_based_on_type(type, klass = nil) - load_unless_loaded! - if link = other_links.detect { |link| link[:type] == type } - case type - when "application/vnd.tmrk.ecloud.publicIpsList+xml" - Fog::Vcloud::Terremark::Ecloud::PublicIps - when "application/vnd.tmrk.ecloud.internetServicesList+xml" - klass || Fog::Vcloud::Terremark::Ecloud::InternetServices - when "application/vnd.vmware.vcloud.catalog+xml" - Fog::Vcloud::Terremark::Ecloud::Catalog - when "application/vnd.tmrk.ecloud.firewallAclsList+xml" - Fog::Vcloud::Terremark::Ecloud::FirewallAcls - end.new( :connection => connection, :href => link[:href] ) - else - [ ] - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb b/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb deleted file mode 100644 index b7cd51b0a..000000000 --- a/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'fog/vcloud/terremark/ecloud/models/vdc' - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Vdcs < Collection - - model Fog::Vcloud::Terremark::Ecloud::Vdc - - undef_method :create - - def all - data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" } - data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } } - load(data) - end - - def get(uri) - if data = connection.get_vdc(uri) - new(data.body) - end - rescue Fog::Errors::NotFound - nil - end - - def organization_uri - @organizatio_uri ||= connection.default_organization_uri - end - - private - - def organization_uri=(new_organization_uri) - @organization_uri = new_organization_uri - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb deleted file mode 100644 index adc66c3ed..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +++ /dev/null @@ -1,111 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - def validate_backup_internet_service_data(service_data, configure=false) - required_opts = [:name, :protocol, :description, :enabled] - if configure - required_opts + [ :id, :href, :timeout ] - end - unless required_opts.all? { |opt| service_data.keys.include?(opt) } - raise ArgumentError.new("Required Backup Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") - end - end - end - - class Real - include Shared - - def add_backup_internet_service(internet_services_uri, service_data) - validate_backup_internet_service_data(service_data) - if monitor = service_data[:monitor] - validate_internet_service_monitor(monitor) - ensure_monitor_defaults!(monitor) - end - - request( - :body => generate_backup_internet_service_request(service_data), - :expects => 200, - :headers => {'Content-Type' => 'application/xml'}, - :method => 'POST', - :uri => internet_services_uri, - :parse => true - ) - end - - private - - def generate_backup_internet_service_request(service_data) - builder = Builder::XmlMarkup.new - builder.CreateBackupInternetServiceRequest("xmlns" => "urn:tmrk:eCloudExtensions-2.5") { - builder.Name(service_data[:name]) - builder.Protocol(service_data[:protocol]) - builder.Enabled(service_data[:enabled]) - builder.Description(service_data[:description]) - builder.RedirectURL(service_data[:redirect_url]) - if monitor = service_data[:monitor] - generate_monitor_section(builder,monitor) - end - } - end - end - - class Mock - include Shared - - # - # Based on - # http://support.theenterprisecloud.com/kb/default.asp?id=729&Lang=1&SID= - # and many tears shed. - # - - def add_backup_internet_service(internet_services_uri, service_data) - validate_backup_internet_service_data(service_data) - - internet_services_uri = ensure_unparsed(internet_services_uri) - - if vdc_internet_service_collection = mock_data.vdc_internet_service_collection_from_href(internet_services_uri) - new_backup_internet_service = MockBackupInternetService.new(service_data, vdc_internet_service_collection.backup_internet_services) - vdc_internet_service_collection.backup_internet_services << new_backup_internet_service - xml = generate_backup_internet_service_added_response(new_backup_internet_service) - - mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - - private - - def generate_backup_internet_service_added_response(new_backup_internet_service) - builder = Builder::XmlMarkup.new - builder.InternetService("xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") { - builder.Id new_backup_internet_service.object_id - builder.Href new_backup_internet_service.href - builder.Name new_backup_internet_service.name - # so broken - builder.PublicIpAddress do - builder.Id -2147483648 - builder.Id "http://totally.invalid/1234" - builder.Name - end - builder.Port new_backup_internet_service.port - builder.Protocol new_backup_internet_service.protocol - builder.Enabled new_backup_internet_service.enabled - builder.Timeout new_backup_internet_service.timeout - builder.Description new_backup_internet_service.description - builder.RedirectURL new_backup_internet_service.redirect_url - builder.Monitor "i:nil" => true - # so broken - builder.IsBackupService false - builder.BackupService "i:nil" => true - builder.BackupOf "i:nil" => true - } - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb deleted file mode 100644 index aa384db12..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +++ /dev/null @@ -1,152 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - def validate_internet_service_monitor(monitor) - #FIXME: Refactor this type of function into something generic - unless ['Disabled','HTTP','ECV'].include?(monitor[:type]) - raise ArgumentError.new("Supported monitor types are: ECV & HTTP") - end - - required_opts = case monitor[:type] - when "Disabled" - [:type, :is_enabled] - else - [:type, :url_send_string, :http_headers, :receive_string, :is_enabled] - end - - unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] } - raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}") - end - - case monitor[:type] - when "HTTP", "ECV" - unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String) - raise ArgumentError.new("Monitor :http_headers must be a String or Array") - end - end - - unless [true, false, "true", "false"].include?(monitor[:is_enabled]) - raise ArgumentError.new("Monitor :is_enabled must be true or false") - end - end - - def validate_internet_service_data(service_data, configure=false) - required_opts = [:name, :protocol, :port, :description, :enabled] - if configure - required_opts + [ :id, :href, :timeout ] - end - unless required_opts.all? { |opt| service_data.keys.include?(opt) } - raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") - end - end - - def ensure_monitor_defaults!(monitor) - if monitor[:http_headers].is_a?(String) - monitor[:http_headers] = [ monitor[:http_headers] ] - end - - unless monitor[:retries] - monitor[:retries] = 3 - end - - unless monitor[:response_timeout] - monitor[:response_timeout] = 2 - end - - unless monitor[:down_time] - monitor[:down_time] = 30 - end - - unless monitor[:interval] - monitor[:interval] = 5 - end - end - end - - class Real - include Shared - - def add_internet_service(internet_services_uri, service_data) - validate_internet_service_data(service_data) - if monitor = service_data[:monitor] - validate_internet_service_monitor(monitor) - ensure_monitor_defaults!(monitor) - end - - request( - :body => generate_internet_service_request(service_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}, - :method => 'POST', - :uri => internet_services_uri, - :parse => true - ) - end - - private - - def generate_internet_service_request(service_data) - builder = Builder::XmlMarkup.new - builder.CreateInternetServiceRequest(ecloud_xmlns) { - builder.Name(service_data[:name]) - builder.Protocol(service_data[:protocol]) - builder.Port(service_data[:port]) - builder.Enabled(service_data[:enabled]) - builder.Description(service_data[:description]) - builder.RedirectURL(service_data[:redirect_url]) - if monitor = service_data[:monitor] - generate_monitor_section(builder,monitor) - end - } - end - - def generate_monitor_section(builder, monitor) - builder.Monitor { - builder.MonitorType(monitor[:type]) - case monitor[:type] - when "ECV","HTTP" - builder.UrlSendString(monitor[:url_send_string]) - builder.HttpHeader(monitor[:http_headers].join("\n")) - builder.ReceiveString(monitor[:receive_string]) - builder.Interval(monitor[:interval]) - builder.ResponseTimeOut(monitor[:response_timeout]) - builder.DownTime(monitor[:downtime]) - builder.Retries(monitor[:retries]) - end - builder.IsEnabled(monitor[:is_enabled]) - } - end - - end - - class Mock - include Shared - - # - # Based on - # http://support.theenterprisecloud.com/kb/default.asp?id=561&Lang=1&SID= - # - - def add_internet_service(internet_services_uri, service_data) - validate_internet_service_data(service_data) - - internet_services_uri = ensure_unparsed(internet_services_uri) - - if public_ip_internet_service_collection = mock_data.public_ip_internet_service_collection_from_href(internet_services_uri) - new_public_ip_internet_service = MockPublicIpInternetService.new(service_data, public_ip_internet_service_collection) - public_ip_internet_service_collection.items << new_public_ip_internet_service - xml = generate_internet_service(Builder::XmlMarkup.new, new_public_ip_internet_service, true) - - mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb b/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb deleted file mode 100644 index d70b69a01..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +++ /dev/null @@ -1,64 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def generate_node_request(node_data) - builder = Builder::XmlMarkup.new - builder.CreateNodeServiceRequest(ecloud_xmlns) { - builder.IpAddress(node_data[:ip_address]) - builder.Name(node_data[:name]) - builder.Port(node_data[:port]) - builder.Enabled(node_data[:enabled]) - builder.Description(node_data[:description]) - } - end - - def validate_node_data(node_data, configure=false) - valid_opts = [:name, :port, :enabled, :description, :ip_address] - if configure - valid_opts.delete_if { |opt| ![:name, :enabled, :description].include?(opt) } - end - unless valid_opts.all? { |opt| node_data.keys.include?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - node_data.keys).map(&:inspect).join(", ")}") - end - end - end - - class Real - include Shared - - def add_node(nodes_uri, node_data) - validate_node_data(node_data) - - request( - :body => generate_node_request(node_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'}, - :method => 'POST', - :uri => nodes_uri, - :parse => true - ) - end - end - - class Mock - include Shared - - def add_node(nodes_uri, node_data) - validate_node_data(node_data) - if node_collection = mock_data.public_ip_internet_service_node_collection_from_href(ensure_unparsed(nodes_uri)) - new_node = MockPublicIpInternetServiceNode.new(node_data, node_collection) - node_collection.items << new_node - mock_it 200, mock_node_service_response(new_node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/clone_vapp.rb b/lib/fog/vcloud/terremark/ecloud/requests/clone_vapp.rb deleted file mode 100644 index ed90b361b..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/clone_vapp.rb +++ /dev/null @@ -1,42 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Real - - def validate_clone_vapp_options(options) - valid_opts = [:name, :poweron] - unless valid_opts.all? { |opt| options.keys.include?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}") - end - end - - def generate_clone_vapp_request(uri, options) - xml = Builder::XmlMarkup.new - xml.CloneVAppParams(xmlns.merge!(:name => options[:name], :deploy => "true", :powerOn => options[:poweron])) { - xml.VApp( :href => uri, :type => "application/vnd.vmware.vcloud.vApp+xml", - :xmlns => "http://www.vmware.com/vcloud/v0.8") - } - end - - def clone_vapp(vdc_uri, vapp_uri, options = {}) - unless options.has_key?(:poweron) - options[:poweron] = "false" - end - - validate_clone_vapp_options(options) - - request( - :body => generate_clone_vapp_request(vapp_uri, options), - :expects => 202, - :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneVAppParams+xml'}, - :method => 'POST', - :uri => vdc_uri + '/action/clonevapp', - :parse => true - ) - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb deleted file mode 100644 index 7bdd5af86..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +++ /dev/null @@ -1,115 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def validate_public_ip_address_data(ip_address_data) - valid_opts = [:name, :href, :id] - unless valid_opts.all? { |opt| ip_address_data.keys.include?(opt) } - raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - ip_address_data.keys).map(&:inspect).join(", ")}") - end - end - end - - class Real - include Shared - - def configure_internet_service(internet_service_uri, service_data, ip_address_data) - validate_internet_service_data(service_data, true) - - validate_public_ip_address_data(ip_address_data) - - if monitor = service_data[:monitor] - validate_internet_service_monitor(monitor) - ensure_monitor_defaults!(monitor) - end - - request( - :body => generate_configure_internet_service_request(service_data, ip_address_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}, - :method => 'PUT', - :uri => internet_service_uri, - :parse => true - ) - end - - private - - def generate_configure_internet_service_request(service_data, ip_address_data) - builder = Builder::XmlMarkup.new - builder.InternetService(ecloud_xmlns) { - builder.Id(service_data[:id]) - builder.Href(service_data[:href]) - builder.Name(service_data[:name]) - builder.Protocol(service_data[:protocol]) - builder.Port(service_data[:port]) - builder.Enabled(service_data[:enabled]) - builder.Description(service_data[:description]) - builder.Timeout(service_data[:timeout]) - builder.RedirectURL(service_data[:redirect_url]) - builder.PublicIpAddress { - builder.Id(ip_address_data[:id]) - builder.Href(ip_address_data[:href]) - builder.Name(ip_address_data[:name]) - } - if monitor = service_data[:monitor] - generate_monitor_section(builder, monitor) - end - if service_data[:backup_service_uri] - builder.BackupService do - builder.Href(service_data[:backup_service_uri]) - end - end - } - end - end - - class Mock - include Shared - - # - # Based on - # http://support.theenterprisecloud.com/kb/default.asp?id=583&Lang=1&SID= - # - - def configure_internet_service(internet_service_uri, service_data, ip_address_data) - service_data = service_data.dup - - validate_internet_service_data(service_data, true) - - if monitor = service_data[:monitor] - validate_internet_service_monitor(monitor) - ensure_monitor_defaults!(monitor) - end - - validate_public_ip_address_data(ip_address_data) - - internet_service_uri = ensure_unparsed(internet_service_uri) - - backup_service_uri = service_data.delete(:backup_service_uri) - backup_service = backup_service_uri && mock_data.backup_internet_service_from_href(backup_service_uri) - - xml = nil - - if (public_ip_internet_service = mock_data.public_ip_internet_service_from_href(internet_service_uri)) && - (backup_service_uri.nil? || backup_service) - public_ip_internet_service.update(service_data.reject {|k, v| [:id, :href].include?(k) }) - public_ip_internet_service[:backup_service] = backup_service - xml = generate_internet_service(Builder::XmlMarkup.new, public_ip_internet_service, true) - end - - if xml - mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb b/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb deleted file mode 100644 index f6f60d73a..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - class Real - - def validate_network_data(network_data, configure=false) - valid_opts = [:id, :href, :name, :rnat, :address, :broadcast, :gateway] - unless valid_opts.all? { |opt| network_data.keys.include?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - network_data.keys).map(&:inspect).join(", ")}") - end - end - - def configure_network(network_uri, network_data) - validate_network_data(network_data) - - request( - :body => generate_configure_network_request(network_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.networkService+xml'}, - :method => 'PUT', - :uri => network_uri, - :parse => true - ) - end - - private - - def generate_configure_network_request(network_data) - builder = Builder::XmlMarkup.new - builder.Network(ecloud_xmlns) { - builder.Id(network_data[:id]) - builder.Href(network_data[:href]) - builder.Name(network_data[:name]) - builder.RnatAddress(network_data[:rnat]) - builder.Address(network_data[:address]) - builder.BroadcastAddress(network_data[:broadcast]) - builder.GatewayAddress(network_data[:gateway]) - } - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb b/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb deleted file mode 100644 index c0caf1e19..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +++ /dev/null @@ -1,68 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def validate_network_ip_data(network_ip_data) - valid_opts = [:id, :href, :name, :status, :server, :rnat] - unless valid_opts.all? { |opt| network_ip_data.keys.include?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - network_ip_data.keys).map(&:inspect).join(", ")}") - end - end - end - - class Real - include Shared - - def configure_network_ip(network_ip_uri, network_ip_data) - validate_network_ip_data(network_ip_data) - - request( - :body => generate_configure_network_ip_request(network_ip_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' }, - :method => 'PUT', - :uri => network_ip_uri, - :parse => true - ) - end - - private - - def generate_configure_network_ip_request(network_ip_data) - builder = Builder::XmlMarkup.new - builder.IpAddress(ecloud_xmlns) { - builder.Id(network_ip_data[:id]) - builder.Href(network_ip_data[:href]) - builder.Name(network_ip_data[:name]) - builder.Status(network_ip_data[:status]) - builder.Server(network_ip_data[:server]) - builder.RnatAddress(network_ip_data[:rnat]) - } - end - end - - class Mock - include Shared - - def configure_network_ip(network_ip_uri, network_ip_data) - validate_network_ip_data(network_ip_data) - - if network_ip = mock_data.network_ip_from_href(network_ip_uri) - network_ip[:rnat] = network_ip_data[:rnat] - - builder = Builder::XmlMarkup.new - xml = network_ip_response(builder, network_ip, ecloud_xmlns) - - mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb b/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb deleted file mode 100644 index 6ee1bc29f..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +++ /dev/null @@ -1,58 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def generate_configure_node_request(node_data) - builder = Builder::XmlMarkup.new - builder.NodeService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance", - :xmlns => "urn:tmrk:eCloudExtensions-2.0") { - builder.Name(node_data[:name]) - builder.Enabled(node_data[:enabled].to_s) - builder.Description(node_data[:description]) - } - end - - end - - class Real - include Shared - - def configure_node(node_uri, node_data) - validate_node_data(node_data, true) - - request( - :body => generate_configure_node_request(node_data), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'}, - :method => 'PUT', - :uri => node_uri, - :parse => true - ) - end - - end - - class Mock - include Shared - - def configure_node(node_uri, node_data) - validate_node_data(node_data, true) - - if node = mock_data.public_ip_internet_service_node_from_href(ensure_unparsed(node_uri)) - node.update(node_data) - #if node_data[:enabled] - # node.enabled = (node_data[:enabled] == "true") ? true : false - #end - mock_it 200, mock_node_service_response(node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb b/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb deleted file mode 100644 index 084bf7ce6..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +++ /dev/null @@ -1,147 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def validate_vapp_data(vapp_data) - valid_opts = [:name, :cpus, :memory, :disks] - unless valid_opts.all? { |opt| vapp_data.keys.include?(opt) } - raise ArgumentError.new("Required Vapp data missing: #{(valid_opts - vapp_data.keys).map(&:inspect).join(", ")}") - end - end - end - - class Real - include Shared - - def generate_configure_vapp_request(vapp_uri, vapp_data) - rasd_xmlns = { "xmlns" => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" } - - xml = Nokogiri::XML(request( :uri => vapp_uri).body) - xml.root['name'] = vapp_data[:name] - - #cpu - xml.at("//xmlns:ResourceType[.='3']/..", rasd_xmlns).at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:cpus] - - #memory - xml.at("//xmlns:ResourceType[.='4']/..", rasd_xmlns).at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:memory] - - #disks - real_disks = xml.xpath("//xmlns:ResourceType[ .='17']/..", rasd_xmlns) - real_disk_numbers = real_disks.map { |disk| disk.at('.//xmlns:AddressOnParent', rasd_xmlns).content } - disk_numbers = vapp_data[:disks].map { |vdisk| vdisk[:number].to_s } - - if vapp_data[:disks].length < real_disks.length - #Assume we're removing a disk - remove_disk_numbers = real_disk_numbers - disk_numbers - remove_disk_numbers.each do |number| - if result = xml.at("//xmlns:ResourceType[ .='17']/../xmlns:AddressOnParent[.='#{number}']/..", rasd_xmlns) - result.remove - end - end - elsif vapp_data[:disks].length > real_disks.length - add_disk_numbers = disk_numbers - real_disk_numbers - - add_disk_numbers.each do |number| - new_disk = real_disks.first.dup - new_disk.at('.//xmlns:AddressOnParent', rasd_xmlns).content = -1 - new_disk.at('.//xmlns:VirtualQuantity', rasd_xmlns).content = vapp_data[:disks].detect { |disk| disk[:number].to_s == number.to_s }[:size] - real_disks.first.parent << new_disk - end - end - - #puts xml.root.to_s - xml.root.to_s - - #builder = Builder::XmlMarkup.new - #builder.Vapp(:href => vapp_uri.to_s, - # :type => 'application/vnd.vmware.vcloud.vApp+xml', - # :name => vapp_data[:name], - # :status => 2, - # :size => 0, - # :xmlns => 'http://www.vmware.com/vcloud/v0.8', - # :"xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance', - # :"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema') { - # #builder.VirtualHardwareSection(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { - # builder.Section(:"xsi:type" => "q2:VirtualHardwareSection_Type", :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"xmlns:q2" => "http://www.vmware.com/vcloud/v0.8") { - # builder.Info('Virtual Hardware') - # builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { - # #builder.Item { - # builder.InstanceID(1, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.ResourceType(3, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.VirtualQuantity(vapp_data[:cpus], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # } - # builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { - # #builder.Item { - # builder.InstanceID(2, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.ResourceType(4, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.VirtualQuantity(vapp_data[:memory], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # } - # vapp_data[:disks].each do |disk_data| - # #builder.Item(:xmlns => 'http://schemas.dmtf.org/ovf/envelope/1') { - # builder.Item { - # builder.AddressOnParent(disk_data[:number], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.HostResource(disk_data[:resource], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.InstanceID(9, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.ResourceType(17, :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # builder.VirtualQuantity(disk_data[:size], :xmlns => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData') - # } - # end - # - # } - #} - end - - def configure_vapp(vapp_uri, vapp_data) - validate_vapp_data(vapp_data) - - request( - :body => generate_configure_vapp_request(vapp_uri, vapp_data), - :expects => 202, - :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vApp+xml' }, - :method => 'PUT', - :uri => vapp_uri, - :parse => true - ) - end - - end - - class Mock - include Shared - - def configure_vapp(vapp_uri, vapp_data) - validate_vapp_data(vapp_data) - - if vapp = mock_data.virtual_machine_from_href(vapp_uri) - vapp_data.each do |key, value| - case key - when :cpus, :memory - vapp[key] = value - when :disks - addresses_to_delete = vapp.disks.map {|d| d.address } - value.map {|d| d[:number] } - addresses_to_delete.each do |address_to_delete| - vapp.disks.delete(vapp.disks.at_address(address_to_delete)) - end - - current_addresses = vapp.disks.map {|d| d.address } - disks_to_add = value.find_all {|d| !current_addresses.include?(d[:number]) } - disks_to_add.each do |disk_to_add| - vapp.disks << MockVirtualMachineDisk.new(:size => disk_to_add[:size] / 1024, :address => disk_to_add[:number]) - end - end - end - - mock_it 200, '', { "Location" => mock_data.base_url + "/some_tasks/1234" } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb deleted file mode 100644 index d38d25a03..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :delete_internet_service, 200, 'DELETE', {}, "" - end - - class Mock - def delete_internet_service(service_uri) - if public_ip_internet_service = mock_data.public_ip_internet_service_from_href(service_uri) - public_ip_internet_service._parent.items.delete(public_ip_internet_service) - - mock_it 200, '', { } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb b/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb deleted file mode 100644 index df6903544..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :delete_node, 200, 'DELETE', {}, "" - end - - class Mock - - def delete_node(node_uri) - if node = mock_data.public_ip_internet_service_node_from_href(ensure_unparsed(node_uri)) - node._parent.items.delete(node) - mock_it 200, '', {} - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb b/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb deleted file mode 100644 index 7b7897d16..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +++ /dev/null @@ -1,32 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :delete_vapp, 202, "DELETE" - end - - class Mock - def delete_vapp(vapp_uri) - if virtual_machine = mock_data.virtual_machine_from_href(vapp_uri) - vdc = virtual_machine._parent - - if vdc.internet_service_collection.items.detect {|is| is.node_collection.items.any? {|isn| isn.ip_address == virtual_machine.ip } } || - virtual_machine.status != 2 || - virtual_machine.network_ip.rnat_set? - mock_it 202, '', {} - else - vdc.virtual_machines.delete(virtual_machine) - mock_it 202, '', { "Location" => mock_data.base_url + "/some_tasks/1234" } - end - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb deleted file mode 100644 index 0e6613fcf..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_catalog - end - - class Mock - def get_catalog(catalog_uri) - catalog_uri = ensure_unparsed(catalog_uri) - xml = nil - - if catalog = mock_data.catalog_from_href(catalog_uri) - builder = Builder::XmlMarkup.new - - xml = builder.Catalog(xmlns.merge( - :type => "application/vnd.vmware.vcloud.catalog+xml", - :href => catalog.href, - :name => catalog.name - )) do |xml| - xml.CatalogItems do |xml| - catalog.items.each do |catalog_item| - xml.CatalogItem( - :type => "application/vnd.vmware.vcloud.catalogItem+xml", - :href => catalog_item.href, - :name => catalog_item.name - ) - end - end - end - end - - if xml - mock_it 200, - xml, { 'Content-Type' => 'application/vnd.vmware.vcloud.catalog+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb deleted file mode 100644 index a6a337dd5..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_catalog_item - end - - class Mock - - # - # Based on - # http://support.theenterprisecloud.com/kb/default.asp?id=542&Lang=1&SID= - # - - def get_catalog_item(catalog_item_uri) - if catalog_item = mock_data.catalog_item_from_href(catalog_item_uri) - builder = Builder::XmlMarkup.new - - xml = builder.CatalogItem(xmlns.merge(:href => catalog_item.href, :name => catalog_item.name)) do - builder.Link( - :rel => "down", - :href => catalog_item.customization.href, - :type => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml", - :name => catalog_item.customization.name - ) - - builder.Entity( - :href => catalog_item.vapp_template.href, - :type => "application/vnd.vmware.vcloud.vAppTemplate+xml", - :name => catalog_item.vapp_template.name - ) - - builder.Property(0, :key => "LicensingCost") - end - end - - if xml - mock_it 200, xml, {'Content-Type' => 'application/vnd.vmware.vcloud.catalogItem+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb deleted file mode 100644 index 598f010a5..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_customization_options - end - - class Mock - def get_customization_options(options_uri) - builder = Builder::XmlMarkup.new - xml = builder.CustomizationParameters(xmlns) do - builder.CustomizeNetwork "true" - builder.CustomizePassword "false" - end - - mock_it 200, xml, "Content-Type" => "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acl.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acl.rb deleted file mode 100644 index 40cbedb81..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acl.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_firewall_acl - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acls.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acls.rb deleted file mode 100644 index e689532ac..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_firewall_acls.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_firewall_acls - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb deleted file mode 100644 index 2394ab9f9..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +++ /dev/null @@ -1,84 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_internet_services - end - - class Mock - # - #Based off of: - #http://support.theenterprisecloud.com/kb/default.asp?id=580&Lang=1&SID= - #http://support.theenterprisecloud.com/kb/default.asp?id=560&Lang=1&SID= - # - # - - def get_internet_services(internet_services_uri) - internet_services_uri = ensure_unparsed(internet_services_uri) - xml = nil - - if vdc_internet_service_collection = mock_data.vdc_internet_service_collection_from_href(internet_services_uri) - xml = generate_internet_services(vdc_internet_service_collection.items) - elsif public_ip_internet_service_collection = mock_data.public_ip_internet_service_collection_from_href(internet_services_uri) - xml = generate_internet_services(public_ip_internet_service_collection.items) - end - - if xml - mock_it 200, - xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.internetServicesList+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - - private - - def generate_internet_services(services) - builder = Builder::XmlMarkup.new - - builder.InternetServices("xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {|xml| - services.each do |service| - generate_internet_service(xml, service) - end - } - end - - def generate_internet_service(xml, service, by_itself = false) - xml.InternetService(by_itself ? { "xmlns" => "urn:tmrk:eCloudExtensions-2.5", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" } : {}) { - xml.Id service.object_id - xml.Href service.href - xml.Name service.name - if MockDataClasses::MockBackupInternetService === service - xml.PublicIpAddress "i:nil" => true - else - xml.PublicIpAddress { - xml.Id service._parent._parent.object_id - xml.Href service._parent._parent.href - xml.Name service._parent._parent.name - } - end - xml.Port service.port - xml.Protocol service.protocol - xml.Enabled service.enabled - xml.Timeout service.timeout - xml.Description service.description - xml.RedirectURL service.redirect_url - xml.Monitor "i:nil" => true - xml.IsBackupService MockDataClasses::MockBackupInternetService === service - if MockDataClasses::MockPublicIpInternetService === service && service.backup_service - xml.BackupService do - xml.Href service.backup_service.href - end - else - xml.BackupService "i:nil" => true - end - xml.BackupOf - } - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb deleted file mode 100644 index 3df88a1e0..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_network - end - - class Mock - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=546&Lang=1&SID= - # - - def get_network(network_uri) - network_uri = ensure_unparsed(network_uri) - - if network = mock_data.network_from_href(network_uri) - builder = Builder::XmlMarkup.new - xml = builder.Network(xmlns.merge(:href => network.href, :name => network.name, :type => "application/vnd.vmware.vcloud.network+xml")) { - builder.Link(:rel => "down", :href => network.ip_collection.href, :type => "application/xml", :name => network.ip_collection.name) - builder.Link(:rel => "down", :href => network.extensions.href, :type => "application/xml", :name => network.name) - builder.Configuration { - builder.Gateway(network.gateway) - builder.Netmask(network.netmask) - } - if network.features - builder.Features { - network.features.each do |feature| - builder.tag!(feature[:type], feature[:value]) - end - } - end - } - - mock_it 200, xml, { "Content-Type" => "application/vnd.vmware.vcloud.network+xml" } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb deleted file mode 100644 index d6a9fa4f7..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_network_extensions - end - - class Mock - - def get_network_extensions(network_extension_uri) - if network_extension = mock_data.network_extension_from_href(ensure_unparsed(network_extension_uri)) - xml = Builder::XmlMarkup.new - mock_it 200, xml.Network(ecloud_xmlns) { - xml.Address network_extension.address - xml.RnatAddress network_extension.rnat - xml.Href network_extension.href - xml.Id network_extension.object_id - xml.Name network_extension.name - xml.GatewayAddress network_extension.gateway - xml.BroadcastAddress network_extension.broadcast - xml.NetworkType network_extension.type - xml.Vlan network_extension.vlan - xml.FriendlyName network_extension.friendly_name - }, { 'Content-Type' => "application/vnd.tmrk.ecloud.network+xml" } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb deleted file mode 100644 index 8462a37b0..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# AFAICT this is basically undocumented ATM - 6/18/2010 - freeformz -# - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_network_ip - end - - class Mock - - def get_network_ip(network_ip_uri) - if network_ip = mock_data.network_ip_from_href(network_ip_uri) - builder = Builder::XmlMarkup.new - xml = network_ip_response(builder, network_ip, ecloud_xmlns) - - mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ip+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - - def network_ip_response(builder, network_ip, xmlns = {}) - builder.IpAddress(xmlns) do - builder.Id network_ip.object_id - builder.Href network_ip.href - builder.Name network_ip.name - - builder.Status network_ip.status - if network_ip.used_by - builder.Server network_ip.used_by.name - end - - builder.RnatAddress(network_ip.rnat) - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb deleted file mode 100644 index 11ec22ca6..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +++ /dev/null @@ -1,37 +0,0 @@ -# -# AFAICT - This is basically undocumented - 6/18/2010 - freeformz -# - -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_network_ips - end - - class Mock - - def get_network_ips(network_ips_uri) - network_ips_uri = ensure_unparsed(network_ips_uri) - - if network_ip_collection = mock_data.network_ip_collection_from_href(network_ips_uri) - builder = Builder::XmlMarkup.new - xml = builder.IpAddresses do - network_ip_collection.ordered_ips.each do |network_ip| - network_ip_response(builder, network_ip) - end - end - - mock_it 200, xml, { 'Content-Type' => 'application/vnd.tmrk.ecloud.ipAddressesList+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb deleted file mode 100644 index 60b786d23..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +++ /dev/null @@ -1,42 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_node - end - - class Mock - # - # Based on http://support.theenterprisecloud.com/kb/default.asp?id=641&Lang=1&SID= - # - - def mock_node_service_response(node) - xml = Builder::XmlMarkup.new - xml.NodeService(ecloud_xmlns) { - xml.Id(node.object_id) - xml.Href(node.href) - xml.Name(node.name) - xml.IpAddress(node.ip_address) - xml.Port(node.port) - xml.Enabled(node.enabled) - xml.Description(node.description) - } - end - - def get_node(node_uri) - node_uri = ensure_unparsed(node_uri) - - if public_ip_internet_service_node = mock_data.public_ip_internet_service_node_from_href(node_uri) - xml = Builder::XmlMarkup.new - mock_it 200, mock_node_service_response(public_ip_internet_service_node), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb deleted file mode 100644 index b0a74b0f9..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_nodes - end - - class Mock - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=637&Lang=1&SID= - # - - def get_nodes(nodes_uri) - nodes_uri = ensure_unparsed(nodes_uri) - - if public_ip_internet_service_node_collection = mock_data.public_ip_internet_service_node_collection_from_href(nodes_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.NodeServices(ecloud_xmlns) { - public_ip_internet_service_node_collection.items.each do |node| - xml.NodeService { - xml.Id node.object_id - xml.Href node.href - xml.Name node.name - xml.IpAddress node.ip_address - xml.Port node.port - xml.Enabled node.enabled - xml.Description node.description - } - end - }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_organization.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_organization.rb deleted file mode 100644 index 863da146b..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_organization.rb +++ /dev/null @@ -1,52 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_organization - end - - class Mock - - def get_organization(organization_uri) - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=540&Lang=1&SID= - # - # vCloud API Guide v0.9 - Page 26 - # - organization_uri = ensure_unparsed(organization_uri) - if organization = mock_data.organization_from_href(organization_uri) - xml = Builder::XmlMarkup.new - - mock_it 200, - xml.Org(xmlns.merge(:href => organization.href, :name => organization.name)) { - - organization.vdcs.each do |vdc| - xml.Link(:rel => "down", - :href => vdc.href, - :type => "application/vnd.vmware.vcloud.vdc+xml", - :name => vdc.name) - xml.Link(:rel => "down", - :href => vdc.catalog.href, - :type => "application/vnd.vmware.vcloud.catalog+xml", - :name => vdc.catalog.name) - xml.Link(:rel => "down", - :href => vdc.task_list.href, - :type => "application/vnd.vmware.vcloud.tasksList+xml", - :name => vdc.task_list.name) - end - }, - {'Content-Type' => "application/vnd.vmware.vcloud.org+xml" } - else - mock_error 200, "401 Unauthorized" - end - end - end - - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb deleted file mode 100644 index 26bb7e825..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_public_ip - end - - class Mock - # - #Based off of: - #http://support.theenterprisecloud.com/kb/default.asp?id=567&Lang=1&SID= - # - - def get_public_ip(public_ip_uri) - public_ip_uri = ensure_unparsed(public_ip_uri) - - if public_ip = mock_data.public_ip_from_href(public_ip_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.PublicIp(:xmlns => "urn:tmrk:eCloudExtensions-2.0", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") { - xml.Id public_ip.object_id - xml.Href public_ip.href - xml.Name public_ip.name - }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.publicIp+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb deleted file mode 100644 index 7fabb4a42..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +++ /dev/null @@ -1,41 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_public_ips - end - - class Mock - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=577&Lang=1&SID= - # - - def get_public_ips(public_ips_uri) - public_ips_uri = ensure_unparsed(public_ips_uri) - - if public_ip_collection = mock_data.public_ip_collection_from_href(public_ips_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.PublicIPAddresses { - public_ip_collection.items.each do |ip| - xml.PublicIPAddress { - xml.Id ip.object_id - xml.Href ip.href - xml.Name ip.name - } - end - }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.publicIpsList+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb deleted file mode 100644 index 8ffa5c553..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_task - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb deleted file mode 100644 index de7d21f1d..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_task_list - end - - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb deleted file mode 100644 index 7c4f524c3..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +++ /dev/null @@ -1,101 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_vapp - end - - class Mock - def return_vapp_as_creating!(name) - vapps_to_return_as_creating[name] = true - end - - def vapps_to_return_as_creating - @vapps_to_return_as_creating ||= {} - end - - def get_vapp(vapp_uri) - xml = nil - - if vapp = mock_data.virtual_machine_from_href(vapp_uri) - if vapps_to_return_as_creating[vapp.name] - xml = generate_instantiate_vapp_template_response(vapp) - else - xml = generate_get_vapp_response(vapp) - end - end - - if xml - mock_it 200, xml, "Content-Type" => "application/vnd.vmware.vcloud.vApp+xml" - else - mock_error 200, "401 Unauthorized" - end - end - - private - - def generate_get_vapp_response(vapp) - builder = Builder::XmlMarkup.new - builder.VApp(xmlns.merge( - :href => vapp.href, - :type => "application/vnd.vmware.vcloud.vApp+xml", - :name => vapp.name, - :status => vapp.status, - :size => vapp.size - )) do - builder.Link(:rel => "up", :href => vapp._parent.href, :type => "application/vnd.vmware.vcloud.vdc+xml") - - builder.NetworkConnectionSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do - builder.NetworkConnection(:Network => "Internal", :xmlns => "http://www.vmware.com/vcloud/v0.8") do - builder.IpAddress vapp.ip - end - end - - builder.OperatingSystemSection( - "d2p1:id" => 4, - :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", - "xmlns:d2p1" => "http://schemas.dmtf.org/ovf/envelope/1") do - builder.Info "The kind of installed guest operating system" - builder.Description "Red Hat Enterprise Linux 5 (64-bit)" - end - - builder.VirtualHardwareSection(:xmlns => "http://schemas.dmtf.org/ovf/envelope/1") do - builder.Info - builder.System - builder.Item do - # CPUs - builder.VirtualQuantity vapp.cpus - builder.ResourceType 3 - end - builder.Item do - # memory - builder.VirtualQuantity vapp.memory - builder.ResourceType 4 - end - builder.Item do - # SCSI controller - builder.Address 0 - builder.ResourceType 6 - builder.InstanceId 3 - end - - # Hard Disks - vapp.disks.each do |disk| - builder.Item do - builder.Parent 3 - builder.VirtualQuantity disk.vcloud_size - builder.HostResource disk.vcloud_size - builder.ResourceType 17 - builder.AddressOnParent disk.address - end - end - end - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_vapp_template.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_vapp_template.rb deleted file mode 100644 index 24f9125f7..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_vapp_template.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_vapp_template - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb deleted file mode 100644 index 875761df2..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +++ /dev/null @@ -1,87 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :get_vdc - end - - class Mock - # - #Based off of: - #http://support.theenterprisecloud.com/kb/default.asp?id=545&Lang=1&SID= - - def get_vdc(vdc_uri) - vdc_uri = ensure_unparsed(vdc_uri) - - if vdc = mock_data.vdc_from_href(vdc_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.Vdc(xmlns.merge(:href => vdc.href, :name => vdc.name)) { - xml.Link(:rel => "down", - :href => vdc.catalog.href, - :type => "application/vnd.vmware.vcloud.catalog+xml", - :name => vdc.catalog.name) - xml.Link(:rel => "down", - :href => vdc.public_ip_collection.href, - :type => "application/vnd.tmrk.ecloud.publicIpsList+xml", - :name => vdc.public_ip_collection.name) - xml.Link(:rel => "down", - :href => vdc.internet_service_collection.href, - :type => "application/vnd.tmrk.ecloud.internetServicesList+xml", - :name => vdc.internet_service_collection.name) - xml.Link(:rel => "down", - :href => vdc.firewall_acls.href, - :type => "application/vnd.tmrk.ecloud.firewallAclsList+xml", - :name => vdc.firewall_acls.name) - xml.Description("") - xml.StorageCapacity { - xml.Units("bytes * 10^9") - xml.Allocated(vdc.storage_allocated) - xml.Used(vdc.storage_used) - } - xml.ComputeCapacity { - xml.Cpu { - xml.Units("hz * 10^6") - xml.Allocated(vdc.cpu_allocated) - } - xml.Memory { - xml.Units("bytes * 2^20") - xml.Allocated(vdc.memory_allocated) - } - xml.DeployedVmsQuota { - xml.Limit("-1") - xml.Used("-1") - } - xml.InstantiatedVmsQuota { - xml.Limit("-1") - xml.Used("-1") - } - } - xml.ResourceEntities { - vdc.virtual_machines.each do |virtual_machine| - xml.ResourceEntity(:href => virtual_machine.href, - :type => "application/vnd.vmware.vcloud.vApp+xml", - :name => virtual_machine.name) - end - } - xml.AvailableNetworks { - vdc.networks.each do |network| - xml.Network(:href => network.href, - :type => "application/vnd.vmware.vcloud.network+xml", - :name => network.name) - end - } - }, { 'Content-Type' => 'application/vnd.vmware.vcloud.vdc+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - - end - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/get_versions.rb b/lib/fog/vcloud/terremark/ecloud/requests/get_versions.rb deleted file mode 100644 index 84d68e2d7..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/get_versions.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - unauthenticated_basic_request :get_versions - end - - class Mock - - def get_versions(versions_uri) - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=535&Lang=1&SID= - # https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/02-get-versions.aspx - # vCloud API Guide v0.9 - Page 89 - # - xml = Builder::XmlMarkup.new - - mock_it 200, - xml.SupportedVersions( xmlns.merge("xmlns" => "http://www.vmware.com/vcloud/versions")) { - - mock_data.versions.select {|version| version.supported }.each do |version| - xml.VersionInfo { - xml.Version(version.version) - xml.LoginUrl(version.login_url) - } - end - } - - end - - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb b/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb deleted file mode 100644 index c9dc2600e..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +++ /dev/null @@ -1,144 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - module Shared - private - - def validate_instantiate_vapp_template_options(catalog_item_uri, options) - valid_opts = [:name, :vdc_uri, :network_uri, :cpus, :memory, :row, :group] - unless valid_opts.all? { |opt| options.keys.include?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}") - end - - # Figure out the template_uri - catalog_item = get_catalog_item( catalog_item_uri ).body - catalog_item[:Entity] = [ catalog_item[:Entity] ] if catalog_item[:Entity].is_a?(Hash) - catalog_item[:Link] = [ catalog_item[:Link] ] if catalog_item[:Link].is_a?(Hash) - - options[:template_uri] = begin - catalog_item[:Entity].detect { |entity| entity[:type] == "application/vnd.vmware.vcloud.vAppTemplate+xml" }[:href] - rescue - raise RuntimeError.new("Unable to locate template uri for #{catalog_item_uri}") - end - - customization_options = begin - customization_href = catalog_item[:Link].detect { |link| link[:type] == "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" }[:href] - get_customization_options( customization_href ).body - rescue - raise RuntimeError.new("Unable to get customization options for #{catalog_item_uri}") - end - - # Check to see if we can set the password - if options[:password] and customization_options[:CustomizePassword] == "false" - raise ArgumentError.new("This catalog item (#{catalog_item_uri}) does not allow setting a password.") - end - - # According to the docs if CustomizePassword is "true" then we NEED to set a password - if customization_options[:CustomizePassword] == "true" and ( options[:password].nil? or options[:password].empty? ) - raise ArgumentError.new("This catalog item (#{catalog_item_uri}) requires a :password to instantiate.") - end - end - - def generate_instantiate_vapp_template_request(options) - xml = Builder::XmlMarkup.new - xml.InstantiateVAppTemplateParams(xmlns.merge!(:name => options[:name], :"xml:lang" => "en")) { - xml.VAppTemplate(:href => options[:template_uri]) - xml.InstantiationParams { - xml.ProductSection( :"xmlns:q1" => "http://www.vmware.com/vcloud/v0.8", :"xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { - if options[:password] - xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "password", :"ovf:value" => options[:password] ) - end - xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "row", :"ovf:value" => options[:row] ) - xml.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "group", :"ovf:value" => options[:group] ) - } - xml.VirtualHardwareSection( :"xmlns:q1" => "http://www.vmware.com/vcloud/v0.8" ) { - # # of CPUS - xml.Item( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1" ) { - xml.InstanceID(1, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - xml.ResourceType(3, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - xml.VirtualQuantity(options[:cpus], :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - } - # Memory - xml.Item( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1" ) { - xml.InstanceID(2, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - xml.ResourceType(4, :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - xml.VirtualQuantity(options[:memory], :xmlns => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") - } - } - xml.NetworkConfigSection { - xml.NetworkConfig { - xml.NetworkAssociation( :href => options[:network_uri] ) - } - } - } - } - end - end - - class Real - include Shared - - def instantiate_vapp_template(catalog_item_uri, options = {}) - validate_instantiate_vapp_template_options(catalog_item_uri, options) - - request( - :body => generate_instantiate_vapp_template_request(options), - :expects => 200, - :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'}, - :method => 'POST', - :uri => options[:vdc_uri] + '/action/instantiatevAppTemplate', - :parse => true - ) - end - end - - class Mock - include Shared - - # - # Based on - # http://support.theenterprisecloud.com/kb/default.asp?id=554&Lang=1&SID= - # - - def instantiate_vapp_template(catalog_item_uri, options = {}) - validate_instantiate_vapp_template_options(catalog_item_uri, options) - catalog_item = mock_data.catalog_item_from_href(catalog_item_uri) - - xml = nil - if vdc = mock_data.vdc_from_href(options[:vdc_uri]) - if network = mock_data.network_from_href(options[:network_uri]) - new_vm = MockVirtualMachine.new({ :name => options[:name], :ip => network.random_ip, :cpus => options[:cpus], :memory => options[:memory] }, vdc) - new_vm.disks.push(*catalog_item.disks.dup) - vdc.virtual_machines << new_vm - - xml = generate_instantiate_vapp_template_response(new_vm) - end - end - - if xml - mock_it 200, xml, {'Content-Type' => 'application/xml'} - else - mock_error 200, "401 Unauthorized" - end - end - - private - - def generate_instantiate_vapp_template_response(vapp) - builder = Builder::XmlMarkup.new - builder.VApp(xmlns.merge( - :href => vapp.href, - :type => "application/vnd.vmware.vcloud.vApp+xml", - :name => vapp.name, - :status => 0, - :size => 4 - )) { - builder.Link(:rel => "up", :href => vapp._parent.href, :type => "application/vnd.vmware.vcloud.vdc+xml") - } - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/login.rb b/lib/fog/vcloud/terremark/ecloud/requests/login.rb deleted file mode 100644 index e43af934d..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/login.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - - - def login - unauthenticated_request({ - :expects => 200, - :headers => { - 'Authorization' => authorization_header - }, - :method => 'POST', - :parse => true, - :uri => login_uri - }) - end - - end - - class Mock - - def login - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=536&Lang=1&SID= - # https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/01-get-login-token.aspx - # vCloud API Guide v0.9 - Page 17 - # - xml = Builder::XmlMarkup.new - - mock_it 200, - xml.OrgList(xmlns) { - mock_data.organizations.each do |organization| - xml.Org( :type => "application/vnd.vmware.vcloud.org+xml", :href => organization.href, :name => organization.name ) - end - }, - { 'Set-Cookie' => 'vcloud-token=fc020a05-21d7-4f33-9b2a-25d8cd05a44e; path=/', - 'Content-Type' => 'application/vnd.vmware.vcloud.orgslist+xml' } - - end - - end - - end - end - end -end - diff --git a/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb b/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb deleted file mode 100644 index 059fe412f..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :power_off, 202, 'POST' - end - - class Mock - def power_off(vapp_uri) - if vapp = mock_data.virtual_machine_from_href(vapp_uri) - vapp.power_off! - - builder = Builder::XmlMarkup.new - mock_it 200, builder.Task(xmlns) - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb b/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb deleted file mode 100644 index c98c5f6b9..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :power_on, 202, 'POST' - end - - class Mock - def power_on(vapp_uri) - if vapp = mock_data.virtual_machine_from_href(vapp_uri) - vapp.power_on! - - builder = Builder::XmlMarkup.new - mock_it 200, builder.Task(xmlns) - else - mock_error 200, "401 Unauthorized" - end - end - end - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb b/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb deleted file mode 100644 index 57586d0b5..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :power_reset, 202, 'POST' - end - - end - end - end -end diff --git a/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb b/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb deleted file mode 100644 index cc8e3628f..000000000 --- a/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Fog - class Vcloud - module Terremark - class Ecloud - - class Real - basic_request :power_shutdown, 204, 'POST' - end - - end - end - end -end diff --git a/spec/ecloud/bin_spec.rb b/spec/ecloud/bin_spec.rb new file mode 100644 index 000000000..1f934c44d --- /dev/null +++ b/spec/ecloud/bin_spec.rb @@ -0,0 +1,22 @@ +require 'ecloud/spec_helper' + +describe 'Ecloud' do + it { Ecloud.should be_available } + + it { Ecloud.should have_at_least(1).services } + + describe "when indexing it like an array" do + describe "with a service that exists" do + it "should return something when indexed with a configured service" do + Ecloud[:compute].should_not be_nil + end + end + + describe "with a service that does not exist" do + it "should raise an ArgumentError" do + lambda {Ecloud[:foozle]}.should raise_error(ArgumentError) + end + end + + end +end diff --git a/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb b/spec/ecloud/models/backup_internet_service_spec.rb similarity index 83% rename from spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb rename to spec/ecloud/models/backup_internet_service_spec.rb index 537a3d55b..705568321 100644 --- a/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +++ b/spec/ecloud/models/backup_internet_service_spec.rb @@ -1,11 +1,11 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::BackupInternetService", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::BackupInternetService", :type => :mock_tmrk_ecloud_model do subject { @vcloud.vdcs[0].backup_internet_services[0] } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::BackupInternetService } + subject { Fog::Ecloud::Compute::BackupInternetService } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :name, :id, :protocol, :enabled, :description, :timeout, :redirect_url, :monitor]) } @@ -13,7 +13,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::BackupInternetService.new() } + subject { Fog::Ecloud::Compute::BackupInternetService.new() } it { should have_all_attributes_be_nil } end @@ -23,7 +23,7 @@ if Fog.mocking? let(:composed_service_data) { @vcloud.vdcs[0].backup_internet_services[0].send(:_compose_service_data) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::BackupInternetService) } + it { should be_an_instance_of(Fog::Ecloud::Compute::BackupInternetService) } its(:href) { should == @mock_backup_service.href } its(:identity) { should == @mock_backup_service.href } diff --git a/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb b/spec/ecloud/models/backup_internet_services_spec.rb similarity index 62% rename from spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb rename to spec/ecloud/models/backup_internet_services_spec.rb index 84064285e..40de52f21 100644 --- a/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +++ b/spec/ecloud/models/backup_internet_services_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::InternetServices", :type => :mock_tmrk_ecloud_model do context "as an attribute of a VDC" do subject { @vcloud.vdcs[0] } @@ -9,7 +9,7 @@ if Fog.mocking? describe :class do subject { @vcloud.vdcs[0].backup_internet_services.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::BackupInternetService } + its(:model) { should == Fog::Ecloud::Compute::BackupInternetService } end describe :backup_internet_services do @@ -17,7 +17,7 @@ if Fog.mocking? it { should respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::BackupInternetServices) } + it { should be_an_instance_of(Fog::Ecloud::Compute::BackupInternetServices) } its(:length) { should == 1 } diff --git a/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb b/spec/ecloud/models/internet_service_spec.rb similarity index 92% rename from spec/vcloud/terremark/ecloud/models/internet_service_spec.rb rename to spec/ecloud/models/internet_service_spec.rb index 42e90521e..90267fa06 100644 --- a/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +++ b/spec/ecloud/models/internet_service_spec.rb @@ -1,11 +1,11 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::InternetService", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::InternetService", :type => :mock_tmrk_ecloud_model do subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::InternetService } + subject { Fog::Ecloud::Compute::InternetService } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :name, :id, :protocol, :port, :enabled, :description, :public_ip, :timeout, :redirect_url, :monitor, :backup_service_data]) } @@ -13,7 +13,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::InternetService.new() } + subject { Fog::Ecloud::Compute::InternetService.new() } it { should have_all_attributes_be_nil } end @@ -29,7 +29,7 @@ if Fog.mocking? let(:composed_public_ip_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_ip_data) } let(:composed_service_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_service_data) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::InternetService) } + it { should be_an_instance_of(Fog::Ecloud::Compute::InternetService) } its(:href) { should == @mock_service.href } its(:identity) { should == @mock_service.href } diff --git a/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb b/spec/ecloud/models/internet_services_spec.rb similarity index 62% rename from spec/vcloud/terremark/ecloud/models/internet_services_spec.rb rename to spec/ecloud/models/internet_services_spec.rb index 03e4e5542..67284411e 100644 --- a/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +++ b/spec/ecloud/models/internet_services_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::InternetServices", :type => :mock_tmrk_ecloud_model do context "as an attribute of a VDC" do subject { @vcloud.vdcs[0] } @@ -9,7 +9,7 @@ if Fog.mocking? describe :class do subject { @vcloud.vdcs[0].internet_services.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::InternetService } + its(:model) { should == Fog::Ecloud::Compute::InternetService } end describe :internet_services do @@ -17,7 +17,7 @@ if Fog.mocking? it { should respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::InternetServices) } + it { should be_an_instance_of(Fog::Ecloud::Compute::InternetServices) } its(:length) { should == 4 } diff --git a/spec/vcloud/terremark/ecloud/models/ip_spec.rb b/spec/ecloud/models/ip_spec.rb similarity index 69% rename from spec/vcloud/terremark/ecloud/models/ip_spec.rb rename to spec/ecloud/models/ip_spec.rb index 6959f9233..3d3cf0ea7 100644 --- a/spec/vcloud/terremark/ecloud/models/ip_spec.rb +++ b/spec/ecloud/models/ip_spec.rb @@ -1,18 +1,18 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Ip", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Ip", :type => :mock_tmrk_ecloud_model do subject { @vcloud } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::Ip } + subject { Fog::Ecloud::Compute::Ip } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :name, :status, :server, :rnat, :id]) } end context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::Ip.new() } + subject { Fog::Ecloud::Compute::Ip.new() } it { should have_all_attributes_be_nil } end @@ -20,7 +20,7 @@ if Fog.mocking? context "as a collection member" do subject { @ip = @vcloud.vdcs[0].networks[0].ips[0] } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Ip) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Ip) } its(:name) { should == @mock_data.network_ip_from_href(@ip.href).name } its(:status) { should == @mock_data.network_ip_from_href(@ip.href).status } diff --git a/spec/vcloud/terremark/ecloud/models/ips_spec.rb b/spec/ecloud/models/ips_spec.rb similarity index 60% rename from spec/vcloud/terremark/ecloud/models/ips_spec.rb rename to spec/ecloud/models/ips_spec.rb index 3c81d5155..8ee243c83 100644 --- a/spec/vcloud/terremark/ecloud/models/ips_spec.rb +++ b/spec/ecloud/models/ips_spec.rb @@ -1,21 +1,21 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Ips", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Ips", :type => :mock_tmrk_ecloud_model do subject { @vcloud } it { should respond_to(:ips) } describe :class do subject { @vcloud.vdcs[0].networks[0].ips.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Ip } + its(:model) { should == Fog::Ecloud::Compute::Ip } end describe :ips do subject { @vcloud.vdcs[0].networks[0].ips.reload } it { should_not respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Ips) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Ips) } its(:length) { should == 252 } diff --git a/spec/vcloud/terremark/ecloud/models/network_spec.rb b/spec/ecloud/models/network_spec.rb similarity index 88% rename from spec/vcloud/terremark/ecloud/models/network_spec.rb rename to spec/ecloud/models/network_spec.rb index 24c6589da..4c42c5dfa 100644 --- a/spec/vcloud/terremark/ecloud/models/network_spec.rb +++ b/spec/ecloud/models/network_spec.rb @@ -1,11 +1,11 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Network", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Network", :type => :mock_tmrk_ecloud_model do subject { @vcloud } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::Network } + subject { Fog::Ecloud::Compute::Network } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :name, :features, :links, :type, :gateway, :broadcast, :address, :rnat, :extension_href, :network_type, :vlan, :friendly_name]) } @@ -13,7 +13,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::Network.new() } + subject { Fog::Ecloud::Compute::Network.new() } it { should have_all_attributes_be_nil } end @@ -21,7 +21,7 @@ if Fog.mocking? context "as a collection member" do subject { @vcloud.vdcs[0].networks[0].reload } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Network) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Network) } its(:href) { should == @mock_network.href } its(:identity) { should == @mock_network.href } diff --git a/spec/vcloud/terremark/ecloud/models/networks_spec.rb b/spec/ecloud/models/networks_spec.rb similarity index 57% rename from spec/vcloud/terremark/ecloud/models/networks_spec.rb rename to spec/ecloud/models/networks_spec.rb index 04fe67447..48d829576 100644 --- a/spec/vcloud/terremark/ecloud/models/networks_spec.rb +++ b/spec/ecloud/models/networks_spec.rb @@ -1,21 +1,21 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Networks", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Networks", :type => :mock_tmrk_ecloud_model do subject { @vcloud } it { should respond_to(:networks) } describe :class do subject { @vcloud.networks.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Network } + its(:model) { should == Fog::Ecloud::Compute::Network } end describe :networks do subject { @vcloud.vdcs[0].networks } it { should_not respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Networks) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Networks) } its(:length) { should == 2 } diff --git a/spec/vcloud/terremark/ecloud/models/node_spec.rb b/spec/ecloud/models/node_spec.rb similarity index 76% rename from spec/vcloud/terremark/ecloud/models/node_spec.rb rename to spec/ecloud/models/node_spec.rb index b0df0cba8..ee253406f 100644 --- a/spec/vcloud/terremark/ecloud/models/node_spec.rb +++ b/spec/ecloud/models/node_spec.rb @@ -1,12 +1,12 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Node", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Node", :type => :mock_tmrk_ecloud_model do subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::Node } + subject { Fog::Ecloud::Compute::Node } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :ip_address, :description, :name, :port, :enabled, :id]) } @@ -14,7 +14,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::Node.new() } + subject { Fog::Ecloud::Compute::Node.new() } it { should have_all_attributes_be_nil } end @@ -22,7 +22,7 @@ if Fog.mocking? context "as a collection member" do subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first.reload } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Node) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Node) } its(:href) { should == @mock_node.href } its(:identity) { should == @mock_node.href } diff --git a/spec/vcloud/terremark/ecloud/models/nodes_spec.rb b/spec/ecloud/models/nodes_spec.rb similarity index 67% rename from spec/vcloud/terremark/ecloud/models/nodes_spec.rb rename to spec/ecloud/models/nodes_spec.rb index 3de6f9a03..7e748d989 100644 --- a/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +++ b/spec/ecloud/models/nodes_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::InternetServices", :type => :mock_tmrk_ecloud_model do context "as an attribute of an internet_service" do subject { @vcloud.vdcs.first.public_ips.first.internet_services.first } @@ -9,7 +9,7 @@ if Fog.mocking? describe :class do subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Node } + its(:model) { should == Fog::Ecloud::Compute::Node } end describe :nodes do @@ -17,7 +17,7 @@ if Fog.mocking? it { should respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Nodes) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Nodes) } its(:length) { should == 3 } diff --git a/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb b/spec/ecloud/models/public_ip_spec.rb similarity index 70% rename from spec/vcloud/terremark/ecloud/models/public_ip_spec.rb rename to spec/ecloud/models/public_ip_spec.rb index 5d3b0d466..7e55bb122 100644 --- a/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +++ b/spec/ecloud/models/public_ip_spec.rb @@ -1,11 +1,11 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::PublicIp", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::PublicIp", :type => :mock_tmrk_ecloud_model do subject { @vcloud } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::PublicIp } + subject { Fog::Ecloud::Compute::PublicIp } it { should have_identity(:href) } it { should have_only_these_attributes([:name, :id, :href]) } @@ -13,7 +13,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::PublicIp.new() } + subject { Fog::Ecloud::Compute::PublicIp.new() } it { should have_all_attributes_be_nil } end @@ -21,7 +21,7 @@ if Fog.mocking? context "as a collection member" do subject { @vcloud.vdcs[0].public_ips[0].reload; @vcloud.vdcs[0].public_ips[0] } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::PublicIp) } + it { should be_an_instance_of(Fog::Ecloud::Compute::PublicIp) } its(:href) { should == @mock_public_ip.href } its(:identity) { should == @mock_public_ip.href } diff --git a/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb b/spec/ecloud/models/public_ips_spec.rb similarity index 58% rename from spec/vcloud/terremark/ecloud/models/public_ips_spec.rb rename to spec/ecloud/models/public_ips_spec.rb index 1d5f71114..38b906c4a 100644 --- a/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +++ b/spec/ecloud/models/public_ips_spec.rb @@ -1,21 +1,21 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::PublicIps", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::PublicIps", :type => :mock_tmrk_ecloud_model do subject { @vcloud } it { should respond_to(:public_ips) } describe :class do subject { @vcloud.public_ips.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::PublicIp } + its(:model) { should == Fog::Ecloud::Compute::PublicIp } end describe :public_ips do subject { @vcloud.vdcs[0].public_ips } it { should_not respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::PublicIps) } + it { should be_an_instance_of(Fog::Ecloud::Compute::PublicIps) } its(:length) { should == 3 } diff --git a/spec/vcloud/terremark/ecloud/models/server_spec.rb b/spec/ecloud/models/server_spec.rb similarity index 88% rename from spec/vcloud/terremark/ecloud/models/server_spec.rb rename to spec/ecloud/models/server_spec.rb index 1155d7e18..a347a6138 100644 --- a/spec/vcloud/terremark/ecloud/models/server_spec.rb +++ b/spec/ecloud/models/server_spec.rb @@ -1,18 +1,18 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Vdc", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Vdc", :type => :mock_tmrk_ecloud_model do subject { @vcloud } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::Server } + subject { Fog::Ecloud::Compute::Server } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :type, :name, :status, :network_connections, :os, :virtual_hardware, :storage_size, :links]) } end context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::Server.new() } + subject { Fog::Ecloud::Compute::Server.new() } it { should have_all_attributes_be_nil } end diff --git a/spec/vcloud/terremark/ecloud/models/vdc_spec.rb b/spec/ecloud/models/vdc_spec.rb similarity index 90% rename from spec/vcloud/terremark/ecloud/models/vdc_spec.rb rename to spec/ecloud/models/vdc_spec.rb index c93d779e8..72a953f89 100644 --- a/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +++ b/spec/ecloud/models/vdc_spec.rb @@ -1,13 +1,13 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Vdc", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Vdc", :type => :mock_tmrk_ecloud_model do subject { @vcloud } it { should respond_to(:get_vdc) } describe :class do - subject { Fog::Vcloud::Terremark::Ecloud::Vdc } + subject { Fog::Ecloud::Compute::Vdc } it { should have_identity(:href) } it { should have_only_these_attributes([:href, :name, :type, :description, :other_links, :compute_capacity, :storage_capacity, :available_networks, @@ -16,7 +16,7 @@ if Fog.mocking? context "with no uri" do - subject { Fog::Vcloud::Terremark::Ecloud::Vdc.new() } + subject { Fog::Ecloud::Compute::Vdc.new() } it { should have_all_attributes_be_nil } end @@ -27,7 +27,7 @@ if Fog.mocking? its(:href) { should == @mock_vdc.href } its(:identity) { should == @mock_vdc.href } its(:name) { should == @mock_vdc.name } - its(:public_ips) { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::PublicIps) } + its(:public_ips) { should be_an_instance_of(Fog::Ecloud::Compute::PublicIps) } its(:other_links) { should have(4).items } its(:resource_entities) { should have(3).items } its(:available_networks) { should have(2).items } diff --git a/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb b/spec/ecloud/models/vdcs_spec.rb similarity index 61% rename from spec/vcloud/terremark/ecloud/models/vdcs_spec.rb rename to spec/ecloud/models/vdcs_spec.rb index 65332ea98..951f9a086 100644 --- a/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +++ b/spec/ecloud/models/vdcs_spec.rb @@ -1,21 +1,21 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud::Terremark::Ecloud::Vdcs", :type => :mock_tmrk_ecloud_model do + describe "Fog::Ecloud::Compute::Vdcs", :type => :mock_tmrk_ecloud_model do subject { @vcloud } it { should respond_to(:vdcs) } describe :class do subject { @vcloud.vdcs.class } - its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Vdc } + its(:model) { should == Fog::Ecloud::Compute::Vdc } end describe :vdcs do subject { @vcloud.vdcs } it { should_not respond_to(:create) } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Vdcs) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Vdcs) } its(:length) { should == 2 } diff --git a/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb b/spec/ecloud/requests/add_backup_internet_service_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb rename to spec/ecloud/requests/add_backup_internet_service_spec.rb index 8b8e4536a..3446107c2 100644 --- a/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +++ b/spec/ecloud/requests/add_backup_internet_service_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:add_backup_internet_service) } diff --git a/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb b/spec/ecloud/requests/add_internet_service_spec.rb similarity index 96% rename from spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb rename to spec/ecloud/requests/add_internet_service_spec.rb index d2fedb382..71bda22f8 100644 --- a/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +++ b/spec/ecloud/requests/add_internet_service_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:add_internet_service) } diff --git a/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb b/spec/ecloud/requests/add_node_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/add_node_spec.rb rename to spec/ecloud/requests/add_node_spec.rb index e91d2f12e..b35818425 100644 --- a/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +++ b/spec/ecloud/requests/add_node_spec.rb @@ -1,8 +1,8 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? #FIXME: with rspec2 - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:add_node) } diff --git a/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb b/spec/ecloud/requests/configure_internet_service_spec.rb similarity index 96% rename from spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb rename to spec/ecloud/requests/configure_internet_service_spec.rb index 1e494c58e..11d54d7d0 100644 --- a/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +++ b/spec/ecloud/requests/configure_internet_service_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:configure_internet_service) } diff --git a/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb b/spec/ecloud/requests/configure_network_ip_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb rename to spec/ecloud/requests/configure_network_ip_spec.rb index 360488f3f..720d79372 100644 --- a/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +++ b/spec/ecloud/requests/configure_network_ip_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:configure_network_ip) } diff --git a/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb b/spec/ecloud/requests/configure_node_spec.rb similarity index 94% rename from spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb rename to spec/ecloud/requests/configure_node_spec.rb index bf97df757..a599d067d 100644 --- a/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +++ b/spec/ecloud/requests/configure_node_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:configure_node) } diff --git a/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb b/spec/ecloud/requests/configure_vapp_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb rename to spec/ecloud/requests/configure_vapp_spec.rb index c987c9fe4..98069eb2c 100644 --- a/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +++ b/spec/ecloud/requests/configure_vapp_spec.rb @@ -1,4 +1,4 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' shared_examples_for "a successful configure vapp" do specify { after_vapp_data.should == new_vapp_data } @@ -13,7 +13,7 @@ shared_examples_for "a successful configure vapp" do end if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:configure_vapp) } diff --git a/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb b/spec/ecloud/requests/delete_internet_service_spec.rb similarity index 90% rename from spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb rename to spec/ecloud/requests/delete_internet_service_spec.rb index 1f303b298..3a39696ba 100644 --- a/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +++ b/spec/ecloud/requests/delete_internet_service_spec.rb @@ -1,8 +1,8 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' #FIXME: Make this more sane with rspec2 if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:delete_internet_service) } diff --git a/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb b/spec/ecloud/requests/delete_node_spec.rb similarity index 89% rename from spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb rename to spec/ecloud/requests/delete_node_spec.rb index 0aab3ba52..72fb799aa 100644 --- a/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +++ b/spec/ecloud/requests/delete_node_spec.rb @@ -1,8 +1,8 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? #FIXME: with rspec2 - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:delete_node) } diff --git a/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb b/spec/ecloud/requests/delete_vapp_spec.rb similarity index 96% rename from spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb rename to spec/ecloud/requests/delete_vapp_spec.rb index 71e713dee..b9d2d7020 100644 --- a/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +++ b/spec/ecloud/requests/delete_vapp_spec.rb @@ -1,4 +1,4 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' shared_examples_for "a failed vapp deletion" do it "should not change the mock data" do @@ -20,7 +20,7 @@ end #FIXME: Make this more sane with rspec2 if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:delete_vapp) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb b/spec/ecloud/requests/get_catalog_item_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb rename to spec/ecloud/requests/get_catalog_item_spec.rb index 750c629e2..afc61154a 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +++ b/spec/ecloud/requests/get_catalog_item_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_catalog_item) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb b/spec/ecloud/requests/get_catalog_spec.rb similarity index 92% rename from spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb rename to spec/ecloud/requests/get_catalog_spec.rb index 90f5fc92b..78314298e 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +++ b/spec/ecloud/requests/get_catalog_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_catalog) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb b/spec/ecloud/requests/get_customization_options_spec.rb similarity index 93% rename from spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb rename to spec/ecloud/requests/get_customization_options_spec.rb index a57baf822..91145657b 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +++ b/spec/ecloud/requests/get_customization_options_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_customization_options) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb b/spec/ecloud/requests/get_internet_services_spec.rb similarity index 98% rename from spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb rename to spec/ecloud/requests/get_internet_services_spec.rb index 7bd076edd..8fe931904 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +++ b/spec/ecloud/requests/get_internet_services_spec.rb @@ -1,4 +1,4 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? shared_examples_for "a basic internet service" do @@ -56,7 +56,7 @@ if Fog.mocking? specify { service[:BackupOf].should == "" } end - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_internet_services) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb b/spec/ecloud/requests/get_network_ip_spec.rb similarity index 92% rename from spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb rename to spec/ecloud/requests/get_network_ip_spec.rb index 20fa698ac..08a8c12ea 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +++ b/spec/ecloud/requests/get_network_ip_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_network_ip) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb b/spec/ecloud/requests/get_network_ips_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb rename to spec/ecloud/requests/get_network_ips_spec.rb index 27928c3c9..ead5d8c26 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +++ b/spec/ecloud/requests/get_network_ips_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_network_ips) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb b/spec/ecloud/requests/get_network_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/get_network_spec.rb rename to spec/ecloud/requests/get_network_spec.rb index d6f1968ac..afcd39695 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +++ b/spec/ecloud/requests/get_network_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_network) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb b/spec/ecloud/requests/get_node_spec.rb similarity index 92% rename from spec/vcloud/terremark/ecloud/requests/get_node_spec.rb rename to spec/ecloud/requests/get_node_spec.rb index 010bae4e5..0626d0f09 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +++ b/spec/ecloud/requests/get_node_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_node) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb b/spec/ecloud/requests/get_nodes_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb rename to spec/ecloud/requests/get_nodes_spec.rb index 3358654da..d1735ae6e 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +++ b/spec/ecloud/requests/get_nodes_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_nodes) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_organization_spec.rb b/spec/ecloud/requests/get_organization_spec.rb similarity index 96% rename from spec/vcloud/terremark/ecloud/requests/get_organization_spec.rb rename to spec/ecloud/requests/get_organization_spec.rb index c128c5388..d25565359 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_organization_spec.rb +++ b/spec/ecloud/requests/get_organization_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_organization) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb b/spec/ecloud/requests/get_public_ip_spec.rb similarity index 91% rename from spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb rename to spec/ecloud/requests/get_public_ip_spec.rb index 6579bd218..9f2797c19 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +++ b/spec/ecloud/requests/get_public_ip_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_public_ip) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb b/spec/ecloud/requests/get_public_ips_spec.rb similarity index 94% rename from spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb rename to spec/ecloud/requests/get_public_ips_spec.rb index 50b8005d1..051a881a1 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +++ b/spec/ecloud/requests/get_public_ips_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_public_ips) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb b/spec/ecloud/requests/get_vapp_spec.rb similarity index 98% rename from spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb rename to spec/ecloud/requests/get_vapp_spec.rb index 704049eac..4c03767db 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +++ b/spec/ecloud/requests/get_vapp_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_vapp) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb b/spec/ecloud/requests/get_vdc_spec.rb similarity index 98% rename from spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb rename to spec/ecloud/requests/get_vdc_spec.rb index 8ef411956..4f99380f6 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +++ b/spec/ecloud/requests/get_vdc_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:get_vdc) } diff --git a/spec/vcloud/terremark/ecloud/requests/get_versions_spec.rb b/spec/ecloud/requests/get_versions_spec.rb similarity index 90% rename from spec/vcloud/terremark/ecloud/requests/get_versions_spec.rb rename to spec/ecloud/requests/get_versions_spec.rb index 717c93b91..2955015e8 100644 --- a/spec/vcloud/terremark/ecloud/requests/get_versions_spec.rb +++ b/spec/ecloud/requests/get_versions_spec.rb @@ -1,4 +1,4 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' shared_examples_for "real or mock get_versions requests" do @@ -38,7 +38,7 @@ shared_examples_for "real or mock get_versions requests" do end if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do it_should_behave_like "real or mock get_versions requests" @@ -48,7 +48,7 @@ if Fog.mocking? end end else - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do it_should_behave_like "real or mock get_versions requests" end end diff --git a/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb b/spec/ecloud/requests/instantiate_vapp_template_spec.rb similarity index 95% rename from spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb rename to spec/ecloud/requests/instantiate_vapp_template_spec.rb index 11f5202c6..bb1d702a8 100644 --- a/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +++ b/spec/ecloud/requests/instantiate_vapp_template_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do + describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:instantiate_vapp_template) } @@ -42,7 +42,7 @@ if Fog.mocking? before { template_instantiation } subject { added_mock_data } - it { should be_an_instance_of(Fog::Vcloud::MockDataClasses::MockVirtualMachine) } + it { should be_an_instance_of(Fog::Ecloud::MockDataClasses::MockVirtualMachine) } its(:name) { should == new_vapp_data[:name] } its(:memory) { should == new_vapp_data[:memory] } diff --git a/spec/vcloud/terremark/ecloud/requests/login_spec.rb b/spec/ecloud/requests/login_spec.rb similarity index 53% rename from spec/vcloud/terremark/ecloud/requests/login_spec.rb rename to spec/ecloud/requests/login_spec.rb index 9252640d6..15c00deba 100644 --- a/spec/vcloud/terremark/ecloud/requests/login_spec.rb +++ b/spec/ecloud/requests/login_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do subject { @vcloud } it_should_behave_like "all login requests" diff --git a/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb b/spec/ecloud/requests/power_off_spec.rb similarity index 91% rename from spec/vcloud/terremark/ecloud/requests/power_off_spec.rb rename to spec/ecloud/requests/power_off_spec.rb index eac53dc88..3f7a9b44a 100644 --- a/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +++ b/spec/ecloud/requests/power_off_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:power_off) } diff --git a/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb b/spec/ecloud/requests/power_on_spec.rb similarity index 91% rename from spec/vcloud/terremark/ecloud/requests/power_on_spec.rb rename to spec/ecloud/requests/power_on_spec.rb index c30ddc331..e51d0331f 100644 --- a/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +++ b/spec/ecloud/requests/power_on_spec.rb @@ -1,7 +1,7 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do subject { @vcloud } it { should respond_to(:power_on) } diff --git a/spec/vcloud/spec_helper.rb b/spec/ecloud/spec_helper.rb similarity index 93% rename from spec/vcloud/spec_helper.rb rename to spec/ecloud/spec_helper.rb index 996cdf34a..ad311d47c 100644 --- a/spec/vcloud/spec_helper.rb +++ b/spec/ecloud/spec_helper.rb @@ -1,6 +1,10 @@ require 'spec' require 'pp' +require 'fog' +require 'fog/bin' +require 'fog/bin/ecloud' + module Spec module Example module Subject @@ -19,13 +23,8 @@ end #Initialize this to a known seed srand 1234 -require 'fog' -require 'fog/bin' - Fog.mock! if ENV['FOG_MOCK'] -require 'fog/bin/vcloud' - def arrayify(item) item.is_a?(Array) ? item : [ item ] end @@ -228,8 +227,8 @@ def setup_generic_mock_data end def setup_ecloud_mock_data - @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url - @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data + @base_url = Fog::Ecloud::Compute::Mock.base_url + @mock_data = Fog::Ecloud::Compute::Mock.data setup_generic_mock_data @mock_vdc_service_collection = @mock_vdc.internet_service_collection @mock_public_ip_collection = @mock_vdc.public_ip_collection @@ -247,29 +246,29 @@ def setup_ecloud_mock_data end def setup_vcloud_mock_data - @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url - @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data + @base_url = Fog::Ecloud::Compute::Mock.base_url + @mock_data = Fog::Ecloud::Compute::Mock.data setup_generic_mock_data end Spec::Runner.configure do |config| config.after(:all) do - Fog::Vcloud::Terremark::Ecloud::Mock.data_reset + Fog::Ecloud::Compute::Mock.data_reset end config.before(:each, :type => :vcloud_request) do - @vcloud = Fog::Vcloud::Terremark::Ecloud.new(Fog.credentials[:vcloud][:ecloud]) + @vcloud = Fog::Ecloud::Compute.new(Fog.credentials[:vcloud][:ecloud]) end config.before(:each, :type => :mock_tmrk_ecloud_request) do - Fog::Vcloud::Terremark::Ecloud::Mock.data_reset + Fog::Ecloud::Compute::Mock.data_reset setup_ecloud_mock_data - @vcloud = Fog::Vcloud::Terremark::Ecloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions") + @vcloud = Fog::Ecloud::Compute.new(:ecloud_username => "foo", :ecloud_password => "bar", :ecloud_versions_uri => "http://fakey.com/api/versions") end config.before(:each, :type => :mock_tmrk_ecloud_model) do - Fog::Vcloud::Terremark::Ecloud::Mock.data_reset + Fog::Ecloud::Compute::Mock.data_reset setup_ecloud_mock_data - @vcloud = Fog::Vcloud::Terremark::Ecloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions") + @vcloud = Fog::Ecloud::Compute.new(:ecloud_username => "foo", :ecloud_password => "bar", :ecloud_versions_uri => "http://fakey.com/api/versions") end end diff --git a/spec/vcloud/vcloud_spec.rb b/spec/ecloud/vcloud_spec.rb similarity index 63% rename from spec/vcloud/vcloud_spec.rb rename to spec/ecloud/vcloud_spec.rb index a74513823..275bb95c4 100644 --- a/spec/vcloud/vcloud_spec.rb +++ b/spec/ecloud/vcloud_spec.rb @@ -1,10 +1,10 @@ -require 'vcloud/spec_helper' +require 'ecloud/spec_helper' if Fog.mocking? - describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do + describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do subject { @vcloud } - it { should be_an_instance_of(Fog::Vcloud::Terremark::Ecloud::Mock) } + it { should be_an_instance_of(Fog::Ecloud::Compute::Mock) } it { should respond_to(:default_organization_uri) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5d7d231ec..53647b1f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,6 @@ require 'spec' require 'open-uri' require 'fog' require 'fog/bin' -require 'fog/bin/vcloud' if ENV["FOG_MOCK"] == "true" Fog.mock! diff --git a/spec/vcloud/bin_spec.rb b/spec/vcloud/bin_spec.rb deleted file mode 100644 index fae4e844f..000000000 --- a/spec/vcloud/bin_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'vcloud/spec_helper' - -describe Vcloud do - it { should be_initialized } - - it { should have_at_least(1).services } - - describe "#registered_services" do - subject { Vcloud.registered_services } - - it { should have_at_least(1).services } - end - - describe "when indexing it like an array" do - describe "with a service that exists" do - it "should return something when indexed with a configured service" do - Vcloud[:ecloud].should_not be_nil - end - end - - describe "with a service that does not exist" do - it "should raise an ArgumentError" do - lambda {Vcloud[:foozle]}.should raise_error(ArgumentError) - end - end - - end -end