Module: Fog::Compute::Ecloud::Shared
- Included in:
- Real
- Defined in:
- lib/fog/ecloud/compute.rb,
lib/fog/ecloud/requests/compute/compute_pool_edit.rb,
lib/fog/ecloud/requests/compute/node_service_edit.rb,
lib/fog/ecloud/requests/compute/node_service_create.rb,
lib/fog/ecloud/requests/compute/virtual_machine_copy.rb,
lib/fog/ecloud/requests/compute/virtual_machine_edit.rb,
lib/fog/ecloud/requests/compute/internet_service_edit.rb,
lib/fog/ecloud/requests/compute/virtual_machine_add_ip.rb,
lib/fog/ecloud/requests/compute/virtual_machine_import.rb,
lib/fog/ecloud/requests/compute/internet_service_create.rb,
lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb,
lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb,
lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb
Instance Attribute Summary collapse
-
#versions_uri ⇒ Object
readonly
Returns the value of attribute versions_uri.
Instance Method Summary collapse
- #build_compute_pool_body_edit(options) ⇒ Object
- #build_node_service_body_edit(options) ⇒ Object
- #build_request_body(options) ⇒ Object
- #build_request_body_add_ip(networks) ⇒ Object
- #build_request_body_copy(options) ⇒ Object
- #build_request_body_edit(options) ⇒ Object
- #build_request_body_identical(options) ⇒ Object
- #build_request_body_import(options) ⇒ Object
- #default_organization_uri ⇒ Object
-
#do_login ⇒ Object
login handles the auth, but we just need the Set-Cookie header from that call.
- #ecloud_xmlns ⇒ Object
- #ensure_unparsed(uri) ⇒ Object
- #supported_versions ⇒ Object
- #validate_create_server_options(template_uri, options) ⇒ Object
- #validate_create_server_options_copy(template_uri, options) ⇒ Object
- #validate_create_server_options_identical(template_uri, options) ⇒ Object
- #validate_data(required_opts = [], options = {}) ⇒ Object
- #validate_edit_compute_pool_options(options) ⇒ Object
- #validate_edit_internet_service_options(options) ⇒ Object
- #validate_edit_node_service_options(options) ⇒ Object
- #validate_edit_server_options(options) ⇒ Object
- #validate_import_server_options(template_uri, options) ⇒ Object
- #validate_internet_service_data(service_data) ⇒ Object
- #validate_node_service_data(service_data) ⇒ Object
- #validate_upload_file_options(options) ⇒ Object
- #xmlns ⇒ Object
Instance Attribute Details
#versions_uri ⇒ Object (readonly)
Returns the value of attribute versions_uri.
264 265 266 |
# File 'lib/fog/ecloud/compute.rb', line 264 def versions_uri @versions_uri end |
Instance Method Details
#build_compute_pool_body_edit(options) ⇒ Object
13 14 15 16 17 |
# File 'lib/fog/ecloud/requests/compute/compute_pool_edit.rb', line 13 def build_compute_pool_body_edit() xml = Builder::XmlMarkup.new xml.ComputePool(:name => [:name]) do end end |
#build_node_service_body_edit(options) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/fog/ecloud/requests/compute/node_service_edit.rb', line 13 def build_node_service_body_edit() xml = Builder::XmlMarkup.new xml.NodeService(:name => [:name]) do xml.Enabled [:enabled] if [:description] xml.Description [:description] end end end |
#build_request_body(options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb', line 35 def build_request_body() xml = Builder::XmlMarkup.new xml.CreateVirtualMachine(:name => [:name]) do xml.ProcessorCount [:cpus] xml.Memory do xml.Unit "MB" xml.Value [:memory] end xml.Layout do xml.NewRow [:row] xml.NewGroup [:group] end xml.Description [:description] xml.Tags do [:tags].each do |tag| xml.Tag tag end end if [:customization] == :windows xml.WindowsCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do [: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 [:dns_settings] xml.DnsSettings do xml.PrimaryDns [:dns_settings][:primary_dns] if [:dns_settings][:secondary_dns] xml.SecondaryDns [:dns_settings][:secondary_dns] end end end end xml.Password [:windows_password] if [:windows_license_key] xml.LicenseKey [:windows_license_key] end end else xml.LinuxCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [: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 [:dns_settings] xml.DnsSettings do xml.PrimaryDns [:dns_settings][:primary_dns] if [:dns_settings][:secondary_dns] xml.SecondaryDns [:dns_settings][:secondary_dns] end end end end end xml.SshKey(:href => [:ssh_key_uri]) end xml.PoweredOn [:powered_on] xml.Template(:href => [:template_uri], :type => [:template_type]) end end |
#build_request_body_add_ip(networks) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_add_ip.rb', line 6 def build_request_body_add_ip(networks) xml = Builder::XmlMarkup.new xml.AssignedIpAddresses do xml.Networks do networks.each do |network| xml.Network(:href => network[:href], :type => network[:type]) do xml.IpAddresses do network[:ips].each do |ip| xml.IpAddress ip end end end end end end end |
#build_request_body_copy(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy.rb', line 28 def build_request_body_copy() xml = Builder::XmlMarkup.new xml.CopyVirtualMachine(:name => [:name]) do xml.Source(:href => [:source], :type => "application/vnd.tmrk.cloud.virtualMachine") xml.ProcessorCount [:cpus] xml.Memory do xml.Unit "MB" xml.Value [:memory] end xml.Layout do xml.NewRow [:row] xml.NewGroup [:group] end if [:customization] == :windows xml.WindowsCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do [: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 [:dns_settings] xml.DnsSettings do xml.PrimaryDns [:dns_settings][:primary_dns] if [:dns_settings][:secondary_dns] xml.SecondaryDns [:dns_settings][:secondary_dns] end end end end xml.Password [:windows_password] if [:windows_license_key] xml.LicenseKey [:windows_license_key] end end else xml.LinuxCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [: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 [:dns_settings] xml.DnsSettings do xml.PrimaryDns [:dns_settings][:primary_dns] if [:dns_settings][:secondary_dns] xml.SecondaryDns [:dns_settings][:secondary_dns] end end end end end xml.SshKey(:href => [:ssh_key_uri]) end xml.Description [:description] xml.Tags do [:tags].each do |tag| xml.Tag tag end end xml.PoweredOn [:powered_on] end end |
#build_request_body_edit(options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_edit.rb', line 13 def build_request_body_edit() xml = Builder::XmlMarkup.new xml.VirtualMachine(:name => [:name]) do if [:description] xml.Description [:description] end if [:tags] xml.Tags do [:tags].each do |tag| xml.Tag tag end end end end end |
#build_request_body_identical(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb', line 15 def build_request_body_identical() xml = Builder::XmlMarkup.new xml.CopyIdenticalVirtualMachine(:name => [:name]) do xml.Source(:href => [:source], :type => "application/vnd.tmrk.cloud.virtualMachine") xml.Layout do xml.NewRow [:row] xml.NewGroup [:group] end xml.Description [:description] end end |
#build_request_body_import(options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_import.rb', line 17 def build_request_body_import() xml = Builder::XmlMarkup.new xml.ImportVirtualMachine(:name => [:name]) do xml.ProcessorCount [:cpus] xml.Memory do xml.Unit "MB" xml.Value [:memory] end xml.Layout do xml.NewRow [:row] xml.NewGroup [:group] end xml.Description [:description] if [:tags] xml.Tags do [:tags].each do |tag| xml.Tag tag end end end xml.CatalogEntry(:href => [:template_uri]) xml.NetworkMappings do xml.NetworkMapping(:name => [:catalog_network_name]) do xml.Network(:href => [:network_uri][0]) end end if [:operating_system] xml.OperatingSystem(:href => [:operating_system][:href], :name => [:operating_system][:name], :type => "application/vnd.tmrk.cloud.operatingSystem") end end end |
#default_organization_uri ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/fog/ecloud/compute.rb', line 266 def default_organization_uri @default_organization_uri ||= begin unless @login_results do_login end case @login_results.body[:Org] when Array @login_results.body[:Org].first[:href] when Hash @login_results.body[:Org][:href] else nil end end end |
#do_login ⇒ Object
login handles the auth, but we just need the Set-Cookie header from that call.
284 285 286 |
# File 'lib/fog/ecloud/compute.rb', line 284 def do_login @login_results = get_organizations end |
#ecloud_xmlns ⇒ Object
288 289 290 291 292 293 |
# File 'lib/fog/ecloud/compute.rb', line 288 def ecloud_xmlns { "xmlns" => "urn:tmrk:eCloudExtensions-2.8", "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" } end |
#ensure_unparsed(uri) ⇒ Object
295 296 297 298 299 300 301 |
# File 'lib/fog/ecloud/compute.rb', line 295 def ensure_unparsed(uri) if uri.is_a?(String) uri else uri.to_s end end |
#supported_versions ⇒ Object
303 304 305 |
# File 'lib/fog/ecloud/compute.rb', line 303 def supported_versions @supported_versions ||= get_versions(@versions_uri).body[:VersionInfo] end |
#validate_create_server_options(template_uri, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb', line 6 def (template_uri, ) required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri] if [:customization] == :windows required_opts.push(:windows_password) else required_opts.push(:ssh_key_uri) end unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end if template_uri.scan(/\/catalog\/\d+/)[0] [:template_type] = get_catalog_item(template_uri).body[:type] elsif template_uri.scan(/\/templates\/\d+/)[0] [:template_type] = get_template(template_uri).body[:type] end [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [:network_uri].map! do |uri| network = get_network(uri).body if [:ips] ip = [:ips][[:network_uri].index(uri)] end {:href => uri, :name => network[:name], :ip => ip} end [:template_uri] = template_uri end |
#validate_create_server_options_copy(template_uri, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy.rb', line 6 def (template_uri, ) required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri, :source] if [:customization] == :windows required_opts.push(:windows_password) else required_opts.push(:ssh_key_uri) end unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [:network_uri].map! do |uri| network = get_network(uri).body if [:ips] ip = [:ips][[:network_uri].index(uri)] end {:href => uri, :name => network[:name], :ip => ip} end end |
#validate_create_server_options_identical(template_uri, options) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb', line 6 def (template_uri, ) required_opts = [:name, :row, :group, :source] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_data(required_opts = [], options = {}) ⇒ Object
313 314 315 316 317 |
# File 'lib/fog/ecloud/compute.rb', line 313 def validate_data(required_opts = [], = {}) unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_compute_pool_options(options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/ecloud/requests/compute/compute_pool_edit.rb', line 6 def () required_opts = [:name] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_internet_service_options(options) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fog/ecloud/requests/compute/internet_service_edit.rb', line 6 def () required_opts = [:name, :enabled, :persistence] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end raise ArgumentError.new("Required data missing: #{:persistence[:type]}") unless [:persistence][:type] end |
#validate_edit_node_service_options(options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/ecloud/requests/compute/node_service_edit.rb', line 6 def () required_opts = [:name, :enabled] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_server_options(options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_edit.rb', line 6 def () required_opts = [:name] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_import_server_options(template_uri, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_import.rb', line 6 def (template_uri, ) required_opts = [:name, :cpus, :memory, :row, :group, :network_uri, :catalog_network_name] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [:template_uri] = template_uri end |
#validate_internet_service_data(service_data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/ecloud/requests/compute/internet_service_create.rb', line 5 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 |
#validate_node_service_data(service_data) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/fog/ecloud/requests/compute/node_service_create.rb', line 5 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 |
#validate_upload_file_options(options) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb', line 6 def () required_opts = [:file, :path, :credentials] unless required_opts.all? { |opt| .has_key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#xmlns ⇒ Object
307 308 309 310 311 |
# File 'lib/fog/ecloud/compute.rb', line 307 def xmlns { "xmlns" => "http://www.vmware.com/vcloud/v0.8", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" } end |