module Fog module Terremark module Shared class Real # Instatiate a vapp template # # ==== Parameters # * name<~String>: Name of the resulting vapp .. must start with letter, up to 15 chars alphanumeric. # * options<~Hash>: # * cpus<~Integer>: Number of cpus in [1, 2, 4, 8], defaults to 1 # * memory<~Integer>: Amount of memory either 512 or a multiple of 1024, defaults to 512 # * vapp_template<~String>: id of the vapp template to be instantiated # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * 'Links;<~Array> (e.g. up to vdc) # * 'href'<~String> Link to the resulting vapp # * 'name'<~String> - name of item # * 'type'<~String> - type of item # * 'status'<~String> - 0(pending) --> 2(off) -->4(on) def instantiate_vapp_template(name, vapp_template, options = {}) unless name.length < 15 raise ArgumentError.new('Name must be fewer than 15 characters') end options['cpus'] ||= 1 options['memory'] ||= 512 options['network_id'] ||= default_network_id options['vdc_id'] ||= default_vdc_id data = <<-DATA 1 3 #{options['cpus']} 2 4 #{options['memory']} DATA request( :body => data, :expects => 200, :headers => { 'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml' }, :method => 'POST', :parser => Fog::Parsers::Terremark::InstantiateVappTemplate.new, :path => "vdc/#{options['vdc_id']}/action/instantiatevAppTemplate" ) end end class Mock def instatiate_vapp_template(vapp_template_id) raise MockNotImplemented.new("Contributions welcome!") end end end end end