server/lib/deltacloud/drivers/terremark/terremark_driver.rb
#--
# CREATE INSTANCE
#--
#launch a vapp template. Needs a name, ram, no. cpus, id of vapp_template
CREATE INSTANCE
launch a vapp template. Needs a name, ram, no. cpus, id of vapp_template
CREATE INSTANCE launch a vapp template . Needs a name ram no . cpus id of vapp_template
def create_instance(credentials, image_id, opts)
    new_vapp = nil
    vapp_opts = {} 
    terremark_hwp = hardware_profiles(credentials, {:name => 'default'}).first 
    name = opts[:name]
    if not name
      name = "inst#{Time.now.to_i}"
    end
    if name.length > USER_NAME_MAX
      raise "Parameter name must be #{USER_NAME_MAX} characters or less"
    end
    unless ( (terremark_hwp.include?(:cpu, opts[:hwp_cpu].to_i)) &&
              (terremark_hwp.include?(:memory, opts[:hwp_memory].to_i)) ) then
        raise Deltacloud::Exceptions::ValidationFailure.new(
          StandardError.new("Error with cpu and/or memory values. you said cpu->#{opts[:hwp_cpu]} and mem->#{opts[:hwp_memory]}")
        )
    end
    vapp_opts['cpus'] = opts[:hwp_cpu]
    vapp_opts['memory'] =  opts[:hwp_memory]
    safely do
      terremark_client = new_client(credentials)
      vapp_id = terremark_client.instantiate_vapp_template(name, image_id, vapp_opts).body['href'].split('/').last
      new_vapp = terremark_client.get_vapp(vapp_id)
      return convert_instance(new_vapp, terremark_client, credentials.user) 
    end
  end
def create_instance ( credentials , image_id , opts ) new_vapp = nil vapp_opts = { } terremark_hwp = hardware_profiles ( credentials , { :name => 'default' } ) . first name = opts [ :name ] if not name name = "inst#{Time.now.to_i}" end if name . length > USER_NAME_MAX raise "Parameter name must be #{USER_NAME_MAX} characters or less" end unless ( ( terremark_hwp . include? ( :cpu , opts [ :hwp_cpu ] . to_i ) ) && ( terremark_hwp . include? ( :memory , opts [ :hwp_memory ] . to_i ) ) ) then raise Deltacloud :: Exceptions :: ValidationFailure . new ( StandardError . new ( "Error with cpu and/or memory values. you said cpu->#{opts[:hwp_cpu]} and mem->#{opts[:hwp_memory]}" ) ) end vapp_opts [ 'cpus' ] = opts [ :hwp_cpu ] vapp_opts [ 'memory' ] = opts [ :hwp_memory ] safely do terremark_client = new_client ( credentials ) vapp_id = terremark_client . instantiate_vapp_template ( name , image_id , vapp_opts ) . body [ 'href' ] . split ( '/' ) . last new_vapp = terremark_client . get_vapp ( vapp_id ) return convert_instance ( new_vapp , terremark_client , credentials . user ) end end
CREATE INSTANCE
launch a vapp template.
CREATE INSTANCE launch a vapp template .
#assemble options to pass to Fog::Terremark::Real.instantiate_vapp_template #sanity check values against default ####### #FIXME#  what happens if there is an issue getting the new vapp id? (eg even though created succesfully) ####### #return an Instance object
credentials
<not_specific>
image_id
<not_specific>
opts
<not_specific>