Class: Fog::Vcloud::Terremark::Vcloud::Mock
- Defined in:
- lib/fog/vcloud/terremark/vcloud.rb,
lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb
Instance Attribute Summary
Attributes included from Shared
Instance Method Summary collapse
- #get_vdc(vdc_uri) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
Methods inherited from Mock
base_url, data, data_reset, #get_network, #get_organization, #get_versions, #login, #mock_data, #mock_error, #mock_it
Methods included from Shared
#default_organization_uri, #do_login, #ensure_unparsed, #supported_versions, #xmlns
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
26 27 28 29 30 31 32 |
# File 'lib/fog/vcloud/terremark/vcloud.rb', line 26 def initialize( = {}) location = caller.first warning = "[yellow][WARN] Fog::Vcloud::Terremark::Vcloud is deprecated, to be replaced with Vcloud 1.0 someday/maybe[/]" warning << " [light_black](" << location << ")[/] " Formatador.display_line(warning) super end |
Instance Method Details
#get_vdc(vdc_uri) ⇒ Object
15 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 47 48 49 50 51 |
# File 'lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb', line 15 def get_vdc(vdc_uri) vdc_uri = ensure_unparsed(vdc_uri) if vdc = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:href] == vdc_uri } xml = Builder::XmlMarkup.new mock_it 200, xml.Vdc(xmlns.merge(:href => vdc[:href], :name => vdc[:name])) { xml.Link(:rel => "down", :href => vdc[:href] + "/catalog", :type => "application/vnd.vmware.vcloud.catalog+xml", :name => vdc[:name]) xml.Link(:rel => "down", :href => vdc[:href] + "/publicIps", :type => "application/xml", :name => "Public IPs") xml.Link(:rel => "down", :href => vdc[:href] + "/internetServices", :type => "application/xml", :name => "Internet Services") xml.ResourceEntities { vdc[:vms].each do |vm| xml.ResourceEntity(:href => vm[:href], :type => "application/vnd.vmware.vcloud.vApp+xml", :name => vm[:name]) end } xml.AvailableNetworks { vdc[:networks].each do |network| xml.Network(:href => network[:href], :type => "application/vnd.vmware.vcloud.network+xml", :name => network[:name]) end } }, { 'Content-Type' => 'application/vnd.vmware.vcloud.vdc+xml'} else mock_error 200, "401 Unauthorized" end end |