fog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/Gemfile +8 -8
  2. data/Gemfile.lock +3 -3
  3. data/bin/fog +2 -10
  4. data/fog.gemspec +45 -20
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/attributes.rb +48 -8
  7. data/lib/fog/aws/ec2.rb +5 -2
  8. data/lib/fog/aws/elb.rb +5 -2
  9. data/lib/fog/aws/models/ec2/server.rb +1 -1
  10. data/lib/fog/aws/requests/simpledb/put_attributes.rb +43 -12
  11. data/lib/fog/aws/s3.rb +2 -2
  12. data/lib/fog/aws/simpledb.rb +15 -3
  13. data/lib/fog/bin.rb +11 -2
  14. data/lib/fog/bluebox.rb +5 -1
  15. data/lib/fog/connection.rb +9 -1
  16. data/lib/fog/credentials.rb +3 -0
  17. data/lib/fog/new_servers.rb +89 -0
  18. data/lib/fog/new_servers/bin.rb +30 -0
  19. data/lib/fog/new_servers/requests/add_server.rb +39 -0
  20. data/lib/fog/new_servers/requests/cancel_server.rb +36 -0
  21. data/lib/fog/new_servers/requests/get_server.rb +42 -0
  22. data/lib/fog/new_servers/requests/list_images.rb +33 -0
  23. data/lib/fog/new_servers/requests/list_plans.rb +36 -0
  24. data/lib/fog/new_servers/requests/list_servers.rb +43 -0
  25. data/lib/fog/new_servers/requests/reboot_server.rb +30 -0
  26. data/lib/fog/parser.rb +6 -0
  27. data/lib/fog/rackspace/files.rb +8 -2
  28. data/lib/fog/rackspace/models/servers/server.rb +5 -0
  29. data/lib/fog/rackspace/servers.rb +5 -1
  30. data/lib/fog/service.rb +6 -1
  31. data/lib/fog/slicehost.rb +5 -1
  32. data/lib/fog/terremark/ecloud.rb +1 -0
  33. data/lib/fog/terremark/shared.rb +4 -1
  34. data/lib/fog/terremark/vcloud.rb +1 -0
  35. data/lib/fog/vcloud.rb +150 -141
  36. data/lib/fog/vcloud/bin.rb +2 -2
  37. data/lib/fog/vcloud/collection.rb +3 -84
  38. data/lib/fog/vcloud/extension.rb +44 -0
  39. data/lib/fog/vcloud/generators.rb +33 -0
  40. data/lib/fog/vcloud/model.rb +5 -38
  41. data/lib/fog/vcloud/models/vdc.rb +14 -24
  42. data/lib/fog/vcloud/models/vdcs.rb +13 -8
  43. data/lib/fog/vcloud/requests/get_network.rb +4 -11
  44. data/lib/fog/vcloud/requests/get_organization.rb +4 -11
  45. data/lib/fog/vcloud/requests/get_vdc.rb +4 -12
  46. data/lib/fog/vcloud/requests/get_versions.rb +4 -13
  47. data/lib/fog/vcloud/requests/login.rb +4 -4
  48. data/lib/fog/vcloud/terremark/ecloud.rb +125 -54
  49. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +30 -0
  50. data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +31 -0
  51. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +21 -22
  52. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +11 -25
  53. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +38 -5
  54. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +11 -15
  55. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +52 -11
  56. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +14 -13
  57. data/lib/fog/vcloud/terremark/ecloud/models/node.rb +47 -0
  58. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +30 -0
  59. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +6 -9
  60. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +19 -3
  61. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +203 -0
  62. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +43 -0
  63. data/lib/fog/vcloud/terremark/ecloud/models/task.rb +22 -0
  64. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +30 -0
  65. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +32 -10
  66. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +5 -6
  67. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +23 -10
  68. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +54 -0
  69. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +14 -12
  70. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +53 -0
  71. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +52 -0
  72. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +42 -0
  73. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +115 -0
  74. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +4 -23
  75. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -0
  76. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +19 -0
  77. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +18 -0
  78. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +18 -0
  79. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +18 -0
  80. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +9 -16
  81. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +8 -14
  82. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +36 -0
  83. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +44 -0
  84. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +11 -12
  85. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +18 -0
  86. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +18 -0
  87. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -19
  88. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +5 -12
  89. data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +18 -0
  90. data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +19 -0
  91. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +18 -0
  92. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +7 -15
  93. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +18 -0
  94. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +18 -0
  95. data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +18 -0
  96. data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +18 -0
  97. data/lib/fog/vcloud/terremark/vcloud.rb +4 -18
  98. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +4 -12
  99. data/spec/aws/requests/simpledb/put_attributes_spec.rb +18 -0
  100. data/spec/vcloud/bin_spec.rb +2 -2
  101. data/spec/vcloud/models/vdc_spec.rb +35 -29
  102. data/spec/vcloud/requests/get_network_spec.rb +32 -43
  103. data/spec/vcloud/requests/get_organization_spec.rb +45 -38
  104. data/spec/vcloud/requests/get_vdc_spec.rb +42 -32
  105. data/spec/vcloud/requests/get_versions_spec.rb +17 -17
  106. data/spec/vcloud/requests/login_spec.rb +7 -4
  107. data/spec/vcloud/spec_helper.rb +137 -46
  108. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +53 -58
  109. data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +20 -20
  110. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +22 -21
  111. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +18 -18
  112. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +55 -51
  113. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +16 -15
  114. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +26 -27
  115. data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +16 -15
  116. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +52 -36
  117. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +18 -15
  118. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +46 -43
  119. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +37 -32
  120. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +26 -23
  121. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +57 -49
  122. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +41 -0
  123. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +39 -34
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +26 -48
  125. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +25 -26
  126. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +35 -27
  127. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +85 -110
  128. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -4
  129. data/spec/vcloud/vcloud_spec.rb +9 -8
  130. metadata +62 -26
  131. data/lib/fog/vcloud/parser.rb +0 -42
  132. data/lib/fog/vcloud/parsers/get_organization.rb +0 -37
  133. data/lib/fog/vcloud/parsers/get_vdc.rb +0 -62
  134. data/lib/fog/vcloud/parsers/get_versions.rb +0 -46
  135. data/lib/fog/vcloud/parsers/login.rb +0 -36
  136. data/lib/fog/vcloud/parsers/network.rb +0 -53
  137. data/lib/fog/vcloud/terremark/all.rb +0 -9
  138. data/lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb +0 -59
  139. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb +0 -30
  140. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb +0 -40
  141. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +0 -59
  142. data/lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb +0 -58
  143. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +0 -28
  144. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +0 -31
  145. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +0 -27
  146. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +0 -34
  147. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +0 -74
@@ -17,7 +17,7 @@ module Vcloud
17
17
  if Fog.credentials.has_key?(:vcloud)
18
18
  if Fog.credentials[:vcloud].has_key?(service)
19
19
  service = Fog.credentials[:vcloud][service]
20
- if Fog::Vcloud::Options::REQUIRED.all? { |option| service.has_key?(option) }
20
+ if Fog::Vcloud.requirements.all? { |option| service.has_key?(option) }
21
21
  return true
22
22
  end
23
23
  end
@@ -38,7 +38,7 @@ module Vcloud
38
38
  def [](service)
39
39
  @@connections ||= Hash.new do |hash, key|
40
40
  if credentials = Fog.credentials[:vcloud][key]
41
- hash[key] = Fog::Vcloud.new(credentials.reject { |k,value| Fog::Vcloud::Options::ALL.include?(value) })
41
+ hash[key] = Fog::Vcloud.new(credentials)
42
42
  else
43
43
  raise ArgumentError.new("Unregistered service: :#{key}. Registered services are: #{Vcloud.registered_services}")
44
44
  end
@@ -2,92 +2,11 @@ module Fog
2
2
  module Vcloud
3
3
  class Collection < Fog::Collection
4
4
 
5
- class << self
6
-
7
- def inherited(klass)
8
- klass.instance_variable_set(:@model, @model)
9
- klass.all_request @all_request
10
- klass.vcloud_type @vcloud_type
11
- klass.get_request @get_request
12
- end
13
-
14
- def all_request(all_request=nil)
15
- unless all_request
16
- @all_request
17
- else
18
- @all_request = all_request
19
- class_eval <<-EOS, __FILE__, __LINE__
20
- def all
21
- raw_all = self.class.all_request.call(self)
22
- data = (raw_all.is_a?(Array) ? raw_all : raw_all.body.links).select do |link|
23
- link.type == self.class.vcloud_type
24
- end.map { |link| {:href => link.href, :name => link.name } }
25
- load(data)
26
- end
27
- EOS
28
- end
29
- end
30
-
31
- def vcloud_type(vcloud_type=nil)
32
- unless vcloud_type
33
- @vcloud_type
34
- else
35
- @vcloud_type = vcloud_type
36
- end
37
- end
38
-
39
- def get_request(get_request=nil)
40
- unless get_request
41
- @get_request
42
- else
43
- @get_request = get_request
44
- class_eval <<-EOS, __FILE__, __LINE__
45
- def get(uri)
46
- item = new(:href => uri)
47
- item.reload
48
- end
49
- def get_raw(uri)
50
- connection.#{@get_request}(uri)
51
- end
52
- EOS
53
- end
54
- end
55
- end
56
-
57
- attr_accessor :href
58
-
59
- def create(attributes = {})
60
- attributes.merge!(:new => true)
61
- obj = super(attributes)
62
- self << obj
63
- obj
5
+ def load(objects)
6
+ objects = [ objects ] if objects.is_a?(Hash)
7
+ super
64
8
  end
65
9
 
66
- def each
67
- super do |item|
68
- item.reload unless item.loaded?
69
- yield(item)
70
- end
71
- end
72
-
73
- def map
74
- super do |item|
75
- item.reload unless item.loaded?
76
- yield(item)
77
- end
78
- end
79
-
80
- def [](index)
81
- if obj = super
82
- obj.reload unless obj.loaded?
83
- end
84
- obj
85
- end
86
-
87
- #def reload
88
- # self.all
89
- #end
90
-
91
10
  end
92
11
  end
93
12
  end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Extension
4
+ include Fog::Service
5
+
6
+ @versions = []
7
+
8
+ def self.extended(other)
9
+ other.module_eval <<-EOS,__FILE__,__LINE__
10
+ module #{other}::Real
11
+ extend Fog::Vcloud::Generators
12
+ end
13
+ module #{other}::Mock
14
+ end
15
+ module #{other}::Versions
16
+ SUPPORTED = @versions
17
+ end
18
+ def self.extended(klass)
19
+ unless @required
20
+ models.each do |model|
21
+ require File.join(@model_path, model.to_s)
22
+ end
23
+ requests.each do |request|
24
+ require File.join(@request_path, request.to_s)
25
+ end
26
+ @required = true
27
+ end
28
+ if Fog.mocking?
29
+ klass.extend #{other}::Real
30
+ klass.extend #{other}::Mock
31
+ else
32
+ klass.extend #{other}::Real
33
+ end
34
+ end
35
+ EOS
36
+ end
37
+
38
+ def versions(*args)
39
+ @versions = args
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Generators
4
+
5
+ def unauthenticated_basic_request(*args)
6
+ self.class_eval <<-EOS, __FILE__,__LINE__
7
+ def #{args[0]}(uri)
8
+ unauthenticated_request({
9
+ :expects => #{args[1] || 200},
10
+ :method => '#{args[2] || 'GET'}',
11
+ :headers => #{args[3] ? args[3].inspect : '{}'},
12
+ :parse => true,
13
+ :uri => uri })
14
+ end
15
+ EOS
16
+ end
17
+
18
+ def basic_request(*args)
19
+ self.class_eval <<-EOS, __FILE__,__LINE__
20
+ def #{args[0]}(uri)
21
+ request({
22
+ :expects => #{args[1] || 200},
23
+ :method => '#{args[2] || 'GET'}',
24
+ :headers => #{args[3] ? args[3].inspect : '{}'},
25
+ :body => '#{args[4] ? args[4] : ''}',
26
+ :parse => true,
27
+ :uri => uri })
28
+ end
29
+ EOS
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,50 +2,17 @@ module Fog
2
2
  module Vcloud
3
3
  class Model < Fog::Model
4
4
 
5
- #def self.attribute(name, other_names = [])
6
- # super
7
- # class_eval <<-EOS, __FILE__, __LINE__
8
- # def #{name}=(new_#{name})
9
- # @#{name} = new_#{name}
10
- # end
11
- # EOS
12
- #end
13
-
14
- def self.inherited(klass)
15
- attributes.each { |attribute| klass.attribute attribute }
16
- klass.instance_variable_set(:@identity, @identity)
17
- klass.instance_variable_set(:@aliases, @aliases)
18
- end
19
-
20
- def self.delete_attribute(name)
21
- if @attributes.reject! { |item| item == name }
22
- class_eval <<-EOS,__FILE__,__LINE__
23
- undef_method :#{name}
24
- undef_method :#{name}=
25
- EOS
26
- aliases.reject! { |key, value| value == name || key == name }
27
- end
28
- end
29
-
30
5
  attr_accessor :loaded
31
6
  alias_method :loaded?, :loaded
32
7
 
33
8
  def reload
34
- if data = collection.get_raw(identity)
35
- merge_get_raw_result(data)
36
- @loaded = true
37
- self
38
- end
9
+ super
10
+ @loaded = true
39
11
  end
40
12
 
41
- def merge_get_raw_result(data)
42
- #data.body.each_pair do |key,value|
43
- (data.respond_to?(:body) ? data.body : data).each_pair do |key,value|
44
- if aliased_key = self.class.aliases[key]
45
- send("#{aliased_key}=", value)
46
- else
47
- send("#{key}=", value)
48
- end
13
+ def load_unless_loaded!
14
+ unless @loaded
15
+ reload
49
16
  end
50
17
  end
51
18
 
@@ -1,34 +1,24 @@
1
- require 'fog/model'
2
-
3
1
  module Fog
4
2
  module Vcloud
5
3
  class Vdc < Fog::Vcloud::Model
6
4
 
7
5
  identity :href
8
6
 
9
- attribute :name
10
- attribute :other_links, :links
11
- attribute :resource_entity_links, :resource_entities
12
- attribute :network_links, :networks
13
- attribute :cpu_capacity
14
- attribute :storage_capacity
15
- attribute :memory_capacity
16
- attribute :vm_quota
17
- attribute :enabled
18
- attribute :nic_quota
19
- attribute :network_quota
20
- attribute :vcloud_type, :type
21
- attribute :xmlns
22
- attribute :description
23
- attribute :allocation_model
24
-
25
- #def networks
26
- # connection.networks(:vdc_uri => @uri)
27
- #end
7
+ ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
28
8
 
29
- #def addresses
30
- # connection.addresses(:vdc_uri => @uri)
31
- #end
9
+ attribute :name
10
+ attribute :type
11
+ attribute :description, :aliases => :Description
12
+ attribute :other_links, :aliases => :Link
13
+ attribute :compute_capacity, :aliases => :ComputeCapacity
14
+ attribute :storage_capacity, :aliases => :StorageCapacity
15
+ attribute :available_networks, :aliases => :AvailableNetworks, :squash => :Network
16
+ attribute :resource_entities, :aliases => :ResourceEntities, :squash => :ResourceEntity
17
+ attribute :enabled, :aliases => :IsEnabled
18
+ attribute :vm_quota, :aliases => :VmQuota
19
+ attribute :nic_quota, :aliases => :NicQuota
20
+ attribute :network_quota, :aliases => :NetworkQuota
21
+ attribute :allocation_model, :aliases => :AllocationModel
32
22
 
33
23
  end
34
24
 
@@ -1,10 +1,5 @@
1
1
  module Fog
2
2
  module Vcloud
3
- class Mock
4
- def vdcs(options = {})
5
- @vdcs ||= Fog::Vcloud::Vdcs.new(options.merge(:connection => self))
6
- end
7
- end
8
3
 
9
4
  class Real
10
5
  def vdcs(options = {})
@@ -16,9 +11,19 @@ module Fog
16
11
 
17
12
  model Fog::Vcloud::Vdc
18
13
 
19
- get_request :get_vdc
20
- vcloud_type "application/vnd.vmware.vcloud.vdc+xml"
21
- all_request lambda { |vdcs| vdcs.connection.get_organization(vdcs.organization_uri) }
14
+ def all
15
+ data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
16
+ data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } }
17
+ load(data)
18
+ end
19
+
20
+ def get(uri)
21
+ if data = connection.get_vdc(uri)
22
+ new(data.body)
23
+ end
24
+ rescue Fog::Errors::NotFound
25
+ nil
26
+ end
22
27
 
23
28
  def organization_uri
24
29
  @organizatio_uri ||= connection.default_organization_uri
@@ -1,16 +1,8 @@
1
1
  module Fog
2
2
  module Vcloud
3
- class Real
4
-
5
- def get_network(network_uri)
6
- request(
7
- :expects => 200,
8
- :method => 'GET',
9
- :parser => Fog::Parsers::Vcloud::Network.new,
10
- :uri => uri
11
- )
12
- end
13
3
 
4
+ class Real
5
+ basic_request :get_network
14
6
  end
15
7
 
16
8
  class Mock
@@ -23,11 +15,12 @@ module Fog
23
15
  # Did not implement AssociatedNetwork, seems redundant, haven't seen it in use yet
24
16
  # Did not implement the following features: Dhcp, Nat & Firewall
25
17
  #
18
+ network_uri = ensure_unparsed(network_uri)
26
19
  type = "application/vnd.vmware.vcloud.network+xml"
27
20
  response = Excon::Response.new
28
21
  if network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_uri.to_s }
29
22
  xml = Builder::XmlMarkup.new
30
- mock_it Fog::Parsers::Vcloud::Network.new, 200,
23
+ mock_it 200,
31
24
  xml.Network(xmlns.merge(:href => network[:href], :name => network[:name], :type => type)) {
32
25
  xml.Description(network[:name])
33
26
  xml.Configuration {
@@ -2,15 +2,7 @@ module Fog
2
2
  module Vcloud
3
3
 
4
4
  class Real
5
- def get_organization(organization_uri)
6
- request(
7
- :expects => 200,
8
- :method => 'GET',
9
- :parser => Fog::Parsers::Vcloud::GetOrganization.new,
10
- :uri => organization_uri
11
- )
12
- end
13
-
5
+ basic_request :get_organization
14
6
  end
15
7
 
16
8
  class Mock
@@ -22,10 +14,11 @@ module Fog
22
14
  #
23
15
  # vCloud API Guide v0.9 - Page 26
24
16
  #
25
- if org = mock_data[:organizations].detect { |org| URI.parse(org[:info][:href]) == organization_uri }
17
+ organization_uri = ensure_unparsed(organization_uri)
18
+ if org = mock_data[:organizations].detect { |org| org[:info][:href] == organization_uri }
26
19
  xml = Builder::XmlMarkup.new
27
20
 
28
- mock_it Fog::Parsers::Vcloud::GetOrganization.new, 200,
21
+ mock_it 200,
29
22
  xml.Org(xmlns.merge(:href => org[:info][:href], :name => org[:info][:name])) {
30
23
 
31
24
  org[:vdcs].each do |vdc|
@@ -2,16 +2,7 @@ module Fog
2
2
  module Vcloud
3
3
 
4
4
  class Real
5
- # Get details of a vdc
6
- def get_vdc(vdc_uri)
7
- request(
8
- :expects => 200,
9
- :method => 'GET',
10
- :parser => Fog::Parsers::Vcloud::GetVdc.new,
11
- :uri => vdc_uri
12
- )
13
- end
14
-
5
+ basic_request :get_vdc
15
6
  end
16
7
 
17
8
  class Mock
@@ -20,9 +11,10 @@ module Fog
20
11
  #vCloud API Guide v0.9 - Page 27
21
12
 
22
13
  def get_vdc(vdc_uri)
23
- if vdc = Fog::Vcloud::Mock.data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| URI.parse(vdc[:href]) == vdc_uri }
14
+ vdc_uri = ensure_unparsed(vdc_uri)
15
+ if vdc = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:href] == vdc_uri }
24
16
  xml = Builder::XmlMarkup.new
25
- mock_it Fog::Parsers::Vcloud::GetVdc.new, 200,
17
+ mock_it 200,
26
18
  xml.Vdc(xmlns.merge(:href => vdc[:href], :name => vdc[:name])) {
27
19
  xml.Link(:rel => "up",
28
20
  :href => Fog::Vcloud::Mock.data[:organizations].detect { |org| org[:vdcs].detect { |_vdc| vdc[:href] == _vdc[:href] }[:href] == vdc[:href] }[:info][:href],
@@ -2,21 +2,12 @@ module Fog
2
2
  module Vcloud
3
3
 
4
4
  class Real
5
-
6
- def get_versions
7
- unauthenticated_request({
8
- :expects => 200,
9
- :method => 'GET',
10
- :parser => Fog::Parsers::Vcloud::GetVersions.new,
11
- :uri => @versions_uri
12
- })
13
- end
14
-
5
+ unauthenticated_basic_request :get_versions
15
6
  end
16
7
 
17
8
  class Mock
18
9
 
19
- def get_versions
10
+ def get_versions(versions_uri)
20
11
  #
21
12
  # Based off of:
22
13
  # http://support.theenterprisecloud.com/kb/default.asp?id=535&Lang=1&SID=
@@ -25,10 +16,10 @@ module Fog
25
16
  #
26
17
  xml = Builder::XmlMarkup.new
27
18
 
28
- mock_it Fog::Parsers::Vcloud::GetVersions.new, 200,
19
+ mock_it 200,
29
20
  xml.SupportedVersions( xmlns.merge("xmlns" => "http://www.vmware.com/vcloud/versions")) {
30
21
 
31
- Fog::Vcloud::Mock.data[:versions].select {|version| version[:supported] }.each do |version|
22
+ mock_data[:versions].select {|version| version[:supported] }.each do |version|
32
23
  xml.VersionInfo {
33
24
  xml.Version(version[:version])
34
25
  xml.LoginUrl(version[:login_url])