Changeset - d3ee86d58ec1
[Not reviewed]
default
0 1 0
ethanzonca@localhost.localdomain - 16 years ago 2009-07-01 12:19:40
ethanzonca@localhost.localdomain
added some registration stuff
1 file changed with 76 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -20,24 +20,25 @@
 

	
 
/* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */
 

	
 
 /* Just some notes -- Ethan Zonca
 
 * ++ Make data availible for other apps to parse
 
 * Server<==>Client Communication
 
 * Upload while rendering
 
 */
 

	
 
#include <stdio.h>
 
#include "execio.h"
 
#include "options.h"
 
#include <confuse.h>
 

	
 
#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;
 

	
 
// Structures for storing job information
 
struct {
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  int priority;
 
  struct frameset **frameset; // What exactly is this now? hehe
 
@@ -50,24 +51,91 @@ struct {
 
  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[])
 
{
 

	
 

	
 

	
 

	
 
// We need the conf parser code from options.c here!!!
 

	
 

	
 
char *username = "unregistered";
 
int registered;
 
if(username == "unregistered") {
 
  registered = 0;
 
}
 

	
 

	
 

	
 

	
 

	
 
// Registration on server. Needs attention. (e.g., people could make tons of accounts with the key we give them...
 
if(registered==0) {
 
char newusername[100];
 

	
 
  fprintf(stderr, "Please enter your desired username: ");
 
  fgets(newusername,100,stdin);
 
  fprintf(stderr, "\nChecking availibility of username: %s\n\n",newusername);
 
  // Mostly kinda copied from old code, but I understand it a tad better now :)
 
  // Logs into sandboxed user on zserver2 and registers a user
 
  char buf[10];
 
  struct execio *testrem;
 
  char *execargv[] =
 
    {
 
  "ssh",
 
  "distren_setup@protofusion.org",
 
  "-i",
 
  "setup.rsa",
 
  "-p",
 
  "23",
 
  "sh",
 
  "-c",
 
  "sudo /usr/sbin/useradd",
 
  "-M",
 
  "-c",
 
  "email",
 
  "-d",
 
  "/home/distren",
 
  "--gid 537",
 
  newusername,
 
  (char *)NULL
 
  };
 
  size_t readlen;
 
  fprintf(stderr, "execio_open:", 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");
 
      }
 
    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);
 
  
 
 }
 
else{
 
  // Login with credentials
 
}
 

	
 

	
 

	
 
/*
 
 frame[frame] Assignments:
 
  "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.
 
*/
 

	
 

	
 
// Queuer: this function should add files to the queue
 
@@ -88,48 +156,32 @@ void queue(int type, char *name, char *s
 
    luxjob[jobnum].priority = priority;
 
    luxjob[jobnum].mode = mode;
 
    luxjob[jobnum].spp = spp;
 
    luxjob[jobnum].frameset = frameset;
 
    // handle lux modes somehow.
 
}
 
  else{
 
    // Throw error.
 
  }
 
jobnum++;
 
}
 

	
 
// Mostly kinda copied from old code, but I understand it a tad better now :)
 
char buf[10];
 
struct execio *testrem;
 
char *execargv[] =
 
  {
 
"ssh",
 
"ethanzonca@protofusion.org",
 
"sh",
 
"-c",
 
"\"echo hello from ${HOSTNAME}\"",
 
(char *)NULL
 
 };
 
size_t readlen;
 
fprintf(stderr, "execio_open:", 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");
 
    }
 
   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);
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
///////////////////////// SLAVE ///////////////////////////////
 

	
 
/*
 
Slave listens on server for a command in the format of each function...
 
We need if's for returns... ==> watchdog
 
*/
 

	
 

	
 
// Executors
 

	
 
void exec_blender(char *input, char *output, int sframe, int eframe) {
0 comments (0 inline, 0 general)