Class: Fog::Compute::Ecloud::Real

Inherits:
Object
  • Object
show all
Includes:
Errors, Shared
Defined in:
lib/fog/compute/ecloud.rb,
lib/fog/compute/ecloud/requests/get_row.rb,
lib/fog/compute/ecloud/requests/get_tag.rb,
lib/fog/compute/ecloud/requests/get_node.rb,
lib/fog/compute/ecloud/requests/get_rnat.rb,
lib/fog/compute/ecloud/requests/get_role.rb,
lib/fog/compute/ecloud/requests/get_rows.rb,
lib/fog/compute/ecloud/requests/get_tags.rb,
lib/fog/compute/ecloud/requests/get_task.rb,
lib/fog/compute/ecloud/requests/get_user.rb,
lib/fog/compute/ecloud/requests/power_on.rb,
lib/fog/compute/ecloud/requests/get_group.rb,
lib/fog/compute/ecloud/requests/get_nodes.rb,
lib/fog/compute/ecloud/requests/get_rnats.rb,
lib/fog/compute/ecloud/requests/get_roles.rb,
lib/fog/compute/ecloud/requests/get_tasks.rb,
lib/fog/compute/ecloud/requests/get_users.rb,
lib/fog/compute/ecloud/requests/power_off.rb,
lib/fog/compute/ecloud/requests/rows_edit.rb,
lib/fog/compute/ecloud/requests/get_groups.rb,
lib/fog/compute/ecloud/requests/get_layout.rb,
lib/fog/compute/ecloud/requests/get_server.rb,
lib/fog/compute/ecloud/requests/get_api_key.rb,
lib/fog/compute/ecloud/requests/get_catalog.rb,
lib/fog/compute/ecloud/requests/get_layouts.rb,
lib/fog/compute/ecloud/requests/get_monitor.rb,
lib/fog/compute/ecloud/requests/get_network.rb,
lib/fog/compute/ecloud/requests/get_process.rb,
lib/fog/compute/ecloud/requests/get_servers.rb,
lib/fog/compute/ecloud/requests/get_ssh_key.rb,
lib/fog/compute/ecloud/requests/groups_edit.rb,
lib/fog/compute/ecloud/requests/power_reset.rb,
lib/fog/compute/ecloud/requests/rows_create.rb,
lib/fog/compute/ecloud/requests/rows_delete.rb,
lib/fog/compute/ecloud/requests/rows_moveup.rb,
lib/fog/compute/ecloud/requests/get_api_keys.rb,
lib/fog/compute/ecloud/requests/get_location.rb,
lib/fog/compute/ecloud/requests/get_monitors.rb,
lib/fog/compute/ecloud/requests/get_networks.rb,
lib/fog/compute/ecloud/requests/get_ssh_keys.rb,
lib/fog/compute/ecloud/requests/get_template.rb,
lib/fog/compute/ecloud/requests/ssh_key_edit.rb,
lib/fog/compute/ecloud/requests/get_locations.rb,
lib/fog/compute/ecloud/requests/get_processes.rb,
lib/fog/compute/ecloud/requests/get_public_ip.rb,
lib/fog/compute/ecloud/requests/get_templates.rb,
lib/fog/compute/ecloud/requests/groups_create.rb,
lib/fog/compute/ecloud/requests/groups_delete.rb,
lib/fog/compute/ecloud/requests/groups_moveup.rb,
lib/fog/compute/ecloud/requests/rows_movedown.rb,
lib/fog/compute/ecloud/requests/get_ip_address.rb,
lib/fog/compute/ecloud/requests/get_public_ips.rb,
lib/fog/compute/ecloud/requests/power_shutdown.rb,
lib/fog/compute/ecloud/requests/ssh_key_create.rb,
lib/fog/compute/ecloud/requests/ssh_key_delete.rb,
lib/fog/compute/ecloud/requests/get_association.rb,
lib/fog/compute/ecloud/requests/get_environment.rb,
lib/fog/compute/ecloud/requests/groups_movedown.rb,
lib/fog/compute/ecloud/requests/monitors_enable.rb,
lib/fog/compute/ecloud/requests/get_associations.rb,
lib/fog/compute/ecloud/requests/get_catalog_item.rb,
lib/fog/compute/ecloud/requests/get_compute_pool.rb,
lib/fog/compute/ecloud/requests/get_firewall_acl.rb,
lib/fog/compute/ecloud/requests/get_login_banner.rb,
lib/fog/compute/ecloud/requests/get_organization.rb,
lib/fog/compute/ecloud/requests/monitors_disable.rb,
lib/fog/compute/ecloud/requests/compute_pool_edit.rb,
lib/fog/compute/ecloud/requests/get_compute_pools.rb,
lib/fog/compute/ecloud/requests/get_detached_disk.rb,
lib/fog/compute/ecloud/requests/get_firewall_acls.rb,
lib/fog/compute/ecloud/requests/get_guest_process.rb,
lib/fog/compute/ecloud/requests/get_login_banners.rb,
lib/fog/compute/ecloud/requests/get_organizations.rb,
lib/fog/compute/ecloud/requests/monitors_edit_ecv.rb,
lib/fog/compute/ecloud/requests/node_service_edit.rb,
lib/fog/compute/ecloud/requests/get_detached_disks.rb,
lib/fog/compute/ecloud/requests/get_support_ticket.rb,
lib/fog/compute/ecloud/requests/monitors_edit_http.rb,
lib/fog/compute/ecloud/requests/monitors_edit_ping.rb,
lib/fog/compute/ecloud/requests/public_ip_activate.rb,
lib/fog/compute/ecloud/requests/get_guest_processes.rb,
lib/fog/compute/ecloud/requests/get_network_summary.rb,
lib/fog/compute/ecloud/requests/get_physical_device.rb,
lib/fog/compute/ecloud/requests/get_support_tickets.rb,
lib/fog/compute/ecloud/requests/monitors_create_ecv.rb,
lib/fog/compute/ecloud/requests/node_service_create.rb,
lib/fog/compute/ecloud/requests/node_service_delete.rb,
lib/fog/compute/ecloud/requests/firewall_acls_create.rb,
lib/fog/compute/ecloud/requests/firewall_acls_delete.rb,
lib/fog/compute/ecloud/requests/get_cpu_usage_detail.rb,
lib/fog/compute/ecloud/requests/get_internet_service.rb,
lib/fog/compute/ecloud/requests/get_operating_system.rb,
lib/fog/compute/ecloud/requests/get_physical_devices.rb,
lib/fog/compute/ecloud/requests/monitors_create_http.rb,
lib/fog/compute/ecloud/requests/monitors_create_ping.rb,
lib/fog/compute/ecloud/requests/virtual_machine_copy.rb,
lib/fog/compute/ecloud/requests/virtual_machine_edit.rb,
lib/fog/compute/ecloud/requests/get_internet_services.rb,
lib/fog/compute/ecloud/requests/internet_service_edit.rb,
lib/fog/compute/ecloud/requests/get_admin_organization.rb,
lib/fog/compute/ecloud/requests/virtual_machine_delete.rb,
lib/fog/compute/ecloud/requests/virtual_machine_import.rb,
lib/fog/compute/ecloud/requests/admin_edit_login_banner.rb,
lib/fog/compute/ecloud/requests/get_memory_usage_detail.rb,
lib/fog/compute/ecloud/requests/internet_service_create.rb,
lib/fog/compute/ecloud/requests/internet_service_delete.rb,
lib/fog/compute/ecloud/requests/monitors_create_default.rb,
lib/fog/compute/ecloud/requests/get_authentication_level.rb,
lib/fog/compute/ecloud/requests/get_storage_usage_detail.rb,
lib/fog/compute/ecloud/requests/monitors_create_loopback.rb,
lib/fog/compute/ecloud/requests/rnat_associations_delete.rb,
lib/fog/compute/ecloud/requests/get_authentication_levels.rb,
lib/fog/compute/ecloud/requests/get_catalog_configuration.rb,
lib/fog/compute/ecloud/requests/get_trusted_network_group.rb,
lib/fog/compute/ecloud/requests/get_catalog_configurations.rb,
lib/fog/compute/ecloud/requests/get_hardware_configuration.rb,
lib/fog/compute/ecloud/requests/get_trusted_network_groups.rb,
lib/fog/compute/ecloud/requests/admin_enable_support_access.rb,
lib/fog/compute/ecloud/requests/get_backup_internet_service.rb,
lib/fog/compute/ecloud/requests/get_hardware_configurations.rb,
lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb,
lib/fog/compute/ecloud/requests/virtual_machine_attach_disk.rb,
lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb,
lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb,
lib/fog/compute/ecloud/requests/admin_disable_support_access.rb,
lib/fog/compute/ecloud/requests/backup_internet_service_edit.rb,
lib/fog/compute/ecloud/requests/get_backup_internet_services.rb,
lib/fog/compute/ecloud/requests/get_cpu_usage_detail_summary.rb,
lib/fog/compute/ecloud/requests/get_password_complexity_rule.rb,
lib/fog/compute/ecloud/requests/get_operating_system_families.rb,
lib/fog/compute/ecloud/requests/get_password_complexity_rules.rb,
lib/fog/compute/ecloud/requests/trusted_network_groups_create.rb,
lib/fog/compute/ecloud/requests/trusted_network_groups_delete.rb,
lib/fog/compute/ecloud/requests/backup_internet_service_create.rb,
lib/fog/compute/ecloud/requests/backup_internet_service_delete.rb,
lib/fog/compute/ecloud/requests/rnat_associations_edit_network.rb,
lib/fog/compute/ecloud/requests/virtual_machine_copy_identical.rb,
lib/fog/compute/ecloud/requests/get_memory_usage_detail_summary.rb,
lib/fog/compute/ecloud/requests/get_server_configuration_option.rb,
lib/fog/compute/ecloud/requests/rnat_associations_create_device.rb,
lib/fog/compute/ecloud/requests/admin_edit_authentication_levels.rb,
lib/fog/compute/ecloud/requests/get_server_configuration_options.rb,
lib/fog/compute/ecloud/requests/get_storage_usage_detail_summary.rb,
lib/fog/compute/ecloud/requests/get_virtual_machine_assigned_ips.rb,
lib/fog/compute/ecloud/requests/virtual_machine_edit_assigned_ips.rb,
lib/fog/compute/ecloud/requests/admin_edit_password_complexity_rules.rb,
lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.rb,
lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb

Instance Attribute Summary

Attributes included from Shared

#base_path, #versions_uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shared

#build_compute_pool_body_edit, #build_node_service_body_edit, #build_request_body, #build_request_body_attach_disk, #build_request_body_copy, #build_request_body_detach_disk, #build_request_body_edit, #build_request_body_edit_assigned_ips, #build_request_body_identical, #build_request_body_import, #default_organization_uri, #id_from_uri, #validate_create_server_options, #validate_create_server_options_copy, #validate_create_server_options_identical, #validate_data, #validate_edit_compute_pool_options, #validate_edit_internet_service_options, #validate_edit_node_service_options, #validate_edit_server_options, #validate_import_server_options, #validate_internet_service_data, #validate_node_service_data, #validate_upload_file_options

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/fog/compute/ecloud.rb', line 291

def initialize(options = {})
  @base_path               = options[:base_path] || "/cloudapi/ecloud"
  @connections             = {}
  @connection_options      = options[:connection_options] || {}
  @host                    = options[:ecloud_host] || API_URL
  @persistent              = options[:persistent] || false
  @version                 = options[:ecloud_version] || "2015-05-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 ArgumentError, "No credentials (cloud auth, or basic auth) passed!"
    end
  else
    if @access_key.nil?
      raise ArgumentError, "Incomplete cloud auth credentials supplied!"
    end
    @private_key = @private_key.to_s
    @access_key = @access_key.to_s
    @hmac = Fog::HMAC.new("sha256", @private_key)
  end
end

Class Method Details

.basic_request(name, expects = [200], method = :get, headers = {}, body = "") ⇒ Object



277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/fog/compute/ecloud.rb', line 277

def basic_request(name, expects = [200], method = :get, headers = {}, body = "")
  define_method(name) do |uri|
    request(
      :expects => expects,
      :method  => method,
      :headers => headers,
      :body    => body,
      :parse   => true,
      :uri     => uri
    )
  end
end

Instance Method Details

#authentication_levels_edit(data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/compute/ecloud/requests/admin_edit_authentication_levels.rb', line 5

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

#backup_internet_service_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/ecloud/requests/backup_internet_service_create.rb', line 7

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

#backup_internet_service_edit(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/ecloud/requests/backup_internet_service_edit.rb', line 7

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

#build_request_body_edit_hardware_configuration(data) ⇒ Object



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
48
# File 'lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb', line 18

def build_request_body_edit_hardware_configuration(data)
  xml = Builder::XmlMarkup.new
  xml.HardwareConfiguration do
    xml.ProcessorCount data[:cpus]
    xml.Memory do
      xml.Unit "MB"
      xml.Value data[:memory]
    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

#compute_pool_edit(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/ecloud/requests/compute_pool_edit.rb', line 20

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

#firewall_acls_create(data) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/ecloud/requests/firewall_acls_create.rb', line 7

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

#get_virtual_machine_assigned_ips(virtual_machine_id) ⇒ Object



5
6
7
8
9
10
# File 'lib/fog/compute/ecloud/requests/get_virtual_machine_assigned_ips.rb', line 5

def get_virtual_machine_assigned_ips(virtual_machine_id)
  request(
    :uri => "#{base_path}/virtualmachines/#{virtual_machine_id}/assignedips",
    :parse   => true
  )
end

#groups_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/groups_create.rb', line 7

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

#groups_edit(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/groups_edit.rb', line 7

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

#internet_service_create(service_data) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/ecloud/requests/internet_service_create.rb', line 22

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

#login_banner_edit(data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/compute/ecloud/requests/admin_edit_login_banner.rb', line 5

def (data)
  validate_data([:display], data)
  body = (data)
  request(
    :expects => 200,
    :method => "PUT",
    :headers => {},
    :body => body,
    :uri => data[:uri],
    :parse => true
  )
end

#monitors_create_ecv(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_create_ecv.rb', line 7

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

#monitors_create_http(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_create_http.rb', line 7

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

#monitors_create_ping(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_create_ping.rb', line 7

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

#monitors_edit_ecv(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_edit_ecv.rb', line 7

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

#monitors_edit_http(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_edit_http.rb', line 7

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

#monitors_edit_ping(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/monitors_edit_ping.rb', line 7

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

#node_service_create(service_data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/compute/ecloud/requests/node_service_create.rb', line 16

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

#node_service_edit(options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/compute/ecloud/requests/node_service_edit.rb', line 24

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

#password_complexity_rules_edit(data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/ecloud/requests/admin_edit_password_complexity_rules.rb', line 5

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

#request(params) ⇒ Object



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/fog/compute/ecloud.rb', line 318

def request(params)
  # Convert the uri to a URI if it's a string.
  if params[:uri].is_a?(String)
    params[:uri] = URI.parse(@host + params[:uri])
  end
  host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}"

  # Hash connections on the host_url ... There"s nothing to say we won"t get URI"s that go to
  # different hosts.
  @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)

  # Set headers to an empty hash if none are set.
  headers = set_extra_headers_for(params) || set_extra_headers_for({})

  # Make the request
  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].nil? || params[:body].empty?
    options.merge!(:body => params[:body])
  end

  begin
    response = @connections[host_url].request(options)
  rescue Excon::Errors::Error => error
    raise ServiceError.slurp(error)
  end

  # Parse the response body into a hash
  unless response.body.empty?
    if params[:parse]
      document = Fog::ToHashDocument.new
      parser = Nokogiri::XML::SAX::PushParser.new(document)
      parser << response.body
      parser.finish

      response.body = document.body
    end
  end

  response
end

#rnat_associations_create_device(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/rnat_associations_create_device.rb', line 7

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

#rnat_associations_edit_network(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/rnat_associations_edit_network.rb', line 7

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

#rows_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/rows_create.rb', line 7

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

#rows_edit(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/rows_edit.rb', line 7

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

#ssh_key_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/compute/ecloud/requests/ssh_key_create.rb', line 7

def ssh_key_create(data)
  validate_data([:Name], data)

  request(
    :body => generate_ssh_key_create_request(data),
    :expects => 201,
    :method => "POST",
    :headers => {},
    :uri => data[:uri],
    :parse => true
  ).body
end

#ssh_key_edit(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/compute/ecloud/requests/ssh_key_edit.rb', line 7

def ssh_key_edit(data)
  request(
    :body => generate_ssh_key_edit_request(data),
    :expects => 200,
    :method => "PUT",
    :headers => {},
    :uri => data[:uri],
    :parse => true
  ).body
end

#trusted_network_groups_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/ecloud/requests/trusted_network_groups_create.rb', line 7

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

#trusted_network_groups_edit(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb', line 7

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

#virtual_machine_attach_disk(href, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/compute/ecloud/requests/virtual_machine_attach_disk.rb', line 16

def virtual_machine_attach_disk(href, options)
  body = build_request_body_attach_disk(options)
  request(
    :expects => 202,
    :method => "POST",
    :headers => {},
    :body => body,
    :uri => href,
    :parse => true
  )
end

#virtual_machine_copy(template_uri, options) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/fog/compute/ecloud/requests/virtual_machine_copy.rb', line 101

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

#virtual_machine_copy_identical(template_uri, options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/compute/ecloud/requests/virtual_machine_copy_identical.rb', line 28

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

#virtual_machine_create_from_template(template_uri, options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.rb', line 102

def virtual_machine_create_from_template(template_uri, options)
  options = validate_create_server_options(template_uri, options)

  request(
    :expects => 201,
    :method  => "POST",
    :body    => build_request_body(options),
    :uri     => options[:uri],
    :parse   => true
  )
end

#virtual_machine_detach_disk(href, options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb', line 17

def virtual_machine_detach_disk(href, options)
  body = build_request_body_detach_disk(options)
  request(
    :expects => 201,
    :method => "POST",
    :headers => {},
    :body => body,
    :uri => href,
    :parse => true
  )
end

#virtual_machine_edit(vm_uri, options) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/compute/ecloud/requests/virtual_machine_edit.rb', line 30

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

#virtual_machine_edit_assigned_ips(href, options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/ecloud/requests/virtual_machine_edit_assigned_ips.rb', line 24

def virtual_machine_edit_assigned_ips(href, options)
  body = build_request_body_edit_assigned_ips(options)
  request(
    :expects => 202,
    :method => "PUT",
    :headers => {},
    :body => body,
    :uri => href,
    :parse => true
  )
end

#virtual_machine_edit_hardware_configuration(vm_uri, data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb', line 5

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

#virtual_machine_import(template_uri, options) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/compute/ecloud/requests/virtual_machine_import.rb', line 50

def virtual_machine_import(template_uri, options)
  options = validate_import_server_options(template_uri, options)

  request(
    :expects => 201,
    :method  => "POST",
    :body    => build_request_body_import(options),
    :uri     => options[:uri],
    :parse   => true
  )
end

#virtual_machine_upload_file(vm_uri, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb', line 14

def virtual_machine_upload_file(vm_uri, options)
  validate_upload_file_options(options)
  request(
    :expects => 204,
    :method => "POST",
    :headers => { "Content-Type" => "application/octet-stream", "X-Guest-User" => options[:credentials][:user], "X-Guest-Password" => options[:credentials][:password], "Content-Range" => "0-#{options[:file].bytesize - 1}/#{options[:file].bytesize}" },
    :body => options[:file],
    :uri => vm_uri + "?path=#{options[:path]}",
    :parse => true
  )
end