root/saga/trunk/examples/misc/aws_simple.cpp

Revision 3242, 1.2 kB (checked in by amerzky, 11 months ago)

cloud job submission examples, for Kate.
Need aws adaptors and a number of ini settings to work.
A

Line 
1
2 #include <saga/saga.hpp>
3
4 ///////////////////////////////////////////////////////////////////////////////
5 int main (int argc, char* argv[])
6 {
7   try
8   {
9     // set up security
10     saga::context c ("eucalyptus");
11     c.set_defaults ();
12
13     saga::session s;
14     s.add_context (c);
15
16     // start job service: this creates a VM
17     saga::job::service js (s, "eucalyptus://");
18
19     // job description to run
20     saga::job::description jd;
21
22     jd.set_attribute (saga::job::attributes::description_executable, "/bin/ls");
23     jd.set_attribute (saga::job::attributes::description_interactive, "True");
24
25     std::vector <std::string> args;
26
27     args.push_back ("/");
28
29     jd.set_vector_attribute (saga::job::attributes::description_arguments, args);
30
31     // run job
32     saga::job::job j = js.create_job (jd);
33     j.run ();
34
35     // catch stdout
36     saga::job::istream out = j.get_stdout ();
37     while ( true )
38     {
39       char buffer[255];
40       out.read (buffer, sizeof (buffer));
41
42       if ( out.gcount () > 0 )
43         std::cout << std::string (buffer, out.gcount ());
44
45       if ( out.fail () )
46         break;
47     }
48   }
49   catch ( saga::exception const & e )
50   {
51     std::cerr << e.what ();
52   }
53
54   return 0;
55 }
56
Note: See TracBrowser for help on using the browser.