Module: Fog::Compute::Ecloud::Shared
- 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_import.rb,
lib/fog/ecloud/requests/compute/internet_service_create.rb,
lib/fog/ecloud/requests/compute/virtual_machine_attach_disk.rb,
lib/fog/ecloud/requests/compute/virtual_machine_detach_disk.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_edit_assigned_ips.rb,
lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
Returns the value of attribute base_path.
-
#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_attach_disk(options) ⇒ Object
- #build_request_body_copy(options) ⇒ Object
- #build_request_body_detach_disk(options) ⇒ Object
- #build_request_body_edit(options) ⇒ Object
- #build_request_body_edit_assigned_ips(networks) ⇒ Object
- #build_request_body_identical(options) ⇒ Object
- #build_request_body_import(options) ⇒ Object
- #default_organization_uri ⇒ Object
- #id_from_uri(uri) ⇒ 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
Instance Attribute Details
#base_path ⇒ Object
Returns the value of attribute base_path.
250 251 252 |
# File 'lib/fog/ecloud/compute.rb', line 250 def base_path @base_path end |
#versions_uri ⇒ Object (readonly)
Returns the value of attribute versions_uri.
251 252 253 |
# File 'lib/fog/ecloud/compute.rb', line 251 def versions_uri @versions_uri end |
Instance Method Details
#build_compute_pool_body_edit(options) ⇒ Object
12 13 14 15 16 |
# File 'lib/fog/ecloud/requests/compute/compute_pool_edit.rb', line 12 def build_compute_pool_body_edit() xml = Builder::XmlMarkup.new xml.ComputePool(:name => [:name]) do end end |
#build_node_service_body_edit(options) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/ecloud/requests/compute/node_service_edit.rb', line 12 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
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_create_from_template.rb', line 28 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 xml.SshKey(:href => [:ssh_key_uri]) end end xml.PoweredOn [:powered_on] xml.Template(:href => [:template_uri], :type => [:template_type]) end end |
#build_request_body_attach_disk(options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_attach_disk.rb', line 5 def build_request_body_attach_disk() xml = Builder::XmlMarkup.new xml.AttachDisks(:name => [:name]) do xml.DetachedDisks do xml.DetachedDisk(:href => [:href], :name => [:name], :type => "application/vnd.tmrk.cloud.detachedDisk") end end end |
#build_request_body_copy(options) ⇒ Object
27 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 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy.rb', line 27 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_detach_disk(options) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_detach_disk.rb', line 5 def build_request_body_detach_disk() xml = Builder::XmlMarkup.new xml.DetachDisk(:name => [:name]) do xml.Description [:description] xml.Disk do xml.Index [:disk][:Index] end end end |
#build_request_body_edit(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_edit.rb', line 12 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_edit_assigned_ips(networks) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_edit_assigned_ips.rb', line 5 def build_request_body_edit_assigned_ips(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_identical(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb', line 14 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
16 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 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_import.rb', line 16 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
263 264 265 |
# File 'lib/fog/ecloud/compute.rb', line 263 def default_organization_uri "#{@base_path}/organizations" end |
#id_from_uri(uri) ⇒ Object
259 260 261 |
# File 'lib/fog/ecloud/compute.rb', line 259 def id_from_uri(uri) uri.match(/(\d+)$/)[1].to_i end |
#validate_create_server_options(template_uri, options) ⇒ Object
5 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_create_from_template.rb', line 5 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| .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 [:template_uri] = template_uri end |
#validate_create_server_options_copy(template_uri, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy.rb', line 5 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| .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
5 6 7 8 9 10 11 12 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb', line 5 def (template_uri, ) required_opts = [:name, :row, :group, :source] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_data(required_opts = [], options = {}) ⇒ Object
253 254 255 256 257 |
# File 'lib/fog/ecloud/compute.rb', line 253 def validate_data(required_opts = [], = {}) unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_compute_pool_options(options) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/fog/ecloud/requests/compute/compute_pool_edit.rb', line 5 def () required_opts = [:name] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_internet_service_options(options) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/ecloud/requests/compute/internet_service_edit.rb', line 5 def () required_opts = [:name, :enabled, :persistence] unless required_opts.all? { |opt| .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
5 6 7 8 9 10 |
# File 'lib/fog/ecloud/requests/compute/node_service_edit.rb', line 5 def () required_opts = [:name, :enabled] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_edit_server_options(options) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_edit.rb', line 5 def () required_opts = [:name] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |
#validate_import_server_options(template_uri, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_import.rb', line 5 def (template_uri, ) required_opts = [:name, :cpus, :memory, :row, :group, :network_uri, :catalog_network_name] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end [: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.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.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
5 6 7 8 9 10 |
# File 'lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb', line 5 def () required_opts = [:file, :path, :credentials] unless required_opts.all? { |opt| .key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - .keys).map(&:inspect).join(", ")}") end end |