def create_instance(credentials, image_id, opts)
new_vapp = nil
vapp_opts = {}
terremark_hwp = hardware_profiles(credentials, {:name => 'default'}).first
name = opts['name']
name = "inst#{Time.now.to_i}" if (name.nil? || (name.length == 0))
name = name.slice(0..13)
unless ( (terremark_hwp.include?(:cpu, opts[:hwp_cpu].to_i)) &&
(terremark_hwp.include?(:memory, opts[:hwp_memory].to_i)) ) then
raise Deltacloud::Validation::Failure.new(Deltacloud::Validation::Param.new(["cpu"]), "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