# HG changeset patch # User ethanzonca # Date 2009-07-06 18:02:19 # Node ID c44707a801aa36267595ae0fb65350d14f350fab # Parent 73902eddcef80c1880014fe35b9ee185219fbbdf Commenting, removed some lux stuff so we can focus on blender. We really need to clean up. diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -29,23 +29,18 @@ #include #include "execio.h" - -// needs to be implemented #include "options.h" - #include -#define max 100 -// maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory... +#define max 100 // maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory... int jobnum = 0; -int hcfjob; //highest consecutively finished job +int hcfjob; // Highest consecutively finished job int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs // Structures for storing job information -// OOOOOOkay so we really need a struct for frameset rather than just an array, because we should track who each frame was sent out to. Please do this, someone! :D struct { char *name; char *submitter; @@ -55,16 +50,13 @@ struct { int completed_frames; // number of completed frames int assigned_frames; // number of assigned frames (that are not yet completed) int total_frames; // how many frames are in the animation + struct frameset **frameset; - struct frameset **frameset; // What exactly is this now? hehe - + // Ok... what's going on with using these??? --ethanzonca int frame_num[]; char slave_name[][]; short int frame_status[]; - // For secondary upload location... - char url; - char login_name; - char login_pass; + } blendjob[max]; /* @@ -79,17 +71,6 @@ struct { // -- end of Matthew's handywork -- */ -struct { - char *name; - char *submitter; - char *email; - int priority; - int mode; // 0 = Static Render, stop at Spp, or infinity if spp is null. Framerange is ignored || 1 = animation, stop at Spp and stay in framerange. - int spp; - struct frameset ** frameset; -} luxjob[max]; - - int main(int argc, char *argv[]) { @@ -156,91 +137,6 @@ struct distrend_config } -/* Notes on Registration: -We need to generate a key in registeruser() that is returned to the client. -How will we transfer the key? -*/ - -// Registration on server. Needs attention. Prevent account spamming. -// Set up something like: distrend -c username email@example.com -void registeruser(char *username, char *email){ - // Logs into sandboxed user on zserver2 and registers a user. Should eventually generate a key on the server and return it to the user. - // All created user accounts should be sandboxed accordingly, requiring a different skel, and the default shell to be rbash. Also, - // a custom path defined in the .bash_profile of the skel is needed. - char buf[10]; - struct execio *testrem; - char *execargv[] = - { - "ssh", - "distren_setup@protofusion.org", - "-i", - "setup.rsa", // default distributed key, account can only create users. - "-p", - "23", - "sudo /usr/sbin/useradd", - "-M", - "-c", - email, - "-d", - "/home/distren", - "--gid", - "541", // Add in shellscript to generate ssh key and return it to the user somehow - username, - (char *)NULL - }; - size_t readlen; - fprintf(stderr, "Opening stream:\n", execio_open(&testrem, "ssh", execargv)); - buf[9] = '\0'; // null-terminating the array... - while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff? - { - if(readlen > 9) { - fprintf(stderr, "!!!! Something is terribly wrong!\n"); - } - if(buf == 0) { - fprintf(stderr, "Make this throw a successfull message if no output is returned... maybe"); - } - buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is? - fprintf(stderr, "read \"%s\"\n", buf); - } - execio_close(testrem); -} - - - - - -void loginuser(char *username, int secret){ - // Logs into sandboxed user on zserver2 as a client, currently does nothing - char buf[10]; - struct execio *testrem; - char *execargv[] = - { - "ssh", - "username@protofusion.org", // username must be read from the conf - "-i", - "username.rsa", // Key created from registeruser() - "-p", - "23", - "echo", - "hello", // This should eventually open a non-terminating connection to the server for communication - (char *)NULL - }; - size_t readlen; - fprintf(stderr, "Opening stream:\n", execio_open(&testrem, "ssh", execargv)); - buf[9] = '\0'; // null-terminating the array... - while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff? - { - if(readlen > 9) { - fprintf(stderr, "!!!! Something is terribly wrong!\n"); - } - if(buf == 0) { - fprintf(stderr, "Put stuff here-ish to check whether the operation(s) were successful."); - } - buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is? - fprintf(stderr, "read \"%s\"\n", buf); - } - execio_close(testrem); -} @@ -252,16 +148,18 @@ void loginuser(char *username, int secre /* frame[frame] Assignments: + "NULL" - don't render me "0" - cancelled "1" - unassigned "2" - assigned to slave "3" - completed by slave and uploaded - Have a script crawl through each job in the arrays, ordered by priority?, and assign a certain number of frames to each slave. - Then we will need some sort of watchdog to monitor slaves on the main server to check for stales. + + Have a script crawl through each job in the arrays, priority-biased, and assign a frame to each slave. + Then we will need some sort of watchdog to monitor slaves on the main server to check for stales. Maybe not worry about this for now. */ -/* -- Coding using OLD FRAMESET STRUCTURE... temporarily saving it!! -- +/* -- Coding using OLD FRAMESET STRUCTURE... temporarily saving it!! -- :: Normaldotcom glances at lordofwar with a concerned look... // This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. void frame_num_struct_builder(int sframe, int eframe) { int jobnum_new = highest_jobnum + 1; @@ -436,6 +334,9 @@ if(your_frame = null) // If that job ha return your_frame; // your_frame is returned as the frame to be rendered } + + + // This figures out how much of the job is done, where jobnum corresponds to the job number // This uses pointers, so when it is run it updates certain values in memory void status_report_generator(){ @@ -518,12 +419,100 @@ jobnum++; /* -Slave execution code lies below + * -------------------------------------------------------------------- + * Slave code resides below. + * + * Slave listens on server for a command in the format of each function... + * We need if's for returns... ==> watchdog +*/ + + -Slave listens on server for a command in the format of each function... -We need if's for returns... ==> watchdog -*/ +// Registration on server. Needs attention. Prevent account spamming. +// Key transfer? +// Set up something like: distrend -c username email@example.com +void registeruser(char *username, char *email){ + // Logs into sandboxed user on zserver2 and registers a user. Should eventually generate a key on the server and return it to the user. + // All created user accounts should be sandboxed accordingly, requiring a different skel, and the default shell to be rbash. Also, + // a custom path defined in the .bash_profile of the skel is needed. + char buf[10]; + struct execio *testrem; + char *execargv[] = + { + "ssh", + "distren_setup@protofusion.org", + "-i", + "setup.rsa", // default distributed key, account can only create users. + "-p", + "23", + "sudo /usr/sbin/useradd", + "-M", + "-c", + email, + "-d", + "/home/distren", + "--gid", + "541", // Add in shellscript to generate ssh key and return it to the user somehow + username, + (char *)NULL + }; + size_t readlen; + fprintf(stderr, "Opening stream:\n", execio_open(&testrem, "ssh", execargv)); + buf[9] = '\0'; // null-terminating the array... + while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff? + { + if(readlen > 9) { + fprintf(stderr, "!!!! Something is terribly wrong!\n"); + } + if(buf == 0) { + fprintf(stderr, "Make this throw a successfull message if no output is returned... maybe"); + } + buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is? + fprintf(stderr, "read \"%s\"\n", buf); + } + execio_close(testrem); +} + + + + + +void loginuser(char *username, int secret){ + // Logs into sandboxed user on zserver2 as a client, currently does nothing + char buf[10]; + struct execio *testrem; + char *execargv[] = + { + "ssh", + "username@protofusion.org", // username must be read from the conf + "-i", + "username.rsa", // Key created from registeruser() + "-p", + "23", + "echo", + "hello", // This should eventually open a non-terminating connection to the server for communication + (char *)NULL + }; + size_t readlen; + fprintf(stderr, "Opening stream:\n", execio_open(&testrem, "ssh", execargv)); + buf[9] = '\0'; // null-terminating the array... + while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff? + { + if(readlen > 9) { + fprintf(stderr, "!!!! Something is terribly wrong!\n"); + } + if(buf == 0) { + fprintf(stderr, "Put stuff here-ish to check whether the operation(s) were successful."); + } + buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is? + fprintf(stderr, "read \"%s\"\n", buf); + } + execio_close(testrem); +} + + + // Executors @@ -536,21 +525,4 @@ void exec_blender(char *input, char *out // OHNOBINKI! ... check this... Its supposed to send a command back to the server and run the_finisher(); function which sets the frame status to complete. fprintf(stdin, the_finisher(frame)); - -void exec_luxrender_single(char *input, char *output) { - int ret; - char *cmd[] = { "luxrender", "-something", "something", "something", (char *)0 }; - ret = execv("/usr/bin/luxrender", cmd); } - -void exec_luxrender_anim(char *input, char *output, int sframe, int eframe, int spp) { -// spp is samples per pixel limitation on each frame - int ret; - char *cmd[] = { "luxrender", "-something", "something", "something", (char *)0 }; - ret = execv ("/usr/bin/luxrender", cmd); -} - - - - return 0; -}