IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 14, 2005, 8:18:09 AM (21 years ago)
Author:
eugene
Message:

updating user commands

Location:
trunk/Ohana/src/opihi/pantasks
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r4452 r4552  
    33# define CONNECT_TIMEOUT 300
    44
    5 int status = FALSE;
    6 int stdin_cntl, stdout_cntl, stderr_cntl;
     5static int status = FALSE;
     6static int stdin_cntl, stdout_cntl, stderr_cntl;
     7
     8int CheckControllerStatus () {
     9  return (status);
     10}
    711
    812int CheckControllerJob (Job *job) {
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r4450 r4552  
    2626
    2727funcs = \
     28$(SDIR)/init.$(ARCH).o \
     29$(SDIR)/scheduler.$(ARCH).o \
    2830$(SDIR)/CheckJobs.$(ARCH).o \
    2931$(SDIR)/CheckSystem.$(ARCH).o \
     
    3436$(SDIR)/TaskOps.$(ARCH).o \
    3537$(SDIR)/IOBufferOps.$(ARCH).o \
    36 $(SDIR)/memstr.$(ARCH).o \
    37 $(SDIR)/init.$(ARCH).o
     38$(SDIR)/memstr.$(ARCH).o
    3839
    3940cmds = \
     41$(SDIR)/run.$(ARCH).o \
     42$(SDIR)/stop.$(ARCH).o \
     43$(SDIR)/status.$(ARCH).o \
     44$(SDIR)/kill.$(ARCH).o \
     45$(SDIR)/delete.$(ARCH).o \
    4046$(SDIR)/controller.$(ARCH).o \
    41 $(SDIR)/run.$(ARCH).o \
    42 $(SDIR)/scheduler.$(ARCH).o \
     47$(SDIR)/controller_host.$(ARCH).o \
     48$(SDIR)/controller_check.$(ARCH).o \
     49$(SDIR)/controller_status.$(ARCH).o \
    4350$(SDIR)/task.$(ARCH).o \
    4451$(SDIR)/task_command.$(ARCH).o \
  • trunk/Ohana/src/opihi/pantasks/controller.c

    r4539 r4552  
    11# include "scheduler.h"
     2
     3int controller_host    PROTO((int, char **));
     4int controller_status  PROTO((int, char **));
     5int controller_check   PROTO((int, char **));
    26
    37static Command controller_cmds[] = {
     
    3438
    3539  for (i = 0; i < N; i++) {
    36     if (!strcmp (controller_cmds[i].name, argv[1])) {
     40    if (!strcmp (controller_cmds[i].name, cmd)) {
    3741      return (controller_cmds[i].func);
    3842    }
  • trunk/Ohana/src/opihi/pantasks/controller_check.c

    r4539 r4552  
    11# include "scheduler.h"
    22
    3 int controller_host (int argc, char **argv) {
     3int controller_check (int argc, char **argv) {
    44
    55  int status;
     
    77  IOBuffer buffer;
    88
    9   if (argc != 3) {
    10     fprintf (stderr, "USAGE: controller host (hostname)\n");
    11     return (FALSE);
     9  if (argc != 3) goto usage;
     10  if (strcasecmp (argv[2], "JOB") &&
     11      strcasecmp (argv[2], "HOST")) goto usage;
     12
     13  /* check if controller is running */
     14  status = CheckControllerStatus ();
     15  if (!status) {
     16    fprintf (stderr, "controller is not running\n");
     17    return (TRUE);
    1218  }
    1319
    14   /* start controller connection (if needed) */
    15   StartController ();
    16 
    17   sprintf (command, "host %s", argv[2]);
     20  sprintf (command, "check %s %s", argv[2], argv[3]);
    1821  InitIOBuffer (&buffer, 0x100);
    1922  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
     
    3235    case CONTROLLER_GOOD:
    3336      fprintf (stderr, "controller command sent\n"); 
     37      fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
    3438      return (TRUE);
    3539
     
    4145  fprintf (stderr, "programming error: should not reach here\n"); 
    4246  exit (1);
     47
     48usage:
     49  fprintf (stderr, "USAGE: controller check job (jobID)\n");
     50  fprintf (stderr, "USAGE: controller check host (hostID)\n");
     51  return (FALSE);
    4352}
  • trunk/Ohana/src/opihi/pantasks/controller_status.c

    r4539 r4552  
    11# include "scheduler.h"
    22
    3 int controller_host (int argc, char **argv) {
     3int controller_status (int argc, char **argv) {
    44
    55  int status;
     
    88
    99  if (argc != 3) {
    10     fprintf (stderr, "USAGE: controller host (hostname)\n");
     10    fprintf (stderr, "USAGE: controller status\n");
    1111    return (FALSE);
    1212  }
    1313
    14   /* start controller connection (if needed) */
    15   StartController ();
     14  /* check if controller is running */
     15  status = CheckControllerStatus ();
     16  if (!status) {
     17    fprintf (stderr, "controller is not running\n");
     18    return (TRUE);
     19  }
    1620
    17   sprintf (command, "host %s", argv[2]);
     21  sprintf (command, "status");
    1822  InitIOBuffer (&buffer, 0x100);
    1923  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
     
    3236    case CONTROLLER_GOOD:
    3337      fprintf (stderr, "controller command sent\n"); 
     38      fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
    3439      return (TRUE);
    3540
  • trunk/Ohana/src/opihi/pantasks/delete.c

    r4539 r4552  
    1 # include "pcontrol.h"
     1# include "scheduler.h"
    22
    3 int delete (int argc, char **argv) {
     3int delete_job (int argc, char **argv) {
    44
    55  Job *job;
     
    1313  /* use a string interp to convert JobIDs to ints ? */
    1414
    15   job = PullJob (JobID, PCONTROL_JOB_PENDING);
    16   if (job != NULL) goto found;
    17 
    18   job = PullJob (JobID, PCONTROL_JOB_CRASH);
    19   if (job != NULL) goto found;
    20 
    21   job = PullJob (JobID, PCONTROL_JOB_EXIT);
    22   if (job != NULL) goto found;
    23 
    24   fprintf (stderr, "job %s not PENDING, CRASH, EXIT\n", argv[1]);
    25   return (FALSE);
    26  
    27 found:
    28   {
    29     int j;
    30     fprintf (stderr, "deleting job  %s  %d  ", job[0].hostname, job[0].argc);
    31     for (j = 0; j < job[0].argc; j++) {
    32       fprintf (stderr, "%s ", job[0].argv[j]);
    33     }
    34     PrintID (stderr, job[0].JobID);
    35     fprintf (stderr, "\n");
    36   } 
    37   DelJob (job);
    38 
     15  fprintf (stderr, "this function is not yet implemented\n");
    3916  return (TRUE);
    4017}
  • trunk/Ohana/src/opihi/pantasks/init.c

    r4539 r4552  
    1 # include "basic.h"
    21# include "scheduler.h"
    32
     
    109int run             PROTO((int, char **));
    1110int stop            PROTO((int, char **));
     11int status_sys      PROTO((int, char **));
     12int kill_job        PROTO((int, char **));
     13int delete_job      PROTO((int, char **));
    1214
    1315static Command cmds[] = { 
     
    2123  {"run",        run,          "run the scheduler"},
    2224  {"stop",       stop,         "stop the scheduler"},
     25  {"status",     status_sys,   "get system status"},
     26  {"kill",       kill_job,     "kill job"},
     27  {"delete",     delete_job,   "delete job"},
     28};
    2329
     30/* these are functions which duplicate actions on the
     31   controller.  these could simply pass the command along
     32   to the controller (and should then be in 'controller'),
     33   or they could add / modify the jobs in the scheduler
     34   job stack
     35
     36  {"job",        job,          "add job"},
    2437  {"kill",       kill_sh,      "kill job"},
    2538  {"delete",     delete,       "delete job"},
    26   {"job",        job,          "add job"},
    27   {"host",       host,         "add / delete / modify host"},
    28   {"check",      check,        "get job or host status"},
    29   {"status",     status,       "get system status"},
    30   {"stdout",     stdout_pc,    "get stdout buffer for job"},
    31   {"stderr",     stderr_pc,    "get stderr buffer for job"},
    32 };
     39  {"stdout",     stdout_sh,    "get stdout buffer for job"},
     40  {"stderr",     stderr_sh,    "get stderr buffer for job"},
     41*/
    3342
    3443void InitSched () {
  • trunk/Ohana/src/opihi/pantasks/job.c

    r4539 r4552  
    1 # include "pcontrol.h"
     1# include "scheduler.h"
     2
     3/* this will require a bit of care: to define a job, we need
     4   to specify:
     5   - the command
     6     this is defined in the job command: job argv0 argv1 argv2...
     7   - timeout (an option to the command)
     8   - exit macros?
     9     do nothing by default?
     10   - stderr / stdout disposal?
     11     save in a specific buffer by default?
     12     send to a file?
     13
     14   the command can look just like the controller equivalent one:
     15   job [-host host] [-timeout timeout] args...
     16
     17*/
    218
    319int job (int argc, char **argv) {
  • trunk/Ohana/src/opihi/pantasks/kill.c

    r4539 r4552  
    1 # include "pcontrol.h"
     1# include "scheduler.h"
    22
    3 int kill_pc (int argc, char **argv) {
     3int kill_job (int argc, char **argv) {
    44
    55  Job *job;
     
    1212  JobID = atoi (argv[1]);
    1313
    14   job = PullJob (JobID, PCONTROL_JOB_BUSY);
    15   if (job == NULL) {
    16     fprintf (stderr, "job %s not BUSY\n", argv[1]);
    17     return (FALSE);
    18   }
    19   KillJob (job);
     14  /* not yet implemented */
     15
     16  fprintf (stderr, "this function is not yet implemented\n");
    2017  return (TRUE);
    2118}
    22 
    23 /* find job from jobID, kill locally or on controller */
  • trunk/Ohana/src/opihi/pantasks/run.c

    r4450 r4552  
    1414  return (TRUE);
    1515}
    16 
    17 int stop (int argc, char **argv) {
    18 
    19   if (argc != 1) {
    20     fprintf (stderr, "USAGE: stop\n");
    21     return (FALSE);
    22   }
    23 
    24   rl_event_hook = NULL;
    25   rl_set_keyboard_input_timeout (1000000);
    26 
    27   return (TRUE);
    28 }
Note: See TracChangeset for help on using the changeset viewer.