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

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

Instance Attribute Summary

Attributes included from Shared

#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_add_ip, #build_request_body_copy, #build_request_body_edit, #build_request_body_identical, #build_request_body_import, #do_login, #ecloud_xmlns, #ensure_unparsed, #supported_versions, #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, #xmlns

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/fog/ecloud/compute.rb', line 379

def initialize(options = {})
  require 'builder'
  require 'fog/core/parser'
  @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

Class Method Details

.basic_request(*args) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/fog/ecloud/compute.rb', line 350

def basic_request(*args)
  self.class_eval <<-EOS, __FILE__,__LINE__
    def #{args[0]}(uri)
      request({
      :expects => #{args[1] || 200},
      :method => '#{args[2] || 'GET'}',
      :headers => #{args[3] ? args[3].inspect : '{}'},
      :body => '#{args[4] ? args[4] : ''}',
      :parse => true,
      :uri => uri })
    end
  EOS
end

.unauthenticated_basic_request(*args) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/fog/ecloud/compute.rb', line 364

def unauthenticated_basic_request(*args)
  self.class_eval <<-EOS, __FILE__,__LINE__
    def #{args[0]}(uri)
      unauthenticated_request({
      :expects => #{args[1] || 200},
      :method => '#{args[2] || 'GET'}',
      :headers => #{args[3] ? args[3].inspect : '{}'},
      :parse => true,
      :uri => uri })
    end
  EOS
end

Instance Method Details

#authentication_levels_edit(data) ⇒ Object



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

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/ecloud/requests/compute/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/ecloud/requests/compute/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



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

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

#compute_pool_edit(options) ⇒ Object



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

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

#default_organization_uriObject



402
403
404
# File 'lib/fog/ecloud/compute.rb', line 402

def default_organization_uri
  "/cloudapi/ecloud/organizations/"
end

#do_request(params) ⇒ Object



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/fog/ecloud/compute.rb', line 414

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(@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::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].empty?
    options.merge!({:body => params[:body]})
  end
  #puts options[:body].inspect
  response = @connections[host_url].request(options)

  # 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

#firewall_acls_create(data) ⇒ Object

Raises:

  • (ArgumentError)


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

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

#groups_create(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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



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

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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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



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

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



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

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



406
407
408
409
410
411
412
# File 'lib/fog/ecloud/compute.rb', line 406

def request(params)
  begin
    do_request(params)
  rescue Excon::Errors::Unauthorized => e
    raise RuntimeError, "Invalid authentication data: #{e}"
  end
end

#rnat_associations_create_device(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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/ecloud/requests/compute/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

#trusted_network_groups_create(data) ⇒ Object



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

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



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

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_add_ip(href, options) ⇒ Object



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

def virtual_machine_add_ip(href, options)
  body = build_request_body_add_ip(options)
  request(
    :expects => 202,
    :method => 'PUT',
    :headers => {},
    :body => body,
    :uri => href,
    :parse => true
  )
end

#virtual_machine_copy(template_uri, options) ⇒ Object



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

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



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

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



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb', line 110

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

#virtual_machine_edit(vm_uri, options) ⇒ Object



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

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_hardware_configuration(vm_uri, data) ⇒ Object



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

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



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

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

#virtual_machine_upload_file(vm_uri, options) ⇒ Object



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

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