From 825d7996aa6862382d2ff6aadd59f9aeb2aeb71a Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Thu, 7 Jun 2012 12:50:11 -0400 Subject: [PATCH 1/2] Removed non-functioning Mock classes --- lib/fog/ecloud.rb | 2 +- lib/fog/ecloud/collection.rb | 26 + lib/fog/ecloud/compute.rb | 1486 ++++------------- lib/fog/ecloud/generate_collection.rb | 130 ++ lib/fog/ecloud/ipaddr.rb | 5 + lib/fog/ecloud/mock_data_classes.rb | 768 +++++++++ lib/fog/ecloud/model.rb | 22 + .../models/compute/admin_organization.rb | 39 + .../models/compute/admin_organizations.rb | 27 + lib/fog/ecloud/models/compute/api_key.rb | 21 + lib/fog/ecloud/models/compute/api_keys.rb | 27 + lib/fog/ecloud/models/compute/association.rb | 23 + lib/fog/ecloud/models/compute/associations.rb | 35 + .../models/compute/authentication_level.rb | 22 + .../models/compute/authentication_levels.rb | 27 + .../models/compute/backup_internet_service.rb | 67 +- .../compute/backup_internet_services.rb | 31 +- lib/fog/ecloud/models/compute/catalog.rb | 22 +- .../models/compute/catalog_configuration.rb | 23 + .../models/compute/catalog_configurations.rb | 27 + lib/fog/ecloud/models/compute/catalog_item.rb | 29 +- lib/fog/ecloud/models/compute/compute_pool.rb | 56 +- .../ecloud/models/compute/compute_pools.rb | 14 +- .../ecloud/models/compute/cpu_usage_detail.rb | 17 + .../compute/cpu_usage_detail_summary.rb | 27 + lib/fog/ecloud/models/compute/environment.rb | 105 ++ lib/fog/ecloud/models/compute/environments.rb | 40 + lib/fog/ecloud/models/compute/firewall_acl.rb | 25 +- .../ecloud/models/compute/firewall_acls.rb | 17 +- lib/fog/ecloud/models/compute/group.rb | 39 + lib/fog/ecloud/models/compute/groups.rb | 28 + .../ecloud/models/compute/guest_process.rb | 15 + .../ecloud/models/compute/guest_processes.rb | 27 + .../models/compute/hardware_configuration.rb | 18 + .../models/compute/hardware_configurations.rb | 27 + .../ecloud/models/compute/internet_service.rb | 132 +- .../models/compute/internet_services.rb | 33 +- lib/fog/ecloud/models/compute/ip.rb | 49 - lib/fog/ecloud/models/compute/ip_address.rb | 25 + lib/fog/ecloud/models/compute/ip_addresses.rb | 27 + lib/fog/ecloud/models/compute/ips.rb | 32 - lib/fog/ecloud/models/compute/layout.rb | 20 + lib/fog/ecloud/models/compute/layouts.rb | 27 + lib/fog/ecloud/models/compute/location.rb | 23 + lib/fog/ecloud/models/compute/locations.rb | 31 + lib/fog/ecloud/models/compute/login_banner.rb | 16 + .../ecloud/models/compute/login_banners.rb | 27 + .../models/compute/memory_usage_detail.rb | 16 + .../compute/memory_usage_detail_summary.rb | 27 + lib/fog/ecloud/models/compute/monitor.rb | 46 + lib/fog/ecloud/models/compute/monitors.rb | 31 + lib/fog/ecloud/models/compute/network.rb | 73 +- lib/fog/ecloud/models/compute/networks.rb | 15 +- lib/fog/ecloud/models/compute/node.rb | 50 +- lib/fog/ecloud/models/compute/nodes.rb | 25 +- .../ecloud/models/compute/operating_system.rb | 17 + .../compute/operating_system_families.rb | 27 + .../models/compute/operating_system_family.rb | 21 + .../models/compute/operating_systems.rb | 26 + lib/fog/ecloud/models/compute/organization.rb | 79 + .../ecloud/models/compute/organizations.rb | 39 + .../compute/password_complexity_rule.rb | 49 + .../compute/password_complexity_rules.rb | 27 + .../ecloud/models/compute/physical_device.rb | 22 + .../ecloud/models/compute/physical_devices.rb | 27 + lib/fog/ecloud/models/compute/public_ip.rb | 24 +- lib/fog/ecloud/models/compute/public_ips.rb | 19 +- lib/fog/ecloud/models/compute/rnat.rb | 27 + lib/fog/ecloud/models/compute/rnats.rb | 27 + lib/fog/ecloud/models/compute/role.rb | 24 + lib/fog/ecloud/models/compute/roles.rb | 37 + lib/fog/ecloud/models/compute/row.rb | 53 + lib/fog/ecloud/models/compute/rows.rb | 37 + lib/fog/ecloud/models/compute/server.rb | 320 ++-- .../compute/server_configuration_option.rb | 17 + .../compute/server_configuration_options.rb | 27 + lib/fog/ecloud/models/compute/servers.rb | 67 +- lib/fog/ecloud/models/compute/ssh_key.rb | 20 + lib/fog/ecloud/models/compute/ssh_keys.rb | 27 + .../models/compute/storage_usage_detail.rb | 16 + .../compute/storage_usage_detail_summary.rb | 27 + .../ecloud/models/compute/support_ticket.rb | 29 + .../ecloud/models/compute/support_tickets.rb | 27 + lib/fog/ecloud/models/compute/tag.rb | 13 + lib/fog/ecloud/models/compute/tags.rb | 27 + lib/fog/ecloud/models/compute/task.rb | 21 +- lib/fog/ecloud/models/compute/tasks.rb | 16 +- lib/fog/ecloud/models/compute/template.rb | 24 + lib/fog/ecloud/models/compute/templates.rb | 40 + .../models/compute/trusted_network_group.rb | 33 + .../models/compute/trusted_network_groups.rb | 28 + lib/fog/ecloud/models/compute/user.rb | 35 + lib/fog/ecloud/models/compute/users.rb | 27 + lib/fog/ecloud/models/compute/vdc.rb | 87 - lib/fog/ecloud/models/compute/vdcs.rb | 40 - .../compute/add_backup_internet_service.rb | 109 -- .../requests/compute/add_internet_service.rb | 149 -- lib/fog/ecloud/requests/compute/add_node.rb | 62 - .../compute/admin_disable_support_access.rb | 9 + .../admin_edit_authentication_levels.rb | 34 + .../compute/admin_edit_login_banner.rb | 32 + .../admin_edit_password_complexity_rules.rb | 74 + .../compute/admin_enable_support_access.rb | 9 + .../compute/backup_internet_service_create.rb | 47 + .../compute/backup_internet_service_delete.rb | 11 + .../compute/backup_internet_service_edit.rb | 47 + lib/fog/ecloud/requests/compute/clone_vapp.rb | 40 - .../requests/compute/compute_pool_edit.rb | 37 + .../compute/configure_internet_service.rb | 112 -- .../requests/compute/configure_network.rb | 44 - .../requests/compute/configure_network_ip.rb | 66 - .../ecloud/requests/compute/configure_node.rb | 56 - .../ecloud/requests/compute/configure_vapp.rb | 144 -- .../compute/delete_internet_service.rb | 22 - .../ecloud/requests/compute/delete_node.rb | 22 - .../ecloud/requests/compute/delete_vapp.rb | 29 - .../requests/compute/firewall_acls_create.rb | 79 + .../requests/compute/firewall_acls_delete.rb | 11 + .../compute/get_admin_organization.rb | 11 + .../compute/get_admin_organizations.rb | 11 + .../{get_task_list.rb => get_api_key.rb} | 2 +- .../{get_vapp_template.rb => get_api_keys.rb} | 2 +- .../requests/compute/get_association.rb | 11 + .../requests/compute/get_associations.rb | 11 + .../compute/get_authentication_level.rb | 11 + .../compute/get_authentication_levels.rb | 11 + .../compute/get_backup_internet_service.rb | 11 + .../compute/get_backup_internet_services.rb | 11 + .../ecloud/requests/compute/get_catalog.rb | 33 - .../compute/get_catalog_configuration.rb | 11 + .../compute/get_catalog_configurations.rb | 11 + .../requests/compute/get_catalog_item.rb | 36 - .../requests/compute/get_compute_pool.rb | 25 - .../requests/compute/get_compute_pools.rb | 29 - .../requests/compute/get_cpu_usage_detail.rb | 11 + .../compute/get_cpu_usage_detail_summary.rb | 11 + .../compute/get_customization_options.rb | 22 - .../requests/compute/get_environment.rb | 11 + .../requests/compute/get_environments.rb | 0 lib/fog/ecloud/requests/compute/get_group.rb | 11 + lib/fog/ecloud/requests/compute/get_groups.rb | 11 + .../requests/compute/get_guest_process.rb | 11 + .../requests/compute/get_guest_processes.rb | 11 + .../compute/get_hardware_configuration.rb | 11 + .../compute/get_hardware_configurations.rb | 11 + .../requests/compute/get_internet_service.rb | 11 + .../requests/compute/get_internet_services.rb | 71 - .../ecloud/requests/compute/get_ip_address.rb | 11 + .../requests/compute/get_ip_addresses.rb | 11 + lib/fog/ecloud/requests/compute/get_layout.rb | 11 + .../ecloud/requests/compute/get_layouts.rb | 11 + .../ecloud/requests/compute/get_location.rb | 12 + .../ecloud/requests/compute/get_locations.rb | 12 + .../requests/compute/get_login_banner.rb | 11 + .../requests/compute/get_login_banners.rb | 11 + .../compute/get_memory_usage_detail.rb | 11 + .../get_memory_usage_detail_summary.rb | 11 + .../ecloud/requests/compute/get_monitor.rb | 11 + .../ecloud/requests/compute/get_monitors.rb | 11 + .../ecloud/requests/compute/get_network.rb | 35 +- .../compute/get_network_extensions.rb | 33 - .../ecloud/requests/compute/get_network_ip.rb | 43 - .../requests/compute/get_network_ips.rb | 35 - .../requests/compute/get_network_summary.rb | 11 + .../ecloud/requests/compute/get_networks.rb | 11 + lib/fog/ecloud/requests/compute/get_node.rb | 29 - lib/fog/ecloud/requests/compute/get_nodes.rb | 30 - .../requests/compute/get_operating_system.rb | 11 + .../compute/get_operating_system_families.rb | 11 + .../compute/get_operating_system_family.rb | 11 + .../requests/compute/get_organization.rb | 38 - .../requests/compute/get_organizations.rb | 11 + .../compute/get_password_complexity_rule.rb | 11 + .../compute/get_password_complexity_rules.rb | 11 + .../requests/compute/get_physical_device.rb | 11 + .../requests/compute/get_physical_devices.rb | 11 + .../ecloud/requests/compute/get_process.rb | 11 + .../ecloud/requests/compute/get_processes.rb | 11 + .../ecloud/requests/compute/get_public_ip.rb | 23 - .../ecloud/requests/compute/get_public_ips.rb | 27 - lib/fog/ecloud/requests/compute/get_rnat.rb | 11 + lib/fog/ecloud/requests/compute/get_rnats.rb | 11 + lib/fog/ecloud/requests/compute/get_role.rb | 11 + lib/fog/ecloud/requests/compute/get_roles.rb | 11 + lib/fog/ecloud/requests/compute/get_row.rb | 11 + lib/fog/ecloud/requests/compute/get_rows.rb | 11 + lib/fog/ecloud/requests/compute/get_server.rb | 11 + .../get_server_configuration_option.rb | 11 + .../get_server_configuration_options.rb | 11 + .../ecloud/requests/compute/get_servers.rb | 11 + .../ecloud/requests/compute/get_ssh_key.rb | 11 + .../ecloud/requests/compute/get_ssh_keys.rb | 11 + .../compute/get_storage_usage_detail.rb | 11 + .../get_storage_usage_detail_summary.rb | 11 + .../requests/compute/get_support_ticket.rb | 11 + .../requests/compute/get_support_tickets.rb | 11 + lib/fog/ecloud/requests/compute/get_tag.rb | 11 + lib/fog/ecloud/requests/compute/get_tags.rb | 11 + lib/fog/ecloud/requests/compute/get_task.rb | 2 +- lib/fog/ecloud/requests/compute/get_tasks.rb | 11 + .../ecloud/requests/compute/get_template.rb | 11 + .../ecloud/requests/compute/get_templates.rb | 11 + .../compute/get_trusted_network_group.rb | 11 + .../compute/get_trusted_network_groups.rb | 11 + lib/fog/ecloud/requests/compute/get_user.rb | 11 + lib/fog/ecloud/requests/compute/get_users.rb | 11 + lib/fog/ecloud/requests/compute/get_vapp.rb | 99 -- lib/fog/ecloud/requests/compute/get_vdc.rb | 84 - .../ecloud/requests/compute/get_versions.rb | 37 - .../ecloud/requests/compute/groups_create.rb | 31 + .../ecloud/requests/compute/groups_delete.rb | 11 + .../ecloud/requests/compute/groups_edit.rb | 29 + .../requests/compute/groups_movedown.rb | 11 + .../ecloud/requests/compute/groups_moveup.rb | 11 + .../compute/instantiate_vapp_template.rb | 144 -- .../compute/internet_service_create.rb | 67 + .../compute/internet_service_delete.rb | 11 + .../requests/compute/internet_service_edit.rb | 60 + lib/fog/ecloud/requests/compute/login.rb | 48 - .../compute/monitors_create_default.rb | 11 + .../requests/compute/monitors_create_ecv.rb | 40 + .../requests/compute/monitors_create_http.rb | 44 + .../compute/monitors_create_loopback.rb | 11 + .../requests/compute/monitors_create_ping.rb | 35 + .../requests/compute/monitors_disable.rb | 11 + .../requests/compute/monitors_edit_ecv.rb | 40 + .../requests/compute/monitors_edit_http.rb | 44 + .../requests/compute/monitors_edit_ping.rb | 35 + .../requests/compute/monitors_enable.rb | 11 + .../requests/compute/node_service_create.rb | 45 + .../requests/compute/node_service_delete.rb | 11 + .../requests/compute/node_service_edit.rb | 41 + lib/fog/ecloud/requests/compute/power_off.rb | 12 - lib/fog/ecloud/requests/compute/power_on.rb | 12 - .../ecloud/requests/compute/power_shutdown.rb | 2 +- .../requests/compute/public_ip_activate.rb | 11 + .../rnat_associations_create_device.rb | 32 + .../compute/rnat_associations_delete.rb | 9 + .../compute/rnat_associations_edit_network.rb | 31 + .../ecloud/requests/compute/rows_create.rb | 29 + .../ecloud/requests/compute/rows_delete.rb | 11 + lib/fog/ecloud/requests/compute/rows_edit.rb | 29 + .../ecloud/requests/compute/rows_movedown.rb | 11 + .../ecloud/requests/compute/rows_moveup.rb | 11 + .../compute/trusted_network_groups_create.rb | 53 + .../compute/trusted_network_groups_delete.rb | 11 + .../compute/trusted_network_groups_edit.rb | 53 + .../requests/compute/virtual_machine_copy.rb | 118 ++ .../compute/virtual_machine_copy_identical.rb | 45 + .../virtual_machine_create_from_template.rb | 125 ++ .../compute/virtual_machine_delete.rb | 11 + .../requests/compute/virtual_machine_edit.rb | 47 + ...ual_machine_edit_hardware_configuration.rb | 53 + .../compute/virtual_machine_import.rb | 67 + spec/ecloud/bin_spec.rb | 28 - .../models/backup_internet_service_spec.rb | 48 - .../models/backup_internet_services_spec.rb | 28 - spec/ecloud/models/internet_service_spec.rb | 104 -- spec/ecloud/models/internet_services_spec.rb | 29 - spec/ecloud/models/ip_spec.rb | 33 - spec/ecloud/models/ips_spec.rb | 28 - spec/ecloud/models/network_spec.rb | 71 - spec/ecloud/models/networks_spec.rb | 27 - spec/ecloud/models/node_spec.rb | 38 - spec/ecloud/models/nodes_spec.rb | 28 - spec/ecloud/models/public_ip_spec.rb | 36 - spec/ecloud/models/public_ips_spec.rb | 27 - spec/ecloud/models/server_spec.rb | 62 - spec/ecloud/models/vdc_spec.rb | 63 - spec/ecloud/models/vdcs_spec.rb | 28 - .../add_backup_internet_service_spec.rb | 60 - .../requests/add_internet_service_spec.rb | 65 - spec/ecloud/requests/add_node_spec.rb | 56 - .../configure_internet_service_spec.rb | 61 - .../requests/configure_network_ip_spec.rb | 55 - spec/ecloud/requests/configure_node_spec.rb | 52 - spec/ecloud/requests/configure_vapp_spec.rb | 71 - .../requests/delete_internet_service_spec.rb | 34 - spec/ecloud/requests/delete_node_spec.rb | 30 - spec/ecloud/requests/delete_vapp_spec.rb | 92 - spec/ecloud/requests/get_catalog_item_spec.rb | 62 - spec/ecloud/requests/get_catalog_spec.rb | 44 - .../get_customization_options_spec.rb | 39 - .../requests/get_internet_services_spec.rb | 150 -- spec/ecloud/requests/get_network_ip_spec.rb | 40 - spec/ecloud/requests/get_network_ips_spec.rb | 58 - spec/ecloud/requests/get_network_spec.rb | 49 - spec/ecloud/requests/get_node_spec.rb | 41 - spec/ecloud/requests/get_nodes_spec.rb | 58 - spec/ecloud/requests/get_organization_spec.rb | 52 - spec/ecloud/requests/get_public_ip_spec.rb | 38 - spec/ecloud/requests/get_public_ips_spec.rb | 52 - spec/ecloud/requests/get_vapp_spec.rb | 125 -- spec/ecloud/requests/get_vdc_spec.rb | 112 -- spec/ecloud/requests/get_versions_spec.rb | 57 - .../instantiate_vapp_template_spec.rb | 95 -- spec/ecloud/requests/login_spec.rb | 10 - spec/ecloud/requests/power_off_spec.rb | 34 - spec/ecloud/requests/power_on_spec.rb | 34 - spec/ecloud/spec_helper.rb | 387 ----- spec/ecloud/vcloud_spec.rb | 18 - 301 files changed, 6254 insertions(+), 6470 deletions(-) create mode 100644 lib/fog/ecloud/collection.rb create mode 100644 lib/fog/ecloud/generate_collection.rb create mode 100644 lib/fog/ecloud/ipaddr.rb create mode 100644 lib/fog/ecloud/mock_data_classes.rb create mode 100644 lib/fog/ecloud/model.rb create mode 100644 lib/fog/ecloud/models/compute/admin_organization.rb create mode 100644 lib/fog/ecloud/models/compute/admin_organizations.rb create mode 100644 lib/fog/ecloud/models/compute/api_key.rb create mode 100644 lib/fog/ecloud/models/compute/api_keys.rb create mode 100644 lib/fog/ecloud/models/compute/association.rb create mode 100644 lib/fog/ecloud/models/compute/associations.rb create mode 100644 lib/fog/ecloud/models/compute/authentication_level.rb create mode 100644 lib/fog/ecloud/models/compute/authentication_levels.rb create mode 100644 lib/fog/ecloud/models/compute/catalog_configuration.rb create mode 100644 lib/fog/ecloud/models/compute/catalog_configurations.rb create mode 100644 lib/fog/ecloud/models/compute/cpu_usage_detail.rb create mode 100644 lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb create mode 100644 lib/fog/ecloud/models/compute/environment.rb create mode 100644 lib/fog/ecloud/models/compute/environments.rb create mode 100644 lib/fog/ecloud/models/compute/group.rb create mode 100644 lib/fog/ecloud/models/compute/groups.rb create mode 100644 lib/fog/ecloud/models/compute/guest_process.rb create mode 100644 lib/fog/ecloud/models/compute/guest_processes.rb create mode 100644 lib/fog/ecloud/models/compute/hardware_configuration.rb create mode 100644 lib/fog/ecloud/models/compute/hardware_configurations.rb delete mode 100644 lib/fog/ecloud/models/compute/ip.rb create mode 100644 lib/fog/ecloud/models/compute/ip_address.rb create mode 100644 lib/fog/ecloud/models/compute/ip_addresses.rb delete mode 100644 lib/fog/ecloud/models/compute/ips.rb create mode 100644 lib/fog/ecloud/models/compute/layout.rb create mode 100644 lib/fog/ecloud/models/compute/layouts.rb create mode 100644 lib/fog/ecloud/models/compute/location.rb create mode 100644 lib/fog/ecloud/models/compute/locations.rb create mode 100644 lib/fog/ecloud/models/compute/login_banner.rb create mode 100644 lib/fog/ecloud/models/compute/login_banners.rb create mode 100644 lib/fog/ecloud/models/compute/memory_usage_detail.rb create mode 100644 lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb create mode 100644 lib/fog/ecloud/models/compute/monitor.rb create mode 100644 lib/fog/ecloud/models/compute/monitors.rb create mode 100644 lib/fog/ecloud/models/compute/operating_system.rb create mode 100644 lib/fog/ecloud/models/compute/operating_system_families.rb create mode 100644 lib/fog/ecloud/models/compute/operating_system_family.rb create mode 100644 lib/fog/ecloud/models/compute/operating_systems.rb create mode 100644 lib/fog/ecloud/models/compute/organization.rb create mode 100644 lib/fog/ecloud/models/compute/organizations.rb create mode 100644 lib/fog/ecloud/models/compute/password_complexity_rule.rb create mode 100644 lib/fog/ecloud/models/compute/password_complexity_rules.rb create mode 100644 lib/fog/ecloud/models/compute/physical_device.rb create mode 100644 lib/fog/ecloud/models/compute/physical_devices.rb create mode 100644 lib/fog/ecloud/models/compute/rnat.rb create mode 100644 lib/fog/ecloud/models/compute/rnats.rb create mode 100644 lib/fog/ecloud/models/compute/role.rb create mode 100644 lib/fog/ecloud/models/compute/roles.rb create mode 100644 lib/fog/ecloud/models/compute/row.rb create mode 100644 lib/fog/ecloud/models/compute/rows.rb create mode 100644 lib/fog/ecloud/models/compute/server_configuration_option.rb create mode 100644 lib/fog/ecloud/models/compute/server_configuration_options.rb create mode 100644 lib/fog/ecloud/models/compute/ssh_key.rb create mode 100644 lib/fog/ecloud/models/compute/ssh_keys.rb create mode 100644 lib/fog/ecloud/models/compute/storage_usage_detail.rb create mode 100644 lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb create mode 100644 lib/fog/ecloud/models/compute/support_ticket.rb create mode 100644 lib/fog/ecloud/models/compute/support_tickets.rb create mode 100644 lib/fog/ecloud/models/compute/tag.rb create mode 100644 lib/fog/ecloud/models/compute/tags.rb create mode 100644 lib/fog/ecloud/models/compute/template.rb create mode 100644 lib/fog/ecloud/models/compute/templates.rb create mode 100644 lib/fog/ecloud/models/compute/trusted_network_group.rb create mode 100644 lib/fog/ecloud/models/compute/trusted_network_groups.rb create mode 100644 lib/fog/ecloud/models/compute/user.rb create mode 100644 lib/fog/ecloud/models/compute/users.rb delete mode 100644 lib/fog/ecloud/models/compute/vdc.rb delete mode 100644 lib/fog/ecloud/models/compute/vdcs.rb delete mode 100644 lib/fog/ecloud/requests/compute/add_backup_internet_service.rb delete mode 100644 lib/fog/ecloud/requests/compute/add_internet_service.rb delete mode 100644 lib/fog/ecloud/requests/compute/add_node.rb create mode 100644 lib/fog/ecloud/requests/compute/admin_disable_support_access.rb create mode 100644 lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb create mode 100644 lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb create mode 100644 lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb create mode 100644 lib/fog/ecloud/requests/compute/admin_enable_support_access.rb create mode 100644 lib/fog/ecloud/requests/compute/backup_internet_service_create.rb create mode 100644 lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb delete mode 100644 lib/fog/ecloud/requests/compute/clone_vapp.rb create mode 100644 lib/fog/ecloud/requests/compute/compute_pool_edit.rb delete mode 100644 lib/fog/ecloud/requests/compute/configure_internet_service.rb delete mode 100644 lib/fog/ecloud/requests/compute/configure_network.rb delete mode 100644 lib/fog/ecloud/requests/compute/configure_network_ip.rb delete mode 100644 lib/fog/ecloud/requests/compute/configure_node.rb delete mode 100644 lib/fog/ecloud/requests/compute/configure_vapp.rb delete mode 100644 lib/fog/ecloud/requests/compute/delete_internet_service.rb delete mode 100644 lib/fog/ecloud/requests/compute/delete_node.rb delete mode 100644 lib/fog/ecloud/requests/compute/delete_vapp.rb create mode 100644 lib/fog/ecloud/requests/compute/firewall_acls_create.rb create mode 100644 lib/fog/ecloud/requests/compute/firewall_acls_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/get_admin_organization.rb create mode 100644 lib/fog/ecloud/requests/compute/get_admin_organizations.rb rename lib/fog/ecloud/requests/compute/{get_task_list.rb => get_api_key.rb} (71%) rename lib/fog/ecloud/requests/compute/{get_vapp_template.rb => get_api_keys.rb} (69%) create mode 100644 lib/fog/ecloud/requests/compute/get_association.rb create mode 100644 lib/fog/ecloud/requests/compute/get_associations.rb create mode 100644 lib/fog/ecloud/requests/compute/get_authentication_level.rb create mode 100644 lib/fog/ecloud/requests/compute/get_authentication_levels.rb create mode 100644 lib/fog/ecloud/requests/compute/get_backup_internet_service.rb create mode 100644 lib/fog/ecloud/requests/compute/get_backup_internet_services.rb create mode 100644 lib/fog/ecloud/requests/compute/get_catalog_configuration.rb create mode 100644 lib/fog/ecloud/requests/compute/get_catalog_configurations.rb create mode 100644 lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb create mode 100644 lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_customization_options.rb create mode 100644 lib/fog/ecloud/requests/compute/get_environment.rb create mode 100644 lib/fog/ecloud/requests/compute/get_environments.rb create mode 100644 lib/fog/ecloud/requests/compute/get_group.rb create mode 100644 lib/fog/ecloud/requests/compute/get_groups.rb create mode 100644 lib/fog/ecloud/requests/compute/get_guest_process.rb create mode 100644 lib/fog/ecloud/requests/compute/get_guest_processes.rb create mode 100644 lib/fog/ecloud/requests/compute/get_hardware_configuration.rb create mode 100644 lib/fog/ecloud/requests/compute/get_hardware_configurations.rb create mode 100644 lib/fog/ecloud/requests/compute/get_internet_service.rb create mode 100644 lib/fog/ecloud/requests/compute/get_ip_address.rb create mode 100644 lib/fog/ecloud/requests/compute/get_ip_addresses.rb create mode 100644 lib/fog/ecloud/requests/compute/get_layout.rb create mode 100644 lib/fog/ecloud/requests/compute/get_layouts.rb create mode 100644 lib/fog/ecloud/requests/compute/get_location.rb create mode 100644 lib/fog/ecloud/requests/compute/get_locations.rb create mode 100644 lib/fog/ecloud/requests/compute/get_login_banner.rb create mode 100644 lib/fog/ecloud/requests/compute/get_login_banners.rb create mode 100644 lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb create mode 100644 lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb create mode 100644 lib/fog/ecloud/requests/compute/get_monitor.rb create mode 100644 lib/fog/ecloud/requests/compute/get_monitors.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_network_extensions.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_network_ip.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_network_ips.rb create mode 100644 lib/fog/ecloud/requests/compute/get_network_summary.rb create mode 100644 lib/fog/ecloud/requests/compute/get_networks.rb create mode 100644 lib/fog/ecloud/requests/compute/get_operating_system.rb create mode 100644 lib/fog/ecloud/requests/compute/get_operating_system_families.rb create mode 100644 lib/fog/ecloud/requests/compute/get_operating_system_family.rb create mode 100644 lib/fog/ecloud/requests/compute/get_organizations.rb create mode 100644 lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb create mode 100644 lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb create mode 100644 lib/fog/ecloud/requests/compute/get_physical_device.rb create mode 100644 lib/fog/ecloud/requests/compute/get_physical_devices.rb create mode 100644 lib/fog/ecloud/requests/compute/get_process.rb create mode 100644 lib/fog/ecloud/requests/compute/get_processes.rb create mode 100644 lib/fog/ecloud/requests/compute/get_rnat.rb create mode 100644 lib/fog/ecloud/requests/compute/get_rnats.rb create mode 100644 lib/fog/ecloud/requests/compute/get_role.rb create mode 100644 lib/fog/ecloud/requests/compute/get_roles.rb create mode 100644 lib/fog/ecloud/requests/compute/get_row.rb create mode 100644 lib/fog/ecloud/requests/compute/get_rows.rb create mode 100644 lib/fog/ecloud/requests/compute/get_server.rb create mode 100644 lib/fog/ecloud/requests/compute/get_server_configuration_option.rb create mode 100644 lib/fog/ecloud/requests/compute/get_server_configuration_options.rb create mode 100644 lib/fog/ecloud/requests/compute/get_servers.rb create mode 100644 lib/fog/ecloud/requests/compute/get_ssh_key.rb create mode 100644 lib/fog/ecloud/requests/compute/get_ssh_keys.rb create mode 100644 lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb create mode 100644 lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb create mode 100644 lib/fog/ecloud/requests/compute/get_support_ticket.rb create mode 100644 lib/fog/ecloud/requests/compute/get_support_tickets.rb create mode 100644 lib/fog/ecloud/requests/compute/get_tag.rb create mode 100644 lib/fog/ecloud/requests/compute/get_tags.rb create mode 100644 lib/fog/ecloud/requests/compute/get_tasks.rb create mode 100644 lib/fog/ecloud/requests/compute/get_template.rb create mode 100644 lib/fog/ecloud/requests/compute/get_templates.rb create mode 100644 lib/fog/ecloud/requests/compute/get_trusted_network_group.rb create mode 100644 lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb create mode 100644 lib/fog/ecloud/requests/compute/get_user.rb create mode 100644 lib/fog/ecloud/requests/compute/get_users.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_vapp.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_vdc.rb delete mode 100644 lib/fog/ecloud/requests/compute/get_versions.rb create mode 100644 lib/fog/ecloud/requests/compute/groups_create.rb create mode 100644 lib/fog/ecloud/requests/compute/groups_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/groups_edit.rb create mode 100644 lib/fog/ecloud/requests/compute/groups_movedown.rb create mode 100644 lib/fog/ecloud/requests/compute/groups_moveup.rb delete mode 100644 lib/fog/ecloud/requests/compute/instantiate_vapp_template.rb create mode 100644 lib/fog/ecloud/requests/compute/internet_service_create.rb create mode 100644 lib/fog/ecloud/requests/compute/internet_service_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/internet_service_edit.rb delete mode 100644 lib/fog/ecloud/requests/compute/login.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_create_default.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_create_ecv.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_create_http.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_create_loopback.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_create_ping.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_disable.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_edit_http.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_edit_ping.rb create mode 100644 lib/fog/ecloud/requests/compute/monitors_enable.rb create mode 100644 lib/fog/ecloud/requests/compute/node_service_create.rb create mode 100644 lib/fog/ecloud/requests/compute/node_service_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/node_service_edit.rb create mode 100644 lib/fog/ecloud/requests/compute/public_ip_activate.rb create mode 100644 lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb create mode 100644 lib/fog/ecloud/requests/compute/rnat_associations_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb create mode 100644 lib/fog/ecloud/requests/compute/rows_create.rb create mode 100644 lib/fog/ecloud/requests/compute/rows_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/rows_edit.rb create mode 100644 lib/fog/ecloud/requests/compute/rows_movedown.rb create mode 100644 lib/fog/ecloud/requests/compute/rows_moveup.rb create mode 100644 lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb create mode 100644 lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_copy.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_delete.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_edit.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb create mode 100644 lib/fog/ecloud/requests/compute/virtual_machine_import.rb delete mode 100644 spec/ecloud/bin_spec.rb delete mode 100644 spec/ecloud/models/backup_internet_service_spec.rb delete mode 100644 spec/ecloud/models/backup_internet_services_spec.rb delete mode 100644 spec/ecloud/models/internet_service_spec.rb delete mode 100644 spec/ecloud/models/internet_services_spec.rb delete mode 100644 spec/ecloud/models/ip_spec.rb delete mode 100644 spec/ecloud/models/ips_spec.rb delete mode 100644 spec/ecloud/models/network_spec.rb delete mode 100644 spec/ecloud/models/networks_spec.rb delete mode 100644 spec/ecloud/models/node_spec.rb delete mode 100644 spec/ecloud/models/nodes_spec.rb delete mode 100644 spec/ecloud/models/public_ip_spec.rb delete mode 100644 spec/ecloud/models/public_ips_spec.rb delete mode 100644 spec/ecloud/models/server_spec.rb delete mode 100644 spec/ecloud/models/vdc_spec.rb delete mode 100644 spec/ecloud/models/vdcs_spec.rb delete mode 100644 spec/ecloud/requests/add_backup_internet_service_spec.rb delete mode 100644 spec/ecloud/requests/add_internet_service_spec.rb delete mode 100644 spec/ecloud/requests/add_node_spec.rb delete mode 100644 spec/ecloud/requests/configure_internet_service_spec.rb delete mode 100644 spec/ecloud/requests/configure_network_ip_spec.rb delete mode 100644 spec/ecloud/requests/configure_node_spec.rb delete mode 100644 spec/ecloud/requests/configure_vapp_spec.rb delete mode 100644 spec/ecloud/requests/delete_internet_service_spec.rb delete mode 100644 spec/ecloud/requests/delete_node_spec.rb delete mode 100644 spec/ecloud/requests/delete_vapp_spec.rb delete mode 100644 spec/ecloud/requests/get_catalog_item_spec.rb delete mode 100644 spec/ecloud/requests/get_catalog_spec.rb delete mode 100644 spec/ecloud/requests/get_customization_options_spec.rb delete mode 100644 spec/ecloud/requests/get_internet_services_spec.rb delete mode 100644 spec/ecloud/requests/get_network_ip_spec.rb delete mode 100644 spec/ecloud/requests/get_network_ips_spec.rb delete mode 100644 spec/ecloud/requests/get_network_spec.rb delete mode 100644 spec/ecloud/requests/get_node_spec.rb delete mode 100644 spec/ecloud/requests/get_nodes_spec.rb delete mode 100644 spec/ecloud/requests/get_organization_spec.rb delete mode 100644 spec/ecloud/requests/get_public_ip_spec.rb delete mode 100644 spec/ecloud/requests/get_public_ips_spec.rb delete mode 100644 spec/ecloud/requests/get_vapp_spec.rb delete mode 100644 spec/ecloud/requests/get_vdc_spec.rb delete mode 100644 spec/ecloud/requests/get_versions_spec.rb delete mode 100644 spec/ecloud/requests/instantiate_vapp_template_spec.rb delete mode 100644 spec/ecloud/requests/login_spec.rb delete mode 100644 spec/ecloud/requests/power_off_spec.rb delete mode 100644 spec/ecloud/requests/power_on_spec.rb delete mode 100644 spec/ecloud/spec_helper.rb delete mode 100644 spec/ecloud/vcloud_spec.rb diff --git a/lib/fog/ecloud.rb b/lib/fog/ecloud.rb index 9bf63b868..3031c450e 100644 --- a/lib/fog/ecloud.rb +++ b/lib/fog/ecloud.rb @@ -1,4 +1,4 @@ -require 'fog/core' +require(File.expand_path(File.join(File.dirname(__FILE__), 'core'))) module Fog module Ecloud diff --git a/lib/fog/ecloud/collection.rb b/lib/fog/ecloud/collection.rb new file mode 100644 index 000000000..03ff2932d --- /dev/null +++ b/lib/fog/ecloud/collection.rb @@ -0,0 +1,26 @@ +module Fog + module Ecloud + class Collection < Fog::Collection + + def load(objects) + objects = [ objects ] if objects.is_a?(Hash) + super + end + + def check_href!(opts = {}) + unless href + opts = { :parent => opts } if opts.is_a?(String) + msg = ":href missing, call with a :href pointing to #{if opts[:message] + opts[:message] + elsif opts[:parent] + "the #{opts[:parent]} whos #{self.class.to_s.split('::').last.downcase} you want to enumerate" + else + "the resource" + end}" + raise Fog::Errors::Error.new(msg) + end + end + + end + end +end diff --git a/lib/fog/ecloud/compute.rb b/lib/fog/ecloud/compute.rb index 01362a792..61eb136f5 100644 --- a/lib/fog/ecloud/compute.rb +++ b/lib/fog/ecloud/compute.rb @@ -1,800 +1,4 @@ -require 'fog/ecloud' -require 'ipaddr' - -class IPAddr - def mask_string - _to_string(@mask_addr) - end -end - -module Fog - module Ecloud - class Collection < Fog::Collection - - def load(objects) - objects = [ objects ] if objects.is_a?(Hash) - super - end - - def check_href!(opts = {}) - unless href - opts = { :parent => opts } if opts.is_a?(String) - msg = ":href missing, call with a :href pointing to #{if opts[:message] - opts[:message] - elsif opts[:parent] - "the #{opts[:parent]} whos #{self.class.to_s.split('::').last.downcase} you want to enumerate" - else - "the resource" - end}" - raise Fog::Errors::Error.new(msg) - end - end - - end - end -end - -module Fog - module Ecloud - module MockDataClasses - class Base < Hash - def self.base_url=(url) - @base_url = url - end - - self.base_url = "http://vcloud.example.com" - - def self.base_url - @base_url - end - - def first - raise "Don't do this" - end - - def last - raise "Don't do this" - end - - def initialize(data = {}, parent = nil) - @parent = parent - - replace(data) - end - - def _parent - @parent - end - - def base_url - Base.base_url - end - - def href - [base_url, self.class.name.split("::").last, object_id].join("/") - end - - def inspect - "<#{self.class.name} #{object_id} data=#{super}>" - end - end - - class MockData < Base - def versions - @versions ||= [] - end - - def organizations - @organizations ||= [] - end - - def organization_from_href(href) - find_href_in(href, organizations) - end - - def all_vdcs - organizations.map(&:vdcs).flatten - end - - def vdc_from_href(href) - find_href_in(href, all_vdcs) - end - - def all_catalogs - all_vdcs.map(&:catalog).flatten - end - - def catalog_from_href(href) - find_href_in(href, all_catalogs) - end - - def all_catalog_items - all_catalogs.map(&:items).flatten - end - - def catalog_item_from_href(href) - find_href_in(href, all_catalog_items) - end - - def all_virtual_machines - all_vdcs.map(&:virtual_machines).flatten - end - - def virtual_machine_from_href(href) - find_href_prefixed_in(href, all_virtual_machines) - end - - - def all_networks - all_vdcs.map(&:networks).flatten - end - - def network_from_href(href) - find_href_in(href, all_networks) - end - - def all_network_extensions - all_networks.map(&:extensions).flatten - end - - def network_extension_from_href(href) - find_href_in(href, all_network_extensions) - end - - def all_vdc_internet_service_collections - all_vdcs.map(&:internet_service_collection).flatten - end - - def vdc_internet_service_collection_from_href(href) - find_href_in(href, all_vdc_internet_service_collections) - end - - def all_backup_internet_services - all_vdc_internet_service_collections.map(&:backup_internet_services).flatten - end - - def backup_internet_service_from_href(href) - find_href_in(href, all_backup_internet_services) - end - - def all_public_ip_collections - all_vdcs.map {|v| v.public_ip_collection }.flatten - end - - def public_ip_collection_from_href(href) - find_href_in(href, all_public_ip_collections) - end - - def all_public_ips - all_public_ip_collections.map(&:items).flatten - end - - def public_ip_from_href(href) - find_href_in(href, all_public_ips) - end - - def all_public_ip_internet_service_collections - all_public_ips.map(&:internet_service_collection).flatten - end - - def public_ip_internet_service_collection_from_href(href) - find_href_in(href, all_public_ip_internet_service_collections) - end - - def all_public_ip_internet_services - all_public_ip_internet_service_collections.map(&:items).flatten - end - - def public_ip_internet_service_from_href(href) - find_href_in(href, all_public_ip_internet_services) - end - - def all_public_ip_internet_service_node_collections - all_public_ip_internet_services.map(&:node_collection).flatten - end - - def public_ip_internet_service_node_collection_from_href(href) - find_href_in(href, all_public_ip_internet_service_node_collections) - end - - def all_public_ip_internet_service_nodes - all_public_ip_internet_service_node_collections.map(&:items).flatten - end - - def public_ip_internet_service_node_from_href(href) - find_href_in(href, all_public_ip_internet_service_nodes) - end - - def all_network_ip_collections - all_networks.map(&:ip_collection) - end - - def network_ip_collection_from_href(href) - find_href_in(href, all_network_ip_collections) - end - - def all_network_ips - all_network_ip_collections.map {|c| c.items.values }.flatten - end - - def network_ip_from_href(href) - find_href_in(href, all_network_ips) - end - - private - - def find_href_in(href, objects) - objects.detect {|o| o.href == href } - end - - def find_href_prefixed_in(href, objects) - objects.detect {|o| href =~ %r{^#{o.href}($|/)} } - end - end - - class MockVersion < Base - def version - self[:version] - end - - def supported - !!self[:supported] - end - - def login_url - href - end - end - - class MockOrganization < Base - def name - self[:name] - end - - def vdcs - @vdcs ||= [] - end - end - - class MockVdc < Base - def name - self[:name] - end - - def storage_allocated - self[:storage_allocated] || 200 - end - - def storage_used - self[:storage_used] || 105 - end - - def cpu_allocated - self[:cpu_allocated] || 10000 - end - - def memory_allocated - self[:memory_allocated] || 20480 - end - - def catalog - @catalog ||= MockCatalog.new({}, self) - end - - def networks - @networks ||= [] - end - - def virtual_machines - @virtual_machines ||= [] - end - - def task_list - @task_list ||= MockTaskList.new({}, self) - end - - # for TM eCloud, should probably be subclassed - def public_ip_collection - @public_ip_collection ||= MockPublicIps.new({}, self) - end - - def internet_service_collection - @internet_service_collection ||= MockVdcInternetServices.new({}, self) - end - - def firewall_acls - @firewall_acls ||= MockFirewallAcls.new({}, self) - end - end - - class MockTaskList < Base - def name - self[:name] || "Tasks List" - end - end - - class MockCatalog < Base - def name - self[:name] || "Catalog" - end - - def items - @items ||= [] - end - end - - class MockCatalogItem < Base - def name - self[:name] - end - - def disks - @disks ||= MockVirtualMachineDisks.new(self) - end - - def customization - @customization ||= MockCatalogItemCustomization.new({}, self) - end - - def vapp_template - @vapp_template ||= MockCatalogItemVappTemplate.new({ :name => name }, self) - end - end - - class MockCatalogItemCustomization < Base - def name - self[:name] || "Customization Options" - end - end - - class MockCatalogItemVappTemplate < Base - def name - self[:name] - end - end - - class MockNetwork < Base - def name - self[:name] || subnet - end - - def subnet - self[:subnet] - end - - def gateway - self[:gateway] || subnet_ips[1] - end - - def netmask - self[:netmask] || subnet_ipaddr.mask_string - end - - def dns - "8.8.8.8" - end - - def features - [ - { :type => :FenceMode, :value => "isolated" } - ] - end - - def ip_collection - @ip_collection ||= MockNetworkIps.new({}, self) - end - - def extensions - @extensions ||= MockNetworkExtensions.new({}, self) - end - - def random_ip - usable_subnet_ips[rand(usable_subnet_ips.length)] - end - - # for TM eCloud. should probably be a subclass - def rnat - self[:rnat] - end - - def usable_subnet_ips - subnet_ips[3..-2] - end - - def address - subnet_ips.first - end - - def broadcast - subnet_ips.last - end - - private - - def subnet_ipaddr - @ipaddr ||= IPAddr.new(subnet) - end - - def subnet_ips - subnet_ipaddr.to_range.to_a.map(&:to_s) - end - end - - class MockNetworkIps < Base - def items - @items ||= _parent.usable_subnet_ips.inject({}) do |out, subnet_ip| - out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self)) - end - end - - def ordered_ips - items.values.sort_by {|i| i.ip.split(".").map(&:to_i) } - end - - def name - "IP Addresses" - end - end - - class MockNetworkIp < Base - def name - self[:name] || ip - end - - def ip - self[:ip] - end - - def used_by - self[:used_by] || _parent._parent._parent.virtual_machines.detect {|v| v.ip == ip } - end - - def status - if used_by - "Assigned" - else - "Available" - end - end - - def rnat - self[:rnat] || _parent._parent.rnat - end - - def rnat_set? - !!self[:rnat] - end - end - - class MockNetworkExtensions < Base - def name - _parent.name - end - - def gateway - _parent.gateway - end - - def broadcast - _parent.broadcast - end - - def address - _parent.address - end - - def rnat - _parent.rnat - end - - def type - self[:type] || "DMZ" - end - - def vlan - object_id.to_s - end - - def friendly_name - "#{name} (#{type}_#{object_id})" - end - end - - class MockVirtualMachine < Base - def name - self[:name] - end - - def ip - self[:ip] - end - - def cpus - self[:cpus] || 1 - end - - def memory - self[:memory] || 1024 - end - - def disks - @disks ||= MockVirtualMachineDisks.new(self) - end - - def status - self[:status] || 2 - end - - def power_off! - self[:status] = 2 - end - - def power_on! - self[:status] = 4 - end - - def size - disks.inject(0) {|s, d| s + d.vcloud_size } - end - - def network_ip - if network = _parent.networks.detect {|n| n.ip_collection.items[ip] } - network.ip_collection.items[ip] - end - end - - # from fog ecloud server's _compose_vapp_data - def to_configure_vapp_hash - { - :name => name, - :cpus => cpus, - :memory => memory, - :disks => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } } - } - end - - def href(purpose = :base) - case purpose - when :base - super() - when :power_on - super() + "/power/action/powerOn" - when :power_off - super() + "/power/action/powerOff" - end - end - end - - class MockVirtualMachineDisks < Array - def initialize(parent = nil) - @parent = parent - end - - def _parent - @parent - end - - def <<(disk) - next_address = 0 - disk_with_max_address = max {|a, b| a[:address] <=> b[:address] } - disk_with_max_address && next_address = disk_with_max_address.address + 1 - disk[:address] ||= next_address - - super(disk) - - if (addresses = map {|d| d.address }).uniq.size != size - raise "Duplicate disk address in: #{addresses.inspect} (#{size})" - end - - sort! {|a, b| a.address <=> b.address } - self - end - - def at_address(address) - detect {|d| d.address == address } - end - end - - class MockVirtualMachineDisk < Base - def size - self[:size].to_i - end - - def vcloud_size - # kilobytes - size * 1024 - end - - def address - self[:address].to_i - end - end - - # for Terremark eCloud - - class MockVdcInternetServices < Base - def href - _parent.href + "/internetServices" - end - - def name - "Internet Services" - end - - def items - public_ip_internet_services + backup_internet_services - end - - def public_ip_internet_services - _parent.public_ip_collection.items.inject([]) do |services, public_ip| - services + public_ip.internet_service_collection.items - end - end - - def backup_internet_services - @backup_internet_services ||= [] - end - end - - class MockBackupInternetService < Base - def name - self[:name] || "Backup Internet Service #{object_id}" - end - - def protocol - self[:protocol] - end - - def port - 0 - end - - def enabled - self[:enabled].to_s.downcase != "false" - end - - def timeout - self[:timeout] || 2 - end - - def description - self[:description] || "Description for Backup Service #{name}" - end - - def redirect_url - nil - end - - def node_collection - @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) - end - end - - class MockFirewallAcls < Base - def name - "Firewall Access List" - end - end - - class MockPublicIps < Base - def name - self[:name] || "Public IPs" - end - - def items - @items ||= [] - end - end - - class MockPublicIp < Base - def name - self[:name] - end - - def internet_service_collection - @internet_service_collection ||= MockPublicIpInternetServices.new({}, self) - end - end - - class MockPublicIpInternetServices < Base - def href - _parent.href + "/internetServices" - end - - def items - @items ||= [] - end - end - - class MockPublicIpInternetService < Base - def name - self[:name] || "Public IP Service #{object_id}" - end - - def description - self[:description] || "Description for Public IP Service #{name}" - end - - def protocol - self[:protocol] - end - - def port - self[:port] - end - - def enabled - !!self[:enabled] - end - - def redirect_url - self[:redirect_url] - end - - def timeout - self[:timeout] || 2 - end - - def node_collection - @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) - end - - def monitor - nil - end - - def backup_service - self[:backup_service] - end - end - - class MockPublicIpInternetServiceNodes < Base - def href - _parent.href + "/nodeServices" - end - - def items - @items ||= [].tap do |node_array| - node_array.instance_variable_set("@default_port", _parent.port) - - def node_array.<<(node) - node[:port] ||= @default_port - super - end - end - end - end - - class MockPublicIpInternetServiceNode < Base - def ip_address - self[:ip_address] - end - - def name - self[:name] || "Public IP Service Node #{object_id}" - end - - def description - self[:description] || "Description for Public IP Service Node #{name}" - end - - def port - self[:port] - end - - def enabled - self[:enabled].to_s.downcase != "false" - end - - def enabled=(new_value) - self[:enabled] = new_value - end - end - end - end -end - - +require 'fog/ecloud/collection' module Fog module Ecloud class Model < Fog::Model @@ -817,84 +21,241 @@ module Fog end end end - module Fog module Compute + + class Ecloud < Fog::Service - class UnsupportedVersion < Exception ; end + API_URL = "https://services.enterprisecloud.terremark.com" + attr_reader :authentication_method, :version - requires :ecloud_username, :ecloud_password, :ecloud_versions_uri - recognizes :ecloud_version + #### Credentials + #requires + recognizes :ecloud_username, :ecloud_password, :ecloud_version, :ecloud_access_key, :ecloud_private_key, :ecloud_authentication_method + #### Models model_path 'fog/ecloud/models/compute' - 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 :compute_pool - collection :compute_pools + model :organization + collection :organizations + model :location + collection :locations + model :catalog_item + collection :catalog + model :catalog_configuration + collection :catalog_configurations + model :environment + collection :environments + model :task + collection :tasks + model :compute_pool + collection :compute_pools + model :server + collection :servers + model :hardware_configuration + collection :hardware_configurations + model :server_configuration_option + collection :server_configuration_options + model :guest_process + collection :guest_processes + model :layout + collection :layouts + model :row + collection :rows + model :group + collection :groups + model :internet_service + collection :internet_services + model :node + collection :nodes + model :monitor + collection :monitors + model :cpu_usage_detail + collection :cpu_usage_detail_summary + model :memory_usage_detail + collection :memory_usage_detail_summary + model :storage_usage_detail + collection :storage_usage_detail_summary + model :operating_system_family + collection :operating_system_families + model :operating_system + collection :operating_systems + model :template + collection :templates + model :firewall_acl + collection :firewall_acls + model :network + collection :networks + model :ip_address + collection :ip_addresses + model :physical_device + collection :physical_devices + model :public_ip + collection :public_ips + model :trusted_network_group + collection :trusted_network_groups + model :backup_internet_service + collection :backup_internet_services + model :rnat + collection :rnats + model :association + collection :associations + model :tag + collection :tags + model :admin_organization + collection :admin_organizations + model :ssh_key + collection :ssh_keys + model :password_complexity_rule + collection :password_complexity_rules + model :authentication_level + collection :authentication_levels + model :login_banner + collection :login_banners + model :user + collection :users + model :role + collection :roles + model :ssh_key + collection :ssh_keys + model :support_ticket + collection :support_tickets + #### Requests request_path 'fog/ecloud/requests/compute' - 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_organizations + request :get_location + request :get_locations + request :get_environment 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 :get_tasks request :get_compute_pool request :get_compute_pools + request :get_server + request :get_servers + request :get_network + request :get_networks + request :get_physical_device + request :get_physical_devices + request :get_layout + request :get_layouts + request :get_row + request :get_rows + request :get_group + request :get_groups + request :get_public_ip + request :get_public_ips + request :get_network_summary + request :get_internet_service + request :get_internet_services + request :get_node + request :get_nodes + request :get_firewall_acl + request :get_firewall_acls + request :get_trusted_network_group + request :get_trusted_network_groups + request :get_catalog + request :get_catalog_item + request :get_tag + request :get_tags + request :get_hardware_configuration + request :get_hardware_configurations + request :get_server_configuration_option + request :get_server_configuration_options + request :get_guest_process + request :get_guest_processes + request :get_cpu_usage_detail + request :get_cpu_usage_detail_summary + request :get_memory_usage_detail + request :get_memory_usage_detail_summary + request :get_storage_usage_detail + request :get_storage_usage_detail_summary + request :get_operating_system_family + request :get_operating_system_families + request :get_operating_system + request :get_template + request :get_templates + request :get_monitor + request :get_monitors + request :get_backup_internet_service + request :get_backup_internet_services + request :get_rnat + request :get_rnats + request :get_association + request :get_associations + request :get_admin_organization + request :get_admin_organizations + request :get_ssh_key + request :get_ssh_keys + request :get_password_complexity_rule + request :get_password_complexity_rules + request :get_authentication_level + request :get_authentication_levels + request :get_login_banner + request :get_login_banners + request :get_user + request :get_users + request :get_role + request :get_roles + request :get_api_key + request :get_api_keys + request :get_support_ticket + request :get_support_tickets + request :get_ip_address + request :get_ip_addresses + request :get_catalog_configuration + request :get_catalog_configurations + request :compute_pool_edit + request :virtual_machine_create_from_template + request :virtual_machine_import + request :virtual_machine_copy + request :virtual_machine_copy_identical + request :virtual_machine_edit + request :virtual_machine_edit_hardware_configuration + request :virtual_machine_delete + request :internet_service_create + request :internet_service_edit + request :internet_service_delete + request :backup_internet_service_create + request :backup_internet_service_edit + request :backup_internet_service_delete + request :node_service_create + request :node_service_delete + request :node_service_edit + request :monitors_create_default + request :monitors_create_ping + request :monitors_create_http + request :monitors_create_ecv + request :monitors_create_loopback + request :monitors_edit_ping + request :monitors_edit_http + request :monitors_edit_ecv + request :monitors_enable + request :monitors_disable + request :rnat_associations_edit_network + request :rnat_associations_create_device + request :rnat_associations_delete + request :rows_create + request :rows_edit + request :rows_moveup + request :rows_movedown + request :rows_delete + request :groups_create + request :groups_edit + request :groups_moveup + request :groups_movedown + request :groups_delete + request :trusted_network_groups_create + request :trusted_network_groups_edit + request :trusted_network_groups_delete + request :firewall_acls_create + request :firewall_acls_delete + request :public_ip_activate + request :power_on + request :power_off + request :power_reset + request :power_shutdown module Shared @@ -919,13 +280,12 @@ module Fog # 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'] + @login_results = get_organizations end def ecloud_xmlns { - "xmlns" => "urn:tmrk:eCloudExtensions-2.6", + "xmlns" => "urn:tmrk:eCloudExtensions-2.8", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" } end @@ -948,178 +308,53 @@ module Fog "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" } end + def validate_data(required_opts = [], options) + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + end + end class Mock - include Shared - include Fog::Ecloud::MockDataClasses - - def self.base_url - "https://fakey.com/api/v0.8b-ext2.6" - 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 + def self.data + @data ||= Hash.new do |hash, key| + hash[key] = {} end end def self.reset - @mock_data = nil + @data = nil end - def self.data_reset - Fog::Logger.deprecation("#{self} => #data_reset is deprecated, use #reset instead [light_black](#{caller.first})[/]") - self.reset + def initialize(options={}) + @ecloud_api_key = options[:ecloud] end - def initialize(options = {}) - require 'builder' - require 'fog/core/parser' - - @versions_uri = URI.parse('https://vcloud.fakey.com/api/versions') + def data + self.class.data[@ecloud_api_key] end - def mock_data - Fog::Compute::Ecloud::Mock.data + def reset_data + self.class.data.delete(@ecloud_api_key) 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 }) + :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 @@ -1128,142 +363,56 @@ module Fog 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 }) + :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 = {} - @connection_options = options[:connection_options] || {} - @versions_uri = URI.parse(options[:ecloud_versions_uri]) - @version = options[:ecloud_version] - @username = options[:ecloud_username] - @password = options[:ecloud_password] - @persistent = options[:persistent] || false + @connections = {} + @connection_options = options[:connection_options] || {} + @host = options[:ecloud_host] || API_URL + @persistent = options[:persistent] || false + @version = options[:ecloud_version] || "2012-03-01" + @authentication_method = options[:ecloud_authentication_method] || :cloud_api_auth + @access_key = options[:ecloud_access_key] + @private_key = options[:ecloud_private_key] + if @private_key.nil? || @authentication_method == :basic_auth + @authentication_method = :basic_auth + @username = options[:ecloud_username] + @password = options[:ecloud_password] + if @username.nil? || @password.nil? + raise RuntimeError, "No credentials (cloud auth, or basic auth) passed!" + end + else + @hmac = Fog::HMAC.new("sha256", @private_key) + end 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 + "/cloudapi/ecloud/organizations/" 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 - do_login - do_request(params) + rescue Excon::Errors::Unauthorized => e + raise RuntimeError, "Invalid authentication data: #{e}" end end - def supporting_versions - ["v0.8b-ext2.6", "0.8b-ext2.6", "v0.8b-ext2.8" , "0.8b-ext2.8"] - 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]) + params[:uri] = URI.parse(@host + params[:uri]) end host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}" @@ -1272,24 +421,17 @@ module Fog @connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options) # 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 + headers = set_extra_headers_for(params) || set_extra_headers_for({}) # 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 - }) + options = {:expects => params[:expects] || 200, :method => params[:method] || 'GET', :path => params[:uri].path + "#{"?#{params[:uri].query}" if params[:uri].query}", :headers => headers} + unless params[:body].empty? + options.merge!({:body => params[:body]}) + end + #puts options[:body].inspect + response = @connections[host_url].request(options) # Parse the response body into a hash - #puts response.body unless response.body.empty? if params[:parse] document = Fog::ToHashDocument.new @@ -1300,12 +442,72 @@ module Fog response.body = document.body end end - response end + private + + # if Authorization and x-tmrk-authorization are used, the x-tmrk-authorization takes precendence. + def set_extra_headers_for(params) + maor_headers = { + 'x-tmrk-version' => @version, + 'Date' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"), + } + params[:headers].merge!(maor_headers) + if params[:method]=="POST" || params[:method]=="PUT" + params[:headers].merge!({"Content-Type" => 'application/xml'}) + params[:headers].merge!({"Accept" => 'application/xml'}) + end + unless params[:body].empty? + params[:headers].merge!({"x-tmrk-contenthash" => "Sha256 #{Base64.encode64(Digest::SHA2.digest(params[:body].to_s)).chomp}"}) + end + if @authentication_method == :basic_auth + params[:headers].merge!({'Authorization' => "Basic #{Base64.encode64(@username+":"+@password).delete("\r\n")}"}) + elsif @authentication_method == :cloud_api_auth + signature = cloud_api_signature(params) + params[:headers].merge!({ + "x-tmrk-authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"} + }) + end + params[:headers] + end + + def cloud_api_signature(params) + verb = params[:method].upcase + headers = params[:headers] + path = params[:uri].path + canonicalized_headers = canonicalize_headers(headers) + canonicalized_resource = canonicalize_resource(path) + string = [ verb, + headers['Content-Length'].to_s, + headers['Content-Type'].to_s, + headers['Date'].to_s, + canonicalized_headers, + canonicalized_resource + "\n" + ].join("\n") + Base64.encode64(@hmac.sign(string)).chomp + end + + + # section 5.6.3.2 in the ~1000 page pdf spec + def canonicalize_headers(headers) + tmp = headers.inject({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret } + tmp.reject! {|k,v| k == "x-tmrk-authorization" } + tmp = tmp.sort.map{|e| "#{e.first}:#{e.last}" }.join("\n") + tmp + end + + # section 5.6.3.3 in the ~1000 page pdf spec + def canonicalize_resource(path) + uri, query_string = path.split("?") + return uri if query_string.nil? + query_string_pairs = query_string.split("&").sort.map{|e| e.split("=") } + tm_query_string = query_string_pairs.map{|x| "#{x.first.downcase}:#{x.last}" }.join("\n") + "#{uri.downcase}\n#{tm_query_string}\n" + end end + end end end diff --git a/lib/fog/ecloud/generate_collection.rb b/lib/fog/ecloud/generate_collection.rb new file mode 100644 index 000000000..775667f21 --- /dev/null +++ b/lib/fog/ecloud/generate_collection.rb @@ -0,0 +1,130 @@ +require 'optparse' + +class String + def camelize + self.split('_').map {|w| w.capitalize}.join + end +end + + +options = {} +OptionParser.new do |opts| + opts.banner = "Usage: #{__FILE__} [options]" + opts.on("-m", "--model-name NAME", "Model Name") { |v| options[:model] = v } + opts.on("-c", "--collection-name NAME", "Collection Name") { |v| options[:collection] = v } + opts.on("-M", "--methods a:href,b:href,c:href", Array, "List of methods to be defined and href to the method") { |v| options[:methods] = v.map { |a| a.split(':') } } + opts.on("-a", "--attributes name:alias,other_name:other_alias", Array, "List of attributes to be defined") { |v| options[:attributes] = v.map { |a| a.split(':') } } +end.parse! + +if options[:methods] + methods = options[:methods].map do |m| + m = < connection, :href => "#{m[1]}") + end +METHOD + end.join("\n ") +end + + +if options[:attributes] + attributes = options[:attributes].map do |a| + a = "attribute :#{a[0]}, :aliases => :#{a[1] || a[0].camelize}" + end.join("\n ") +end + +collection_file = "#{File.expand_path(File.dirname(__FILE__))}/models/compute/#{options[:collection]}.rb" +model_file = "#{File.expand_path(File.dirname(__FILE__))}/models/compute/#{options[:model]}.rb" +collection_request_file = "#{File.expand_path(File.dirname(__FILE__))}/requests/compute/get_#{options[:collection]}.rb" +model_request_file = "#{File.expand_path(File.dirname(__FILE__))}/requests/compute/get_#{options[:model]}.rb" + +collection = <" + end + end + + class MockData < Base + def versions + @versions ||= [] + end + + def organizations + @organizations ||= [] + end + + def organization_collection_from_href(href) + find_href_in(href, all_organizations) + end + + def all_organizations + organizations.map(&:environments).flatten + end + + def organization_from_href(href) + find_href_in(href, all_organizations) + end + + def all_vdcs + organizations.map(&:environments).flatten + end + + def vdc_from_href(href) + find_href_in(href, all_vdcs) + end + + def all_catalogs + all_vdcs.map(&:catalog).flatten + end + + def catalog_from_href(href) + find_href_in(href, all_catalogs) + end + + def all_catalog_items + all_catalogs.map(&:items).flatten + end + + def catalog_item_from_href(href) + find_href_in(href, all_catalog_items) + end + + def all_virtual_machines + all_vdcs.map(&:virtual_machines).flatten + end + + def virtual_machine_from_href(href) + find_href_prefixed_in(href, all_virtual_machines) + end + + + def all_networks + all_vdcs.map(&:networks).flatten + end + + def network_from_href(href) + find_href_in(href, all_networks) + end + + def all_network_extensions + all_networks.map(&:extensions).flatten + end + + def network_extension_from_href(href) + find_href_in(href, all_network_extensions) + end + + def all_vdc_internet_service_collections + all_vdcs.map(&:internet_service_collection).flatten + end + + def vdc_internet_service_collection_from_href(href) + find_href_in(href, all_vdc_internet_service_collections) + end + + def all_backup_internet_services + all_vdc_internet_service_collections.map(&:backup_internet_services).flatten + end + + def backup_internet_service_from_href(href) + find_href_in(href, all_backup_internet_services) + end + + def all_public_ip_collections + all_vdcs.map {|v| v.public_ip_collection }.flatten + end + + def public_ip_collection_from_href(href) + find_href_in(href, all_public_ip_collections) + end + + def all_public_ips + all_public_ip_collections.map(&:items).flatten + end + + def public_ip_from_href(href) + find_href_in(href, all_public_ips) + end + + def all_public_ip_internet_service_collections + all_public_ips.map(&:internet_service_collection).flatten + end + + def public_ip_internet_service_collection_from_href(href) + find_href_in(href, all_public_ip_internet_service_collections) + end + + def all_public_ip_internet_services + all_public_ip_internet_service_collections.map(&:items).flatten + end + + def public_ip_internet_service_from_href(href) + find_href_in(href, all_public_ip_internet_services) + end + + def all_public_ip_internet_service_node_collections + all_public_ip_internet_services.map(&:node_collection).flatten + end + + def public_ip_internet_service_node_collection_from_href(href) + find_href_in(href, all_public_ip_internet_service_node_collections) + end + + def all_public_ip_internet_service_nodes + all_public_ip_internet_service_node_collections.map(&:items).flatten + end + + def public_ip_internet_service_node_from_href(href) + find_href_in(href, all_public_ip_internet_service_nodes) + end + + def all_network_ip_collections + all_networks.map(&:ip_collection) + end + + def network_ip_collection_from_href(href) + find_href_in(href, all_network_ip_collections) + end + + def all_network_ips + all_network_ip_collections.map {|c| c.items.values }.flatten + end + + def network_ip_from_href(href) + find_href_in(href, all_network_ips) + end + + private + + def find_href_in(href, objects) + objects.detect {|o| o.href == href } + end + + def find_href_prefixed_in(href, objects) + objects.detect {|o| href =~ %r{^#{o.href}($|/)} } + end + end + + class MockVersion < Base + def version + self[:version] + end + + def supported + !!self[:supported] + end + + def login_url + href + end + end + + class MockOrganization < Base + def name + self[:name] + end + + def environments + @vdcs ||= [] + end + + end + + class MockVdc < Base + def name + self[:name] + end + + def storage_allocated + self[:storage_allocated] || 200 + end + + def storage_used + self[:storage_used] || 105 + end + + def cpu_allocated + self[:cpu_allocated] || 10000 + end + + def memory_allocated + self[:memory_allocated] || 20480 + end + + def catalog + @catalog ||= MockCatalog.new({}, self) + end + + def networks + @networks ||= [] + end + + def virtual_machines + @virtual_machines ||= [] + end + + def task_list + @task_list ||= MockTaskList.new({}, self) + end + + # for TM eCloud, should probably be subclassed + def public_ip_collection + @public_ip_collection ||= MockPublicIps.new({}, self) + end + + def internet_service_collection + @internet_service_collection ||= MockVdcInternetServices.new({}, self) + end + + def firewall_acls + @firewall_acls ||= MockFirewallAcls.new({}, self) + end + end + + class MockTaskList < Base + def name + self[:name] || "Tasks List" + end + end + + class MockCatalog < Base + def name + self[:name] || "Catalog" + end + + def items + @items ||= [] + end + end + + class MockCatalogItem < Base + def name + self[:name] + end + + def disks + @disks ||= MockVirtualMachineDisks.new(self) + end + + def customization + @customization ||= MockCatalogItemCustomization.new({}, self) + end + + def vapp_template + @vapp_template ||= MockCatalogItemVappTemplate.new({ :name => name }, self) + end + end + + class MockCatalogItemCustomization < Base + def name + self[:name] || "Customization Options" + end + end + + class MockCatalogItemVappTemplate < Base + def name + self[:name] + end + end + + class MockNetwork < Base + def name + self[:name] || subnet + end + + def subnet + self[:subnet] + end + + def gateway + self[:gateway] || subnet_ips[1] + end + + def netmask + self[:netmask] || subnet_ipaddr.mask + end + + def dns + "8.8.8.8" + end + + def features + [ + { :type => :FenceMode, :value => "isolated" } + ] + end + + def ip_collection + @ip_collection ||= MockNetworkIps.new({}, self) + end + + def extensions + @extensions ||= MockNetworkExtensions.new({}, self) + end + + def random_ip + usable_subnet_ips[rand(usable_subnet_ips.length)] + end + + # for TM eCloud. should probably be a subclass + def rnat + self[:rnat] + end + + def usable_subnet_ips + subnet_ips[3..-2] + end + + def address + subnet_ips.first + end + + def broadcast + subnet_ips.last + end + + private + + def subnet_ipaddr + @ipaddr ||= IPAddr.new(subnet) + end + + def subnet_ips + subnet_ipaddr.to_range.to_a.map(&:to_s) + end + end + + class MockNetworkIps < Base + def items + @items ||= _parent.usable_subnet_ips.inject({}) do |out, subnet_ip| + out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self)) + end + end + + def ordered_ips + items.values.sort_by {|i| i.ip.split(".").map(&:to_i) } + end + + def name + "IP Addresses" + end + end + + class MockNetworkIp < Base + def name + self[:name] || ip + end + + def ip + self[:ip] + end + + def used_by + self[:used_by] || _parent._parent._parent.virtual_machines.detect {|v| v.ip == ip } + end + + def status + if used_by + "Assigned" + else + "Available" + end + end + + def rnat + self[:rnat] || _parent._parent.rnat + end + + def rnat_set? + !!self[:rnat] + end + end + + class MockNetworkExtensions < Base + def name + _parent.name + end + + def gateway + _parent.gateway + end + + def broadcast + _parent.broadcast + end + + def address + _parent.address + end + + def rnat + _parent.rnat + end + + def type + self[:type] || "DMZ" + end + + def vlan + object_id.to_s + end + + def friendly_name + "#{name} (#{type}_#{object_id})" + end + end + + class MockVirtualMachine < Base + def name + self[:name] + end + + def ip + self[:ip] + end + + def cpus + self[:cpus] || 1 + end + + def memory + self[:memory] || 1024 + end + + def disks + @disks ||= MockVirtualMachineDisks.new(self) + end + + def status + self[:status] || 2 + end + + def power_off! + self[:status] = 2 + end + + def power_on! + self[:status] = 4 + end + + def size + disks.inject(0) {|s, d| s + d.vcloud_size } + end + + def network_ip + if network = _parent.networks.detect {|n| n.ip_collection.items[ip] } + network.ip_collection.items[ip] + end + end + + # from fog ecloud server's _compose_vapp_data + def to_configure_vapp_hash + { + :name => name, + :cpus => cpus, + :memory => memory, + :disks => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } } + } + end + + def href(purpose = :base) + case purpose + when :base + super() + when :power_on + super() + "/power/action/powerOn" + when :power_off + super() + "/power/action/powerOff" + end + end + end + + class MockVirtualMachineDisks < Array + def initialize(parent = nil) + @parent = parent + end + + def _parent + @parent + end + + def <<(disk) + next_address = 0 + disk_with_max_address = max {|a, b| a[:address] <=> b[:address] } + disk_with_max_address && next_address = disk_with_max_address.address + 1 + disk[:address] ||= next_address + + super(disk) + + if (addresses = map {|d| d.address }).uniq.size != size + raise "Duplicate disk address in: #{addresses.inspect} (#{size})" + end + + sort! {|a, b| a.address <=> b.address } + self + end + + def at_address(address) + detect {|d| d.address == address } + end + end + + class MockVirtualMachineDisk < Base + def size + self[:size].to_i + end + + def vcloud_size + # kilobytes + size * 1024 + end + + def address + self[:address].to_i + end + end + + # for Terremark eCloud + + class MockVdcInternetServices < Base + def href + _parent.href + "/internetServices" + end + + def name + "Internet Services" + end + + def items + public_ip_internet_services + backup_internet_services + end + + def public_ip_internet_services + _parent.public_ip_collection.items.inject([]) do |services, public_ip| + services + public_ip.internet_service_collection.items + end + end + + def backup_internet_services + @backup_internet_services ||= [] + end + end + + class MockBackupInternetService < Base + def name + self[:name] || "Backup Internet Service #{object_id}" + end + + def protocol + self[:protocol] + end + + def port + 0 + end + + def enabled + self[:enabled].to_s.downcase != "false" + end + + def timeout + self[:timeout] || 2 + end + + def description + self[:description] || "Description for Backup Service #{name}" + end + + def redirect_url + nil + end + + def node_collection + @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) + end + end + + class MockFirewallAcls < Base + def name + "Firewall Access List" + end + end + + class MockPublicIps < Base + def name + self[:name] || "Public IPs" + end + + def items + @items ||= [] + end + end + + class MockPublicIp < Base + def name + self[:name] + end + + def internet_service_collection + @internet_service_collection ||= MockPublicIpInternetServices.new({}, self) + end + end + + class MockPublicIpInternetServices < Base + def href + _parent.href + "/internetServices" + end + + def items + @items ||= [] + end + end + + class MockPublicIpInternetService < Base + def name + self[:name] || "Public IP Service #{object_id}" + end + + def description + self[:description] || "Description for Public IP Service #{name}" + end + + def protocol + self[:protocol] + end + + def port + self[:port] + end + + def enabled + !!self[:enabled] + end + + def redirect_url + self[:redirect_url] + end + + def timeout + self[:timeout] || 2 + end + + def node_collection + @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) + end + + def monitor + nil + end + + def backup_service + self[:backup_service] + end + end + + class MockPublicIpInternetServiceNodes < Base + def href + _parent.href + "/nodeServices" + end + + def items + @items ||= [].tap do |node_array| + node_array.instance_variable_set("@default_port", _parent.port) + + def node_array.<<(node) + node[:port] ||= @default_port + super + end + end + end + end + + class MockPublicIpInternetServiceNode < Base + def ip_address + self[:ip_address] + end + + def name + self[:name] || "Public IP Service Node #{object_id}" + end + + def description + self[:description] || "Description for Public IP Service Node #{name}" + end + + def port + self[:port] + end + + def enabled + self[:enabled].to_s.downcase != "false" + end + + def enabled=(new_value) + self[:enabled] = new_value + end + end + end + end +end diff --git a/lib/fog/ecloud/model.rb b/lib/fog/ecloud/model.rb new file mode 100644 index 000000000..12bd160a6 --- /dev/null +++ b/lib/fog/ecloud/model.rb @@ -0,0 +1,22 @@ +module Fog + module Ecloud + class Model < Fog::Model + + attr_accessor :loaded + alias_method :loaded?, :loaded + + def reload + instance = super + @loaded = true + instance + end + + def load_unless_loaded! + unless @loaded + reload + end + end + + end + end +end diff --git a/lib/fog/ecloud/models/compute/admin_organization.rb b/lib/fog/ecloud/models/compute/admin_organization.rb new file mode 100644 index 000000000..073e28a73 --- /dev/null +++ b/lib/fog/ecloud/models/compute/admin_organization.rb @@ -0,0 +1,39 @@ +module Fog + module Compute + class Ecloud + class AdminOrganization < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :multifactor_summary, :aliases => :MultifactorSummary + attribute :support_access, :aliases => :SupportAccess + + def ssh_keys + @ssh_keys = Fog::Compute::Ecloud::SshKeys.new(:connection => connection, :href => "/cloudapi/ecloud/admin/sshKeys/organizations/#{org_id}") + end + + def password_complexity_rules + @password_complexity_rules = Fog::Compute::Ecloud::PasswordComplexityRules.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/passwordComplexityRules") + end + + def login_banner + @login_banner = Fog::Compute::Ecloud::LoginBanner.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/loginBanner") + end + + def authentication_levels + @authentication_levels = Fog::Compute::Ecloud::AuthenticationLevels.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{org_id}/authenticationLevels") + end + + def id + href.scan(/\d+/)[0] + end + + def org_id + other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.organization" }[:href].scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/admin_organizations.rb b/lib/fog/ecloud/models/compute/admin_organizations.rb new file mode 100644 index 000000000..0cfc2fc6a --- /dev/null +++ b/lib/fog/ecloud/models/compute/admin_organizations.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/admin_organization' + +module Fog + module Compute + class Ecloud + class AdminOrganizations < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::AdminOrganization + + def all + data = connection.get_admin_organizations(href).body + load(data) + end + + def get(uri) + if data = connection.get_admin_organization(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/api_key.rb b/lib/fog/ecloud/models/compute/api_key.rb new file mode 100644 index 000000000..3b7403d7b --- /dev/null +++ b/lib/fog/ecloud/models/compute/api_key.rb @@ -0,0 +1,21 @@ +module Fog + module Compute + class Ecloud + class ApiKey < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :access_key, :aliases => :AccessKey + attribute :status, :aliases => :Status + attribute :private_key, :aliases => :PrivateKey + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/api_keys.rb b/lib/fog/ecloud/models/compute/api_keys.rb new file mode 100644 index 000000000..1e030b1e3 --- /dev/null +++ b/lib/fog/ecloud/models/compute/api_keys.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/api_key' + +module Fog + module Compute + class Ecloud + class ApiKeys < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::ApiKey + + def all + data = connection.get_api_keys(href).body + load(data) + end + + def get(uri) + if data = connection.get_api_key(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/association.rb b/lib/fog/ecloud/models/compute/association.rb new file mode 100644 index 000000000..954dc7f05 --- /dev/null +++ b/lib/fog/ecloud/models/compute/association.rb @@ -0,0 +1,23 @@ +module Fog + module Compute + class Ecloud + class Association < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :ip_address, :aliases => :IpAddress + + def delete + data = connection.rnat_associations_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => href)[0] + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/associations.rb b/lib/fog/ecloud/models/compute/associations.rb new file mode 100644 index 000000000..014642db2 --- /dev/null +++ b/lib/fog/ecloud/models/compute/associations.rb @@ -0,0 +1,35 @@ +require 'fog/ecloud/models/compute/association' + +module Fog + module Compute + class Ecloud + class Associations < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Association + + def all + data = connection.get_associations(href).body + if data[:Associations] + data = data[:Associations] + if data.is_a?(String) && data.empty? + data = [] + elsif data.is_a?(Hash) + data = data[:Association] + end + end + load(data) + end + + def get(uri) + if data = connection.get_association(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/authentication_level.rb b/lib/fog/ecloud/models/compute/authentication_level.rb new file mode 100644 index 000000000..a43f344f6 --- /dev/null +++ b/lib/fog/ecloud/models/compute/authentication_level.rb @@ -0,0 +1,22 @@ +module Fog + module Compute + class Ecloud + class AuthenticationLevel < Fog::Ecloud::Model + identity :href + + attribute :basic_enabled, :aliases => :BasicEnabled, :type => :boolean + attribute :sha1_enabled, :aliases => :SHA1Enabled, :type => :boolean + attribute :Sha256_enabled, :aliases => :SHA256Enabled, :type => :boolean + attribute :Sha512_enabled, :aliases => :SHA512Enabled, :type => :boolean + attribute :hmacsha1_enabled, :aliases => :HMACSHA1Enabled, :type => :boolean + attribute :hmacsha256_enabled, :aliases => :HMACSHA256Enabled, :type => :boolean + attribute :hmacsha512_enabled, :aliases => :HMACSHA512Enabled, :type => :boolean + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/authentication_levels.rb b/lib/fog/ecloud/models/compute/authentication_levels.rb new file mode 100644 index 000000000..cb1af7fb5 --- /dev/null +++ b/lib/fog/ecloud/models/compute/authentication_levels.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/authentication_level' + +module Fog + module Compute + class Ecloud + class AuthenticationLevels < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::AuthenticationLevel + + def all + data = connection.get_authentication_levels(href).body + load(data) + end + + def get(uri) + if data = connection.get_authentication_level(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/backup_internet_service.rb b/lib/fog/ecloud/models/compute/backup_internet_service.rb index a4dcf9898..f6cc5067a 100644 --- a/lib/fog/ecloud/models/compute/backup_internet_service.rb +++ b/lib/fog/ecloud/models/compute/backup_internet_service.rb @@ -2,54 +2,43 @@ module Fog module Compute class Ecloud class BackupInternetService < Fog::Ecloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i + identity :href attribute :name, :aliases => :Name - attribute :id, :aliases => :Id + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links attribute :protocol, :aliases => :Protocol - attribute :enabled, :aliases => :Enabled + attribute :enabled, :aliases => :Enabled, :type => :boolean attribute :description, :aliases => :Description - attribute :timeout, :aliases => :Timeout - attribute :redirect_url, :aliases => :RedirectURL - attribute :monitor, :aliases => :Monitor + attribute :persistence, :aliases => :Persistence + attribute :redirect_url, :aliases => :RedirectUrl + + def tasks + @tasks = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => href) + end + + def internet_services + @internet_services = Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => href) + end + + def node_services + @node_services = Fog::Compute::Ecloud::NodeServices.new(:connection => connection, :href => href) + end + + def edit(options) + options[:uri] = href + data = connection.backup_internet_service_edit(options).body + object = collection.from_data(data) + end def delete - requires :href - - connection.delete_internet_service( href ) + data = connection.backup_internet_service_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] end - def monitor=(new_monitor = {}) - if new_monitor.nil? || new_monitor.empty? - attributes[:monitor] = nil - end + def id + href.scan(/\d+/)[0] 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::Compute::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 diff --git a/lib/fog/ecloud/models/compute/backup_internet_services.rb b/lib/fog/ecloud/models/compute/backup_internet_services.rb index a13ce46ef..4fd18ba94 100644 --- a/lib/fog/ecloud/models/compute/backup_internet_services.rb +++ b/lib/fog/ecloud/models/compute/backup_internet_services.rb @@ -5,28 +5,37 @@ module Fog class Ecloud class BackupInternetServices < Fog::Ecloud::Collection + identity :href + model Fog::Compute::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 + data = connection.get_backup_internet_services(href).body + load(data) 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) + if data = connection.get_backup_internet_service(uri) + new(data.body) end rescue Fog::Errors::NotFound nil end + def from_data(data) + new(data) + end + + def create(options) + options[:uri] = href + "/action/createBackupInternetService" + options[:enabled] ||= true + data = connection.backup_internet_service_create(options) + new(data) + end + + def internet_service_id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/catalog.rb b/lib/fog/ecloud/models/compute/catalog.rb index e632cc8a4..54bf99018 100644 --- a/lib/fog/ecloud/models/compute/catalog.rb +++ b/lib/fog/ecloud/models/compute/catalog.rb @@ -1,16 +1,29 @@ +require 'fog/ecloud/models/compute/catalog_item' + module Fog module Compute class Ecloud class Catalog < Fog::Ecloud::Collection + identity :href + model Fog::Compute::Ecloud::CatalogItem - attribute :href, :aliases => :Href - def all - check_href! - if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem] + data = connection.get_catalog(href).body#[:Locations][:Location][:Catalog][:CatalogEntry] + if data[:Locations][:Location].is_a?(Hash) + data = [] if data[:Locations][:Location][:Catalog].is_a?(String) && data[:Locations][:Location][:Catalog].empty? load(data) + elsif data[:Locations][:Location].is_a?(Array) + r_data = [] + data[:Locations][:Location].each do |d| + unless d[:Catalog].is_a?(String) && d[:Catalog].empty? + d[:Catalog][:CatalogEntry].each do |c| + r_data << c + end + end + end + load(r_data) end end @@ -21,7 +34,6 @@ module Fog rescue Fog::Errors::NotFound nil end - end end end diff --git a/lib/fog/ecloud/models/compute/catalog_configuration.rb b/lib/fog/ecloud/models/compute/catalog_configuration.rb new file mode 100644 index 000000000..ad87e1879 --- /dev/null +++ b/lib/fog/ecloud/models/compute/catalog_configuration.rb @@ -0,0 +1,23 @@ +module Fog + module Compute + class Ecloud + class CatalogConfiguration < Fog::Ecloud::Model + identity :href + + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :processor_count, :aliases => :ProcessorCount, :type => :integer + attribute :memory, :aliases => :Memory + attribute :operating_system, :aliases => :OperatingSystem + attribute :disks, :aliases => :Disks + attribute :network_adapters, :aliases => :NetworkAdapters, :type => :integer + attribute :network_mappings, :aliases => :NetworkMappings + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/catalog_configurations.rb b/lib/fog/ecloud/models/compute/catalog_configurations.rb new file mode 100644 index 000000000..a7d128fce --- /dev/null +++ b/lib/fog/ecloud/models/compute/catalog_configurations.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/catalog_configuration' + +module Fog + module Compute + class Ecloud + class CatalogConfigurations < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::CatalogConfiguration + + def all + data = connection.get_catalog_configurations(href).body + load(data) + end + + def get(uri) + if data = connection.get_catalog_configuration(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/catalog_item.rb b/lib/fog/ecloud/models/compute/catalog_item.rb index 9bce52023..bb492638c 100644 --- a/lib/fog/ecloud/models/compute/catalog_item.rb +++ b/lib/fog/ecloud/models/compute/catalog_item.rb @@ -2,27 +2,22 @@ module Fog module Compute class Ecloud class CatalogItem < Fog::Ecloud::Model + identity :href - identity :href, :aliases => :Href + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :status, :aliases => :Status + attribute :alerts, :aliases => :Alerts + attribute :files, :aliases => :Files - 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 + def configuration + @configuration = Fog::Compute::Ecloud::CatalogConfigurations.new(:connection => connection, :href => "/cloudapi/ecloud/admin/catalog/#{id}/configuration") end + def id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/compute_pool.rb b/lib/fog/ecloud/models/compute/compute_pool.rb index fdb35f080..5f301ae5b 100644 --- a/lib/fog/ecloud/models/compute/compute_pool.rb +++ b/lib/fog/ecloud/models/compute/compute_pool.rb @@ -3,16 +3,56 @@ module Fog class Ecloud class ComputePool < Fog::Ecloud::Model - identity :href, :aliases => :Href + identity :href - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id attribute :href, :aliases => :Href - attribute :state, :aliases => :State - attribute :is_default, :aliases => :IsDefault - + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :all_servers, :aliases => :VirtualMachines + attribute :purchased, :aliases => :Purchased + attribute :cpu_burst, :aliases => :CpuBurst + attribute :memory_burst, :aliases => :MemoryBurst + + def servers + @servers ||= Fog::Compute::Ecloud::Servers.new( :connection => connection, :href => "/cloudapi/ecloud/virtualMachines/computePools/#{id}" ) + end + + def layout + @layout ||= Fog::Compute::Ecloud::Layouts.new(:connection => connection, :href => "/cloudapi/ecloud/layout/computePools/#{id}").first + end + + def cpu_usage +# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = "" + @cpu_usage ||= Fog::Compute::Ecloud::CpuUsageDetailSummary.new(:connection => connection, :href => "/cloudapi/ecloud/computePools/#{id}/usage/cpu") + end + + def memory_usage +# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = "" + @memory_usage ||= Fog::Compute::Ecloud::MemoryUsageDetailSummary.new(:connection => connection, :href => "/cloudapi/ecloud/computePools/#{id}/usage/memory") + end + + def storage_usage + @storage_usage ||= Fog::Compute::Ecloud::StorageUsageDetailSummary.new(:connection => connection, :href => "/cloudapi/ecloud/computePools/#{id}/usage/storage") + end + + def operating_system_families + @operating_system_families ||= Fog::Compute::Ecloud::OperatingSystemFamilies.new(:connection => connection, :href => "/cloudapi/ecloud/operatingSystemFamilies/computePools/#{id}") + end + + def templates + @templates ||= Fog::Compute::Ecloud::Templates.new(:connection => connection, :href => "/cloudapi/ecloud/templates/computePools/#{id}") + end + + def edit(options) + options[:uri] = href + data = connection.compute_pool_edit(options).body + pool = collection.from_data(data) + end + + def id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/compute_pools.rb b/lib/fog/ecloud/models/compute/compute_pools.rb index 75bd41cd6..88aa98b3e 100644 --- a/lib/fog/ecloud/models/compute/compute_pools.rb +++ b/lib/fog/ecloud/models/compute/compute_pools.rb @@ -11,15 +11,10 @@ module Fog model Fog::Compute::Ecloud::ComputePool - #get_request :get_compute_pool - #vcloud_type "application/vnd.tmrk.ecloud.publicIp+xml" - #all_request lambda { |compute_pools| public_ips.connection.get_public_ips(public_ips.href) } - def all - check_href!(:message => "the Compute Pool href of the Vdc you want to enumerate") - if data = connection.get_compute_pools(href).body[:ComputePool] - load(data) - end + check_href!(:message => "the Compute Pool href of the Environment you want to enumerate") + data = connection.get_compute_pools(href).body[:ComputePool] + load(data) end def get(uri) @@ -30,6 +25,9 @@ module Fog nil end + def from_data(data) + new(data) + end end end end diff --git a/lib/fog/ecloud/models/compute/cpu_usage_detail.rb b/lib/fog/ecloud/models/compute/cpu_usage_detail.rb new file mode 100644 index 000000000..9b89979a6 --- /dev/null +++ b/lib/fog/ecloud/models/compute/cpu_usage_detail.rb @@ -0,0 +1,17 @@ +module Fog + module Compute + class Ecloud + class CpuUsageDetail < Fog::Ecloud::Model + identity :href + + attribute :time, :aliases => :Time + attribute :value, :aliases => :Value + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb b/lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb new file mode 100644 index 000000000..45d91e200 --- /dev/null +++ b/lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/cpu_usage_detail' + +module Fog + module Compute + class Ecloud + class CpuUsageDetailSummary < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::CpuUsageDetail + + def all + data = connection.get_cpu_usage_detail_summary(href).body[:CpuUsageDetailSummary][:CpuUsageDetail] + load(data) + end + + def get(uri) + if data = connection.get_cpu_usage_detail(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/environment.rb b/lib/fog/ecloud/models/compute/environment.rb new file mode 100644 index 000000000..3a339b1c0 --- /dev/null +++ b/lib/fog/ecloud/models/compute/environment.rb @@ -0,0 +1,105 @@ +module Fog + module Compute + class Ecloud + class Environment < Fog::Ecloud::Model + + identity :href + + ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd + + attribute :name + attribute :type + attribute :other_links, :aliases => :Links + + def public_ips + @public_ips ||= Fog::Compute::Ecloud::PublicIps.new(:connection => connection, :href => "/cloudapi/ecloud/publicIps/environments/#{id}") + end + + def internet_services + @internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => "/cloudapi/ecloud/networkSummary/environments/#{id}") + end + + def node_services + @node_services ||= Fog::Compute::Ecloud::Nodes.new(:connection => connection, :href => "/cloudapi/ecloud/networkSummary/environments/#{id}") + end + + def backup_internet_services + @backup_internet_services ||= Fog::Compute::Ecloud::BackupInternetServices.new(:connection, :href => "/cloudapi/ecloud/backupInternetServices/environments/#{id}") + end + + def networks + @networks ||= Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/networks/environments/#{id}") + end + + def servers + @servers = nil + pools = compute_pools + pools.each do |c| + if pools.index(c) == 0 + @servers = c.servers + else + c.servers.each { |s| @servers << s } + end + end + @servers + end + + def layout + @layout ||= Fog::Compute::Ecloud::Layouts.new(:connection => connection, :href => "/cloudapi/ecloud/layout/environments/#{id}").first + end + + def rows + layout.rows + end + + def tasks + @tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/environments/#{id}") + end + + def firewall_acls + @firewall_acls ||= Fog::Compute::Ecloud::FirewallAcls.new(:connection => connection, :href => "/cloudapi/ecloud/firewallAcls/environments/#{id}") + end + + def compute_pools + @compute_pools ||= Fog::Compute::Ecloud::ComputePools.new(:connection => connection, :href => "/cloudapi/ecloud/computePools/environments/#{id}") + end + + def physical_devices + @physical_devices ||= Fog::Compute::Ecloud::PhysicalDevices.new(:connection => connection, :href => "/cloudapi/ecloud/physicalDevices/environments/#{id}") + end + + def trusted_network_groups + @trusted_network_groups ||= Fog::Compute::Ecloud::TrustedNetworkGroups.new(:connection => connection, :href => "/cloudapi/ecloud/trustedNetworkGroups/environments/#{id}") + end + + def catalog + org_href = other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.organization" }[:href] + @catalog ||= Fog::Compute::Ecloud::Catalog.new(:connection => connection, :href => "/cloudapi/ecloud/admin/catalog/organizations/#{org_href.scan(/\d+/)[0]}") + end + + def rnats + @rnats ||= Fog::Compute::Ecloud::Rnats.new(:connection => connection, :href => "/cloudapi/ecloud/rnats/environments/#{id}") + end + + def create_trusted_network_group(options = {}) + options[:uri] = "/cloudapi/ecloud/trustedNetworkGroups/environments/#{id}/action/createTrustedNetworkGroup" + data = connection.trusted_network_groups_create(options).body + tng = Fog::Compute::Ecloud::TrustedNetworkGroups.new(:connection => connection, :href => data[:href])[0] + end + + def create_firewall_acl(options = {}) + options[:uri] = "/cloudapi/ecloud/firewallAcls/environments/#{id}/action/createFirewallAcl" + options[:permission] ||= "deny" + options[:protocol] ||= "any" + data = connection.firewall_acls_create(options).body + acl = Fog::Compute::Ecloud::FirewallAcls.new(:connection => connection, :href => data[:href])[0] + end + + def id + href.scan(/\d+/)[0] + end + end + Vdc = Environment + end + end +end diff --git a/lib/fog/ecloud/models/compute/environments.rb b/lib/fog/ecloud/models/compute/environments.rb new file mode 100644 index 000000000..a0ed7fd35 --- /dev/null +++ b/lib/fog/ecloud/models/compute/environments.rb @@ -0,0 +1,40 @@ +require 'fog/ecloud/models/compute/environment' + +module Fog + module Compute + class Ecloud + + class Environments < Fog::Ecloud::Collection + + model Fog::Compute::Ecloud::Environment + + undef_method :create + + identity :href + + def all + data = [] + connection.get_organization(href).body[:Locations][:Location].each do |d| + if d[:Environments][:Environment].is_a?(Array) + d[:Environments][:Environment].each { |e| data << e } + else + data << d[:Environments][:Environment] + end + end + load(data) + end + + def get(uri) + if data = connection.get_environment(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + Vdcs = Environments + + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/firewall_acl.rb b/lib/fog/ecloud/models/compute/firewall_acl.rb index 0411296d6..9a5b77771 100644 --- a/lib/fog/ecloud/models/compute/firewall_acl.rb +++ b/lib/fog/ecloud/models/compute/firewall_acl.rb @@ -2,22 +2,25 @@ module Fog module Compute class Ecloud class FirewallAcl < Fog::Ecloud::Model + identity :href - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i - - attribute :name, :aliases => :Name - attribute :id, :aliases => :Id + attribute :type, :aliases => :Type + attribute :links, :aliases => :Links + attribute :permission, :aliases => :Permission + attribute :acl_type, :aliases => :AclType + attribute :port_type, :aliases => :PortType 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 + attribute :port_range, :aliases => :PortRange + def tasks + @tasks = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}") + end + + def id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/firewall_acls.rb b/lib/fog/ecloud/models/compute/firewall_acls.rb index d3372ebde..515b11622 100644 --- a/lib/fog/ecloud/models/compute/firewall_acls.rb +++ b/lib/fog/ecloud/models/compute/firewall_acls.rb @@ -5,26 +5,23 @@ module Fog class Ecloud class FirewallAcls < Fog::Ecloud::Collection + identity :href + model Fog::Compute::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 + data = connection.get_firewall_acls(href).body + data = data[:FirewallAcl] ? data[:FirewallAcl] : data + load(data) end def get(uri) - if data = connection.get_firewall_acl(uri).body - new(data) + if data = connection.get_firewall_acl(uri) + new(data.body) end rescue Fog::Errors::NotFound nil end - end end end diff --git a/lib/fog/ecloud/models/compute/group.rb b/lib/fog/ecloud/models/compute/group.rb new file mode 100644 index 000000000..da50a7511 --- /dev/null +++ b/lib/fog/ecloud/models/compute/group.rb @@ -0,0 +1,39 @@ +module Fog + module Compute + class Ecloud + class Group < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :index, :aliases => :Index + + def servers + @servers = Fog::Compute::Ecloud::Servers.new(:connection => connection, :href => href) + end + + def edit(options = {}) + options[:uri] = href + data = connection.groups_edit(options).body + end + + def move_up + connection.groups_moveup(href).body + end + + def move_down + connection.groups_movedown(href).body + end + + def delete + connection.groups_delete(href).body + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/groups.rb b/lib/fog/ecloud/models/compute/groups.rb new file mode 100644 index 000000000..5c2282d02 --- /dev/null +++ b/lib/fog/ecloud/models/compute/groups.rb @@ -0,0 +1,28 @@ +require 'fog/ecloud/models/compute/group' + +module Fog + module Compute + class Ecloud + class Groups < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Group + + def all + data = connection.get_groups(href).body + data = data[:Groups] ? data[:Groups][:Group] : data + load(data) + end + + def get(uri) + if data = connection.get_group(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/guest_process.rb b/lib/fog/ecloud/models/compute/guest_process.rb new file mode 100644 index 000000000..bdce3cbf8 --- /dev/null +++ b/lib/fog/ecloud/models/compute/guest_process.rb @@ -0,0 +1,15 @@ +module Fog + module Compute + class Ecloud + class GuestProcess < Fog::Ecloud::Model + identity :name + + attribute :process_id, :aliases => :ProcessId + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/guest_processes.rb b/lib/fog/ecloud/models/compute/guest_processes.rb new file mode 100644 index 000000000..eabed2af7 --- /dev/null +++ b/lib/fog/ecloud/models/compute/guest_processes.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/guest_process' + +module Fog + module Compute + class Ecloud + class GuestProcesses < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::GuestProcess + + def all + data = connection.get_guest_processes(href).body[:GuestProcess] + load(data) + end + + def get(uri) + if data = connection.get_guest_process(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/hardware_configuration.rb b/lib/fog/ecloud/models/compute/hardware_configuration.rb new file mode 100644 index 000000000..124b3e782 --- /dev/null +++ b/lib/fog/ecloud/models/compute/hardware_configuration.rb @@ -0,0 +1,18 @@ +module Fog + module Compute + class Ecloud + class HardwareConfiguration < Fog::Ecloud::Model + identity :href + + attribute :processor_count, :aliases => :ProcessorCount, :type => :integer + attribute :mem, :aliases => :Memory + attribute :storage, :aliases => :Disks + attribute :network_cards, :aliases => :Nics + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/hardware_configurations.rb b/lib/fog/ecloud/models/compute/hardware_configurations.rb new file mode 100644 index 000000000..092b85285 --- /dev/null +++ b/lib/fog/ecloud/models/compute/hardware_configurations.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/hardware_configuration' + +module Fog + module Compute + class Ecloud + class HardwareConfigurations < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::HardwareConfiguration + + def all + data = connection.get_hardware_configurations(href).body + load(data) + end + + def get(uri) + if data = connection.get_hardware_configuration(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/internet_service.rb b/lib/fog/ecloud/models/compute/internet_service.rb index d3e1c43f9..f2ea6aa41 100644 --- a/lib/fog/ecloud/models/compute/internet_service.rb +++ b/lib/fog/ecloud/models/compute/internet_service.rb @@ -2,94 +2,78 @@ module Fog module Compute class Ecloud class InternetService < Fog::Ecloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i + identity :href attribute :name, :aliases => :Name - attribute :id, :aliases => :Id + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :actions, :aliases => :Actions attribute :protocol, :aliases => :Protocol - attribute :port, :aliases => :Port - attribute :enabled, :aliases => :Enabled + attribute :port, :aliases => :Port, :type => :integer + attribute :enabled, :aliases => :Enabled, :type => :boolean 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 + attribute :public_ip, :aliases => :PublicIp + attribute :persistence, :aliases => :Persistence + attribute :redirect_url, :aliases => :RedirectUrl + attribute :trusted_network_group, :aliases => :TrustedNetworkGroup + attribute :backup_internet_service, :aliases => :BackupInternetService - def delete - requires :href + def nodes + @nodes ||= Fog::Compute::Ecloud::Nodes.new(:connection => connection, :href => href) + end - connection.delete_internet_service( href ) + def monitors + @monitors ||= Fog::Compute::Ecloud::Monitors.new(:connection => connection, :href => "/cloudapi/ecloud/internetServices/#{id}/monitor") end def save if new_record? - result = connection.add_internet_service( collection.href, _compose_service_data ) + result = connection.internet_service_create( 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 edit(options) + options[:uri] = href + data = connection.internet_service_edit(options).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] + end + + def delete + data = connection.internet_service_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] + end + + def create_monitor(options = {}) + options = {:type => :default}.merge(options) + case options[:type] + when :default + data = connection.monitors_create_default(href + "/action/createDefaultMonitor").body + when :ping + options[:enabled] ||= true + options[:uri] = href + "/action/createPingMonitor" + data = connection.monitors_create_ping(options).body + when :http + options[:uri] = href + "/action/createHttpMonitor" + data = connection.monitors_create_http(options).body + when :ecv + options[:uri] = href + "/action/createEcvMonitor" + data = connection.monitors_create_ecv(options).body + when :loopback + data = connection.monitors_create_loopback(href).body + end + monitor = Fog::Compute::Ecloud::Monitors.new(:connection => connection, :href => data[:href]) + end + 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 + data = connection.monitors_disable(href + "/action/disableMonitor").body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href]) 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::Compute::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 - } + def id + href.scan(/\d+/)[0] end private @@ -98,19 +82,9 @@ module Fog #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 diff --git a/lib/fog/ecloud/models/compute/internet_services.rb b/lib/fog/ecloud/models/compute/internet_services.rb index 37d80c2e3..12207f1b8 100644 --- a/lib/fog/ecloud/models/compute/internet_services.rb +++ b/lib/fog/ecloud/models/compute/internet_services.rb @@ -5,28 +5,41 @@ module Fog class Ecloud class InternetServices < Fog::Ecloud::Collection + identity :href + model Fog::Compute::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" }) + data = connection.get_internet_services(href).body[:InternetServices] + if data.is_a?(Hash) + load(data[:InternetService]) + elsif data.is_a?(String) && data.empty? + load([]) 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) + if data = connection.get_internet_service(uri) + new(data.body) end rescue Fog::Errors::NotFound nil end + def create(options) + options[:uri] = "/cloudapi/ecloud/internetServices/publicIps/#{public_ip_id}/action/createInternetService" + options[:protocol] ||= "TCP" + options[:enabled] ||= true + options[:description] ||= "" + options[:persistence] ||= {} + options[:persistence][:type] ||= "None" + data = connection.internet_service_create(options).body + object = new(data) + end + + def public_ip_id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/ip.rb b/lib/fog/ecloud/models/compute/ip.rb deleted file mode 100644 index 57e6c015e..000000000 --- a/lib/fog/ecloud/models/compute/ip.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Fog - module Compute - class Ecloud - 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/ecloud/models/compute/ip_address.rb b/lib/fog/ecloud/models/compute/ip_address.rb new file mode 100644 index 000000000..c73e6a177 --- /dev/null +++ b/lib/fog/ecloud/models/compute/ip_address.rb @@ -0,0 +1,25 @@ +module Fog + module Compute + class Ecloud + class IpAddress < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :host, :aliases => :Host + attribute :detected_on, :aliases => :DetectedOn + attribute :rnat, :aliases => :RnatAddress + attribute :reserved, :aliases => :Reserved, :type => :boolean + + def status + (detected_on || host) ? "Assigned" : "Available" + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/ip_addresses.rb b/lib/fog/ecloud/models/compute/ip_addresses.rb new file mode 100644 index 000000000..a7168eb8a --- /dev/null +++ b/lib/fog/ecloud/models/compute/ip_addresses.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/ip_address' + +module Fog + module Compute + class Ecloud + class IpAddresses < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::IpAddress + + def all + data = connection.get_ip_addresses(href).body[:IpAddresses][:IpAddress] + load(data) + end + + def get(uri) + if data = connection.get_ip_address(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/ips.rb b/lib/fog/ecloud/models/compute/ips.rb deleted file mode 100644 index 4a721e907..000000000 --- a/lib/fog/ecloud/models/compute/ips.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'fog/ecloud/models/compute/ip' - -module Fog - module Compute - class Ecloud - class Ips < Fog::Ecloud::Collection - - model Fog::Compute::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 diff --git a/lib/fog/ecloud/models/compute/layout.rb b/lib/fog/ecloud/models/compute/layout.rb new file mode 100644 index 000000000..09932755e --- /dev/null +++ b/lib/fog/ecloud/models/compute/layout.rb @@ -0,0 +1,20 @@ +module Fog + module Compute + class Ecloud + class Layout < Fog::Ecloud::Model + identity :href + + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + + def rows + @rows = Fog::Compute::Ecloud::Rows.new(:connection => connection, :href => href) + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/layouts.rb b/lib/fog/ecloud/models/compute/layouts.rb new file mode 100644 index 000000000..c2c003b52 --- /dev/null +++ b/lib/fog/ecloud/models/compute/layouts.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/layout' + +module Fog + module Compute + class Ecloud + class Layouts < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Layout + + def all + data = connection.get_layouts(href).body + load(data) + end + + def get(uri) + if data = connection.get_layout(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/location.rb b/lib/fog/ecloud/models/compute/location.rb new file mode 100644 index 000000000..5961dac59 --- /dev/null +++ b/lib/fog/ecloud/models/compute/location.rb @@ -0,0 +1,23 @@ +module Fog + module Compute + class Ecloud + class Location < Fog::Ecloud::Model + + identity :href + + ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + + def catalog(org_href) + @catalog ||= Fog::Compute::Ecloud::Catalog.new(:connection => connection, :href => "/cloudapi/ecloud/admin/catalog/organizations/#{org_href.scan(/\d+/)[0]}/locations/#{id}") + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/locations.rb b/lib/fog/ecloud/models/compute/locations.rb new file mode 100644 index 000000000..76163f861 --- /dev/null +++ b/lib/fog/ecloud/models/compute/locations.rb @@ -0,0 +1,31 @@ +require 'fog/ecloud/models/compute/location' + +module Fog + module Compute + class Ecloud + + class Locations < Fog::Ecloud::Collection + + model Fog::Compute::Ecloud::Location + + undef_method :create + + identity :href + + def all + data = connection.get_organization(href).body[:Locations][:Location] + load(data) + end + + def get(uri) + if data = connection.get_location(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/login_banner.rb b/lib/fog/ecloud/models/compute/login_banner.rb new file mode 100644 index 000000000..202be0d23 --- /dev/null +++ b/lib/fog/ecloud/models/compute/login_banner.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class Ecloud + class LoginBanner < Fog::Ecloud::Model + identity :href + + attribute :display, :aliases => :Display, :type => :boolean + attribute :text, :aliases => :Text + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/login_banners.rb b/lib/fog/ecloud/models/compute/login_banners.rb new file mode 100644 index 000000000..99aa78309 --- /dev/null +++ b/lib/fog/ecloud/models/compute/login_banners.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/login_banner' + +module Fog + module Compute + class Ecloud + class LoginBanners < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::LoginBanner + + def all + data = connection.get_login_banners(href).body + load(data) + end + + def get(uri) + if data = connection.get_login_banner(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/memory_usage_detail.rb b/lib/fog/ecloud/models/compute/memory_usage_detail.rb new file mode 100644 index 000000000..8a578583f --- /dev/null +++ b/lib/fog/ecloud/models/compute/memory_usage_detail.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class Ecloud + class MemoryUsageDetail < Fog::Ecloud::Model + identity :href + + attribute :time, :aliases => :Time + attribute :value, :aliases => :Value + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb b/lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb new file mode 100644 index 000000000..4643f9e66 --- /dev/null +++ b/lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/memory_usage_detail' + +module Fog + module Compute + class Ecloud + class MemoryUsageDetailSummary < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::MemoryUsageDetail + + def all + data = connection.get_memory_usage_detail_summary(href).body[:MemoryUsageDetailSummary][:MemoryUsageDetail] + load(data) + end + + def get(uri) + if data = connection.get_memory_usage_detail(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/monitor.rb b/lib/fog/ecloud/models/compute/monitor.rb new file mode 100644 index 000000000..475b1938c --- /dev/null +++ b/lib/fog/ecloud/models/compute/monitor.rb @@ -0,0 +1,46 @@ +module Fog + module Compute + class Ecloud + class Monitor < Fog::Ecloud::Model + identity :href + + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :interval, :aliases => :Interval, :type => :integer + attribute :response_timeout, :aliases => :ResponseTimeout, :type => :integer + attribute :retries, :aliases => :Retries, :type => :integer + attribute :downtime, :aliases => :Downtime, :type => :integer + attribute :enabled, :aliases => :Enabled, :type => :boolean + attribute :request_uri, :aliases => :RequestUri + attribute :http_headers, :aliases => :HttpHeaders + attribute :response_codes, :aliases => :ResponseCodes + attribute :send_string, :aliases => :SendString + attribute :receive_string, :aliases => :ReceiveString + + def edit(options = {}) + href = "/cloudapi/ecloud/internetServices/#{internet_service_id}/monitor?type=" + case type + when "application/vnd.tmrk.cloud.pingMonitor" + options[:uri] = href + "ping" + data = connection.monitors_edit_ping(options).body + when "application/vnd.tmrk.cloud.httpMonitor" + options[:uri] = href + "http" + data = connection.monitors_edit_http(options).body + when "application/vnd.tmrk.cloud.ecvMonitor" + options[:uri] = href + "ecv" + data = connection.monitors_edit_ecv(options).body + end + object = collection.from_data(data) + end + + def internet_service_id + other_links[:Link][:href].scan(/\d+/)[0] + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/monitors.rb b/lib/fog/ecloud/models/compute/monitors.rb new file mode 100644 index 000000000..53a3d1d39 --- /dev/null +++ b/lib/fog/ecloud/models/compute/monitors.rb @@ -0,0 +1,31 @@ +require 'fog/ecloud/models/compute/monitor' + +module Fog + module Compute + class Ecloud + class Monitors < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Monitor + + def all + data = connection.get_monitors(href).body + load(data) + end + + def get(uri) + if data = connection.get_monitor(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + def from_data(data) + new(data) + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/network.rb b/lib/fog/ecloud/models/compute/network.rb index fa3279cb2..244908cbb 100644 --- a/lib/fog/ecloud/models/compute/network.rb +++ b/lib/fog/ecloud/models/compute/network.rb @@ -2,72 +2,33 @@ module Fog module Compute class Ecloud 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 :type, :aliases => :Type + attribute :other_links, :aliases => :Links 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 + attribute :broadcast_address, :aliases => :BroadcastAddress + attribute :gateway_address, :aliases => :GatewayAddress + attribute :rnat_address, :aliases => :RnatAddress + + def rnats + @rnats ||= Fog::Compute::Ecloud::Rnats.new(:connection => connection, :href => "cloudapi/ecloud/rnats/networks/#{id}") + end def ips - load_unless_loaded! - connection.ips.new - Fog::Compute::Ecloud::Ips.new( - :connection => connection, - :href => links.detect { |link| link[:name] == "IP Addresses" }[:href] - ) + @ips ||= Fog::Compute::Ecloud::IpAddresses.new(:connection => connection, :href => href) end - def rnat=(new_rnat) - attributes[:rnat] = new_rnat - @changed = true + def edit_rnat_association(options) + options[:uri] = href + data = connection.rnat_associations_edit_network(options).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] 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 - } + + def id + href.scan(/\d+/)[0] end end end diff --git a/lib/fog/ecloud/models/compute/networks.rb b/lib/fog/ecloud/models/compute/networks.rb index 5bc594e0a..2dd760620 100644 --- a/lib/fog/ecloud/models/compute/networks.rb +++ b/lib/fog/ecloud/models/compute/networks.rb @@ -3,30 +3,25 @@ require 'fog/ecloud/models/compute/network' module Fog module Compute class Ecloud - class Networks < Fog::Ecloud::Collection - undef_method :create + identity :href model Fog::Compute::Ecloud::Network - attribute :href - def all - check_href!("Vdc") - if data = connection.get_vdc(href).body[:AvailableNetworks][:Network] - load(data) - end + data = connection.get_networks(href).body + data = data[:Networks] ? data[:Networks][:Network] : data[:Network] + load(data) end def get(uri) if data = connection.get_network(uri) new(data.body) end - rescue Fog::Errors::NotFound + rescue Fog::Errors::NotFound nil end - end end end diff --git a/lib/fog/ecloud/models/compute/node.rb b/lib/fog/ecloud/models/compute/node.rb index 43a0fb1f3..c5c383e5c 100644 --- a/lib/fog/ecloud/models/compute/node.rb +++ b/lib/fog/ecloud/models/compute/node.rb @@ -2,41 +2,37 @@ module Fog module Compute class Ecloud class Node < Fog::Ecloud::Model + identity :href - 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 + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :ip_address, :aliases => :IpAddress + attribute :protocol, :aliases => :Protocol + attribute :port, :aliases => :Port, :type => :integer + attribute :enabled, :aliases => :Enabled, :type => :boolean + attribute :description, :aliases => :Description + + def tasks + @tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}") + end def delete - requires :href - - connection.delete_node( href ) + data = connection.node_service_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] 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 + def edit(options) + options[:uri] = href + options[:description] ||= "" + options = {:name => name}.merge(options) + data = connection.node_service_edit(options).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] 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 + + def id + href.scan(/\d+/)[0] end - end end end diff --git a/lib/fog/ecloud/models/compute/nodes.rb b/lib/fog/ecloud/models/compute/nodes.rb index 0de1dce2d..c2ca5359f 100644 --- a/lib/fog/ecloud/models/compute/nodes.rb +++ b/lib/fog/ecloud/models/compute/nodes.rb @@ -3,17 +3,18 @@ require 'fog/ecloud/models/compute/node' module Fog module Compute class Ecloud - class Nodes < Fog::Ecloud::Collection + identity :href + model Fog::Compute::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) + data = connection.get_nodes(href).body + if data[:NodeServices] + load(data[:NodeServices][:NodeService]) + else + load([]) end end @@ -25,6 +26,18 @@ module Fog nil end + def create(options) + options[:uri] = "/cloudapi/ecloud/nodeServices/internetServices/#{internet_service_id}/action/createNodeService" + options[:protocol] ||= "TCP" + options[:enabled] ||= true + options[:description] ||= "" + data = connection.node_service_create(options).body + object = new(data) + end + + def internet_service_id + href.scan(/\d+/)[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/operating_system.rb b/lib/fog/ecloud/models/compute/operating_system.rb new file mode 100644 index 000000000..4b66d5d63 --- /dev/null +++ b/lib/fog/ecloud/models/compute/operating_system.rb @@ -0,0 +1,17 @@ +module Fog + module Compute + class Ecloud + class OperatingSystem < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/operating_system_families.rb b/lib/fog/ecloud/models/compute/operating_system_families.rb new file mode 100644 index 000000000..4adf6d042 --- /dev/null +++ b/lib/fog/ecloud/models/compute/operating_system_families.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/operating_system_family' + +module Fog + module Compute + class Ecloud + class OperatingSystemFamilies < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::OperatingSystemFamily + + def all + data = connection.get_operating_system_families(href).body[:OperatingSystemFamily] + load(data) + end + + def get(uri) + if data = connection.get_operating_system(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/operating_system_family.rb b/lib/fog/ecloud/models/compute/operating_system_family.rb new file mode 100644 index 000000000..1a6a68134 --- /dev/null +++ b/lib/fog/ecloud/models/compute/operating_system_family.rb @@ -0,0 +1,21 @@ +module Fog + module Compute + class Ecloud + class OperatingSystemFamily < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :operating_system_family, :aliases => :OperatingSystems + + def operating_systems + @operating_systems ||= Fog::Compute::Ecloud::OperatingSystems.new(:connection => connection, :data => operating_system_family[:OperatingSystem]) + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/operating_systems.rb b/lib/fog/ecloud/models/compute/operating_systems.rb new file mode 100644 index 000000000..0d349b5e5 --- /dev/null +++ b/lib/fog/ecloud/models/compute/operating_systems.rb @@ -0,0 +1,26 @@ +require 'fog/ecloud/models/compute/operating_system' + +module Fog + module Compute + class Ecloud + class OperatingSystems < Fog::Ecloud::Collection + + model Fog::Compute::Ecloud::OperatingSystem + + identity :data + + def all + load(data) + end + + def get(uri) + if data = connection.get_operating_system(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/organization.rb b/lib/fog/ecloud/models/compute/organization.rb new file mode 100644 index 000000000..75c3ca7f4 --- /dev/null +++ b/lib/fog/ecloud/models/compute/organization.rb @@ -0,0 +1,79 @@ +module Fog + module Compute + class Ecloud + class Organization < Fog::Ecloud::Model + + identity :href + + ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + + def locations + @locations ||= Fog::Compute::Ecloud::Locations.new( :connection => connection, :href => href ) + end + + def environments + @environments ||= Fog::Compute::Ecloud::Environments.new(:connection => connection, :href => href) + end + + def tags + @tags ||= Fog::Compute::Ecloud::Tags.new(:connection => connection, :href => "/cloudapi/ecloud/deviceTags/organizations/#{id}") + end + + def admin + @admin ||= Fog::Compute::Ecloud::AdminOrganizations.new(:connection => connection, :href => "/cloudapi/ecloud/admin/organizations/#{id}").first + end + + def users + @users ||= Fog::Compute::Ecloud::Users.new(:connection => connection, :href => "/cloudapi/ecloud/admin/users/organizations/#{id}") + end + + def support_tickets(type = :open) + case type + when :open + @support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:connection => connection, :href => "/cloudapi/ecloud/admin/tickets/organizations/#{id}/active") + when :closed + @support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:connection => connection, :href => "/cloudapi/ecloud/admin/tickets/organizations/#{id}/closed") + end + end + + def edit_authentication_levels(options = {}) + options[:uri] = "/cloudapi/ecloud/admin/organizations/#{id}/authenticationLevels" + data = connection.admin_edit_authentication_levels(options).body + level = Fog::Compute::Ecloud::AdminOrganizations.new(:connection => connection, :href => data[:href])[0] + end + + def edit_password_complexity_rules(options = {}) + options[:uri] = "/cloudapi/ecloud/admin/organizations/#{id}/passwordComplexityRules" + data = connection.admin_edit_password_complexity_rules(options).body + level = Fog::Compute::Ecloud::PasswordComplexityRules.new(:connection => connection, :href => data[:href])[0] + end + + def edit_login_banner(options = {}) + options[:uri] = "/cloudapi/ecloud/admin/organizations/#{id}/loginBanner" + data = connection.admin_edit_login_banner(options).body + banner = Fog::Compute::Ecloud::LoginBanners.new(:connection => connection, :href => data[:href])[0] + end + + def enable_support_access(options = {}) + options[:uri] = "/cloudapi/ecloud/admin/organizations/#{id}/action/enableSupportAccess" + connection.admin_enable_support_access(options[:uri]) + end + + def disable_support_access(options = {}) + options[:uri] = "/cloudapi/ecloud/admin/organizations/#{id}/action/disableSupportAccess" + connection.admin_disable_support_access(options[:uri]) + end + + def id + href.scan(/\d+/)[0] + end + + alias :vdcs :environments + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/organizations.rb b/lib/fog/ecloud/models/compute/organizations.rb new file mode 100644 index 000000000..25c8a76ae --- /dev/null +++ b/lib/fog/ecloud/models/compute/organizations.rb @@ -0,0 +1,39 @@ +require 'fog/ecloud/models/compute/organization' + +module Fog + module Compute + class Ecloud + class Organizations < Fog::Ecloud::Collection + + model Fog::Compute::Ecloud::Organization + + undef_method :create + + identity :href + + def all + data = connection.get_organizations(organization_uri).body + load(data[:Organization]) + end + + def get(uri) + if data = connection.get_organization(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + def organization_uri + @organization_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/ecloud/models/compute/password_complexity_rule.rb b/lib/fog/ecloud/models/compute/password_complexity_rule.rb new file mode 100644 index 000000000..7895adc25 --- /dev/null +++ b/lib/fog/ecloud/models/compute/password_complexity_rule.rb @@ -0,0 +1,49 @@ +module Fog + module Compute + class Ecloud + class PasswordComplexityRule < Fog::Ecloud::Model + identity :href + + attribute :rule_type, :aliases => :RuleType + attribute :custom_rules, :aliases => :CustomRules + attribute :description, :aliases => :Description + + def minimum_characters + custom_rules[:MinimumCharacters] + end + + def minimum_upper_case_characters + custom_rules[:MinimumUpperCaseCharacters] + end + + def minimum_lower_case_characters + custom_rules[:MinimumLowerCaseCharacters] + end + + def minimum_numeric_characters + custom_rules[:MinimumNumericCharacters] + end + + def minimum_special_characters + custom_rules[:MinimumSpecialCharacters] + end + + def maximum_consecutive_characters_from_prior_password + custom_rules[:MaximumConsecutiveCharactersFromPriorPassword] + end + + def minimum_lifetime_restriction + custom_rules[:MinimumLifetimeRestriction] + end + + def minimum_generations_before_reuse + custom_rules[:MinimumGenerationsBeforeReuse] + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/password_complexity_rules.rb b/lib/fog/ecloud/models/compute/password_complexity_rules.rb new file mode 100644 index 000000000..2af80e080 --- /dev/null +++ b/lib/fog/ecloud/models/compute/password_complexity_rules.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/password_complexity_rule' + +module Fog + module Compute + class Ecloud + class PasswordComplexityRules < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::PasswordComplexityRule + + def all + data = connection.get_password_complexity_rules(href).body + load(data) + end + + def get(uri) + if data = connection.get_password_complexity_rule(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/physical_device.rb b/lib/fog/ecloud/models/compute/physical_device.rb new file mode 100644 index 000000000..4cea4fc81 --- /dev/null +++ b/lib/fog/ecloud/models/compute/physical_device.rb @@ -0,0 +1,22 @@ +module Fog + module Compute + class Ecloud + class PhysicalDevice < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :tags, :aliases => :Tags + attribute :layout, :aliases => :Layout + attribute :network_host, :aliases => :NetworkHost + attribute :classification, :aliases => :Classification + attribute :model, :aliases => :Model + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/physical_devices.rb b/lib/fog/ecloud/models/compute/physical_devices.rb new file mode 100644 index 000000000..5c74bb028 --- /dev/null +++ b/lib/fog/ecloud/models/compute/physical_devices.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/physical_device' + +module Fog + module Compute + class Ecloud + class PhysicalDevices < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::PhysicalDevice + + def all + data = connection.get_physical_devices(href).body[:PhysicalDevice] || [] + load(data) + end + + def get(uri) + if data = connection.get_physical_device(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/public_ip.rb b/lib/fog/ecloud/models/compute/public_ip.rb index 45a9a4939..f753605cf 100644 --- a/lib/fog/ecloud/models/compute/public_ip.rb +++ b/lib/fog/ecloud/models/compute/public_ip.rb @@ -2,21 +2,25 @@ module Fog module Compute class Ecloud class PublicIp < Fog::Ecloud::Model - - identity :href, :aliases => :Href - - ignore_attributes :xmlns, :xmlns_i + identity :href attribute :name, :aliases => :Name - attribute :id, :aliases => :Id + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :ip_type, :aliases => :IpType def internet_services - load_unless_loaded! - @internet_services ||= Fog::Compute::Ecloud::InternetServices. - new( :connection => connection, - :href => href.to_s + "/internetServices" ) + @internet_services = Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => href) + end + + def environment_id + other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0] + end + + def id + href.scan(/\d+/)[0] end end end end -end \ No newline at end of file +end diff --git a/lib/fog/ecloud/models/compute/public_ips.rb b/lib/fog/ecloud/models/compute/public_ips.rb index 04c033cb1..456108172 100644 --- a/lib/fog/ecloud/models/compute/public_ips.rb +++ b/lib/fog/ecloud/models/compute/public_ips.rb @@ -5,21 +5,14 @@ module Fog class Ecloud class PublicIps < Fog::Ecloud::Collection - undef_method :create - - attribute :href, :aliases => :Href + identity :href model Fog::Compute::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 + data = connection.get_public_ips(href).body + data = data[:PublicIp] ? data[:PublicIp] : data + load(data) end def get(uri) @@ -30,6 +23,10 @@ module Fog nil end + def activate + data = connection.public_ip_activate(href + "/action/activatePublicIp").body + ip = Fog::Compute::Ecloud::PublicIps.new(:connection => connection, :href => data[:href])[0] + end end end end diff --git a/lib/fog/ecloud/models/compute/rnat.rb b/lib/fog/ecloud/models/compute/rnat.rb new file mode 100644 index 000000000..4e16d7ff7 --- /dev/null +++ b/lib/fog/ecloud/models/compute/rnat.rb @@ -0,0 +1,27 @@ +module Fog + module Compute + class Ecloud + class Rnat < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :default, :aliases => :Default, :type => :boolean + attribute :public_ip, :aliases => :PublicIp + + def networks + @networks = Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => href) + end + + def associations + @associations = Fog::Compute::Ecloud::Associations.new(:connection => connection, :href => href) + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/rnats.rb b/lib/fog/ecloud/models/compute/rnats.rb new file mode 100644 index 000000000..c1f9ef585 --- /dev/null +++ b/lib/fog/ecloud/models/compute/rnats.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/rnat' + +module Fog + module Compute + class Ecloud + class Rnats < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Rnat + + def all + data = connection.get_rnats(href).body[:Rnats][:Rnat] + load(data) + end + + def get(uri) + if data = connection.get_rnat(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/role.rb b/lib/fog/ecloud/models/compute/role.rb new file mode 100644 index 000000000..22758c8bc --- /dev/null +++ b/lib/fog/ecloud/models/compute/role.rb @@ -0,0 +1,24 @@ +module Fog + module Compute + class Ecloud + class Role < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :environment_name, :aliases => :EnvironmentName + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :role_type, :aliases => :RoleType + attribute :active, :aliases => :Active, :type => :boolean + attribute :category, :aliases => :Category + attribute :is_admin, :aliases => :IsAdmin, :type => :boolean + attribute :business_operations, :aliases => :BusinessOperations + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/roles.rb b/lib/fog/ecloud/models/compute/roles.rb new file mode 100644 index 000000000..5ee29c989 --- /dev/null +++ b/lib/fog/ecloud/models/compute/roles.rb @@ -0,0 +1,37 @@ +require 'fog/ecloud/models/compute/role' + +module Fog + module Compute + class Ecloud + class Roles < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Role + + def all + data = connection.get_roles(href).body + if data[:OrganizationRole] + load(data[:OrganizationRole]) + else + r_data = [] + data[:EnvironmentRoles][:EnvironmentRole].each do |d| + d[:Environment][:EnvironmentName] = d[:Environment][:name] + d[:Environment] = d[:Environment].merge(d[:Role]) if d[:Role] + r_data << d[:Environment] + end + load(r_data) + end + end + + def get(uri) + if data = connection.get_role(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/row.rb b/lib/fog/ecloud/models/compute/row.rb new file mode 100644 index 000000000..ad8113af8 --- /dev/null +++ b/lib/fog/ecloud/models/compute/row.rb @@ -0,0 +1,53 @@ +module Fog + module Compute + class Ecloud + class Row < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :index, :aliases => :Index + + def groups + @groups = Fog::Compute::Ecloud::Groups.new(:connection => connection, :href => href) + end + + def edit(options) + options[:uri] = href + connection.rows_edit(options).body + end + + def move_up(options) + options[:uri] = href + "/action/moveup" + connection.rows_moveup(options).body + end + + def move_down(options) + options[:uri] = href + "/action/movedown" + connection.rows_movedown(options).body + end + + def delete + connection.rows_delete(href).body + end + + def create_group(options = {}) + options[:uri] = "/cloudapi/ecloud/layoutGroups/environments/#{environment_id}/action/createLayoutGroup" + options[:row_name] = name + options[:href] = href + data = connection.groups_create(options).body + group = Fog::Compute::Ecloud::Groups.new(:connection => connection, :href => data[:href])[0] + end + + def environment_id + other_links[:Link][:href].scan(/\d+/)[0] + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/rows.rb b/lib/fog/ecloud/models/compute/rows.rb new file mode 100644 index 000000000..e3dd7cb68 --- /dev/null +++ b/lib/fog/ecloud/models/compute/rows.rb @@ -0,0 +1,37 @@ +require 'fog/ecloud/models/compute/row' + +module Fog + module Compute + class Ecloud + class Rows < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Row + + def all + data = connection.get_layout(href).body[:Rows][:Row] + load(data) + end + + def get(uri) + if data = connection.get_row(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + + def create(options = {}) + options[:uri] = "/cloudapi/ecloud/layoutRows/environments/#{environment_id}/action/createLayoutRow" + data = connection.rows_create(options).body + new(data) + end + + def environment_id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/server.rb b/lib/fog/ecloud/models/compute/server.rb index 9329733d2..bdec7865d 100644 --- a/lib/fog/ecloud/models/compute/server.rb +++ b/lib/fog/ecloud/models/compute/server.rb @@ -2,47 +2,80 @@ module Fog module Compute class Ecloud class Server < Fog::Ecloud::Model + identity :href - identity :href, :aliases => :Href + attribute :name, :aliases => :Name + attribute :type , :aliases => :Type + attribute :other_links, :aliases => :Link + attribute :status, :aliases => :Status + attribute :storage, :aliases => :Storage + attribute :ip_addresses, :aliases => :IpAddresses + attribute :operating_system, :aliases => :OperatingSystem + attribute :powered_on, :aliases => :PoweredOn, :type => :boolean + attribute :tools_status, :aliases => :ToolsStatus + attribute :cpus, :aliases => :ProcessorCount, :type => :integer + attribute :memory, :aliases => :Memory + attribute :description, :aliases => :Description + attribute :tags, :aliases => :Tags + attribute :layout, :aliases => :Layout - ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd + def tasks + @tasks ||= Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => "/cloudapi/ecloud/tasks/virtualMachines/#{id}") + end - 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 processes + @processes ||= Fog::Compute::Ecloud::GuestProcesses.new(:connection, connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/guest/processes") + end - def friendly_status - load_unless_loaded! - case status - when '0' - 'creating' - when '2' - 'off' - when '4' - 'on' - else - 'unkown' + def hardware_configuration + @hardware_configuration ||= Fog::Compute::Ecloud::HardwareConfigurations.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/hardwareConfiguration")[0] + end + + def configuration + @configuration ||= Fog::Compute::Ecloud::ServerConfigurationOptions.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/configurationOptions")[0] + end + + + def ips + network_hash = ip_addresses[:AssignedIpAddresses][:Networks] + network_hash[:Network] = network_hash[:Network].is_a?(Hash) ? [network_hash[:Network]] : network_hash[:Network] + network_hash[:Network].each do |network| + network[:IpAddresses][:IpAddress] = network[:IpAddresses][:IpAddress].is_a?(String) ? [network[:IpAddresses][:IpAddress]] : network[:IpAddresses][:IpAddress] end + @ips = nil + networks = Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/assignedIps") + networks.each do |network| + if networks.index(network) == 0 + if @ips.nil? + @ips = network.ips.select do |ip| + network_hash[:Network].any? do |network| + network[:IpAddresses][:IpAddress].include?(ip.name) + end + end + else + network.ips.each do |ip| + network_hash[:Network].any? do |network| + network[:IpAddresses][:IpAddress].each do |i| + @ips << ip if i == ip.name + end + end + end + end + else + network.ips.each do |ip| + network_hash[:Network].each do |network| + network[:IpAddresses][:IpAddress].each do |i| + @ips << ip if i == ip.name + end + end + end + end + end + @ips end - def ready? - load_unless_loaded! - status == '2' - end - - def on? - load_unless_loaded! - status == '4' - end - - def off? - load_unless_loaded! - status == '2' + def networks + @networks ||= Fog::Compute::Ecloud::Networks.new(:connection => connection, :href => "/cloudapi/ecloud/virtualMachines/#{id}/assignedIps") end def power_on @@ -58,145 +91,150 @@ module Fog end def power_reset - power_operation( :power_reset => :reset ) - end - - def graceful_restart - requires :href - shutdown - wait_for { off? } - power_on + power_operation( :power_reset => :reboot ) end def delete - requires :href - connection.delete_vapp( href) + data = connection.virtual_machine_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] end - def name=(new_name) - attributes[:name] = new_name - @changed = true + def copy(options = {}) + options = {:type => :copy}.merge(options) + options[:source] ||= href + if options[:type] == :copy + options[:cpus] ||= 1 + options[:memory] ||= 512 + options[:customization] ||= :linux + options[:tags] ||= [] + options[:powered_on] ||= false + if options[:ips] + options[:ips] = options[:ips].is_a?(String) ? [options[:ips]] : options[:ips] + else + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].each do |uri| + index = options[:network_uri].index(uri) + ip = Fog::Compute::Ecloud::IpAddresses.new(:connection => connection, :href => uri).detect { |i| i.host == nil }.name + options[:ips] ||= [] + options[:ips][index] = ip + end + end + data = connection.virtual_machine_copy("/cloudapi/ecloud/virtualMachines/computePools/#{compute_pool_id}/action/copyVirtualMachine", options).body + elsif options[:type] == :identical + data = connection.virtual_machine_copy_identical("/cloudapi/ecloud/virtualMachines/computePools/#{compute_pool_id}/action/copyIdenticalVirtualMachine", options).body + end + vm = collection.from_data(data) + vm end - def cpus - if cpu_mess - { :count => cpu_mess[:VirtualQuantity].to_i, - :units => cpu_mess[:AllocationUnits] } + def rnats + rnats = Fog::Compute::Ecloud::Rnats.new(:connection => connection, :href => "/cloudapi/ecloud/rnats/environments/#{environment_id}") + associations = nil + rnats.each do |rnat| + if rnats.index(rnat) == 0 + associations = rnat.associations.select do |association| + ips.any? do |ip| + association.name == ip.name + end + end + else + rnat.associations.select do |association| + ips.each do |ip| + if ip.name == association.name + associations << association + end + end + end + end + end + associations + end + + def edit(options = {}) + data = connection.virtual_machine_edit(href, options).body + if data[:type] == "application/vnd.tmrk.cloud.task" + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] end end - def cpus=(qty) - @changed = true - cpu_mess[:VirtualQuantity] = qty.to_s + def create_rnat(options) + options[:host_ip_href] ||= ips.first.href + options[:uri] = "/cloudapi/ecloud/rnats/environments/#{environment_id}/action/createAssociation" + data = connection.rnat_associations_create_device(options).body + rnat = Fog::Compute::Ecloud::Associations.new(:connection => connection, :href => data[:href])[0] 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 + c = hardware_configuration.storage[:Disk] + c = c.is_a?(Hash) ? [c] : c + @disks = c 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 + index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1 + vm_disks = disks << {:Index => index, :Size=>{:Unit => "GB", :Value => size}} + data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] 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 + def nics + c = hardware_configuration.network_cards[:Nic] + c = c.is_a?(Hash) ? [c] : c + @nics = c end - def reload - reset_tracking - super + def add_nic(network) + unit_number = nics.map { |n| n[:UnitNumber].to_i }.sort[-1] + 1 + vm_nics = nics << {:UnitNumber => unit_number, :Network => {:href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network"}} + data = connection.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] end - def save - if new_record? - #Lame ... - raise RuntimeError, "Should not be here" + def storage_size + vm_disks = disks + disks.map! { |d| d[:Size][:Value].to_i }.inject(0){|sum,item| sum + item} * 1024 * 1024 + end + + def ready? + load_unless_loaded! + unless status =~ /NotDeployed|Orphaned|TaskInProgress|CopyInProgress/ + true 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 ) + false end - reset_tracking + end + + def on? + powered_on == true + end + + def off? + powered_on == false + end + + def compute_pool_id + other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0] + end + + def environment_id + other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0] + end + + def id + href.scan(/\d+/)[0] 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 + def _configuration_data(options = {}) + {:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.mem), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)} end def power_operation(op) requires :href begin - connection.send(op.keys.first, href + "/power/action/#{op.values.first}" ) - rescue Excon::Errors::InternalServerError => e + connection.send(op.keys.first, href + "/action/#{op.values.first}" ) + rescue Excon::Errors::Conflict => e #Frankly we shouldn't get here ... raise e unless e.to_s =~ /because it is already powered o(n|ff)/ end diff --git a/lib/fog/ecloud/models/compute/server_configuration_option.rb b/lib/fog/ecloud/models/compute/server_configuration_option.rb new file mode 100644 index 000000000..32b9fb607 --- /dev/null +++ b/lib/fog/ecloud/models/compute/server_configuration_option.rb @@ -0,0 +1,17 @@ +module Fog + module Compute + class Ecloud + class ServerConfigurationOption < Fog::Ecloud::Model + identity :href + + attribute :disk, :aliases => :Disk + attribute :customization, :aliases => :Customization + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/server_configuration_options.rb b/lib/fog/ecloud/models/compute/server_configuration_options.rb new file mode 100644 index 000000000..7a20f8e0e --- /dev/null +++ b/lib/fog/ecloud/models/compute/server_configuration_options.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/server_configuration_option' + +module Fog + module Compute + class Ecloud + class ServerConfigurationOptions < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::ServerConfigurationOption + + def all + data = connection.get_server_configuration_options(href).body + load(data) + end + + def get(uri) + if data = connection.get_server_configuration_option(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/servers.rb b/lib/fog/ecloud/models/compute/servers.rb index 64ba21d2c..05aefcd3d 100644 --- a/lib/fog/ecloud/models/compute/servers.rb +++ b/lib/fog/ecloud/models/compute/servers.rb @@ -3,56 +3,65 @@ require 'fog/ecloud/models/compute/server' module Fog module Compute class Ecloud - class Servers < Fog::Ecloud::Collection - - undef_method :create - + model Fog::Compute::Ecloud::Server - attribute :href, :aliases => :Href + identity :href def all - check_href!(:parent => "Vdc") - load(_vapps) + data = connection.get_servers(href).body + if data.keys.include?(:VirtualMachines) + data = data[:VirtualMachines][:VirtualMachine] + else + data = data[:VirtualMachine] + end + load(data) end def get(uri) - if data = connection.get_vapp(uri) + if data = connection.get_server(uri) new(data.body) end rescue Fog::Errors::NotFound nil end - def create( catalog_item_uri, options ) - options[:vdc_uri] = href + def from_data(data) + new(data) + end + + def create( template_uri, options ) options[:cpus] ||= 1 options[:memory] ||= 512 - options[:computePool] ||= "" - data = connection.instantiate_vapp_template( catalog_item_uri, options ).body + options[:description] ||= "" + options[:tags] ||= [] + if template_uri =~ /\/templates\/\d+/ + options[:uri] = href + "/action/createVirtualMachine" + options[:customization] ||= :linux + options[:powered_on] ||= false + if options[:ips] + options[:ips] = options[:ips].is_a?(String) ? [options[:ips]] : options[:ips] + else + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].each do |uri| + index = options[:network_uri].index(uri) + ip = Fog::Compute::Ecloud::IpAddresses.new(:connection => connection, :href => uri).detect { |i| i.host == nil }.name + options[:ips] ||= [] + options[:ips][index] = ip + end + end + data = connection.virtual_machine_create_from_template( template_uri, options ).body + else + options[:uri] = href + "/action/importVirtualMachine" + data = connection.virtual_machine_import( template_uri, options ).body + end object = new(data) object end - private - - def _resource_entities - if Hash === resource_entities = connection.get_vdc(href).body[:ResourceEntities] - resource_entities[:ResourceEntity] - end - 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/ecloud/models/compute/ssh_key.rb b/lib/fog/ecloud/models/compute/ssh_key.rb new file mode 100644 index 000000000..9b1b56728 --- /dev/null +++ b/lib/fog/ecloud/models/compute/ssh_key.rb @@ -0,0 +1,20 @@ +module Fog + module Compute + class Ecloud + class SshKey < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :default, :aliases => :Default, :type => :boolean + attribute :finger_print, :aliases => :FingerPrint + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/ssh_keys.rb b/lib/fog/ecloud/models/compute/ssh_keys.rb new file mode 100644 index 000000000..cf95975b7 --- /dev/null +++ b/lib/fog/ecloud/models/compute/ssh_keys.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/ssh_key' + +module Fog + module Compute + class Ecloud + class SshKeys < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::SshKey + + def all + data = connection.get_ssh_keys(href).body[:SshKey] + load(data) + end + + def get(uri) + if data = connection.get_ssh_key(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/storage_usage_detail.rb b/lib/fog/ecloud/models/compute/storage_usage_detail.rb new file mode 100644 index 000000000..10f0870c5 --- /dev/null +++ b/lib/fog/ecloud/models/compute/storage_usage_detail.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class Ecloud + class StorageUsageDetail < Fog::Ecloud::Model + identity :href + + attribute :disk_count, :aliases => :DiskCount + attribute :allocated, :aliases => :Allocated + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb b/lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb new file mode 100644 index 000000000..fc00cc180 --- /dev/null +++ b/lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/storage_usage_detail' + +module Fog + module Compute + class Ecloud + class StorageUsageDetailSummary < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::StorageUsageDetail + + def all + data = connection.get_storage_usage_detail_summary(href).body[:VirtualMachines][:VirtualMachine] + load(data) + end + + def get(uri) + if data = connection.get_storage_usage_detail(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/support_ticket.rb b/lib/fog/ecloud/models/compute/support_ticket.rb new file mode 100644 index 000000000..dbd63eb99 --- /dev/null +++ b/lib/fog/ecloud/models/compute/support_ticket.rb @@ -0,0 +1,29 @@ +module Fog + module Compute + class Ecloud + class SupportTicket < Fog::Ecloud::Model + identity :href + + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :date, :aliases => :Date + attribute :status, :aliases => :Status + attribute :category, :aliases => :Category + attribute :detected_by, :aliases => :DetectedBy + attribute :severity, :aliases => :Severity + attribute :device, :aliases => :Device + attribute :classification, :aliases => :Classification + attribute :owner, :aliases => :Owner + attribute :description, :aliases => :Description + attribute :information, :aliases => :Information + attribute :solution, :aliases => :Solution + attribute :history, :aliases => :History + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/support_tickets.rb b/lib/fog/ecloud/models/compute/support_tickets.rb new file mode 100644 index 000000000..7f17b375c --- /dev/null +++ b/lib/fog/ecloud/models/compute/support_tickets.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/support_ticket' + +module Fog + module Compute + class Ecloud + class SupportTickets < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::SupportTicket + + def all + data = connection.get_support_tickets(href).body[:TicketReference] + load(data) + end + + def get(uri) + if data = connection.get_support_ticket(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/tag.rb b/lib/fog/ecloud/models/compute/tag.rb new file mode 100644 index 000000000..8162a982d --- /dev/null +++ b/lib/fog/ecloud/models/compute/tag.rb @@ -0,0 +1,13 @@ +module Fog + module Compute + class Ecloud + class Tag < Fog::Ecloud::Model + identity :name + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/tags.rb b/lib/fog/ecloud/models/compute/tags.rb new file mode 100644 index 000000000..011638a50 --- /dev/null +++ b/lib/fog/ecloud/models/compute/tags.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/tag' + +module Fog + module Compute + class Ecloud + class Tags < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Tag + + def all + data = connection.get_tags(href).body[:DeviceTag] + load(data) + end + + def get(uri) + if data = connection.get_tag(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/task.rb b/lib/fog/ecloud/models/compute/task.rb index ec2114123..2cfbca998 100644 --- a/lib/fog/ecloud/models/compute/task.rb +++ b/lib/fog/ecloud/models/compute/task.rb @@ -2,18 +2,17 @@ module Fog module Compute class Ecloud class Task < Fog::Ecloud::Model + identity :href - 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 + attribute :type , :aliases => :Type + attribute :operation, :aliases => :Operation + attribute :status, :aliases => :Status + attribute :impacted_item, :aliases => :ImpactedItem + attribute :start_time, :aliases => :StartTime + attribute :completed_time, :aliases => :CompletedTime + attribute :notes, :aliases => :Notes + attribute :error_message, :aliases => :ErrorMessage + attribute :initiated_by, :aliases => :InitiatedBy end end diff --git a/lib/fog/ecloud/models/compute/tasks.rb b/lib/fog/ecloud/models/compute/tasks.rb index 7cbb0c7c6..9688f7b54 100644 --- a/lib/fog/ecloud/models/compute/tasks.rb +++ b/lib/fog/ecloud/models/compute/tasks.rb @@ -3,18 +3,18 @@ require 'fog/ecloud/models/compute/task' module Fog module Compute class Ecloud - class Tasks < Fog::Ecloud::Collection - + model Fog::Compute::Ecloud::Task - attribute :href, :aliases => :Href + identity :href + attribute :other_links, :aliases => :Links + attribute :total_count, :aliases => :TotalCount def all - check_href! - if data = connection.get_task_list(href).body[:Task] - load(data) - end + data = connection.get_tasks(href).body + data = data[:Task] ? data[:Task] : data + load(data) end def get(uri) @@ -24,8 +24,8 @@ module Fog rescue Fog::Errors::NotFound nil end - end end end end + diff --git a/lib/fog/ecloud/models/compute/template.rb b/lib/fog/ecloud/models/compute/template.rb new file mode 100644 index 000000000..9fffb8e3d --- /dev/null +++ b/lib/fog/ecloud/models/compute/template.rb @@ -0,0 +1,24 @@ +module Fog + module Compute + class Ecloud + class Template < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :operating_system, :aliases => :OperatingSystem + attribute :description, :aliases => :Description + attribute :storage, :aliases => :Storage + attribute :network_adapters, :aliases => :NetworkAdapters + attribute :customization, :aliases => :Customization + attribute :licensed_software, :aliases => :LicensedSoftware + + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/templates.rb b/lib/fog/ecloud/models/compute/templates.rb new file mode 100644 index 000000000..87b4383fa --- /dev/null +++ b/lib/fog/ecloud/models/compute/templates.rb @@ -0,0 +1,40 @@ +require 'fog/ecloud/models/compute/template' + +module Fog + module Compute + class Ecloud + class Templates < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::Template + + def all + r_data = [] + data = connection.get_templates(href).body[:Families] + data[:Family].is_a?(Hash) ? data = [data[:Family]] : data = data[:Family] + data.each do |d| + d[:Categories][:Category].each do |cat| + cat[:OperatingSystems][:OperatingSystem].is_a?(Hash) ? cat = [cat[:OperatingSystems][:OperatingSystem]] : cat = cat[:OperatingSystems][:OperatingSystem] + cat.each do |os| + os[:Templates][:Template].is_a?(Hash) ? os = [os[:Templates][:Template]] : os = os[:Templates][:Template] + os.each do |template| + r_data << template + end + end + end + end + load(r_data) + end + + def get(uri) + if data = connection.get_template(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/trusted_network_group.rb b/lib/fog/ecloud/models/compute/trusted_network_group.rb new file mode 100644 index 000000000..4d563c505 --- /dev/null +++ b/lib/fog/ecloud/models/compute/trusted_network_group.rb @@ -0,0 +1,33 @@ +module Fog + module Compute + class Ecloud + class TrustedNetworkGroup < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :hosts, :aliases => :Hosts + + def internet_services + @internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:connection => connection, :href => href) + end + + def edit(options) + options[:uri] = href + data = connection.trusted_network_groups_edit(options).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] + end + + def delete + data = connection.trusted_network_groups_delete(href).body + task = Fog::Compute::Ecloud::Tasks.new(:connection => connection, :href => data[:href])[0] + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/trusted_network_groups.rb b/lib/fog/ecloud/models/compute/trusted_network_groups.rb new file mode 100644 index 000000000..960d225b7 --- /dev/null +++ b/lib/fog/ecloud/models/compute/trusted_network_groups.rb @@ -0,0 +1,28 @@ +require 'fog/ecloud/models/compute/trusted_network_group' + +module Fog + module Compute + class Ecloud + class TrustedNetworkGroups < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::TrustedNetworkGroup + + def all + data = connection.get_trusted_network_groups(href).body + data = data[:TrustedNetworkGroup] ? data[:TrustedNetworkGroup] : data + load(data) + end + + def get(uri) + if data = connection.get_trusted_network_group(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/user.rb b/lib/fog/ecloud/models/compute/user.rb new file mode 100644 index 000000000..1ec1f1120 --- /dev/null +++ b/lib/fog/ecloud/models/compute/user.rb @@ -0,0 +1,35 @@ +module Fog + module Compute + class Ecloud + class User < Fog::Ecloud::Model + identity :href + + attribute :name, :aliases => :Name + attribute :type, :aliases => :Type + attribute :other_links, :aliases => :Links + attribute :first_name, :aliases => :FirstName + attribute :last_name, :aliases => :LastName + attribute :email, :aliases => :Email + attribute :status, :aliases => :Status + attribute :last_login, :aliases => :LastLogin + attribute :multifactor_authentication, :aliases => :MultifactorAuthentication + attribute :is_administrator, :aliases => :IsAdministrator, :type => :boolean + attribute :is_api_user, :aliases => :IsApiUser, :type => :boolean + attribute :is_alert_notification_enabled, :aliases => :IsAlertNotificationEnabled, :type => :boolean + attribute :is_multifactor_authentication_enabled, :aliases => :IsMultifactorAuthenticationEnabled, :type => :boolean + + def roles + @roles = Fog::Compute::Ecloud::Roles.new(:connection => connection, :href => "/cloudapi/ecloud/admin/roles/users/#{id}") + end + + def api_keys + @api_keys = Fog::Compute::Ecloud::ApiKeys.new(:connection => connection, :href => "/cloudapi/ecloud/admin/apiKeys/users/#{id}") + end + + def id + href.scan(/\d+/)[0] + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/users.rb b/lib/fog/ecloud/models/compute/users.rb new file mode 100644 index 000000000..39f63d403 --- /dev/null +++ b/lib/fog/ecloud/models/compute/users.rb @@ -0,0 +1,27 @@ +require 'fog/ecloud/models/compute/user' + +module Fog + module Compute + class Ecloud + class Users < Fog::Ecloud::Collection + + identity :href + + model Fog::Compute::Ecloud::User + + def all + data = connection.get_users(href).body[:User] + load(data) + end + + def get(uri) + if data = connection.get_user(uri) + new(data.body) + end + rescue Fog::Errors::NotFound + nil + end + end + end + end +end diff --git a/lib/fog/ecloud/models/compute/vdc.rb b/lib/fog/ecloud/models/compute/vdc.rb deleted file mode 100644 index 26c566ff3..000000000 --- a/lib/fog/ecloud/models/compute/vdc.rb +++ /dev/null @@ -1,87 +0,0 @@ -module Fog - module Compute - class Ecloud - 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::Compute::Ecloud::Networks. - new( :connection => connection, - :href => href ) - end - - def servers - @servers ||= Fog::Compute::Ecloud::Servers. - new( :connection => connection, - :href => href ) - end - - def tasks - @tasks ||= Fog::Compute::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 - - def compute_pools - @compute_pools ||= Fog::Compute::Ecloud::ComputePools. - new( :connection => connection, - :href => href + "/computePools" ) - 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::Compute::Ecloud::PublicIps - when "application/vnd.tmrk.ecloud.internetServicesList+xml" - klass || Fog::Compute::Ecloud::InternetServices - when "application/vnd.vmware.vcloud.catalog+xml" - Fog::Compute::Ecloud::Catalog - when "application/vnd.tmrk.ecloud.firewallAclsList+xml" - Fog::Compute::Ecloud::FirewallAcls - end.new( :connection => connection, :href => link[:href] ) - else - [ ] - end - end - end - end - end -end diff --git a/lib/fog/ecloud/models/compute/vdcs.rb b/lib/fog/ecloud/models/compute/vdcs.rb deleted file mode 100644 index 058e2906b..000000000 --- a/lib/fog/ecloud/models/compute/vdcs.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'fog/ecloud/models/compute/vdc' - -module Fog - module Compute - class Ecloud - - class Vdcs < Collection - - model Fog::Compute::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 diff --git a/lib/fog/ecloud/requests/compute/add_backup_internet_service.rb b/lib/fog/ecloud/requests/compute/add_backup_internet_service.rb deleted file mode 100644 index 3679f2dd0..000000000 --- a/lib/fog/ecloud/requests/compute/add_backup_internet_service.rb +++ /dev/null @@ -1,109 +0,0 @@ -module Fog - module Compute - 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.has_key?(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/ecloud/requests/compute/add_internet_service.rb b/lib/fog/ecloud/requests/compute/add_internet_service.rb deleted file mode 100644 index ce307d702..000000000 --- a/lib/fog/ecloud/requests/compute/add_internet_service.rb +++ /dev/null @@ -1,149 +0,0 @@ -module Fog - module Compute - 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.has_key?(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.has_key?(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/ecloud/requests/compute/add_node.rb b/lib/fog/ecloud/requests/compute/add_node.rb deleted file mode 100644 index e8e06350e..000000000 --- a/lib/fog/ecloud/requests/compute/add_node.rb +++ /dev/null @@ -1,62 +0,0 @@ -module Fog - module Compute - 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.has_key?(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/ecloud/requests/compute/admin_disable_support_access.rb b/lib/fog/ecloud/requests/compute/admin_disable_support_access.rb new file mode 100644 index 000000000..61892f1b1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/admin_disable_support_access.rb @@ -0,0 +1,9 @@ +module Fog + module Compute + class Ecloud + class Real + basic_request :admin_disable_support_access, 204, 'POST' + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb b/lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb new file mode 100644 index 000000000..19f82c82d --- /dev/null +++ b/lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb @@ -0,0 +1,34 @@ +module Fog + module Compute + class Ecloud + class Real + + def authentication_levels_edit(data) + validate_data([:basic, :sha1, :sha256, :sha512], data) + body = build_authentication_levels_edit(data) + request( + :expects => 202, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => data[:uri], + :parse => true + ) + end + + private + + + def build_authentication_levels_edit(data) + xml = Builder::XmlMarkup.new + xml.AuthenticationLevels do + xml.BasicEnabled data[:basic] + xml.SHA1Enabled data[:sha1] + xml.SHA256Enabled data[:sha256] + xml.SHA512Enabled data[:sha512] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb b/lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb new file mode 100644 index 000000000..d5e537fa0 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb @@ -0,0 +1,32 @@ +module Fog + module Compute + class Ecloud + class Real + + def login_banner_edit(data) + validate_data([:display], data) + body = build_login_banner_edit(data) + request( + :expects => 200, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => data[:uri], + :parse => true + ) + end + + private + + + def build_login_banner_edit(data) + xml = Builder::XmlMarkup.new + xml.LoginBanner do + xml.Display data[:display] + xml.Text data[:text] if data[:text] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb b/lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb new file mode 100644 index 000000000..1bbba462a --- /dev/null +++ b/lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb @@ -0,0 +1,74 @@ +module Fog + module Compute + class Ecloud + class Real + + def password_complexity_rules_edit(data) + validate_data([:rule_type], data) + if data[:rule_type] == "Custom" + raise ArgumentError.new("Required data missing: custom_rules") unless data[:custom_rules] + end + validate_data([:minimum_characters, :minimum_uppercase_characters, :minimum_lowercase_characters, :minimum_numeric_characters, :minimum_special_characters, :maximum_consecutive_characters_from_prior_passwords, :minimum_lifetime_restriction, :minimum_generations_before_reuse], data[:custom_rules]) + body = build_password_complexity_rules_edit(data) + request( + :expects => 202, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => data[:uri], + :parse => true + ) + end + + private + + + def build_password_complexity_rules_edit(data) + xml = Builder::XmlMarkup.new + xml.PasswordComplexityRules do + xml.RuleType data[:rule_type] + if data[:rule_type] == "Custom" + xml.CustomRules do + xml.MinimumCharacters do + xml.Enabled data[:custom_rules][:minimum_characters][:enabled] + xml.Value data[:custom_rules][:minimum_characters][:value] + end + xml.MinimumUpperCaseCharacters do + xml.Enabled data[:custom_rules][:minimum_uppercase_characters][:enabled] + xml.Value data[:custom_rules][:minimum_uppercase_characters][:value] + end + xml.MinimumLowerCaseCharacters do + xml.Enabled data[:custom_rules][:minimum_lowercase_characters][:enabled] + xml.Value data[:custom_rules][:minimum_lowercase_characters][:value] + end + xml.MinimumNumericCharacters do + xml.Enabled data[:custom_rules][:minimum_numeric_characters][:enabled] + xml.Value data[:custom_rules][:minimum_numeric_characters][:value] + end + xml.MinimumSpecialCharacters do + xml.Enabled data[:custom_rules][:minimum_special_characters][:enabled] + xml.Value data[:custom_rules][:minimum_special_characters][:value] + end + xml.MaximumConsecutiveCharactersFromPriorPasswords do + xml.Enabled data[:custom_rules][:maximum_consecutive_characters_from_prior_passwords][:enabled] + xml.Value data[:custom_rules][:maximum_consecutive_characters_from_prior_passwords][:value] + end + xml.MinimumLifetimeRestriction do + xml.Enabled data[:custom_rules][:minimum_lifetime_restriction][:enabled] + xml.Value data[:custom_rules][:minimum_lifetime_restriction][:value] + end + xml.MinimumGenerationsBeforeReuse do + xml.Enabled data[:custom_rules][:minimum_generations_before_reuse][:enabled] + xml.Value data[:custom_rules][:minimum_generations_before_reuse][:value] + end + end + end + if data[:description] + xml.Description data[:description] + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/admin_enable_support_access.rb b/lib/fog/ecloud/requests/compute/admin_enable_support_access.rb new file mode 100644 index 000000000..0d4ed672e --- /dev/null +++ b/lib/fog/ecloud/requests/compute/admin_enable_support_access.rb @@ -0,0 +1,9 @@ +module Fog + module Compute + class Ecloud + class Real + basic_request :admin_enable_support_access, 204, 'POST' + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/backup_internet_service_create.rb b/lib/fog/ecloud/requests/compute/backup_internet_service_create.rb new file mode 100644 index 000000000..5ef4766a4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/backup_internet_service_create.rb @@ -0,0 +1,47 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def backup_internet_service_create(data) + validate_data([:name, :protocol, :enabled, :persistence], data) + unless data[:persistence][:type] + raise ArgumentError.new("Required data missing: :persistence[:type]") + end + + request( + :body => generate_backup_internet_service_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_backup_internet_service_request(data) + xml = Builder::XmlMarkup.new + xml.CreateBackupInternetService(:name => data[:name]) do + xml.Protocol data[:protocol] + xml.Enabled data[:enabled] + if data[:description] + xml.Description data[:description] + end + xml.Persistence do + xml.Type data[:persistence][:type] + if data[:persistence][:timeout] + xml.Timeout data[:persistence][:timeout] + end + end + if data[:redirect_url] + xml.RedirectUrl data[:redirect_url] + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb b/lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb new file mode 100644 index 000000000..2e1c26316 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :backup_internet_service_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb b/lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb new file mode 100644 index 000000000..95d2233d9 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb @@ -0,0 +1,47 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def backup_internet_service_edit(data) + validate_data([:name, :protocol, :enabled, :persistence], data) + unless data[:persistence][:type] + raise ArgumentError.new("Required data missing: :persistence[:type]") + end + + request( + :body => generate_backup_internet_service_request(data), + :expects => 202, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_backup_internet_service_request(data) + xml = Builder::XmlMarkup.new + xml.BackupInternetService(:name => data[:name]) do + xml.Protocol data[:protocol] + xml.Enabled data[:enabled] + if data[:description] + xml.Description data[:description] + end + xml.Persistence do + xml.Type data[:persistence][:type] + if data[:persistence][:timeout] + xml.Timeout data[:persistence][:timeout] + end + end + if data[:redirect_url] + xml.RedirectUrl data[:redirect_url] + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/clone_vapp.rb b/lib/fog/ecloud/requests/compute/clone_vapp.rb deleted file mode 100644 index 616df1642..000000000 --- a/lib/fog/ecloud/requests/compute/clone_vapp.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Fog - module Compute - class Ecloud - class Real - - def validate_clone_vapp_options(options) - valid_opts = [:name, :poweron] - unless valid_opts.all? { |opt| options.has_key?(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/ecloud/requests/compute/compute_pool_edit.rb b/lib/fog/ecloud/requests/compute/compute_pool_edit.rb new file mode 100644 index 000000000..2e865312f --- /dev/null +++ b/lib/fog/ecloud/requests/compute/compute_pool_edit.rb @@ -0,0 +1,37 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_edit_compute_pool_options(options) + required_opts = [:name] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + end + + def build_compute_pool_body_edit(options) + xml = Builder::XmlMarkup.new + xml.ComputePool(:name => options[:name]) do + end + end + end + + class Real + + def compute_pool_edit(options) + validate_edit_compute_pool_options(options) + body = build_compute_pool_body_edit(options) + request( + :expects => 200, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => options[:uri], + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/configure_internet_service.rb b/lib/fog/ecloud/requests/compute/configure_internet_service.rb deleted file mode 100644 index b5270c72e..000000000 --- a/lib/fog/ecloud/requests/compute/configure_internet_service.rb +++ /dev/null @@ -1,112 +0,0 @@ -module Fog - module Compute - 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.has_key?(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/ecloud/requests/compute/configure_network.rb b/lib/fog/ecloud/requests/compute/configure_network.rb deleted file mode 100644 index 044a925d5..000000000 --- a/lib/fog/ecloud/requests/compute/configure_network.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Fog - module Compute - 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.has_key?(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/ecloud/requests/compute/configure_network_ip.rb b/lib/fog/ecloud/requests/compute/configure_network_ip.rb deleted file mode 100644 index c9a816299..000000000 --- a/lib/fog/ecloud/requests/compute/configure_network_ip.rb +++ /dev/null @@ -1,66 +0,0 @@ -module Fog - module Compute - 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.has_key?(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/ecloud/requests/compute/configure_node.rb b/lib/fog/ecloud/requests/compute/configure_node.rb deleted file mode 100644 index 94d9bdf74..000000000 --- a/lib/fog/ecloud/requests/compute/configure_node.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/configure_vapp.rb b/lib/fog/ecloud/requests/compute/configure_vapp.rb deleted file mode 100644 index cd8205d30..000000000 --- a/lib/fog/ecloud/requests/compute/configure_vapp.rb +++ /dev/null @@ -1,144 +0,0 @@ -module Fog - module Compute - class Ecloud - module Shared - private - - def validate_vapp_data(vapp_data) - valid_opts = [:name, :cpus, :memory, :disks] - unless valid_opts.all? { |opt| vapp_data.has_key?(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/ecloud/requests/compute/delete_internet_service.rb b/lib/fog/ecloud/requests/compute/delete_internet_service.rb deleted file mode 100644 index 3be9d4cc8..000000000 --- a/lib/fog/ecloud/requests/compute/delete_internet_service.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/delete_node.rb b/lib/fog/ecloud/requests/compute/delete_node.rb deleted file mode 100644 index 75a267e30..000000000 --- a/lib/fog/ecloud/requests/compute/delete_node.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/delete_vapp.rb b/lib/fog/ecloud/requests/compute/delete_vapp.rb deleted file mode 100644 index 11f0a67e5..000000000 --- a/lib/fog/ecloud/requests/compute/delete_vapp.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Fog - module Compute - 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 \ No newline at end of file diff --git a/lib/fog/ecloud/requests/compute/firewall_acls_create.rb b/lib/fog/ecloud/requests/compute/firewall_acls_create.rb new file mode 100644 index 000000000..f324cad9e --- /dev/null +++ b/lib/fog/ecloud/requests/compute/firewall_acls_create.rb @@ -0,0 +1,79 @@ +module Fog + module Compute + class Ecloud + + class Real + include Shared + + def firewall_acls_create(data) + validate_data([:permission, :protocol, :source, :destination], data) + raise ArgumentError.new("Required data missing: source[:type] is required") unless data[:source][:type] + raise ArgumentError.new("Required data missing: destination[:type] is required") unless data[:destination][:type] + + request( + :body => generate_create_firewall_acls_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_create_firewall_acls_request(data) + xml = Builder::XmlMarkup.new + xml.CreateFirewallAcl do + xml.Permission data[:permission] + xml.Protocol data[:protocol] + xml.Source do + xml.Type data[:source][:type] + if data[:source][:external_ip_address] + xml.ExternalIpAddress data[:external_ip_address] + end + if data[:source][:external_network] + xml.ExternalNetwork do + xml.Address data[:source][:external_network][:address] + xml.Size data[:source][:external_network][:size] + end + end + if data[:source][:ip_address] + xml.IpAddress(:href => data[:source][:ip_address]) + end + if data[:source][:network] + xml.Network(:href => data[:source][:network][:href], :name => data[:source][:network][:name]) + end + end + xml.Destination do + xml.Type data[:destination][:type] + if data[:destination][:external_ip_address] + xml.ExternalIpAddress data[:external_ip_address] + end + if data[:destination][:external_network] + xml.ExternalNetwork do + xml.Address data[:destination][:external_network][:address] + xml.Size data[:destination][:external_network][:size] + end + end + if data[:destination][:ip_address] + xml.IpAddress(:href => data[:destination][:ip_address]) + end + if data[:destination][:network] + xml.Network(:href => data[:destination][:network][:href], :name => data[:destination][:network][:name]) + end + end + xml.PortRange do + if data[:port_range][:start] + xml.Start data[:port_range][:start] + end + if data[:port_range][:end] + xml.End data[:port_range][:end] + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/firewall_acls_delete.rb b/lib/fog/ecloud/requests/compute/firewall_acls_delete.rb new file mode 100644 index 000000000..fd1b072b6 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/firewall_acls_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :firewall_acls_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_admin_organization.rb b/lib/fog/ecloud/requests/compute/get_admin_organization.rb new file mode 100644 index 000000000..5125bb819 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_admin_organization.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_admin_organization + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_admin_organizations.rb b/lib/fog/ecloud/requests/compute/get_admin_organizations.rb new file mode 100644 index 000000000..eaab6f98a --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_admin_organizations.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_admin_organizations + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_task_list.rb b/lib/fog/ecloud/requests/compute/get_api_key.rb similarity index 71% rename from lib/fog/ecloud/requests/compute/get_task_list.rb rename to lib/fog/ecloud/requests/compute/get_api_key.rb index 14b41bd39..ed08549df 100644 --- a/lib/fog/ecloud/requests/compute/get_task_list.rb +++ b/lib/fog/ecloud/requests/compute/get_api_key.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :get_task_list + basic_request :get_api_key end end diff --git a/lib/fog/ecloud/requests/compute/get_vapp_template.rb b/lib/fog/ecloud/requests/compute/get_api_keys.rb similarity index 69% rename from lib/fog/ecloud/requests/compute/get_vapp_template.rb rename to lib/fog/ecloud/requests/compute/get_api_keys.rb index c279925e3..ba89528dc 100644 --- a/lib/fog/ecloud/requests/compute/get_vapp_template.rb +++ b/lib/fog/ecloud/requests/compute/get_api_keys.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :get_vapp_template + basic_request :get_api_keys end end diff --git a/lib/fog/ecloud/requests/compute/get_association.rb b/lib/fog/ecloud/requests/compute/get_association.rb new file mode 100644 index 000000000..4d32598c3 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_association.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_association + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_associations.rb b/lib/fog/ecloud/requests/compute/get_associations.rb new file mode 100644 index 000000000..c787f4111 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_associations.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_associations + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_authentication_level.rb b/lib/fog/ecloud/requests/compute/get_authentication_level.rb new file mode 100644 index 000000000..3c381a117 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_authentication_level.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_authentication_level + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_authentication_levels.rb b/lib/fog/ecloud/requests/compute/get_authentication_levels.rb new file mode 100644 index 000000000..9d2a121de --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_authentication_levels.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_authentication_levels + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_backup_internet_service.rb b/lib/fog/ecloud/requests/compute/get_backup_internet_service.rb new file mode 100644 index 000000000..63c825392 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_backup_internet_service.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_backup_internet_service + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_backup_internet_services.rb b/lib/fog/ecloud/requests/compute/get_backup_internet_services.rb new file mode 100644 index 000000000..f3dc0b432 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_backup_internet_services.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_backup_internet_services + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_catalog.rb b/lib/fog/ecloud/requests/compute/get_catalog.rb index 3997777ea..8c97a0057 100644 --- a/lib/fog/ecloud/requests/compute/get_catalog.rb +++ b/lib/fog/ecloud/requests/compute/get_catalog.rb @@ -6,39 +6,6 @@ module Fog 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/ecloud/requests/compute/get_catalog_configuration.rb b/lib/fog/ecloud/requests/compute/get_catalog_configuration.rb new file mode 100644 index 000000000..7aea2df98 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_catalog_configuration.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_catalog_configuration + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_catalog_configurations.rb b/lib/fog/ecloud/requests/compute/get_catalog_configurations.rb new file mode 100644 index 000000000..43c1d65c8 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_catalog_configurations.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_catalog_configurations + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_catalog_item.rb b/lib/fog/ecloud/requests/compute/get_catalog_item.rb index 3480b3678..a70a58469 100644 --- a/lib/fog/ecloud/requests/compute/get_catalog_item.rb +++ b/lib/fog/ecloud/requests/compute/get_catalog_item.rb @@ -6,42 +6,6 @@ module Fog 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/ecloud/requests/compute/get_compute_pool.rb b/lib/fog/ecloud/requests/compute/get_compute_pool.rb index 38c10405e..b5e030a00 100644 --- a/lib/fog/ecloud/requests/compute/get_compute_pool.rb +++ b/lib/fog/ecloud/requests/compute/get_compute_pool.rb @@ -6,31 +6,6 @@ module Fog basic_request :get_compute_pool end - class Mock - # - #Based off of: - #http://support.theenterprisecloud.com/kb/default.asp?id=567&Lang=1&SID= - # - - def get_compute_pool(compute_pool_uri) - compute_pool_uri = ensure_unparsed(compute_pool_uri) - - if compute_pool = mock_data.compute_pool_from_href(compute_pool_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.ComputePool(:xmlns => "urn:tmrk:eCloudExtensions-2.8", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") { - xml.Id compute_pool.object_id - xml.Href compute_pool.href - xml.Name compute_pool.name - xml.State compute_pool.state - xml.IsDefault compute_pool.is_default - }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.computePoolsList+xml' } - else - mock_error 200, "401 Unauthorized" - end - end - - end end end end diff --git a/lib/fog/ecloud/requests/compute/get_compute_pools.rb b/lib/fog/ecloud/requests/compute/get_compute_pools.rb index 72586b575..9f90df138 100644 --- a/lib/fog/ecloud/requests/compute/get_compute_pools.rb +++ b/lib/fog/ecloud/requests/compute/get_compute_pools.rb @@ -6,35 +6,6 @@ module Fog basic_request :get_compute_pools end - class Mock - # - # Based off of: - # http://support.theenterprisecloud.com/kb/default.asp?id=577&Lang=1&SID= - # - - def get_compute_pools(compute_pools_uri) - compute_pools_uri = ensure_unparsed(compute_pools_uri) - - if compute_pool_collection = mock_data.compute_pool_collection_from_href(compute_pools_uri) - xml = Builder::XmlMarkup.new - mock_it 200, - xml.ComputePools { - compute_pool_collection.items.each do |cp| - xml.ComputePool { - xml.Id cp.object_id - xml.Href cp.href - xml.Name cp.name - xml.State cp.state - xml.IsDefault cp.is_default - } - end - }, { 'Content-Type' => 'application/vnd.tmrk.ecloud.computePoolsList+xml'} - else - mock_error 200, "401 Unauthorized" - end - end - - end end end end diff --git a/lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb b/lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb new file mode 100644 index 000000000..6b0e8ddb4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_cpu_usage_detail + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb b/lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb new file mode 100644 index 000000000..6f4e93258 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_cpu_usage_detail_summary + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_customization_options.rb b/lib/fog/ecloud/requests/compute/get_customization_options.rb deleted file mode 100644 index a325cca0f..000000000 --- a/lib/fog/ecloud/requests/compute/get_customization_options.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_environment.rb b/lib/fog/ecloud/requests/compute/get_environment.rb new file mode 100644 index 000000000..26394881c --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_environment.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_environment + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_environments.rb b/lib/fog/ecloud/requests/compute/get_environments.rb new file mode 100644 index 000000000..e69de29bb diff --git a/lib/fog/ecloud/requests/compute/get_group.rb b/lib/fog/ecloud/requests/compute/get_group.rb new file mode 100644 index 000000000..8dcbb8757 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_group.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_group + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_groups.rb b/lib/fog/ecloud/requests/compute/get_groups.rb new file mode 100644 index 000000000..9694cc043 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_groups.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_groups + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_guest_process.rb b/lib/fog/ecloud/requests/compute/get_guest_process.rb new file mode 100644 index 000000000..fcb776749 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_guest_process.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_guest_process + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_guest_processes.rb b/lib/fog/ecloud/requests/compute/get_guest_processes.rb new file mode 100644 index 000000000..b3d1d9969 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_guest_processes.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_guest_processes + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_hardware_configuration.rb b/lib/fog/ecloud/requests/compute/get_hardware_configuration.rb new file mode 100644 index 000000000..5701e951d --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_hardware_configuration.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_hardware_configuration + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_hardware_configurations.rb b/lib/fog/ecloud/requests/compute/get_hardware_configurations.rb new file mode 100644 index 000000000..ed4d6f57f --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_hardware_configurations.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_hardware_configurations + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_internet_service.rb b/lib/fog/ecloud/requests/compute/get_internet_service.rb new file mode 100644 index 000000000..6ae138469 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_internet_service.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_internet_service + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_internet_services.rb b/lib/fog/ecloud/requests/compute/get_internet_services.rb index 9370e59b7..67aa9a748 100644 --- a/lib/fog/ecloud/requests/compute/get_internet_services.rb +++ b/lib/fog/ecloud/requests/compute/get_internet_services.rb @@ -6,77 +6,6 @@ module Fog 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 Fog::Ecloud::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 Fog::Ecloud::MockDataClasses::MockBackupInternetService === service - if Fog::Ecloud::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/ecloud/requests/compute/get_ip_address.rb b/lib/fog/ecloud/requests/compute/get_ip_address.rb new file mode 100644 index 000000000..aed2b8ce8 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_ip_address.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_ip_address + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_ip_addresses.rb b/lib/fog/ecloud/requests/compute/get_ip_addresses.rb new file mode 100644 index 000000000..735ea65f8 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_ip_addresses.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_ip_addresses + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_layout.rb b/lib/fog/ecloud/requests/compute/get_layout.rb new file mode 100644 index 000000000..e661db9ff --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_layout.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_layout + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_layouts.rb b/lib/fog/ecloud/requests/compute/get_layouts.rb new file mode 100644 index 000000000..5b035331d --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_layouts.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_layouts + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_location.rb b/lib/fog/ecloud/requests/compute/get_location.rb new file mode 100644 index 000000000..732279e60 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_location.rb @@ -0,0 +1,12 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_location + end + + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_locations.rb b/lib/fog/ecloud/requests/compute/get_locations.rb new file mode 100644 index 000000000..4c29ffccc --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_locations.rb @@ -0,0 +1,12 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_locations + end + + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_login_banner.rb b/lib/fog/ecloud/requests/compute/get_login_banner.rb new file mode 100644 index 000000000..2f24959d2 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_login_banner.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_login_banner + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_login_banners.rb b/lib/fog/ecloud/requests/compute/get_login_banners.rb new file mode 100644 index 000000000..47d3347a0 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_login_banners.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_login_banners + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb b/lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb new file mode 100644 index 000000000..7a4da5ae8 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_memory_usage_detail + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb b/lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb new file mode 100644 index 000000000..8843d46dc --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_memory_usage_detail_summary + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_monitor.rb b/lib/fog/ecloud/requests/compute/get_monitor.rb new file mode 100644 index 000000000..bcfa76c21 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_monitor.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_monitor + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_monitors.rb b/lib/fog/ecloud/requests/compute/get_monitors.rb new file mode 100644 index 000000000..07b4cc98e --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_monitors.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_monitors + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_network.rb b/lib/fog/ecloud/requests/compute/get_network.rb index 26952675e..ccbc78dba 100644 --- a/lib/fog/ecloud/requests/compute/get_network.rb +++ b/lib/fog/ecloud/requests/compute/get_network.rb @@ -6,39 +6,6 @@ module Fog 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 +end diff --git a/lib/fog/ecloud/requests/compute/get_network_extensions.rb b/lib/fog/ecloud/requests/compute/get_network_extensions.rb deleted file mode 100644 index ba5fb5ca0..000000000 --- a/lib/fog/ecloud/requests/compute/get_network_extensions.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_network_ip.rb b/lib/fog/ecloud/requests/compute/get_network_ip.rb deleted file mode 100644 index 2ae6a84bb..000000000 --- a/lib/fog/ecloud/requests/compute/get_network_ip.rb +++ /dev/null @@ -1,43 +0,0 @@ -# -# AFAICT this is basically undocumented ATM - 6/18/2010 - freeformz -# - -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_network_ips.rb b/lib/fog/ecloud/requests/compute/get_network_ips.rb deleted file mode 100644 index da22faffa..000000000 --- a/lib/fog/ecloud/requests/compute/get_network_ips.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# AFAICT - This is basically undocumented - 6/18/2010 - freeformz -# - -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_network_summary.rb b/lib/fog/ecloud/requests/compute/get_network_summary.rb new file mode 100644 index 000000000..9f8511866 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_network_summary.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_network_summary + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_networks.rb b/lib/fog/ecloud/requests/compute/get_networks.rb new file mode 100644 index 000000000..e5199ae54 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_networks.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_networks + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_node.rb b/lib/fog/ecloud/requests/compute/get_node.rb index e53e11099..ee087c267 100644 --- a/lib/fog/ecloud/requests/compute/get_node.rb +++ b/lib/fog/ecloud/requests/compute/get_node.rb @@ -6,35 +6,6 @@ module Fog 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/ecloud/requests/compute/get_nodes.rb b/lib/fog/ecloud/requests/compute/get_nodes.rb index 0e6abb139..2010e8f3d 100644 --- a/lib/fog/ecloud/requests/compute/get_nodes.rb +++ b/lib/fog/ecloud/requests/compute/get_nodes.rb @@ -6,36 +6,6 @@ module Fog 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/ecloud/requests/compute/get_operating_system.rb b/lib/fog/ecloud/requests/compute/get_operating_system.rb new file mode 100644 index 000000000..054e24794 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_operating_system.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_operating_system + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_operating_system_families.rb b/lib/fog/ecloud/requests/compute/get_operating_system_families.rb new file mode 100644 index 000000000..1acb3f9e6 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_operating_system_families.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_operating_system_families + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_operating_system_family.rb b/lib/fog/ecloud/requests/compute/get_operating_system_family.rb new file mode 100644 index 000000000..054e24794 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_operating_system_family.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_operating_system + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_organization.rb b/lib/fog/ecloud/requests/compute/get_organization.rb index fb96b7914..95375dccd 100644 --- a/lib/fog/ecloud/requests/compute/get_organization.rb +++ b/lib/fog/ecloud/requests/compute/get_organization.rb @@ -6,44 +6,6 @@ module Fog 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/ecloud/requests/compute/get_organizations.rb b/lib/fog/ecloud/requests/compute/get_organizations.rb new file mode 100644 index 000000000..841a45531 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_organizations.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_organizations + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb b/lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb new file mode 100644 index 000000000..63d4be1cf --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_password_complexity_rule + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb b/lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb new file mode 100644 index 000000000..e7a790712 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_password_complexity_rules + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_physical_device.rb b/lib/fog/ecloud/requests/compute/get_physical_device.rb new file mode 100644 index 000000000..91cae1c61 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_physical_device.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_physical_device + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_physical_devices.rb b/lib/fog/ecloud/requests/compute/get_physical_devices.rb new file mode 100644 index 000000000..96aec665c --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_physical_devices.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_physical_devices + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_process.rb b/lib/fog/ecloud/requests/compute/get_process.rb new file mode 100644 index 000000000..e34a99f8c --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_process.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_process + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_processes.rb b/lib/fog/ecloud/requests/compute/get_processes.rb new file mode 100644 index 000000000..655787141 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_processes.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_processes + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_public_ip.rb b/lib/fog/ecloud/requests/compute/get_public_ip.rb index 75521a2a1..219b724b5 100644 --- a/lib/fog/ecloud/requests/compute/get_public_ip.rb +++ b/lib/fog/ecloud/requests/compute/get_public_ip.rb @@ -6,29 +6,6 @@ module Fog 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/ecloud/requests/compute/get_public_ips.rb b/lib/fog/ecloud/requests/compute/get_public_ips.rb index 0b90fa3c4..3260fc923 100644 --- a/lib/fog/ecloud/requests/compute/get_public_ips.rb +++ b/lib/fog/ecloud/requests/compute/get_public_ips.rb @@ -6,33 +6,6 @@ module Fog 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/ecloud/requests/compute/get_rnat.rb b/lib/fog/ecloud/requests/compute/get_rnat.rb new file mode 100644 index 000000000..0ce034bbc --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_rnat.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_rnat + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_rnats.rb b/lib/fog/ecloud/requests/compute/get_rnats.rb new file mode 100644 index 000000000..b3348a044 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_rnats.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_rnats + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_role.rb b/lib/fog/ecloud/requests/compute/get_role.rb new file mode 100644 index 000000000..3f3e18499 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_role.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_role + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_roles.rb b/lib/fog/ecloud/requests/compute/get_roles.rb new file mode 100644 index 000000000..1a32e8308 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_roles.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_roles + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_row.rb b/lib/fog/ecloud/requests/compute/get_row.rb new file mode 100644 index 000000000..69c32da35 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_row.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_row + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_rows.rb b/lib/fog/ecloud/requests/compute/get_rows.rb new file mode 100644 index 000000000..97b9e25fa --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_rows.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_rows + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_server.rb b/lib/fog/ecloud/requests/compute/get_server.rb new file mode 100644 index 000000000..4e70b4dac --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_server.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_task + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_server_configuration_option.rb b/lib/fog/ecloud/requests/compute/get_server_configuration_option.rb new file mode 100644 index 000000000..a8078558e --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_server_configuration_option.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_server_configuration_option + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_server_configuration_options.rb b/lib/fog/ecloud/requests/compute/get_server_configuration_options.rb new file mode 100644 index 000000000..1b733e4e4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_server_configuration_options.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_server_configuration_options + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_servers.rb b/lib/fog/ecloud/requests/compute/get_servers.rb new file mode 100644 index 000000000..f8e015009 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_servers.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_tasks + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_ssh_key.rb b/lib/fog/ecloud/requests/compute/get_ssh_key.rb new file mode 100644 index 000000000..e7df26b58 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_ssh_key.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_ssh_key + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_ssh_keys.rb b/lib/fog/ecloud/requests/compute/get_ssh_keys.rb new file mode 100644 index 000000000..8b919e3b4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_ssh_keys.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_ssh_keys + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb b/lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb new file mode 100644 index 000000000..2fe2609a9 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_storage_usage_detail + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb b/lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb new file mode 100644 index 000000000..3f5836e99 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_storage_usage_detail_summary + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_support_ticket.rb b/lib/fog/ecloud/requests/compute/get_support_ticket.rb new file mode 100644 index 000000000..861347596 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_support_ticket.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_support_ticket + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_support_tickets.rb b/lib/fog/ecloud/requests/compute/get_support_tickets.rb new file mode 100644 index 000000000..29232a1ef --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_support_tickets.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_support_tickets + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_tag.rb b/lib/fog/ecloud/requests/compute/get_tag.rb new file mode 100644 index 000000000..d830d8ff4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_tag.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_tag + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_tags.rb b/lib/fog/ecloud/requests/compute/get_tags.rb new file mode 100644 index 000000000..ea54d5f9f --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_tags.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_tags + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_task.rb b/lib/fog/ecloud/requests/compute/get_task.rb index 4e70b4dac..f606bb0e8 100644 --- a/lib/fog/ecloud/requests/compute/get_task.rb +++ b/lib/fog/ecloud/requests/compute/get_task.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :get_task + basic_request :get_server end end diff --git a/lib/fog/ecloud/requests/compute/get_tasks.rb b/lib/fog/ecloud/requests/compute/get_tasks.rb new file mode 100644 index 000000000..9372ec9d6 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_tasks.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_servers + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_template.rb b/lib/fog/ecloud/requests/compute/get_template.rb new file mode 100644 index 000000000..77430a5f6 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_template.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_template + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_templates.rb b/lib/fog/ecloud/requests/compute/get_templates.rb new file mode 100644 index 000000000..189ece588 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_templates.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_templates + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_trusted_network_group.rb b/lib/fog/ecloud/requests/compute/get_trusted_network_group.rb new file mode 100644 index 000000000..2396910a4 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_trusted_network_group.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_trusted_network_group + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb b/lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb new file mode 100644 index 000000000..60e5bf7c1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_trusted_network_groups + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_user.rb b/lib/fog/ecloud/requests/compute/get_user.rb new file mode 100644 index 000000000..2eb486fea --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_user.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_user + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_users.rb b/lib/fog/ecloud/requests/compute/get_users.rb new file mode 100644 index 000000000..eb3f0acba --- /dev/null +++ b/lib/fog/ecloud/requests/compute/get_users.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :get_users + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/get_vapp.rb b/lib/fog/ecloud/requests/compute/get_vapp.rb deleted file mode 100644 index 7b750cc9d..000000000 --- a/lib/fog/ecloud/requests/compute/get_vapp.rb +++ /dev/null @@ -1,99 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_vdc.rb b/lib/fog/ecloud/requests/compute/get_vdc.rb deleted file mode 100644 index 0a7862e08..000000000 --- a/lib/fog/ecloud/requests/compute/get_vdc.rb +++ /dev/null @@ -1,84 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/get_versions.rb b/lib/fog/ecloud/requests/compute/get_versions.rb deleted file mode 100644 index 65f4f03da..000000000 --- a/lib/fog/ecloud/requests/compute/get_versions.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/groups_create.rb b/lib/fog/ecloud/requests/compute/groups_create.rb new file mode 100644 index 000000000..47e78e2ad --- /dev/null +++ b/lib/fog/ecloud/requests/compute/groups_create.rb @@ -0,0 +1,31 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def groups_create(data) + validate_data([:name], data) + + request( + :body => generate_groups_create_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_groups_create_request(data) + xml = Builder::XmlMarkup.new + xml.CreateLayoutGroup(:name => data[:name]) do + xml.Row(:href => data[:href], :name => data[:row_name], :type => "application/vnd.tmrk.cloud.layoutRow") + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/groups_delete.rb b/lib/fog/ecloud/requests/compute/groups_delete.rb new file mode 100644 index 000000000..e7bf555fe --- /dev/null +++ b/lib/fog/ecloud/requests/compute/groups_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :groups_delete, 204, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/groups_edit.rb b/lib/fog/ecloud/requests/compute/groups_edit.rb new file mode 100644 index 000000000..8749994e1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/groups_edit.rb @@ -0,0 +1,29 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def groups_edit(data) + validate_data([:name], data) + + request( + :body => generate_groups_edit_request(data), + :expects => 204, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => false + ) + end + + private + + def generate_groups_edit_request(data) + xml = Builder::XmlMarkup.new + xml.LayoutGroup(:name => data[:name]) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/groups_movedown.rb b/lib/fog/ecloud/requests/compute/groups_movedown.rb new file mode 100644 index 000000000..4e4bbdf90 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/groups_movedown.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :groups_movedown, 204, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/groups_moveup.rb b/lib/fog/ecloud/requests/compute/groups_moveup.rb new file mode 100644 index 000000000..03c01e42d --- /dev/null +++ b/lib/fog/ecloud/requests/compute/groups_moveup.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :groups_moveup, 204, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/instantiate_vapp_template.rb b/lib/fog/ecloud/requests/compute/instantiate_vapp_template.rb deleted file mode 100644 index b14aee878..000000000 --- a/lib/fog/ecloud/requests/compute/instantiate_vapp_template.rb +++ /dev/null @@ -1,144 +0,0 @@ -module Fog - module Compute - 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.has_key?(opt) } - raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}") - end - valid_opts.push(:computePool) - - # 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.Property( :xmlns => "http://schemas.dmtf.org/ovf/envelope/1", :"ovf:key" => "computePool", :"ovf:value" => options[:computePool] ) - } - 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/ecloud/requests/compute/internet_service_create.rb b/lib/fog/ecloud/requests/compute/internet_service_create.rb new file mode 100644 index 000000000..d342c0ad5 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/internet_service_create.rb @@ -0,0 +1,67 @@ +module Fog + module Compute + class Ecloud + module Shared + def validate_internet_service_data(service_data) + required_opts = [:name, :protocol, :port, :description, :enabled, :persistence] + unless required_opts.all? { |opt| service_data.has_key?(opt) } + raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") + end + if service_data[:trusted_network_group] + raise ArgumentError.new("Required Trusted Network Group data missing: #{([:name, :href] - service_data[:trusted_network_group].keys).map(&:inspect).join(", ")}") + end + if service_data[:backup_internet_service] + raise ArgumentError.new("Required Backup Internet Service data missing: #{([:name, :href] - service_data[:backup_internet_service].keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def internet_service_create(service_data) + validate_internet_service_data(service_data) + + request( + :body => generate_internet_service_request(service_data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => service_data[:uri], + :parse => true + ) + end + + private + + def generate_internet_service_request(service_data) + xml = Builder::XmlMarkup.new + xml.CreateInternetService(:name => service_data[:name]) do + xml.Protocol service_data[:protocol] + xml.Port service_data[:port] + xml.Enabled service_data[:enabled] + xml.Description service_data[:description] + xml.Persistence do + xml.Type service_data[:persistence][:type] + if service_data[:persistence][:timeout] + xml.Timeout service_data[:persistence][:timeout] + end + end + if service_data[:redirect_url] + xml.RedirectUrl service_data[:redirect_url] + end + if service_data[:trusted_network_group] + xml.TrustedNetworkGroup(:href => service_data[:trusted_network_group][:href], :name => service_data[:trusted_network_group][:name], :type => 'application/vnd.tmrk.cloud.trustedNetworkGroup') + end + if service_data[:backup_internet_service] + xml.BackupInternetService(:href => service_data[:backup_internet_service][:href], :name => service_data[:backup_internet_service][:name], :type => 'application/vnd.tmrk.cloud.backupInternetService') + end + if service_data[:load_balancing_method] + xml.LoadBalancingMethod service_data[:load_balancing_method] + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/internet_service_delete.rb b/lib/fog/ecloud/requests/compute/internet_service_delete.rb new file mode 100644 index 000000000..5a72188e2 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/internet_service_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :internet_service_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/internet_service_edit.rb b/lib/fog/ecloud/requests/compute/internet_service_edit.rb new file mode 100644 index 000000000..95971a367 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/internet_service_edit.rb @@ -0,0 +1,60 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_edit_internet_service_options(options) + required_opts = [:name, :enabled, :persistence] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + raise ArgumentError.new("Required data missing: #{:persistence[:type]}") unless options[:persistence][:type] + end + + def build_node_service_body_edit(options) + xml = Builder::XmlMarkup.new + xml.InternetService(:name => options[:name]) do + xml.Enabled options[:enabled] + if options[:description] + xml.Description options[:description] + end + xml.Persistence do + xml.Type options[:persistence][:type] + if options[:persistence][:timeout] + xml.Timeout options[:persistence][:timeout] + end + end + if options[:redirect_url] + xml.RedirectUrl options[:redirect_url] + end + if options[:trusted_network_group] + xml.TrustedNetworkGroup(:href => options[:trusted_network_group][:href], :name => service_data[:trusted_network_group][:name], :type => 'application/vnd.tmrk.cloud.trustedNetworkGroup') + end + if options[:backup_internet_service] + xml.BackupInternetService(:href => options[:backup_internet_service][:href], :name => service_data[:backup_internet_service][:name], :type => 'application/vnd.tmrk.cloud.backupInternetService') + end + if options[:load_balancing_method] + xml.LoadBalancingMethod options[:load_balancing_method] + end + end + end + end + + class Real + + def node_service_edit(options) + validate_edit_node_service_options(options) + body = build_node_service_body_edit(options) + request( + :expects => 202, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => options[:uri], + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/login.rb b/lib/fog/ecloud/requests/compute/login.rb deleted file mode 100644 index 24d466bd7..000000000 --- a/lib/fog/ecloud/requests/compute/login.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Fog - module Compute - 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 diff --git a/lib/fog/ecloud/requests/compute/monitors_create_default.rb b/lib/fog/ecloud/requests/compute/monitors_create_default.rb new file mode 100644 index 000000000..31283dda7 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_create_default.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :monitors_create_default, 201, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_create_ecv.rb b/lib/fog/ecloud/requests/compute/monitors_create_ecv.rb new file mode 100644 index 000000000..92e957be3 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_create_ecv.rb @@ -0,0 +1,40 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_create_ecv(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :send_string, :receive_string], data) + + request( + :body => generate_ecv_monitor_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_ecv_monitor_request(data) + xml = Builder::XmlMarkup.new + xml.CreateEcvMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + xml.SendString data[:send_string] + if data[:http_headers] + xml.HttpHeaders data[:http_headers] + end + xml.ReceiveString data[:receive_string] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_create_http.rb b/lib/fog/ecloud/requests/compute/monitors_create_http.rb new file mode 100644 index 000000000..291e39173 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_create_http.rb @@ -0,0 +1,44 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_create_http(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :request_uri, :response_codes], data) + + request( + :body => generate_http_monitor_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_http_monitor_request(data) + xml = Builder::XmlMarkup.new + xml.CreateHttpMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + xml.RequestUri data[:request_uri] + if data[:http_headers] + xml.HttpHeaders data[:http_headers] + end + xml.ResponseCodes do + data[:response_codes].each do |c| + xml.ResponseCode c + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_create_loopback.rb b/lib/fog/ecloud/requests/compute/monitors_create_loopback.rb new file mode 100644 index 000000000..e47fc9ed1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_create_loopback.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :monitors_create_loopback, 201, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_create_ping.rb b/lib/fog/ecloud/requests/compute/monitors_create_ping.rb new file mode 100644 index 000000000..f2dba1eb1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_create_ping.rb @@ -0,0 +1,35 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_create_ping(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled], data) + + request( + :body => generate_ping_monitor_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_ping_monitor_request(data) + xml = Builder::XmlMarkup.new + xml.CreatePingMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_disable.rb b/lib/fog/ecloud/requests/compute/monitors_disable.rb new file mode 100644 index 000000000..eb95c5618 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_disable.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :monitors_disable, 202, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb b/lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb new file mode 100644 index 000000000..9bb55b876 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb @@ -0,0 +1,40 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_edit_ecv(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :send_string, :receive_string], data) + + request( + :body => generate_edit_ecv_request(data), + :expects => 200, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_edit_ecv_request(data) + xml = Builder::XmlMarkup.new + xml.EcvMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + xml.SendString data[:send_string] + if data[:http_headers] + xml.HttpHeaders data[:http_headers] + end + xml.ReceiveString data[:receive_string] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_edit_http.rb b/lib/fog/ecloud/requests/compute/monitors_edit_http.rb new file mode 100644 index 000000000..519150512 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_edit_http.rb @@ -0,0 +1,44 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_edit_http(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :request_uri, :response_codes], data) + + request( + :body => generate_edit_http_request(data), + :expects => 200, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_edit_http_request(data) + xml = Builder::XmlMarkup.new + xml.HttpMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + xml.RequestUri data[:request_uri] + if xml[:httpheaders] + xml.HttpHeaders xml[:http_headers] + end + xml.ResponseCodes do + xml[:response_codes].each do |c| + xml.ResponseCode c + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_edit_ping.rb b/lib/fog/ecloud/requests/compute/monitors_edit_ping.rb new file mode 100644 index 000000000..206574b98 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_edit_ping.rb @@ -0,0 +1,35 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def monitors_edit_ping(data) + validate_data([:interval, :response_timeout, :retries, :downtime, :enabled], data) + + request( + :body => generate_edit_ping_request(data), + :expects => 200, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_edit_ping_request(data) + xml = Builder::XmlMarkup.new + xml.PingMonitor do + xml.Interval data[:interval] + xml.ResponseTimeout data[:response_timeout] + xml.Retries data[:retries] + xml.Downtime data[:downtime] + xml.Enabled data[:enabled] + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/monitors_enable.rb b/lib/fog/ecloud/requests/compute/monitors_enable.rb new file mode 100644 index 000000000..2bf4c207d --- /dev/null +++ b/lib/fog/ecloud/requests/compute/monitors_enable.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :monitors_enable, 202, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/node_service_create.rb b/lib/fog/ecloud/requests/compute/node_service_create.rb new file mode 100644 index 000000000..4547bce80 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/node_service_create.rb @@ -0,0 +1,45 @@ +module Fog + module Compute + class Ecloud + module Shared + def validate_node_service_data(service_data) + required_opts = [:name, :port, :enabled, :ip_address] + unless required_opts.all? { |opt| service_data.has_key?(opt) } + raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") + end + end + end + + class Real + include Shared + + def node_service_create(service_data) + validate_node_service_data(service_data) + + request( + :body => generate_node_service_request(service_data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => service_data[:uri], + :parse => true + ) + end + + private + + def generate_node_service_request(service_data) + xml = Builder::XmlMarkup.new + xml.CreateNodeService(:name => service_data[:name]) do + xml.IpAddress(:href => service_data[:ip_address], :name => service_data[:ip_address].scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0]) + xml.Port service_data[:port] + xml.Enabled service_data[:enabled] + if service_data[:description] + xml.Description service_data[:description] + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/node_service_delete.rb b/lib/fog/ecloud/requests/compute/node_service_delete.rb new file mode 100644 index 000000000..651ad60e1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/node_service_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :node_service_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/node_service_edit.rb b/lib/fog/ecloud/requests/compute/node_service_edit.rb new file mode 100644 index 000000000..d71ab22c9 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/node_service_edit.rb @@ -0,0 +1,41 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_edit_node_service_options(options) + required_opts = [:name, :enabled] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + end + + def build_node_service_body_edit(options) + xml = Builder::XmlMarkup.new + xml.NodeService(:name => options[:name]) do + xml.Enabled options[:enabled] + if options[:description] + xml.Description options[:description] + end + end + end + end + + class Real + + def node_service_edit(options) + validate_edit_node_service_options(options) + body = build_node_service_body_edit(options) + request( + :expects => 202, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => options[:uri], + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/power_off.rb b/lib/fog/ecloud/requests/compute/power_off.rb index 365b5da8a..304bab8f4 100644 --- a/lib/fog/ecloud/requests/compute/power_off.rb +++ b/lib/fog/ecloud/requests/compute/power_off.rb @@ -6,18 +6,6 @@ module Fog 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/ecloud/requests/compute/power_on.rb b/lib/fog/ecloud/requests/compute/power_on.rb index d7fcaacbb..b79ff2029 100644 --- a/lib/fog/ecloud/requests/compute/power_on.rb +++ b/lib/fog/ecloud/requests/compute/power_on.rb @@ -6,18 +6,6 @@ module Fog 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/ecloud/requests/compute/power_shutdown.rb b/lib/fog/ecloud/requests/compute/power_shutdown.rb index 482797268..2fc249cfc 100644 --- a/lib/fog/ecloud/requests/compute/power_shutdown.rb +++ b/lib/fog/ecloud/requests/compute/power_shutdown.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :power_shutdown, 204, 'POST' + basic_request :power_shutdown, 202, 'POST' end end diff --git a/lib/fog/ecloud/requests/compute/public_ip_activate.rb b/lib/fog/ecloud/requests/compute/public_ip_activate.rb new file mode 100644 index 000000000..b4c6c1f1b --- /dev/null +++ b/lib/fog/ecloud/requests/compute/public_ip_activate.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :public_ip_activate, 201, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb b/lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb new file mode 100644 index 000000000..3f9a15cea --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb @@ -0,0 +1,32 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def rnat_associations_create_device(data) + validate_data([:host_ip_href, :public_ip_href], data) + + request( + :body => generate_rnat_associations_create_device_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_rnat_associations_create_device_request(data) + xml = Builder::XmlMarkup.new + xml.CreateRnatAssociation do + xml.PublicIp(:href => data[:public_ip_href]) + xml.IpAddress(:href => data[:host_ip_href]) + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rnat_associations_delete.rb b/lib/fog/ecloud/requests/compute/rnat_associations_delete.rb new file mode 100644 index 000000000..14dabc510 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rnat_associations_delete.rb @@ -0,0 +1,9 @@ +module Fog + module Compute + class Ecloud + class Real + basic_request :rnat_associations_delete, 202, 'DELETE' + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb b/lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb new file mode 100644 index 000000000..926e64cb5 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb @@ -0,0 +1,31 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def rnat_associations_edit_network(data) + validate_data([:href], data) + + request( + :body => generate_rnat_associations_edit_network_request(data), + :expects => 202, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_rnat_associations_edit_network_request(data) + xml = Builder::XmlMarkup.new + xml.NetworkRnat do + xml.Rnat(:href => data[:href]) + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rows_create.rb b/lib/fog/ecloud/requests/compute/rows_create.rb new file mode 100644 index 000000000..f4c11eec5 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rows_create.rb @@ -0,0 +1,29 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def rows_create(data) + validate_data([:name], data) + + request( + :body => generate_rows_create_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_rows_create_request(data) + xml = Builder::XmlMarkup.new + xml.CreateLayoutRow(:name => data[:name]) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rows_delete.rb b/lib/fog/ecloud/requests/compute/rows_delete.rb new file mode 100644 index 000000000..8b0e8e158 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rows_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :rows_delete, 204, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rows_edit.rb b/lib/fog/ecloud/requests/compute/rows_edit.rb new file mode 100644 index 000000000..23b6be3fa --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rows_edit.rb @@ -0,0 +1,29 @@ +module Fog + module Compute + class Ecloud + class Real + include Shared + + def rows_edit(data) + validate_data([:name], data) + + request( + :body => generate_rows_edit_request(data), + :expects => 204, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => false + ) + end + + private + + def generate_rows_edit_request(data) + xml = Builder::XmlMarkup.new + xml.LayoutRow(:name => data[:name]) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rows_movedown.rb b/lib/fog/ecloud/requests/compute/rows_movedown.rb new file mode 100644 index 000000000..796ea1b5c --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rows_movedown.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :rows_movedown, 204, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/rows_moveup.rb b/lib/fog/ecloud/requests/compute/rows_moveup.rb new file mode 100644 index 000000000..8ebdc82dd --- /dev/null +++ b/lib/fog/ecloud/requests/compute/rows_moveup.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :rows_moveup, 204, 'POST' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb b/lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb new file mode 100644 index 000000000..7dd4834c3 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb @@ -0,0 +1,53 @@ +module Fog + module Compute + class Ecloud + + class Real + include Shared + + def trusted_network_groups_create(data) + validate_data([:name], data) + unless (data[:hosts] || data[:networks]) + raise ArgumentError.new("Required data missing: Either hosts or networks must be present") + end + + + request( + :body => generate_create_trusted_network_groups_request(data), + :expects => 201, + :method => "POST", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_create_trusted_network_groups_request(data) + xml = Builder::XmlMarkup.new + xml.CreateTrustedNetworkGroup(:name => data[:name]) do + if data[:hosts] + xml.Hosts do + data[:hosts].each do |ip| + xml.IpAddress ip + end + end + end + if data[:networks] + xml.Networks do + data[:networks].each do |network| + address, subnet = network.split('/') + xml.Network do + xml.Address address + xml.Size subnet + end + end + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb b/lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb new file mode 100644 index 000000000..9973fc932 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :trusted_network_groups_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb b/lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb new file mode 100644 index 000000000..a99e67acb --- /dev/null +++ b/lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb @@ -0,0 +1,53 @@ +module Fog + module Compute + class Ecloud + + class Real + include Shared + + def trusted_network_groups_edit(data) + validate_data([:name], data) + unless (data[:hosts] || data[:networks]) + raise ArgumentError.new("Required data missing: Either hosts or networks must be present") + end + + + request( + :body => generate_edit_trusted_network_groups_request(data), + :expects => 202, + :method => "PUT", + :headers => {}, + :uri => data[:uri], + :parse => true + ) + end + + private + + def generate_edit_trusted_network_groups_request(data) + xml = Builder::XmlMarkup.new + xml.TrustedNetworkGroup(:name => data[:name]) do + if data[:hosts] + xml.Hosts do + data[:hosts].each do |ip| + xml.IpAddress ip + end + end + end + if data[:networks] + xml.Networks do + data[:networks].each do |network| + address, subnet = network.split('/') + xml.Network do + xml.Address address + xml.Size subnet + end + end + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_copy.rb b/lib/fog/ecloud/requests/compute/virtual_machine_copy.rb new file mode 100644 index 000000000..5882cfcb2 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_copy.rb @@ -0,0 +1,118 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_create_server_options_copy(template_uri, options) + required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri, :source] + if options[:customization] == :windows + required_opts.push(:windows_password) + else + required_opts.push(:ssh_key_uri) + end + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].map! do |uri| + network = get_network(uri).body + if options[:ips] + ip = options[:ips][options[:network_uri].index(uri)] + end + {:href => uri, :name => network[:name], :ip => ip} + end + options + end + + def build_request_body_copy(options) + xml = Builder::XmlMarkup.new + xml.CopyVirtualMachine(:name => options[:name]) do + xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine") + xml.ProcessorCount options[:cpus] + xml.Memory do + xml.Unit "MB" + xml.Value options[:memory] + end + xml.Layout do + xml.NewRow options[:row] + xml.NewGroup options[:group] + end + if options[:customization] == :windows + xml.WindowsCustomization do + xml.NetworkSettings do + xml.NetworkAdapterSettings do + options[:network_uri].each do |uri| + xml.NetworkAdapter do + xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") + xml.IpAddress uri[:ip] + end + end + end + if options[:dns_settings] + xml.DnsSettings do + xml.PrimaryDns options[:dns_settings][:primary_dns] + if options[:dns_settings][:secondary_dns] + xml.SecondaryDns options[:dns_settings][:secondary_dns] + end + end + end + end + xml.Password options[:windows_password] + if options[:windows_license_key] + xml.LicenseKey options[:windows_license_key] + end + end + else + xml.LinuxCustomization do + xml.NetworkSettings do + xml.NetworkAdapterSettings do + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].each do |uri| + xml.NetworkAdapter do + xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") + xml.IpAddress uri[:ip] + end + end + end + if options[:dns_settings] + xml.DnsSettings do + xml.PrimaryDns options[:dns_settings][:primary_dns] + if options[:dns_settings][:secondary_dns] + xml.SecondaryDns options[:dns_settings][:secondary_dns] + end + end + end + end + end + xml.SshKey(:href => options[:ssh_key_uri]) + end + xml.Description options[:description] + xml.Tags do + options[:tags].each do |tag| + xml.Tag tag + end + end + xml.PoweredOn options[:powered_on] + end + end + end + + class Real + + def virtual_machine_copy(template_uri, options) + options = validate_create_server_options_copy(template_uri, options) + body = build_request_body_copy(options) + request( + :expects => 201, + :method => 'POST', + :headers => {}, + :body => body, + :uri => template_uri, + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb b/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb new file mode 100644 index 000000000..c1698b784 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb @@ -0,0 +1,45 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_create_server_options_identical(template_uri, options) + required_opts = [:name, :row, :group, :source] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + + options + end + + def build_request_body_identical(options) + xml = Builder::XmlMarkup.new + xml.CopyIdenticalVirtualMachine(:name => options[:name]) do + xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine") + xml.Layout do + xml.NewRow options[:row] + xml.NewGroup options[:group] + end + xml.Description options[:description] + end + end + end + + class Real + + def virtual_machine_copy_identical(template_uri, options) + options = validate_create_server_options_identical(template_uri, options) + body = build_request_body_identical(options) + request( + :expects => 201, + :method => 'POST', + :headers => {}, + :body => body, + :uri => template_uri, + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb b/lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb new file mode 100644 index 000000000..6d87c6f09 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb @@ -0,0 +1,125 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_create_server_options(template_uri, options) + required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri] + if options[:customization] == :windows + required_opts.push(:windows_password) + else + required_opts.push(:ssh_key_uri) + end + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + + if template_uri.scan(/\/catalog\/\d+/)[0] + options[:template_type] = get_catalog_item(template_uri).body[:type] + elsif template_uri.scan(/\/templates\/\d+/)[0] + options[:template_type] = get_template(template_uri).body[:type] + end + + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].map! do |uri| + network = get_network(uri).body + if options[:ips] + ip = options[:ips][options[:network_uri].index(uri)] + end + {:href => uri, :name => network[:name], :ip => ip} + end + options[:template_uri] = template_uri + options + end + + def build_request_body(options) + xml = Builder::XmlMarkup.new + xml.CreateVirtualMachine(:name => options[:name]) do + xml.ProcessorCount options[:cpus] + xml.Memory do + xml.Unit "MB" + xml.Value options[:memory] + end + xml.Layout do + xml.NewRow options[:row] + xml.NewGroup options[:group] + end + xml.Description options[:description] + xml.Tags do + options[:tags].each do |tag| + xml.Tag tag + end + end + if options[:customization] == :windows + xml.WindowsCustomization do + xml.NetworkSettings do + xml.NetworkAdapterSettings do + options[:network_uri].each do |uri| + xml.NetworkAdapter do + xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") + xml.IpAddress uri[:ip] + end + end + end + if options[:dns_settings] + xml.DnsSettings do + xml.PrimaryDns options[:dns_settings][:primary_dns] + if options[:dns_settings][:secondary_dns] + xml.SecondaryDns options[:dns_settings][:secondary_dns] + end + end + end + end + xml.Password options[:windows_password] + if options[:windows_license_key] + xml.LicenseKey options[:windows_license_key] + end + end + else + xml.LinuxCustomization do + xml.NetworkSettings do + xml.NetworkAdapterSettings do + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:network_uri].each do |uri| + xml.NetworkAdapter do + xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") + xml.IpAddress uri[:ip] + end + end + end + if options[:dns_settings] + xml.DnsSettings do + xml.PrimaryDns options[:dns_settings][:primary_dns] + if options[:dns_settings][:secondary_dns] + xml.SecondaryDns options[:dns_settings][:secondary_dns] + end + end + end + end + end + xml.SshKey(:href => options[:ssh_key_uri]) + end + xml.PoweredOn options[:powered_on] + xml.Template(:href => options[:template_uri], :type => options[:template_type]) + end + end + end + + class Real + + def virtual_machine_create_from_template(template_uri, options) + options = validate_create_server_options(template_uri, options) + + request( + :expects => 201, + :method => 'POST', + :headers => {}, + :body => build_request_body(options), + :uri => options[:uri], + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_delete.rb b/lib/fog/ecloud/requests/compute/virtual_machine_delete.rb new file mode 100644 index 000000000..70365e01e --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_delete.rb @@ -0,0 +1,11 @@ +module Fog + module Compute + class Ecloud + + class Real + basic_request :virtual_machine_delete, 202, 'DELETE' + end + + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_edit.rb b/lib/fog/ecloud/requests/compute/virtual_machine_edit.rb new file mode 100644 index 000000000..74bbffe01 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_edit.rb @@ -0,0 +1,47 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_edit_server_options(options) + required_opts = [:name] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + end + + def build_request_body_edit(options) + xml = Builder::XmlMarkup.new + xml.VirtualMachine(:name => options[:name]) do + if options[:description] + xml.Description options[:description] + end + if options[:tags] + xml.Tags do + options[:tags].each do |tag| + xml.Tag tag + end + end + end + end + end + end + + class Real + + def virtual_machine_edit(vm_uri, options) + validate_edit_server_options(options) + body = build_request_body_edit(options) + request( + :expects => [202,204], + :method => 'PUT', + :headers => {}, + :body => body, + :uri => vm_uri, + :parse => true + ) + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb b/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb new file mode 100644 index 000000000..69fc487a8 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb @@ -0,0 +1,53 @@ +module Fog + module Compute + class Ecloud + class Real + + def virtual_machine_edit_hardware_configuration(vm_uri, data) + validate_data([:cpus, :memory, :disks, :nics], data) + body = build_request_body_edit_hardware_configuration(data) + request( + :expects => 202, + :method => 'PUT', + :headers => {}, + :body => body, + :uri => vm_uri, + :parse => true + ) + end + + def build_request_body_edit_hardware_configuration(data) + xml = Builder::XmlMarkup.new + xml.HardwareConfiguration do + xml.ProcessorCount data[:cpus] + xml.Memory do + xml.Unit data[:memory][:Unit] + xml.Value data[:memory][:Value] + end + xml.Disks do + data[:disks].each do |disk| + xml.Disk do + xml.Index disk[:Index] + xml.Size do + xml.Unit "GB" + xml.Value disk[:Size][:Value] + end + end + end + end + xml.Nics do + data[:nics].each do |nic| + xml.Nic do + xml.UnitNumber nic[:UnitNumber] + xml.MacAddress nic[:MacAddress] + xml.Network(:href => nic[:Network][:href], :name => nic[:Network][:name], :type => "application/vnd.tmrk.cloud.network") do + end + end + end + end + end + end + end + end + end +end diff --git a/lib/fog/ecloud/requests/compute/virtual_machine_import.rb b/lib/fog/ecloud/requests/compute/virtual_machine_import.rb new file mode 100644 index 000000000..b0a17bab1 --- /dev/null +++ b/lib/fog/ecloud/requests/compute/virtual_machine_import.rb @@ -0,0 +1,67 @@ +module Fog + module Compute + class Ecloud + module Shared + + def validate_import_server_options(template_uri, options) + required_opts = [:name, :cpus, :memory, :row, :group, :network_uri, :catalog_network_name] + unless required_opts.all? { |opt| options.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") + end + + options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] + options[:template_uri] = template_uri + options + end + + def build_request_body_import(options) + xml = Builder::XmlMarkup.new + xml.ImportVirtualMachine(:name => options[:name]) do + xml.ProcessorCount options[:cpus] + xml.Memory do + xml.Unit "MB" + xml.Value options[:memory] + end + xml.Layout do + xml.NewRow options[:row] + xml.NewGroup options[:group] + end + xml.Description options[:description] + if options[:tags] + xml.Tags do + options[:tags].each do |tag| + xml.Tag tag + end + end + end + xml.CatalogEntry(:href => options[:template_uri]) + xml.NetworkMappings do + xml.NetworkMapping(:name => options[:catalog_network_name]) do + xml.Network(:href => options[:network_uri][0]) + end + end + if options[:operating_system] + xml.OperatingSystem(:href => options[:operating_system][:href], :name => options[:operating_system][:name], :type => "application/vnd.tmrk.cloud.operatingSystem") + end + end + end + end + + class Real + + def virtual_machine_import(template_uri, options) + options = validate_import_server_options(template_uri, options) + + request( + :expects => 201, + :method => 'POST', + :headers => {}, + :body => build_request_body_import(options), + :uri => options[:uri], + :parse => true + ) + end + end + end + end +end diff --git a/spec/ecloud/bin_spec.rb b/spec/ecloud/bin_spec.rb deleted file mode 100644 index 747b8e9d0..000000000 --- a/spec/ecloud/bin_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'ecloud/spec_helper' - -describe 'Ecloud' do - - it do - pending unless Ecloud.available? - Ecloud.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 - pending unless Ecloud.available? - Fog::Compute[:ecloud].should_not be_nil - end - end - - describe "with a service that does not exist" do - it "should raise an ArgumentError" do - pending unless Ecloud.available? - lambda {Ecloud[:foozle]}.should raise_error(ArgumentError) - end - end - - end -end diff --git a/spec/ecloud/models/backup_internet_service_spec.rb b/spec/ecloud/models/backup_internet_service_spec.rb deleted file mode 100644 index 5bcdd7198..000000000 --- a/spec/ecloud/models/backup_internet_service_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::BackupInternetService", :type => :mock_tmrk_ecloud_model do - subject { @vcloud.vdcs[0].backup_internet_services[0] } - - describe :class do - subject { Fog::Compute::Ecloud::BackupInternetService } - - it { should have_identity(:href) } - it { should have_only_these_attributes([:href, :name, :id, :protocol, :enabled, :description, :timeout, :redirect_url, :monitor]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::BackupInternetService.new() } - it { should have_all_attributes_be_nil } - - end - - context "as a collection member" do - subject { @vcloud.vdcs[0].backup_internet_services[0].reload } - - let(:composed_service_data) { @vcloud.vdcs[0].backup_internet_services[0].send(:_compose_service_data) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::BackupInternetService) } - - its(:href) { should == @mock_backup_service.href } - its(:identity) { should == @mock_backup_service.href } - its(:name) { should == @mock_backup_service.name } - its(:id) { should == @mock_backup_service.object_id.to_s } - its(:protocol) { should == @mock_backup_service.protocol } - its(:enabled) { should == @mock_backup_service.enabled.to_s } - its(:description) { should == @mock_backup_service.description } - its(:timeout) { should == @mock_backup_service.timeout.to_s } - its(:redirect_url) { should == (@mock_backup_service.redirect_url || "") } - its(:monitor) { should == nil } - - specify { composed_service_data[:href].should == subject.href.to_s } - specify { composed_service_data[:name].should == subject.name } - specify { composed_service_data[:id].should == subject.id.to_s } - specify { composed_service_data[:protocol].should == subject.protocol } - specify { composed_service_data[:enabled].should == subject.enabled.to_s } - specify { composed_service_data[:description].should == subject.description } - specify { composed_service_data[:timeout].should == subject.timeout.to_s } - end - end -end diff --git a/spec/ecloud/models/backup_internet_services_spec.rb b/spec/ecloud/models/backup_internet_services_spec.rb deleted file mode 100644 index dfdc9271d..000000000 --- a/spec/ecloud/models/backup_internet_services_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do - context "as an attribute of a VDC" do - subject { @vcloud.vdcs[0] } - - it { should respond_to(:backup_internet_services) } - - describe :class do - subject { @vcloud.vdcs[0].backup_internet_services.class } - its(:model) { should == Fog::Compute::Ecloud::BackupInternetService } - end - - describe :backup_internet_services do - subject { @vcloud.vdcs[0].backup_internet_services } - - it { should respond_to(:create) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::BackupInternetServices) } - - its(:length) { should == 1 } - - it { should(have_members_of_the_right_model) } - end - end - end -end diff --git a/spec/ecloud/models/internet_service_spec.rb b/spec/ecloud/models/internet_service_spec.rb deleted file mode 100644 index 9d209e171..000000000 --- a/spec/ecloud/models/internet_service_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::InternetService", :type => :mock_tmrk_ecloud_model do - subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] } - - describe :class do - subject { Fog::Compute::Ecloud::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]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::InternetService.new() } - it { should have_all_attributes_be_nil } - - end - - context "as a collection member" do - subject { @vcloud.vdcs[0].public_ips[0].internet_services[0].reload; @vcloud.vdcs[0].public_ips[0].internet_services[0] } - - let(:public_ip) { - pip = @vcloud.get_public_ip(@vcloud.vdcs[0].public_ips[0].internet_services[0].public_ip[:Href]).body - pip.delete_if{ |k,v| [:xmlns, :xmlns_i].include?(k)} - pip - } - 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::Compute::Ecloud::InternetService) } - - its(:href) { should == @mock_service.href } - its(:identity) { should == @mock_service.href } - its(:name) { should == @mock_service.name } - its(:id) { should == @mock_service.object_id.to_s } - its(:protocol) { should == @mock_service.protocol } - its(:port) { should == @mock_service.port.to_s } - its(:enabled) { should == @mock_service.enabled.to_s } - its(:description) { should == @mock_service.description } - its(:public_ip) { should == public_ip } - its(:timeout) { should == @mock_service.timeout.to_s } - its(:redirect_url) { should == @mock_service.redirect_url } - its(:monitor) { should == nil } - its(:backup_service_uri) { should be_nil } - - specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s } - specify { composed_public_ip_data[:name].should == public_ip[:Name] } - specify { composed_public_ip_data[:id].should == public_ip[:Id] } - - specify { composed_service_data[:href].should == subject.href.to_s } - specify { composed_service_data[:name].should == subject.name } - specify { composed_service_data[:id].should == subject.id.to_s } - specify { composed_service_data[:protocol].should == subject.protocol } - specify { composed_service_data[:port].should == subject.port.to_s } - specify { composed_service_data[:enabled].should == subject.enabled.to_s } - specify { composed_service_data[:description].should == subject.description } - specify { composed_service_data[:timeout].should == subject.timeout.to_s } - - context "with a backup internet service" do - before { @mock_service[:backup_service] = @mock_backup_service } - - its(:backup_service_uri) { should == @mock_backup_service.href } - end - - describe "#backup_service_uri=" do - specify do - expect { subject.backup_service_uri = @mock_backup_service.href }. - to change { subject.backup_service_uri }.from(nil).to(@mock_backup_service.href) - end - - specify do - expect { subject.backup_service_uri = @mock_backup_service.href }. - to change { subject.send(:_compose_service_data)[:backup_service_uri] }.from(nil).to(@mock_backup_service.href) - end - end - - describe "disable monitoring via #monitor=" do - specify do - expect { subject.monitor = {:type => "Disabled", :is_enabled => "true" }; subject.save }.to change {subject.monitor}.from(nil).to(ecloud_disabled_default_monitor) - end - - end - - describe "disable monitoring via #disable_monitor" do - specify do - expect { subject.disable_monitor }.to change {subject.monitor}.from(nil).to(ecloud_disabled_default_monitor) - end - end - - context "with a disabled monitor" do - before { subject.disable_monitor } - - describe "enable ping monitoring via #enable_ping_monitor" do - specify do - expect { subject.enable_ping_monitor }.to change {subject.monitor}.from(ecloud_disabled_default_monitor).to(nil) - end - end - end - end - end -else -end diff --git a/spec/ecloud/models/internet_services_spec.rb b/spec/ecloud/models/internet_services_spec.rb deleted file mode 100644 index 54ec3d23f..000000000 --- a/spec/ecloud/models/internet_services_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do - context "as an attribute of a VDC" do - subject { @vcloud.vdcs[0] } - - it { should respond_to(:internet_services) } - - describe :class do - subject { @vcloud.vdcs[0].internet_services.class } - its(:model) { should == Fog::Compute::Ecloud::InternetService } - end - - describe :internet_services do - subject { @vcloud.vdcs[0].internet_services } - - it { should respond_to(:create) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::InternetServices) } - - its(:length) { should == 4 } - - it { should have_members_of_the_right_model } - end - end - end -else -end diff --git a/spec/ecloud/models/ip_spec.rb b/spec/ecloud/models/ip_spec.rb deleted file mode 100644 index aba2bd0d9..000000000 --- a/spec/ecloud/models/ip_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::Ip", :type => :mock_tmrk_ecloud_model do - subject { @vcloud } - - describe :class do - subject { Fog::Compute::Ecloud::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::Compute::Ecloud::Ip.new() } - - it { should have_all_attributes_be_nil } - end - - context "as a collection member" do - subject { @ip = @vcloud.vdcs[0].networks[0].ips[0] } - - it { should be_an_instance_of(Fog::Compute::Ecloud::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 } - its(:server) { should == @mock_data.network_ip_from_href(@ip.href).used_by.name } - - end - end -else -end - diff --git a/spec/ecloud/models/ips_spec.rb b/spec/ecloud/models/ips_spec.rb deleted file mode 100644 index 4a0fbadb3..000000000 --- a/spec/ecloud/models/ips_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::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::Compute::Ecloud::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::Compute::Ecloud::Ips) } - - its(:length) { should == 252 } - - it { should have_members_of_the_right_model } - end - end -else -end - - diff --git a/spec/ecloud/models/network_spec.rb b/spec/ecloud/models/network_spec.rb deleted file mode 100644 index 24101a6c2..000000000 --- a/spec/ecloud/models/network_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::Network", :type => :mock_tmrk_ecloud_model do - subject { @vcloud } - - describe :class do - subject { Fog::Compute::Ecloud::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]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::Network.new() } - - it { should have_all_attributes_be_nil } - end - - context "as a collection member" do - subject { @vcloud.vdcs[0].networks[0].reload } - - it { should be_an_instance_of(Fog::Compute::Ecloud::Network) } - - its(:href) { should == @mock_network.href } - its(:identity) { should == @mock_network.href } - its(:name) { should == @mock_network.name } - its(:type) { should == "application/vnd.vmware.vcloud.network+xml" } - its(:gateway) { should == @mock_network.gateway } - its(:broadcast) { should == @mock_network.broadcast } - its(:address) { should == @mock_network.address } - its(:rnat) { should == @mock_network.rnat } - its(:extension_href) { should == @mock_network.extensions.href } - its(:network_type) { should == @mock_network.extensions.type } - its(:vlan) { should == @mock_network.extensions.vlan } - its(:friendly_name) { should == @mock_network.extensions.friendly_name } - - it { should have(1).features } - - describe :features do - let(:feature) { subject.features.first } - specify { feature.should be_an_instance_of(Array) } - specify { feature.last.should == @mock_network.features[0][:value] } - end - - it { should have(2).links } - - describe :links do - context "[0]" do - let(:link) { subject.links[0] } - specify { link[:rel].should == "down" } - specify { link[:href].should == @mock_network_ip_collection.href } - specify { link[:type].should == "application/xml" } - specify { link[:name].should == @mock_network_ip_collection.name } - end - - context "[1]" do - let(:link) { subject.links[1] } - specify { link[:rel].should == "down" } - specify { link[:href].should == @mock_network.extensions.href } - specify { link[:type].should == "application/xml" } - specify { link[:name].should == @mock_network.name } - end - end - - end - end -else -end - diff --git a/spec/ecloud/models/networks_spec.rb b/spec/ecloud/models/networks_spec.rb deleted file mode 100644 index ba8e8a4bb..000000000 --- a/spec/ecloud/models/networks_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::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::Compute::Ecloud::Network } - end - - describe :networks do - subject { @vcloud.vdcs[0].networks } - it { should_not respond_to(:create) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::Networks) } - - its(:length) { should == 2 } - - it { should have_members_of_the_right_model } - end - end -else -end - diff --git a/spec/ecloud/models/node_spec.rb b/spec/ecloud/models/node_spec.rb deleted file mode 100644 index 699526b99..000000000 --- a/spec/ecloud/models/node_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::Node", :type => :mock_tmrk_ecloud_model do - - subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first } - - describe :class do - subject { Fog::Compute::Ecloud::Node } - - it { should have_identity(:href) } - it { should have_only_these_attributes([:href, :ip_address, :description, :name, :port, :enabled, :id]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::Node.new() } - it { should have_all_attributes_be_nil } - - end - - 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::Compute::Ecloud::Node) } - - its(:href) { should == @mock_node.href } - its(:identity) { should == @mock_node.href } - its(:name) { should == @mock_node.name } - its(:id) { should == @mock_node.object_id.to_s } - its(:port) { should == @mock_node.port.to_s } - its(:enabled) { should == @mock_node.enabled.to_s } - its(:description) { should == @mock_node.description } - - end - end -else -end diff --git a/spec/ecloud/models/nodes_spec.rb b/spec/ecloud/models/nodes_spec.rb deleted file mode 100644 index 1404751e0..000000000 --- a/spec/ecloud/models/nodes_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::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 } - - it { should respond_to(:nodes) } - - describe :class do - subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.class } - its(:model) { should == Fog::Compute::Ecloud::Node } - end - - describe :nodes do - subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes } - - it { should respond_to(:create) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::Nodes) } - - its(:length) { should == 3 } - - it { should have_members_of_the_right_model } - end - end - end -end diff --git a/spec/ecloud/models/public_ip_spec.rb b/spec/ecloud/models/public_ip_spec.rb deleted file mode 100644 index dd0d57b3d..000000000 --- a/spec/ecloud/models/public_ip_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::PublicIp", :type => :mock_tmrk_ecloud_model do - subject { @vcloud } - - describe :class do - subject { Fog::Compute::Ecloud::PublicIp } - - it { should have_identity(:href) } - it { should have_only_these_attributes([:name, :id, :href]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::PublicIp.new() } - - it { should have_all_attributes_be_nil } - end - - 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::Compute::Ecloud::PublicIp) } - - its(:href) { should == @mock_public_ip.href } - its(:identity) { should == @mock_public_ip.href } - its(:name) { should == @mock_public_ip.name } - its(:id) { should == @mock_public_ip.object_id.to_s } - - its(:internet_services) { should have(2).services } - - end - end -else -end diff --git a/spec/ecloud/models/public_ips_spec.rb b/spec/ecloud/models/public_ips_spec.rb deleted file mode 100644 index ae334ed3d..000000000 --- a/spec/ecloud/models/public_ips_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::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::Compute::Ecloud::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::Compute::Ecloud::PublicIps) } - - its(:length) { should == 3 } - - it { should have_members_of_the_right_model } - end - end -else -end - diff --git a/spec/ecloud/models/server_spec.rb b/spec/ecloud/models/server_spec.rb deleted file mode 100644 index e8d038f96..000000000 --- a/spec/ecloud/models/server_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::Vdc", :type => :mock_tmrk_ecloud_model do - subject { @vcloud } - - describe :class do - subject { Fog::Compute::Ecloud::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::Compute::Ecloud::Server.new() } - - it { should have_all_attributes_be_nil } - end - - context "as a collection member" do - subject { @vcloud.vdcs[0].servers.first } - - its(:href) { should == @mock_vm.href } - its(:identity) { should == @mock_vm.href } - its(:name) { should == @mock_vm.name } - its(:cpus) { should == { :count => @mock_vm.cpus, :units => nil } } - its(:memory) { should == { :amount => @mock_vm.memory, :units => nil } } - its(:disks) { should == @mock_vm.to_configure_vapp_hash[:disks] } - - describe "question methods" do - describe "#ready?" do - before { subject.power_off } - - it { should be_ready } - end - - describe "#on?" do - before { subject.power_on } - - it { should be_on } - end - - describe "#off?" do - before { subject.power_off } - - it { should be_off } - end - end - end - - context "as a new server without all info" do - before { @vcloud.return_vapp_as_creating! "test123" } - - subject { @vcloud.vdcs[0].servers.create(@mock_catalog_item.href, { :name => "test123", :row => "foo", :group => "bar", :network_uri => @mock_network.href }) } - - its(:cpus) { should be_nil } - its(:memory) { should be_nil } - its(:disks) { should == [] } - end - end -else -end diff --git a/spec/ecloud/models/vdc_spec.rb b/spec/ecloud/models/vdc_spec.rb deleted file mode 100644 index d5a5c838c..000000000 --- a/spec/ecloud/models/vdc_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::Vdc", :type => :mock_tmrk_ecloud_model do - subject { @vcloud } - - it { should respond_to(:get_vdc) } - - describe :class do - subject { Fog::Compute::Ecloud::Vdc } - - it { should have_identity(:href) } - it { should have_only_these_attributes([:href, :name, :type, :description, :other_links, :compute_capacity, :storage_capacity, :available_networks, - :resource_entities, :deployed_vm_quota, :instantiated_vm_quota]) } - end - - context "with no uri" do - - subject { Fog::Compute::Ecloud::Vdc.new() } - - it { should have_all_attributes_be_nil } - end - - context "as a collection member" do - subject { @vcloud.vdcs[0].reload } - - 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::Compute::Ecloud::PublicIps) } - its(:other_links) { should have(4).items } - its(:resource_entities) { should have(3).items } - its(:available_networks) { should have(2).items } - - its(:compute_capacity) { should == {:Memory => - {:Allocated => @mock_vdc.memory_allocated.to_s, :Units => "bytes * 2^20"}, - :DeployedVmsQuota => - {:Limit => "-1", :Used => "-1"}, - :InstantiatedVmsQuota => - {:Limit => "-1", :Used => "-1"}, - :Cpu => - {:Allocated => @mock_vdc.cpu_allocated.to_s, :Units => "hz * 10^6"}} } - - its(:storage_capacity) { should == {:Allocated => @mock_vdc.storage_allocated.to_s, :Used => @mock_vdc.storage_used.to_s, :Units => "bytes * 10^9"} } - - its(:deployed_vm_quota) { should == nil } - its(:instantiated_vm_quota) { should == nil } - - its(:public_ips) { should have(3).public_ips } - its(:internet_services) { should have(4).services } - its(:networks) { should have(2).networks } - its(:servers) { should have(3).servers } - - #FIXME: need to mock tasks related requests first - #its(:tasks) { should have(0).tasks } - - #FIXME: need to mock catalog related requests first - #its(:catalog) { should have(0).entries } - - end - end -else -end diff --git a/spec/ecloud/models/vdcs_spec.rb b/spec/ecloud/models/vdcs_spec.rb deleted file mode 100644 index f7c453791..000000000 --- a/spec/ecloud/models/vdcs_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Compute::Ecloud::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::Compute::Ecloud::Vdc } - end - - describe :vdcs do - subject { @vcloud.vdcs } - it { should_not respond_to(:create) } - - it { should be_an_instance_of(Fog::Compute::Ecloud::Vdcs) } - - its(:length) { should == 2 } - - it { should have_members_of_the_right_model } - - its(:organization_uri) { should == @mock_organization.href } - end - end -else -end diff --git a/spec/ecloud/requests/add_backup_internet_service_spec.rb b/spec/ecloud/requests/add_backup_internet_service_spec.rb deleted file mode 100644 index 3446107c2..000000000 --- a/spec/ecloud/requests/add_backup_internet_service_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - 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) } - - describe "#add_backup_internet_service" do - before do - @new_backup_service_data = { - :name => "Test Service", - :protocol => "HTTP", - :enabled => "true", - :description => "this is a test", - :redirect_url => "" - } - end - - context "with a valid vdc uri" do - subject { @vcloud.add_backup_internet_service(@mock_vdc.internet_service_collection.href, @new_backup_service_data ) } - - it "has the right number of Internet Services after" do - expect { subject }.to change { @vcloud.get_internet_services(@mock_vdc.internet_service_collection.href).body[:InternetService].size }.by(1) - end - - it_should_behave_like "all responses" - - let(:body) { subject.body } - - its(:body) { should be_an_instance_of(Hash) } - specify { body[:Href].should_not be_empty } - specify { body[:Name].should == @new_backup_service_data[:name] } - specify { body[:Protocol].should == @new_backup_service_data[:protocol] } - specify { body[:Enabled].should == @new_backup_service_data[:enabled] } - specify { body[:Description].should == @new_backup_service_data[:description] } - specify { body[:RedirectURL].should == @new_backup_service_data[:redirect_url] } - specify { body[:Monitor].should == nil } - # so broken - specify { body[:IsBackupService].should == "false" } - - it "should update the mock object properly" do - subject - - backup_internet_service = @vcloud.mock_data.backup_internet_service_from_href(body[:Href]) - backup_internet_service.object_id.to_s.should == body[:Id] - backup_internet_service.node_collection.items.should be_empty - end - end - - context "with a vdc uri that doesn't exist" do - subject { lambda { @vcloud.add_backup_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @new_backup_service_data ) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/add_internet_service_spec.rb b/spec/ecloud/requests/add_internet_service_spec.rb deleted file mode 100644 index 71bda22f8..000000000 --- a/spec/ecloud/requests/add_internet_service_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:add_internet_service) } - - describe "#add_internet_service" do - before do - @public_ip = @vcloud.vdcs.first.public_ips.detect {|p| p.name == @mock_public_ip.name } - - @new_service_data = { :name => "Test Service", - :protocol => "HTTP", - :port => "80", - :enabled => "true", - :description => "this is a test", - :redirect_url => "" } - end - - context "with a valid Public IP uri" do - subject { @vcloud.add_internet_service(@public_ip.internet_services.href, @new_service_data ) } - - it "has the right number of Internet Services after" do - expect { subject }.to change { @vcloud.get_internet_services(@public_ip.internet_services.href).body[:InternetService].size }.by(1) - end - - it_should_behave_like "all responses" - - let(:body) { subject.body } - - its(:body) { should be_an_instance_of(Hash) } - specify { body[:Href].should_not be_empty } - specify { body[:Name].should == @new_service_data[:name] } - specify { body[:Protocol].should == @new_service_data[:protocol] } - specify { body[:Enabled].should == @new_service_data[:enabled] } - specify { body[:Description].should == @new_service_data[:description] } - specify { body[:RedirectURL].should == @new_service_data[:redirect_url] } - specify { body[:Monitor].should == nil } - - let(:referenced_public_ip) { subject.body[:PublicIpAddress] } - specify { referenced_public_ip.should be_an_instance_of(Hash) } - specify { referenced_public_ip[:Name].should == @public_ip.name } - specify { referenced_public_ip[:Id].should == @public_ip.id } - - it "should update the mock object properly" do - subject - - public_ip_internet_service = @vcloud.mock_data.public_ip_internet_service_from_href(body[:Href]) - - public_ip_internet_service.object_id.to_s.should == body[:Id] - public_ip_internet_service.node_collection.items.should be_empty - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.add_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @new_service_data ) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/add_node_spec.rb b/spec/ecloud/requests/add_node_spec.rb deleted file mode 100644 index b35818425..000000000 --- a/spec/ecloud/requests/add_node_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - #FIXME: with rspec2 - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:add_node) } - - describe "#add_node" do - - let(:new_node_data) { { :ip_address => '1.2.3.4', - :name => 'Foo', - :port => '9090', - :enabled => 'true', - :description => 'Foo Service' - } } - - context "with a valid node services uri" do - - subject { @vcloud.add_node(@mock_service.node_collection.href, new_node_data) } - - it_should_behave_like "all responses" - - let(:service) { @vcloud.vdcs.first.public_ips.first.internet_services.first } - - it "should change the count by 1" do - expect { subject }.to change { @vcloud.get_nodes(@mock_service.node_collection.href).body[:NodeService].length}.by(1) - end - - describe "#body" do - subject { @vcloud.add_node(@mock_service.node_collection.href, new_node_data).body } - its(:Enabled) { should == new_node_data[:enabled] } - its(:Port) { should == new_node_data[:port] } - its(:IpAddress) { should == new_node_data[:ip_address] } - its(:Name) { should == new_node_data[:name] } - its(:Description) { should == new_node_data[:description] } - end - - describe "added mock data" do - let(:added_mock_node) { @vcloud.mock_data.public_ip_internet_service_node_from_href(subject.body[:Href]) } - - specify { added_mock_node._parent.should == @mock_service.node_collection } - end - end - - context "with a nodes uri that doesn't exist" do - subject { lambda { @vcloud.add_node(URI.parse('https://www.fakey.c/piv8vc99'), new_node_data ) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/configure_internet_service_spec.rb b/spec/ecloud/requests/configure_internet_service_spec.rb deleted file mode 100644 index 11d54d7d0..000000000 --- a/spec/ecloud/requests/configure_internet_service_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:configure_internet_service) } - - describe "#configure_internet_service" do - before do - @original_service = @vcloud.get_internet_services(@mock_public_ip.internet_service_collection.href).body[:InternetService].first - @ip_data = { :id => @mock_public_ip.object_id, :name => @mock_public_ip.name, :href => @mock_public_ip.href.to_s } - @service_data = { :name => @original_service[:Name], :protocol => @original_service[:Protocol], - :port => @original_service[:Port], :description => @original_service[:Description], - :enabled => @original_service[:Enabled], :redirect_url => @original_service[:RedirectURL], - :id => @original_service[:Id], :href => @original_service[:Href], :timeout => @original_service[:Timeout] } - end - - context "with a valid Internet Service uri and valid data" do - subject { @vcloud.configure_internet_service(@original_service[:Href], @service_data, @ip_data) } - - it_should_behave_like "all responses" - - context "with some changed data" do - before do - @service_data[:description] = "TEST BOOM" - @service_data[:redirect_url] = "http://google.com" - @service_data[:port] = "80" - @service_data[:backup_service_uri] = @mock_backup_service.href - end - - it "should change data" do - @original_service[:Description].should == @mock_service[:description] - @original_service[:RedirectURL].should == @mock_service[:redirect_url] - @original_service[:Port].should == @mock_service[:port].to_s - result = subject - result.body[:Description].should == @service_data[:description] - result.body[:RedirectURL].should == @service_data[:redirect_url] - result.body[:Port].should == @service_data[:port] - result.body[:BackupService][:Href].should == @service_data[:backup_service_uri] - - new_result = @vcloud.get_internet_services(@mock_public_ip.internet_service_collection.href).body[:InternetService].first - - new_result[:Description].should == @service_data[:description] - new_result[:RedirectURL].should == @service_data[:redirect_url] - new_result[:Port].should == @service_data[:port] - new_result[:BackupService][:Href].should == @service_data[:backup_service_uri] - end - end - end - - context "with an internet_services_uri that doesn't exist" do - subject { lambda { @vcloud.configure_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @service_data, @ip_data ) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/configure_network_ip_spec.rb b/spec/ecloud/requests/configure_network_ip_spec.rb deleted file mode 100644 index 720d79372..000000000 --- a/spec/ecloud/requests/configure_network_ip_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:configure_network_ip) } - - describe "#configure_network_ip" do - let(:original_network_ip) { @vcloud.get_network_ip(@mock_network_ip.href).body } - let(:network_ip_data) do - { - :id => original_network_ip[:Id], - :href => original_network_ip[:Href], - :name => original_network_ip[:Name], - :status => original_network_ip[:Status], - :server => original_network_ip[:Server], - :rnat => "1.2.3.4" - } - end - - context "with a valid network ip uri" do - - subject { @vcloud.configure_network_ip(@mock_network_ip.href, network_ip_data) } - - it_should_behave_like "all responses" - - describe "#body" do - subject { @vcloud.configure_network_ip(@mock_network_ip.href, network_ip_data).body } - - #Stuff that shouldn't change - its(:Href) { should == @mock_network_ip.href } - its(:Id) { should == @mock_network_ip.object_id.to_s } - its(:Name) { should == @mock_network_ip.ip } - its(:Status) { should == @mock_network_ip.status } - - #Stuff that should change - it "should change the rnat" do - expect { subject }.to change { @vcloud.get_network_ip(@mock_network_ip.href).body[:RnatAddress] }. - from(@mock_network.rnat). - to(network_ip_data[:rnat]) - end - end - - end - - context "with a nodes uri that doesn't exist" do - subject { lambda { @vcloud.configure_network_ip(URI.parse('https://www.fakey.c/piv8vc99'), network_ip_data) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/configure_node_spec.rb b/spec/ecloud/requests/configure_node_spec.rb deleted file mode 100644 index a599d067d..000000000 --- a/spec/ecloud/requests/configure_node_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:configure_node) } - - describe "#configure_node" do - let(:original_node) { @vcloud.get_node(@mock_node.href).body } - let(:node_data) { { :name => "TEST BOOM", :enabled => "false", :description => "TEST BOOM DESC" } } - - context "with a valid node service uri" do - - subject { @vcloud.configure_node(@mock_node.href,node_data) } - - it_should_behave_like "all responses" - - describe "#body" do - subject { @vcloud.configure_node(@mock_node.href,node_data).body } - - #Stuff that shouldn't change - its(:Href) { should == @mock_node.href } - its(:Id) { should == @mock_node.object_id.to_s } - its(:Port) { should == @mock_node.port.to_s } - its(:IpAddress) { should == @mock_node.ip_address } - - #Stuff that should change - it "should change the name" do - expect { subject }.to change { @vcloud.get_node(@mock_node.href).body[:Name] }.to(node_data[:name]) - end - - it "should change enabled" do - expect { subject }.to change { @vcloud.get_node(@mock_node.href).body[:Enabled] }.to(node_data[:enabled]) - end - - it "should change the description" do - expect { subject }.to change { @vcloud.get_node(@mock_node.href).body[:Description] }.to(node_data[:description]) - end - end - - end - - context "with a nodes uri that doesn't exist" do - subject { lambda { @vcloud.configure_node(URI.parse('https://www.fakey.c/piv8vc99'), node_data) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/configure_vapp_spec.rb b/spec/ecloud/requests/configure_vapp_spec.rb deleted file mode 100644 index 98069eb2c..000000000 --- a/spec/ecloud/requests/configure_vapp_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'ecloud/spec_helper' - -shared_examples_for "a successful configure vapp" do - specify { after_vapp_data.should == new_vapp_data } - - describe "#body" do - its(:body) { should == '' } - end - - describe "#headers" do - its(:headers) { should include("Location") } - end -end - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:configure_vapp) } - - let(:original_vapp_data) { vapp_data.dup } - let(:vapp_data) { @mock_vm.to_configure_vapp_hash } - let(:changed_vapp_data) { {} } - let(:new_vapp_data) { vapp_data.update(changed_vapp_data) } - let(:after_vapp_data) { @mock_vm.to_configure_vapp_hash } - - describe "#configure_vapp" do - context "with a valid vapp uri" do - before { original_vapp_data; subject } - - subject { @vcloud.configure_vapp(@mock_vm.href, new_vapp_data) } - - context "when changing nothing" do - it_should_behave_like "a successful configure vapp" - end - - context "when changing CPUs" do - let(:changed_vapp_data) { { :cpus => @mock_vm.cpus * 2 } } - - it_should_behave_like "a successful configure vapp" - end - - context "when changing memory" do - let(:changed_vapp_data) { { :memory => @mock_vm.memory * 2 } } - - it_should_behave_like "a successful configure vapp" - end - - context "when removing a disk" do - let(:changed_vapp_data) { { :disks => original_vapp_data[:disks][0...1] } } - - it_should_behave_like "a successful configure vapp" - end - - context "when adding a disk" do - let(:changed_vapp_data) { { :disks => original_vapp_data[:disks] + [{ :number => "5", :size => 10 * 1024 * 1024, :resource => (10 * 1024 * 1024).to_s }] } } - - it_should_behave_like "a successful configure vapp" - end - end - - context "with an internet_services_uri that doesn't exist" do - subject { lambda { @vcloud.configure_vapp(URI.parse('https://www.fakey.c/piv8vc99'), new_vapp_data) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/delete_internet_service_spec.rb b/spec/ecloud/requests/delete_internet_service_spec.rb deleted file mode 100644 index 3a39696ba..000000000 --- a/spec/ecloud/requests/delete_internet_service_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'ecloud/spec_helper' - -#FIXME: Make this more sane with rspec2 -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:delete_internet_service) } - - describe "#delete_internet_service" do - context "with a valid internet service uri" do - subject { @vcloud.delete_internet_service(@mock_service.href) } - - it_should_behave_like "all delete responses" - - let(:public_ip) { @vcloud.vdcs.first.public_ips.detect {|i| i.name == @mock_public_ip.name } } - - it "should change the mock data" do - expect { subject }.to change { @mock_public_ip.internet_service_collection.items.count }.by(-1) - end - - it "should change the count by -1" do - expect { subject }.to change { public_ip.reload.internet_services.reload.length }.by(-1) - end - - describe "#body" do - its(:body) { should == '' } - end - end - end - end -else -end - diff --git a/spec/ecloud/requests/delete_node_spec.rb b/spec/ecloud/requests/delete_node_spec.rb deleted file mode 100644 index 72fb799aa..000000000 --- a/spec/ecloud/requests/delete_node_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - #FIXME: with rspec2 - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:delete_node) } - - describe "#delete_node" do - context "with a valid node service uri" do - subject { @vcloud.delete_node(@mock_node.href) } - - it_should_behave_like "all delete responses" - - it "should change the count by -1" do - expect { subject }.to change { @vcloud.get_nodes(@mock_node_collection.href).body[:NodeService].length }.by(-1) - end - end - - context "with a nodes uri that doesn't exist" do - subject { lambda { @vcloud.delete_node(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/delete_vapp_spec.rb b/spec/ecloud/requests/delete_vapp_spec.rb deleted file mode 100644 index b9d2d7020..000000000 --- a/spec/ecloud/requests/delete_vapp_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'ecloud/spec_helper' - -shared_examples_for "a failed vapp deletion" do - it "should not change the mock data" do - expect { subject }.to change { @mock_vdc.virtual_machines.count }.by(0) - end - - it "should not change the model data" do - expect { subject }.to change { vdc.reload.servers.reload.count }.by(0) - end - - describe "#body" do - its(:body) { should == '' } - end - - describe "#headers" do - its(:headers) { should_not include("Location") } - end -end - -#FIXME: Make this more sane with rspec2 -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:delete_vapp) } - - describe "#delete_vapp" do - context "with a valid vapp uri" do - subject { @vcloud.delete_vapp(@mock_vm.href) } - let(:vdc) { @vcloud.vdcs.first } - - context "when there are no internet service nodes attached" do - it_should_behave_like("all delete responses") - - it "should change the mock data" do - expect { subject }.to change { @mock_vdc.virtual_machines.count }.by(-1) - end - - it "should change the model data" do - expect { subject }.to change { vdc.reload.servers.reload.count }.by(-1) - end - - describe "#body" do - its(:body) { should == '' } - end - - describe "#headers" do - its(:headers) { should include("Location") } - end - end - - context "when there are internet service nodes attached" do - before do - vdc.public_ips.first.internet_services.create(:name => "#{@mock_vm.name} service", :port => 1231, :protocol => "TCP", :description => "", :enabled => true).tap do |internet_service| - internet_service.nodes.create(:name => "#{@mock_vm.name} node", :port => 1231, :description => "", :enabled => true, :ip_address => @mock_vm.ip) - end - end - - it_should_behave_like "all delete responses" - it_should_behave_like "a failed vapp deletion" - end - - context "when the VM is powered on" do - before do - @mock_vm.power_on! - end - - it_should_behave_like "all delete responses" - it_should_behave_like "a failed vapp deletion" - end - - context "when the VM's IP has an rnat set" do - before do - @mock_vm.network_ip[:rnat] = "1.2.3.4" - end - - it_should_behave_like "all delete responses" - it_should_behave_like "a failed vapp deletion" - end - end - - context "with a vapp uri that doesn't exist" do - subject { lambda { @vcloud.delete_vapp(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/get_catalog_item_spec.rb b/spec/ecloud/requests/get_catalog_item_spec.rb deleted file mode 100644 index afc61154a..000000000 --- a/spec/ecloud/requests/get_catalog_item_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_catalog_item) } - - describe "#get_catalog_item" do - context "with a valid catalog_item_uri" do - before { @catalog_item = @vcloud.get_catalog_item(@vcloud.vdcs.first.catalog.first.href) } - subject { @catalog_item } - let(:mock_data_catalog_item) { @mock_data.catalog_item_from_href(@catalog_item.body[:href]) } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.catalogItem+xml") } - - describe "#body" do - subject { @catalog_item.body } - - it { should have(8).items } - - it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys - - its(:name) { should == "Item 0" } - - it { should include(:Entity) } - it { should include(:Link) } - it { should include(:Property) } - - describe "Entity" do - subject { @catalog_item.body[:Entity] } - let(:mock_data_catalog_item) { @mock_data.catalog_item_from_href(@catalog_item.body[:href]) } - - it { should have(3).items } - - its(:name) { should == mock_data_catalog_item.name } - its(:type) { should == "application/vnd.vmware.vcloud.vAppTemplate+xml" } - its(:href) { should == mock_data_catalog_item.vapp_template.href } - end - - describe "Link" do - subject { @catalog_item.body[:Link] } - - it { should have(4).items } - - its(:rel) { should == "down" } - its(:href) { should == mock_data_catalog_item.customization.href } - its(:name) { should == mock_data_catalog_item.customization.name } - its(:type) { should == "application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml" } - end - end - end - - context "with a catalog uri that doesn't exist" do - subject { lambda { @vcloud.get_catalog(URI.parse('https://www.fakey.com/api/v0.8/vdc/999/catalog')) } } - - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -end diff --git a/spec/ecloud/requests/get_catalog_spec.rb b/spec/ecloud/requests/get_catalog_spec.rb deleted file mode 100644 index 78314298e..000000000 --- a/spec/ecloud/requests/get_catalog_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_catalog) } - - describe "#get_catalog" do - context "with a valid vdc catalog_uri" do - before { @catalog = @vcloud.get_catalog(@mock_vdc.catalog.href) } - subject { @catalog } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.catalog+xml") } - - describe "#body" do - subject { @catalog.body } - - it { should have(7).items } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - - its(:name) { should == @mock_vdc.catalog.name } - - it { should include(:CatalogItems) } - - describe "CatalogItems" do - subject { @catalog.body[:CatalogItems] } - - it { should have(1).items } - end - end - end - - context "with a catalog uri that doesn't exist" do - subject { lambda { @vcloud.get_catalog(URI.parse('https://www.fakey.com/api/v0.8/vdc/999/catalog')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_customization_options_spec.rb b/spec/ecloud/requests/get_customization_options_spec.rb deleted file mode 100644 index 91145657b..000000000 --- a/spec/ecloud/requests/get_customization_options_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_customization_options) } - - describe "#get_customization_options" do - context "with a valid catalog_item customizations uri" do - let(:catalog_item) { @vcloud.get_catalog_item(@vcloud.vdcs.first.catalog.first.href) } - - before { @customization_options = @vcloud.get_customization_options(catalog_item.body[:Link][:href]) } - subject { @customization_options } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.catalogItemCustomizationParameters+xml") } - - describe "#body" do - subject { @customization_options.body } - - it { should have(5).items } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - - specify { subject[:CustomizeNetwork].should == "true" } - specify { subject[:CustomizePassword].should == "false" } - end - end - - context "with a catalog uri that doesn't exist" do - subject { lambda { @vcloud.get_catalog(URI.parse('https://www.fakey.com/api/v0.8/vdc/999/catalog')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_internet_services_spec.rb b/spec/ecloud/requests/get_internet_services_spec.rb deleted file mode 100644 index 8fe931904..000000000 --- a/spec/ecloud/requests/get_internet_services_spec.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - shared_examples_for "a basic internet service" do - specify { service.should be_an_instance_of(Hash) } - specify { service.should have(14).attributes } - specify { service[:Name].should == mock_service.name } - specify { service[:Id].should == mock_service.object_id.to_s } - specify { service[:Href].should == mock_service.href } - - specify { service[:PublicIpAddress].should be_an_instance_of(Hash) } - specify { service[:PublicIpAddress].should have(3).attributes } - specify { service[:PublicIpAddress][:Name].should == mock_ip.name } - specify { service[:PublicIpAddress][:Href].should == mock_ip.href } - specify { service[:PublicIpAddress][:Id].should == mock_ip.object_id.to_s } - - specify { service[:Port].should == mock_service.port.to_s } - specify { service[:Protocol].should == mock_service.protocol } - specify { service[:Enabled].should == mock_service.enabled.to_s } - specify { service[:Timeout].should == mock_service.timeout.to_s } - specify { service[:Description].should == mock_service.description } - specify { service[:RedirectURL].should == (mock_service.redirect_url || "") } - specify { service[:Monitor].should == "" } - specify { service[:IsBackupService].should == "false" } - specify { service[:BackupOf].should == "" } - end - - shared_examples_for "an internet service without a backup internet service set" do - specify { service[:BackupService].should be_nil } - end - - shared_examples_for "an internet service with a backup internet service set" do - specify { service[:BackupService].should be_an_instance_of(Hash) } - specify { service[:BackupService].should include(:Href) } - specify { service[:BackupService][:Href].should == @mock_backup_service.href } - end - - shared_examples_for "a backup internet service" do - specify { service.should be_an_instance_of(Hash) } - specify { service.should have(14).attributes } - specify { service[:Name].should == mock_service.name } - specify { service[:Id].should == mock_service.object_id.to_s } - specify { service[:Href].should == mock_service.href } - - specify { service[:PublicIpAddress].should be_nil } - - specify { service[:Port].should == mock_service.port.to_s } - specify { service[:Protocol].should == mock_service.protocol } - specify { service[:Enabled].should == mock_service.enabled.to_s } - specify { service[:Timeout].should == mock_service.timeout.to_s } - specify { service[:Description].should == mock_service.description } - specify { service[:RedirectURL].should == (mock_service.redirect_url || "") } - specify { service[:Monitor].should be_nil } - specify { service[:IsBackupService].should == "true" } - specify { service[:BackupService].should be_nil } - specify { service[:BackupOf].should == "" } - end - - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_internet_services) } - - describe "#get_internet_services" do - context "with a valid VDC internet_services_uri" do - before do - @mock_vdc.internet_service_collection.items[3][:backup_service] = @mock_backup_service - @services = @vcloud.get_internet_services(@mock_vdc_service_collection.href) - end - - subject { @services } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.internetServicesList+xml") } - - describe "#body" do - subject { @services.body } - - it { should have(3).items } - - context "[:InternetService]" do - subject { @services.body[:InternetService] } - - it { should have(5).items } - - [0,1,2].each do |idx| - let(:service) { subject[idx] } - let(:mock_service) { @mock_vdc.internet_service_collection.items[idx] } - let(:mock_ip) { mock_service._parent._parent } - - it_should_behave_like "an internet service without a backup internet service set" - end - - context "for a service with a backup internet service" do - let(:service) { subject[3] } - let(:mock_service) { @mock_vdc.internet_service_collection.items[3] } - let(:mock_ip) { mock_service._parent._parent } - - it_should_behave_like("an internet service with a backup internet service set") - end - - context "for a backup internet service" do - let(:service) { subject[4] } - let(:mock_service) { @mock_vdc.internet_service_collection.backup_internet_services.first } - - it_should_behave_like("a backup internet service") - end - end - end - end - - context "with a valid Public IP uri" do - before do - @services = @vcloud.get_internet_services(@mock_service_collection.href) - end - subject { @services } - - it_should_behave_like("all responses") - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.internetServicesList+xml") } - - describe "#body" do - subject { @services.body } - - it { should have(3).items } - - context "[:InternetService]" do - subject { @services.body[:InternetService] } - - it { should have(2).items } - - [0,1].each do |idx| - let(:service) { subject[idx] } - let(:mock_service) { @mock_service_collection.items[idx] } - let(:mock_ip) { @mock_public_ip } - - it_should_behave_like("an internet service without a backup internet service set") - end - end - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.get_internet_services(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -else -end diff --git a/spec/ecloud/requests/get_network_ip_spec.rb b/spec/ecloud/requests/get_network_ip_spec.rb deleted file mode 100644 index 08a8c12ea..000000000 --- a/spec/ecloud/requests/get_network_ip_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_network_ip) } - - describe "#get_network_ip" do - context "with a valid ip_uri" do - before do - @ip = @vcloud.get_network_ip(@mock_network_ip.href) - end - - subject { @ip } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.ip+xml") } - - describe "#body" do - subject { @ip.body } - - its(:Name) { should == @mock_network_ip.name } - its(:Href) { should == @mock_network_ip.href } - its(:Id) { should == @mock_network_ip.object_id.to_s } - its(:RnatAddress) { should == @mock_network_ip.rnat } - its(:Status) { should == @mock_network_ip.status } - - end - end - - context "with an ip_uri that doesn't exist" do - subject { lambda { @vcloud.get_network_ip('https://www.fakey.c/piv89') } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_network_ips_spec.rb b/spec/ecloud/requests/get_network_ips_spec.rb deleted file mode 100644 index ead5d8c26..000000000 --- a/spec/ecloud/requests/get_network_ips_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_network_ips) } - - describe "#get_network_ips" do - context "with a valid VDC network ips_uri" do - before { @ips = @vcloud.get_network_ips(@mock_network_ip_collection.href) } - subject { @ips } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.ipAddressesList+xml") } - - describe "#body" do - subject { @ips.body } - - it { should have(1).item } - - context "[:IpAddress]" do - subject { @ips.body[:IpAddress] } - - # Note the real TMRK API returns only "assigned" ips currently - # This is a bug they've slated to fix in the next release. - it { should have(252).addresses } - - end - - context "one we know is assigned" do - let(:address) { @ips.body[:IpAddress][0] } - specify { address.should have(6).keys } - specify { address[:Status].should == "Assigned" } - specify { address[:Server].should == "Broom 1" } - specify { address[:Name].should == "1.2.3.3" } - specify { address[:RnatAddress].should == "99.1.2.3" } - end - - context "one we know is not assigned" do - let(:address) { @ips.body[:IpAddress][100] } - specify { address.should have(5).keys } - specify { address[:Status].should == "Available" } - specify { address.has_key?(:Server).should be_false } - specify { address[:Name].should == "1.2.3.103" } - specify { address[:RnatAddress].should == "99.1.2.3" } - end - end - end - - context "with a network ips uri that doesn't exist" do - subject { lambda { @vcloud.get_network_ips(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -end diff --git a/spec/ecloud/requests/get_network_spec.rb b/spec/ecloud/requests/get_network_spec.rb deleted file mode 100644 index afcd39695..000000000 --- a/spec/ecloud/requests/get_network_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_network) } - - describe "#get_network" do - context "with a valid network uri" do - before { @network = @vcloud.get_network(@mock_network.href) } - subject { @network } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.network+xml") } - - describe "#body" do - subject { @network.body } - - it { should have(9).keys } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - - its(:type) { should == "application/vnd.vmware.vcloud.network+xml" } - its(:Features) { should == @mock_network.features.map {|f| { f[:type] => f[:value] } }.first } - its(:href) { should == @mock_network.href } - its(:name) { should == @mock_network.name } - its(:Configuration) { should == { :Gateway => @mock_network.gateway, :Netmask => @mock_network.netmask } } - its(:Link) { should == - [{:type => "application/xml", - :rel => "down", - :href => @mock_network_ip_collection.href, - :name => "IP Addresses"}, - {:type => "application/xml", - :rel => "down", - :href => @mock_network_extensions.href, - :name => @mock_network_extensions.name}]} - end - end - - context "with a network uri that doesn't exist" do - subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/network/999')) } } - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/get_node_spec.rb b/spec/ecloud/requests/get_node_spec.rb deleted file mode 100644 index 0626d0f09..000000000 --- a/spec/ecloud/requests/get_node_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_node) } - - describe "#get_node" do - context "with a valid nodes_uri" do - before { @node = @vcloud.get_node(@mock_node.href) } - subject { @node } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.nodeService+xml") } - - describe "#body" do - subject { @node.body } - - it { should have(9).keys } - - its(:Href) { should == @mock_node.href } - its(:Id) { should == @mock_node.object_id.to_s } - its(:Name) { should == @mock_node.name } - its(:Enabled) { should == @mock_node.enabled.to_s } - its(:Port) { should == @mock_node.port.to_s } - its(:Description) { should == @mock_node.description } - its(:IpAddress) { should == @mock_node.ip_address } - - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.get_node(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_nodes_spec.rb b/spec/ecloud/requests/get_nodes_spec.rb deleted file mode 100644 index d1735ae6e..000000000 --- a/spec/ecloud/requests/get_nodes_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_nodes) } - - describe "#get_nodes" do - context "with a valid nodes_uri" do - before { @nodes = @vcloud.get_nodes(@mock_node_collection.href) } - subject { @nodes } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.nodeService+xml") } - - describe "#body" do - subject { @nodes.body } - - it { should have(3).items } - - describe "[:NodeService]" do - subject { @nodes.body[:NodeService] } - - it { should have(@mock_node_collection.items.length).nodes } - - [0,1].each do |idx| - - context "[#{idx}]" do - subject { @nodes.body[:NodeService][idx] } - let(:mock_node) { @mock_node_collection.items[idx] } - let(:keys) { subject.keys.sort_by(&:to_s) } - specify { keys.should == [:Description, :Enabled, :Href, :Id, :IpAddress, :Name, :Port] } - its(:Href) { should == mock_node.href } - its(:Id) { should == mock_node.object_id.to_s } - its(:Name) { should == mock_node.name } - its(:Enabled) { should == mock_node.enabled.to_s } - its(:Port) { should == mock_node.port.to_s } - its(:IpAddress) { should == mock_node.ip_address } - its(:Description) { should == mock_node.description } - end - - end - - end - - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.get_nodes(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_organization_spec.rb b/spec/ecloud/requests/get_organization_spec.rb deleted file mode 100644 index d25565359..000000000 --- a/spec/ecloud/requests/get_organization_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_organization) } - - describe "#get_organization" do - context "with a valid organization uri" do - before { @organization = @vcloud.get_organization(@vcloud.default_organization_uri) } - subject { @organization } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.org+xml") } - - describe "#body" do - subject { @organization.body } - - - let(:links) { subject[:Link] } - - it { should have(6).keys } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - it { should have_key_with_value(:href, @mock_organization.href)} - it { should have_key_with_value(:name, @mock_organization.name) } - it { should have_key_with_array(:Link, @mock_organization.vdcs.map { |vdc| - [{ :type => "application/vnd.vmware.vcloud.vdc+xml", - :href => vdc.href, - :name => vdc.name, - :rel => "down" }, - { :type => "application/vnd.vmware.vcloud.catalog+xml", - :href => vdc.catalog.href, - :name => vdc.catalog.name, - :rel => "down" }, - { :type => "application/vnd.vmware.vcloud.tasksList+xml", - :href => vdc.task_list.href, - :name => vdc.task_list.name, - :rel => "down" }] - }.flatten) } - - end - end - context "with an organization uri that doesn't exist" do - subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } } - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -end - diff --git a/spec/ecloud/requests/get_public_ip_spec.rb b/spec/ecloud/requests/get_public_ip_spec.rb deleted file mode 100644 index 9f2797c19..000000000 --- a/spec/ecloud/requests/get_public_ip_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_public_ip) } - - describe "#get_public_ip" do - context "with a valid public_ip_uri" do - before do - @public_ip = @vcloud.get_public_ip(@mock_public_ip.href) - end - - subject { @public_ip } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.publicIp+xml") } - - describe "#body" do - subject { @public_ip.body } - - its(:Name) { should == @mock_public_ip.name } - its(:Href) { should == @mock_public_ip.href } - its(:Id) { should == @mock_public_ip.object_id.to_s } - - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.get_public_ip(URI.parse('https://www.fakey.c/piv89')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_public_ips_spec.rb b/spec/ecloud/requests/get_public_ips_spec.rb deleted file mode 100644 index 051a881a1..000000000 --- a/spec/ecloud/requests/get_public_ips_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_public_ips) } - - describe "#get_public_ips" do - context "with a valid public_ips_uri" do - before { @public_ips = @vcloud.get_public_ips(@mock_public_ip_collection.href) } - subject { @public_ips } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.tmrk.ecloud.publicIpsList+xml") } - - describe "#body" do - subject { @public_ips.body } - - it { should have(1).item } - - describe "[:PublicIPAddress]" do - subject { @public_ips.body[:PublicIPAddress] } - - it { should have(@mock_public_ip_collection.items.length).addresses } - - [0,1,2].each do |idx| - - context "[#{idx}]" do - subject { @public_ips.body[:PublicIPAddress][idx] } - let(:public_ip) { @mock_public_ip_collection.items[idx] } - its(:Href) { should == public_ip.href } - its(:Id) { should == public_ip.object_id.to_s } - its(:Name) { should == public_ip.name } - end - - end - - end - - end - end - - context "with a public_ips_uri that doesn't exist" do - subject { lambda { @vcloud.get_public_ips(URI.parse('https://www.fakey.c/piv8vc99')) } } - - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end diff --git a/spec/ecloud/requests/get_vapp_spec.rb b/spec/ecloud/requests/get_vapp_spec.rb deleted file mode 100644 index 4c03767db..000000000 --- a/spec/ecloud/requests/get_vapp_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_vapp) } - - describe "#get_vapp" do - context "with a valid vapp_uri" do - before { @vapp = @vcloud.get_vapp(@mock_vm.href) } - subject { @vapp } - let(:vapp_id) { @vapp.body[:href].split("/").last } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.vApp+xml") } - - describe "#body" do - subject { @vapp.body } - - specify { subject.keys.sort_by(&:to_s).should == [:Link, :NetworkConnectionSection, - :OperatingSystemSection, :VirtualHardwareSection, - :href, :name, - :size, :status, - :type, :xmlns, - :xmlns_xsd, :xmlns_xsi] } - - it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys - - its(:href) { should == @mock_vm.href } - its(:name) { should == @mock_vm.name } - its(:status) { should == @mock_vm.status.to_s } - its(:size) { should == (@mock_vm.disks.inject(0) {|s, d| s += d[:size].to_i } * 1024).to_s } - - describe "Link" do - subject { @vapp.body[:Link] } - - its(:rel) { should == "up" } - its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" } - its(:href) { should == @mock_vdc.href } - end - - describe "NetworkConnectionSection" do - subject { @vapp.body[:NetworkConnectionSection] } - - it { should include(:NetworkConnection) } - - describe "NetworkConnection" do - subject { @vapp.body[:NetworkConnectionSection][:NetworkConnection] } - - its(:IpAddress) { should == @mock_vm.ip } - end - end - - describe "OperatingSystemSection" do - subject { @vapp.body[:OperatingSystemSection] } - - its(:Info) { should == "The kind of installed guest operating system" } - its(:Description) { should == "Red Hat Enterprise Linux 5 (64-bit)" } - end - - describe "VirtualHardwareSection" do - subject { @vapp.body[:VirtualHardwareSection] } - - specify { subject.keys.sort_by(&:to_s).should == [:Info, :Item, :System, :xmlns] } - - describe "Item" do - subject { @vapp.body[:VirtualHardwareSection][:Item] } - - it { should have(5).items } - - specify { subject.map {|i| i[:ResourceType] }.uniq.sort.should == %w(3 4 6 17).sort } - - describe "CPU" do - subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "3" } } - - its(:VirtualQuantity) { should == @mock_vm.cpus.to_s } - end - - describe "memory" do - subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "4" } } - - its(:VirtualQuantity) { should == @mock_vm.memory.to_s } - end - - describe "SCSI controller" do - subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "6" } } - - its(:Address) { should == "0" } - end - - describe "Hard Disks" do - subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" } } - - it { should have(2).disks } - - describe "#1" do - subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[0] } - - its(:AddressOnParent) { should == "0" } - its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s } - its(:HostResource) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s } - end - - describe "#2" do - subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[1] } - - its(:AddressOnParent) { should == "1" } - its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s } - its(:HostResource) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s } - end - end - end - end - end - end - - context "with a vapp uri that doesn't exist" do - subject { lambda { @vcloud.get_vapp(URI.parse('https://www.fakey.com/api/v0.8/vApp/99999')) } } - - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -end diff --git a/spec/ecloud/requests/get_vdc_spec.rb b/spec/ecloud/requests/get_vdc_spec.rb deleted file mode 100644 index 4f99380f6..000000000 --- a/spec/ecloud/requests/get_vdc_spec.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:get_vdc) } - - describe "#get_vdc" do - context "with a valid vdc uri" do - before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc.href)) } - subject { @vdc } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.vdc+xml") } - - describe "#body" do - subject { @vdc.body } - - it { should have(11).items } - - it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys - - its(:href) { should == @mock_vdc.href } - its(:name) { should == @mock_vdc.name } - - its(:Description) { should == "" } - its(:StorageCapacity) { should == {:Units => "bytes * 10^9", :Allocated => @mock_vdc.storage_allocated.to_s, :Used => @mock_vdc.storage_used.to_s } } - its(:ComputeCapacity) { should == {:InstantiatedVmsQuota => { :Limit => "-1", :Used => "-1" }, - :Memory => { :Units => "bytes * 2^20", :Allocated => @mock_vdc.memory_allocated.to_s }, - :Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc.cpu_allocated.to_s }, - :DeployedVmsQuota => { :Limit => "-1", :Used => "-1" } } } - - its(:Link) { should have(4).links } - - describe "link 0" do - subject { @vdc.body[:Link][0] } - it { should have(4).attributes } - its(:type) { should == "application/vnd.vmware.vcloud.catalog+xml" } - its(:rel) { should == "down" } - its(:href) { should == @mock_vdc.catalog.href } - its(:name) { should == @mock_vdc.catalog.name } - end - describe "link 1" do - subject { @vdc.body[:Link][1] } - it { should have(4).attributes } - its(:type) { should == "application/vnd.tmrk.ecloud.publicIpsList+xml" } - its(:rel) { should == "down" } - its(:href) { should == @mock_vdc.public_ip_collection.href } - its(:name) { should == @mock_vdc.public_ip_collection.name } - end - describe "link 2" do - subject { @vdc.body[:Link][2] } - it { should have(4).attributes } - its(:type) { should == "application/vnd.tmrk.ecloud.internetServicesList+xml" } - its(:rel) { should == "down" } - its(:href) { should == @mock_vdc.internet_service_collection.href } - its(:name) { should == @mock_vdc.internet_service_collection.name } - end - describe "link 3" do - subject { @vdc.body[:Link][3] } - it { should have(4).attributes } - its(:type) { should == "application/vnd.tmrk.ecloud.firewallAclsList+xml" } - its(:rel) { should == "down" } - its(:href) { should == @mock_vdc.firewall_acls.href } - its(:name) { should == @mock_vdc.firewall_acls.name } - end - - let(:resource_entities) { subject[:ResourceEntities][:ResourceEntity] } - specify { resource_entities.should have(@mock_vdc.virtual_machines.length).vapps } - - describe "[:ResourceEntities][:ResourceEntity]" do - context "[0]" do - subject { @vdc.body[:ResourceEntities][:ResourceEntity][0] } - it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[0]) } - end - context "[1]" do - subject { @vdc.body[:ResourceEntities][:ResourceEntity][1] } - it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[1]) } - end - context "[2]" do - subject { @vdc.body[:ResourceEntities][:ResourceEntity][2] } - it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[2]) } - end - end - - its(:name) { should == @mock_vdc[:name] } - - let(:available_networks) { subject[:AvailableNetworks][:Network] } - specify { available_networks.should have(2).networks } - - describe "[:AvailableNetworks][:Network]" do - context "[0]" do - subject { @vdc.body[:AvailableNetworks][:Network][0] } - it { should be_a_network_link_to(@mock_vdc.networks[0]) } - end - context "[1]" do - subject { @vdc.body[:AvailableNetworks][:Network][1] } - it { should be_a_network_link_to(@mock_vdc.networks[1]) } - end - end - end - end - - context "with a vdc uri that doesn't exist" do - subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } } - - it_should_behave_like("a request for a resource that doesn't exist") - end - end - end -end diff --git a/spec/ecloud/requests/get_versions_spec.rb b/spec/ecloud/requests/get_versions_spec.rb deleted file mode 100644 index 14f0104c4..000000000 --- a/spec/ecloud/requests/get_versions_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'ecloud/spec_helper' - -shared_examples_for "real or mock get_versions requests" do - if Fog.mocking? - - subject { @vcloud } - - it { should respond_to(:get_versions) } - - describe "#get_versions" do - subject { @vcloud.get_versions( @vcloud.versions_uri ) } - - it_should_behave_like "all responses" - - describe "body" do - subject { @vcloud.get_versions( @vcloud.versions_uri ).body } - - it { should have(4).keys } - it_should_behave_like "it has the standard xmlns attributes" # 2 keys - - its(:xmlns) { should == "http://www.vmware.com/vcloud/versions" } - - its(:VersionInfo) { should be_either_a_hash_or_array } - - describe ":VersionInfo" do - subject { arrayify(@vcloud.get_versions( @vcloud.versions_uri ).body[:VersionInfo]) } - - specify { - subject.each do |version_info| - version_info.should include(:LoginUrl) - version_info[:LoginUrl].should be_a_url - version_info.should include(:Version) - version_info[:Version].should be_an_instance_of(String) - end - } - end - end - end - - end -end - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - - it_should_behave_like "real or mock get_versions requests" - - describe "body" do - subject { @vcloud.get_versions( @vcloud.versions_uri ).body } - its(:VersionInfo) { should == { :LoginUrl => @mock_version.login_url , :Version => @mock_version.version } } - end - end -else - 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/ecloud/requests/instantiate_vapp_template_spec.rb b/spec/ecloud/requests/instantiate_vapp_template_spec.rb deleted file mode 100644 index bb1d702a8..000000000 --- a/spec/ecloud/requests/instantiate_vapp_template_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:instantiate_vapp_template) } - - describe "#instantiate_vapp_template" do - let(:vdc) { @vcloud.vdcs.first } - let(:mock_vdc) { @mock_vdc } - - let(:catalog_item) { vdc.catalog.first } - let(:mock_catalog_item) { @vcloud.mock_data.catalog_item_from_href(catalog_item.href) } - - let(:new_vapp_data) do - { - :name => "foobar", - :network_uri => @mock_network.href, - :row => "test row", - :group => "test group", - :memory => 1024, - :cpus => 2, - :vdc_uri => @mock_vdc.href - } - end - - let(:added_mock_data) { mock_vdc.virtual_machines.last } - - context "with a valid data" do - let(:template_instantiation) { @vcloud.instantiate_vapp_template(catalog_item.href, new_vapp_data) } - subject { template_instantiation } - - it_should_behave_like "all responses" - it { should have_headers_denoting_a_content_type_of("application/xml") } - - it "updates the mock data properly" do - expect { subject }.to change { mock_vdc.virtual_machines.size }.by(1) - end - - describe "added mock data" do - before { template_instantiation } - subject { added_mock_data } - - it { should be_an_instance_of(Fog::Ecloud::MockDataClasses::MockVirtualMachine) } - - its(:name) { should == new_vapp_data[:name] } - its(:memory) { should == new_vapp_data[:memory] } - its(:cpus) { should == new_vapp_data[:cpus] } - # WHAT - specify { subject._parent.should == mock_vdc } - specify { subject.status.should == 2 } - specify { subject.disks.should == mock_catalog_item.disks } - # its(:_parent) { should == mock_vdc } - #its(:status) { should == 2 } - #its(:disks) { should == mock_catalog_item.disks } - end - - describe "server based on added mock data" do - before { template_instantiation } - subject { vdc.servers.reload.detect {|s| s.href == added_mock_data.href }.reload } - - its(:name) { should == new_vapp_data[:name] } - end - - describe "#body" do - subject { template_instantiation.body } - - it { should have(9).items } - - it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys - - its(:href) { should == added_mock_data.href } - its(:type) { should == "application/vnd.vmware.vcloud.vApp+xml" } - its(:name) { should == new_vapp_data[:name] } - its(:status) { should == "0" } - its(:size) { should == "4" } - - it { should include(:Link) } - - describe "Link" do - subject { template_instantiation.body[:Link] } - - it { should have(3).keys } - - its(:rel) { should == "up" } - its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" } - # WHAT - its(:href) { blah = vdc.href; should == blah } - end - end - end - end - end -end diff --git a/spec/ecloud/requests/login_spec.rb b/spec/ecloud/requests/login_spec.rb deleted file mode 100644 index 15c00deba..000000000 --- a/spec/ecloud/requests/login_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it_should_behave_like "all login requests" - end -else -end diff --git a/spec/ecloud/requests/power_off_spec.rb b/spec/ecloud/requests/power_off_spec.rb deleted file mode 100644 index 3f7a9b44a..000000000 --- a/spec/ecloud/requests/power_off_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:power_off) } - - describe :power_off, :type => :vcloud_request do - context "with a valid vapp uri" do - before { @mock_vm.power_on!; @power_off = @vcloud.power_off(@mock_vm.href(:power_off)) } - subject { @power_off } - - it_should_behave_like "all responses" - #it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" } - - specify { @mock_vm.status.should == 2 } - - describe :body do - subject { @power_off.body } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - end - end - - context "with a vapp uri that doesn't exist" do - subject { lambda { @vcloud.power_off(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } } - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/requests/power_on_spec.rb b/spec/ecloud/requests/power_on_spec.rb deleted file mode 100644 index e51d0331f..000000000 --- a/spec/ecloud/requests/power_on_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should respond_to(:power_on) } - - describe :power_on, :type => :vcloud_request do - context "with a valid vapp uri" do - before { @mock_vm.power_off!; @power_on = @vcloud.power_on(@mock_vm.href(:power_on)) } - subject { @power_on } - - it_should_behave_like "all responses" - #it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" } - - specify { @mock_vm.status.should == 4 } - - describe :body do - subject { @power_on.body } - - it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys - end - end - - context "with a vapp uri that doesn't exist" do - subject { lambda { @vcloud.power_on(URI.parse('https://www.fakey.com/api/v0.8/vapp/9999')) } } - it_should_behave_like "a request for a resource that doesn't exist" - end - end - end -else -end - diff --git a/spec/ecloud/spec_helper.rb b/spec/ecloud/spec_helper.rb deleted file mode 100644 index be428ff7f..000000000 --- a/spec/ecloud/spec_helper.rb +++ /dev/null @@ -1,387 +0,0 @@ -require 'spec' -require 'pp' - -require 'fog' -require 'fog/bin' -require 'fog/bin/ecloud' - -module Spec - module Example - module Subject - module ExampleGroupMethods - def its(attribute, &block) - describe(attribute) do - define_method(:subject) { s = super(); s.is_a?(Hash) ? s[attribute] : s.send(attribute) } - it(&block) - end - end - end - end - end -end - -#Initialize this to a known seed -srand 1234 - -Fog.mock! if ENV['FOG_MOCK'] - -def arrayify(item) - item.is_a?(Array) ? item : [ item ] -end - -def ecloud_disabled_default_monitor - {:url_send_string=>nil, :receive_string=>nil, :response_timeout=>2, :retries=>3, :is_enabled=>"true", :down_time=>30, :type=>"Disabled", :http_headers=>nil, :interval=>5, :downtime=>nil} -end - -shared_examples_for "all responses" do - it { should be_an_instance_of(Excon::Response) } - it { should respond_to(:body) } - it { should respond_to(:headers) } - it { should have_at_least(1).body } - it { should have_at_least(0).headers } - its(:body) { should be_an_instance_of(Hash) } - its(:headers) { should be_an_instance_of(Hash) } -end - -shared_examples_for "all delete responses" do - it { should be_an_instance_of(Excon::Response) } - it { should respond_to(:body) } - it { should respond_to(:headers) } - its(:headers) { should be_an_instance_of(Hash) } -end - -shared_examples_for "it has a Content-Type header" do - its(:headers) { should include("Content-Type") } -end - -shared_examples_for "all rel=down vcloud links" do - it { should be_an_instance_of(Struct::VcloudLink) } - specify { subject.rel.should == "down" } -end - -shared_examples_for "all vcloud links w/o a rel" do - it { should be_an_instance_of(Struct::VcloudLink) } - specify { subject.rel.should == nil } -end - -shared_examples_for "all vcloud catalog links" do - specify { subject.type.should == "application/vnd.vmware.vcloud.catalog+xml" } -end - -shared_examples_for "all tmrk ecloud publicIpList links" do - specify { subject.type.should == "application/vnd.tmrk.ecloud.publicIpsList+xml" } -end - -shared_examples_for "all tmrk ecloud firewallAclList links" do - specify { subject.type.should == "application/vnd.tmrk.ecloud.firewallAclsList+xml" } -end - -shared_examples_for "all tmrk ecloud internetServicesList links" do - specify { subject.type.should == "application/vnd.tmrk.ecloud.internetServicesList+xml" } -end - -shared_examples_for "all vcloud application/xml types" do - specify { subject.type.should == "application/xml" } -end - -shared_examples_for "a vapp type" do - specify { subject.type.should == "application/vnd.vmware.vcloud.vApp+xml" } -end - -shared_examples_for "all vcloud network types" do - specify { subject.type.should == "application/vnd.vmware.vcloud.network+xml" } -end - -shared_examples_for "all login requests" do - - it { should respond_to(:login) } - - describe "#login" do - before { @login = @vcloud.login } - subject { @login } - - it_should_behave_like("all responses") - - its(:headers) { should include("Set-Cookie") } - - describe "#body" do - subject { @login.body } - - it { should have(4).items } - it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys - it { should include(:Org) } - - describe ":Org" do - subject { arrayify(@login.body[:Org]) } - - specify do - subject.each do |org| - org.should include(:type) - org[:type].should be_of_type("application/vnd.vmware.vcloud.org+xml") - org.should include(:name) - org[:name].should be_an_instance_of(String) - org.should include(:href) - org[:href].should(be_a_url) - end - end - end - end - end -end - -shared_examples_for "it has a vcloud v0.8 xmlns" do - its(:xmlns) { should == 'http://www.vmware.com/vcloud/v0.8' } -end - -shared_examples_for "it has the proper xmlns_xsi" do - its(:xmlns_xsi) { should == "http://www.w3.org/2001/XMLSchema-instance" } -end - -shared_examples_for "it has the proper xmlns_xsd" do - its(:xmlns_xsd) { should == "http://www.w3.org/2001/XMLSchema" } -end - -shared_examples_for "it has the standard xmlns attributes" do - it_should_behave_like("it has the proper xmlns_xsi") - it_should_behave_like("it has the proper xmlns_xsd") -end - -shared_examples_for "it has the standard vcloud v0.8 xmlns attributes" do - it_should_behave_like("it has a vcloud v0.8 xmlns") - it_should_behave_like("it has the standard xmlns attributes") -end - -shared_examples_for "a request for a resource that doesn't exist" do - it { should raise_error(Excon::Errors::Unauthorized) } -end - -shared_examples_for "a vdc catalog link" do - it_should_behave_like "all rel=down vcloud links" - it_should_behave_like "all vcloud catalog links" - its(:href) { should == URI.parse(@mock_vdc[:href] + "/catalog") } -end - -shared_examples_for "a tmrk network link" do - it_should_behave_like("all vcloud links w/o a rel") - it_should_behave_like("all vcloud network types") -end - -shared_examples_for "the mocked tmrk network links" do - it { should have(2).networks } - - describe "[0]" do - subject { @vdc.body.networks[0] } - it_should_behave_like "a tmrk network link" - its(:href) { should == URI.parse(@mock_vdc[:networks][0][:href]) } - its(:name) { should == @mock_vdc[:networks][0][:name] } - end - - describe "[1]" do - subject { @vdc.body.networks[1] } - it_should_behave_like "a tmrk network link" - its(:href) { should == URI.parse(@mock_vdc[:networks][1][:href]) } - its(:name) { should == @mock_vdc[:networks][1][:name] } - end -end - -shared_examples_for "the mocked tmrk resource entity links" do - it { should have(3).resource_entities } - - describe "[0]" do - subject { @vdc.body.resource_entities[0] } - it_should_behave_like("a vapp type") - it_should_behave_like("all vcloud links w/o a rel") - its(:href) { should == URI.parse(@mock_vdc[:vms][0][:href]) } - its(:name) { should == @mock_vdc[:vms][0][:name] } - end - describe "[1]" do - subject { @vdc.body.resource_entities[1] } - it_should_behave_like("a vapp type") - it_should_behave_like("all vcloud links w/o a rel") - its(:href) { should == URI.parse(@mock_vdc[:vms][1][:href]) } - its(:name) { should == @mock_vdc[:vms][1][:name] } - end - describe "[2]" do - subject { @vdc.body.resource_entities[2] } - it_should_behave_like("a vapp type") - it_should_behave_like("all vcloud links w/o a rel") - its(:href) { should == URI.parse(@mock_vdc[:vms][2][:href]) } - its(:name) { should == @mock_vdc[:vms][2][:name] } - end -end - -Spec::Example::ExampleGroupFactory.register(:mock_vcloud_request, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:mock_vcloud_model, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:mock_tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:mock_tmrk_ecloud_model, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:vcloud_request, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup)) -Spec::Example::ExampleGroupFactory.register(:tmrk_vcloud_request, Class.new(Spec::Example::ExampleGroup)) - -def setup_generic_mock_data - @mock_version = @mock_data.versions.first - @mock_organization = @mock_data.organizations.first - @mock_vdc = @mock_organization.vdcs.first - @mock_vm = @mock_vdc.virtual_machines.first - @mock_network = @mock_vdc.networks.first -end - -def setup_ecloud_mock_data - @base_url = Fog::Compute::Ecloud::Mock.base_url - @mock_data = Fog::Compute::Ecloud::Mock.data - setup_generic_mock_data - @mock_vdc_service_collection = @mock_vdc.internet_service_collection - @mock_public_ip_collection = @mock_vdc.public_ip_collection - @mock_public_ip = @mock_public_ip_collection.items.first - @mock_service_collection = @mock_public_ip.internet_service_collection - @mock_service = @mock_service_collection.items.first - @mock_backup_service = @mock_vdc_service_collection.backup_internet_services.first - @mock_node_collection = @mock_service.node_collection - @mock_node = @mock_node_collection.items.first - @mock_catalog = @mock_vdc.catalog - @mock_catalog_item = @mock_catalog.items.first - @mock_network_ip_collection = @mock_network.ip_collection - @mock_network_ip = @mock_network_ip_collection.items.values.first - @mock_network_extensions = @mock_network.extensions -end - -def setup_vcloud_mock_data - @base_url = Fog::Compute::Ecloud::Mock.base_url - @mock_data = Fog::Compute::Ecloud::Mock.data - setup_generic_mock_data -end - -Spec::Runner.configure do |config| - config.after(:all) do - Fog::Compute::Ecloud::Mock.reset - end - - config.before(:each, :type => :vcloud_request) do - @vcloud = Fog::Compute::Ecloud.new(Fog.credentials[:vcloud][:ecloud]) - end - - config.before(:each, :type => :mock_tmrk_ecloud_request) do - Fog::Compute::Ecloud::Mock.reset - setup_ecloud_mock_data - @vcloud = Fog::Compute::Ecloud.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::Compute::Ecloud::Mock.reset - setup_ecloud_mock_data - @vcloud = Fog::Compute::Ecloud.new(:ecloud_username => "foo", :ecloud_password => "bar", :ecloud_versions_uri => "http://fakey.com/api/versions") - end -end - -Spec::Matchers.define :have_only_these_attributes do |expected| - match do |actual| - attributes = actual.instance_variable_get('@attributes') - attributes.all? { |attribute| expected.include?(attribute) } && ( expected.length == attributes.length ) - end - - failure_message_for_should do |actual| - msg = "Expected: [#{expected.map{|e| ":#{e}"}.join(", ")}]\n" - msg += "Got: [#{actual.instance_variable_get('@attributes').map{|a| ":#{a}"}.join(", ")}]" - msg - end -end - -Spec::Matchers.define :have_identity do |expected| - match do |actual| - actual.instance_variable_get('@identity').should == expected - end - - failure_message_for_should do |actual| - "Expected: '#{expected}', but got: '#{actual.instance_variable_get('@identity')}'" - end -end - -Spec::Matchers.define :have_members_of_the_right_model do - match do |actual| - actual.all? { |member| member.is_a?(actual.model) } - end -end - -Spec::Matchers.define :have_key_with_value do |expected_key, expected_value| - match do |actual| - actual.has_key?(expected_key) && actual[expected_key] == expected_value - end -end - -Spec::Matchers.define :have_key_with_array do |expected_key, expected_array| - match do |actual| - actual[expected_key].all? { |item| expected_array.include?(item) } && actual[expected_key].length == expected_array.length - end - failure_message_for_should do |actual| - "Items not found in array:\n#{expected_array.select { |expected_item| !actual[expected_key].include?(expected_item) }.map { |item| item.inspect }.join("\n")}\n" + - "Original items:\n#{actual[expected_key].map { |item| item.inspect }.join("\n") }\n"+ - "Length Difference: #{expected_array.length - actual[expected_key].length}" - end -end - -Spec::Matchers.define :have_headers_denoting_a_content_type_of do |expected| - match do |actual| - actual.headers["Content-Type"] == expected - end -end - -Spec::Matchers.define :have_keys_with_values do |expected| - match do |actual| - actual.each_pair.all? do |key, value| - expected.has_key?(key) && expected[key] == value - end - end -end - -Spec::Matchers.define :be_a_vapp_link_to do |expected| - match do |actual| - actual.is_a?(Hash) and - actual[:type] == "application/vnd.vmware.vcloud.vApp+xml" and - actual[:href] == expected.href and - actual[:name] == expected.name - end -end - -Spec::Matchers.define :be_a_network_link_to do |expected| - match do |actual| - actual.is_a?(Hash) and - actual[:type] == "application/vnd.vmware.vcloud.network+xml" and - actual[:href] == expected.href and - actual[:name] == expected.name - end -end - -Spec::Matchers.define :have_all_attributes_be_nil do - match do |actual| - actual.class.attributes.all? { |attribute| actual.send(attribute.to_sym) == nil } - end -end - -Spec::Matchers.define :be_a_url do - match do |actual| - actual.match(/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix) - end -end - -Spec::Matchers.define :be_either_a_hash_or_array do - match do |actual| - actual.is_a?(Hash) || actual.is_a?(Array) - end -end - -Spec::Matchers.define :be_a_known_vmware_type do - match do |actual| - ["application/vnd.vmware.vcloud.org+xml"].include?(actual) - end -end - -Spec::Matchers.define :be_of_type do |type| - match do |actual| - actual == type || - if actual.is_a?(Hash) && actual[:type] - actual[:type] == type - end || - if actual.respond_to(:type) - actual.type == type - end - end -end diff --git a/spec/ecloud/vcloud_spec.rb b/spec/ecloud/vcloud_spec.rb deleted file mode 100644 index a58c8c1f5..000000000 --- a/spec/ecloud/vcloud_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'ecloud/spec_helper' - -if Fog.mocking? - describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do - subject { @vcloud } - - it { should be_an_instance_of(Fog::Compute::Ecloud::Mock) } - - it { should respond_to(:default_organization_uri) } - - it { should respond_to(:supported_versions) } - - it { should have_at_least(1).supported_versions } - - its(:default_organization_uri) { should == @mock_organization.href } - - end -end From 464c154b51cf5a66109ea9a4617f890838ea31c2 Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Thu, 7 Jun 2012 12:51:42 -0400 Subject: [PATCH 2/2] fixed method name --- lib/fog/ecloud/requests/compute/get_server.rb | 2 +- lib/fog/ecloud/requests/compute/get_task.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fog/ecloud/requests/compute/get_server.rb b/lib/fog/ecloud/requests/compute/get_server.rb index 4e70b4dac..f606bb0e8 100644 --- a/lib/fog/ecloud/requests/compute/get_server.rb +++ b/lib/fog/ecloud/requests/compute/get_server.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :get_task + basic_request :get_server end end diff --git a/lib/fog/ecloud/requests/compute/get_task.rb b/lib/fog/ecloud/requests/compute/get_task.rb index f606bb0e8..4e70b4dac 100644 --- a/lib/fog/ecloud/requests/compute/get_task.rb +++ b/lib/fog/ecloud/requests/compute/get_task.rb @@ -3,7 +3,7 @@ module Fog class Ecloud class Real - basic_request :get_server + basic_request :get_task end end