Module: Fog::Compute::Ecloud::Shared

Included in:
Mock, Real
Defined in:
lib/fog/compute/ecloud.rb,
lib/fog/compute/requests/ecloud/add_node.rb,
lib/fog/compute/requests/ecloud/configure_node.rb,
lib/fog/compute/requests/ecloud/configure_vapp.rb,
lib/fog/compute/requests/ecloud/add_internet_service.rb,
lib/fog/compute/requests/ecloud/configure_network_ip.rb,
lib/fog/compute/requests/ecloud/instantiate_vapp_template.rb,
lib/fog/compute/requests/ecloud/configure_internet_service.rb,
lib/fog/compute/requests/ecloud/add_backup_internet_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#versions_uriObject (readonly)

Returns the value of attribute versions_uri.



901
902
903
# File 'lib/fog/compute/ecloud.rb', line 901

def versions_uri
  @versions_uri
end

Instance Method Details

#default_organization_uriObject



903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/fog/compute/ecloud.rb', line 903

def default_organization_uri
  @default_organization_uri ||= begin
    unless @login_results
      
    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_loginObject

login handles the auth, but we just need the Set-Cookie header from that call.



921
922
923
924
# File 'lib/fog/compute/ecloud.rb', line 921

def 
  @login_results = 
  @cookie = @login_results.headers['Set-Cookie']
end

#ecloud_xmlnsObject



926
927
928
929
930
931
# File 'lib/fog/compute/ecloud.rb', line 926

def ecloud_xmlns
  {
    "xmlns"     => "urn:tmrk:eCloudExtensions-2.6",
    "xmlns:i"   => "http://www.w3.org/2001/XMLSchema-instance"
  }
end

#ensure_monitor_defaults!(monitor) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/compute/requests/ecloud/add_internet_service.rb', line 44

def ensure_monitor_defaults!(monitor)
  if monitor[:http_headers].is_a?(String)
    monitor[:http_headers] = [ monitor[:http_headers] ]
  end

  unless monitor[:retries]
    monitor[:retries] = 3
  end

  unless monitor[:response_timeout]
    monitor[:response_timeout] = 2
  end

  unless monitor[:down_time]
    monitor[:down_time] = 30
  end

  unless monitor[:interval]
    monitor[:interval] = 5
  end
end

#ensure_unparsed(uri) ⇒ Object



933
934
935
936
937
938
939
# File 'lib/fog/compute/ecloud.rb', line 933

def ensure_unparsed(uri)
  if uri.is_a?(String)
    uri
  else
    uri.to_s
  end
end

#supported_versionsObject



941
942
943
# File 'lib/fog/compute/ecloud.rb', line 941

def supported_versions
  @supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
end

#validate_backup_internet_service_data(service_data, configure = false) ⇒ Object



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

def validate_backup_internet_service_data(service_data, configure=false)
  required_opts = [:name, :protocol, :description, :enabled]
  if configure
    required_opts + [ :id, :href, :timeout ]
  end
  unless required_opts.all? { |opt| service_data.keys.include?(opt) }
    raise ArgumentError.new("Required Backup Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
  end
end

#validate_internet_service_data(service_data, configure = false) ⇒ Object



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

def validate_internet_service_data(service_data, configure=false)
  required_opts = [:name, :protocol, :port, :description, :enabled]
  if configure
    required_opts + [ :id, :href, :timeout ]
  end
  unless required_opts.all? { |opt| service_data.keys.include?(opt) }
    raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
  end
end

#validate_internet_service_monitor(monitor) ⇒ Object



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

def validate_internet_service_monitor(monitor)
  #FIXME: Refactor this type of function into something generic
  unless ['Disabled','HTTP','ECV'].include?(monitor[:type])
    raise ArgumentError.new("Supported monitor types are: ECV & HTTP")
  end

  required_opts = case monitor[:type]
                  when "Disabled"
                    [:type, :is_enabled]
                  else
                    [:type, :url_send_string, :http_headers, :receive_string, :is_enabled]
                  end

  unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] }
    raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}")
  end

  case monitor[:type]
    when "HTTP", "ECV"
      unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String)
        raise ArgumentError.new("Monitor :http_headers must be a String or Array")
      end
  end

  unless [true, false, "true", "false"].include?(monitor[:is_enabled])
    raise ArgumentError.new("Monitor :is_enabled must be true or false")
  end
end

#xmlnsObject



945
946
947
948
949
# File 'lib/fog/compute/ecloud.rb', line 945

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