PageRenderTime 43ms CodeModel.GetById 32ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/modules/machines.c

https://code.google.com/
C | 109 lines | 53 code | 16 blank | 40 comment | 2 complexity | b51ee0122d6ec0d29432bd143a99fc56 MD5 | raw file
  1/*****************************************************************************\
  2 *  $Id$
  3 *****************************************************************************
  4 *  Copyright (C) 2001-2002 The Regents of the University of California.
  5 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  6 *  Written by Jim Garlick <garlick@llnl.gov>.
  7 *  UCRL-CODE-2003-005.
  8 *  
  9 *  This file is part of Pdsh, a parallel remote shell program.
 10 *  For details, see <http://www.llnl.gov/linux/pdsh/>.
 11 *  
 12 *  Pdsh is free software; you can redistribute it and/or modify it under
 13 *  the terms of the GNU General Public License as published by the Free
 14 *  Software Foundation; either version 2 of the License, or (at your option)
 15 *  any later version.
 16 *  
 17 *  Pdsh is distributed in the hope that it will be useful, but WITHOUT ANY
 18 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 19 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 20 *  details.
 21 *  
 22 *  You should have received a copy of the GNU General Public License along
 23 *  with Pdsh; if not, write to the Free Software Foundation, Inc.,
 24 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 25\*****************************************************************************/
 26
 27#if HAVE_CONFIG_H
 28#  include "config.h"
 29#endif
 30
 31#include "src/pdsh/wcoll.h"
 32#include "src/pdsh/mod.h"
 33#include "src/common/hostlist.h"
 34#include "src/common/err.h"
 35
 36#if STATIC_MODULES
 37#  define pdsh_module_info machines_module_info
 38#  define pdsh_module_priority machines_module_priority
 39#endif    
 40
 41int pdsh_module_priority = DEFAULT_MODULE_PRIORITY;
 42
 43static hostlist_t read_machines(opt_t *opt);
 44static int machines_opt_a(opt_t *, int, char *);
 45
 46static bool allnodes = false;
 47
 48/* 
 49 * Export pdsh module operations structure
 50 */
 51struct pdsh_module_operations machines_module_ops = {
 52    (ModInitF)       NULL, 
 53    (ModExitF)       NULL, 
 54    (ModReadWcollF)  read_machines, 
 55    (ModPostOpF)     NULL,
 56};
 57
 58/* 
 59 * Export rcmd module operations
 60 */
 61struct pdsh_rcmd_operations machines_rcmd_ops = {
 62    (RcmdInitF)  NULL,
 63    (RcmdSigF)   NULL,
 64    (RcmdF)      NULL,
 65};
 66
 67/* 
 68 * Export module options
 69 */
 70struct pdsh_module_option machines_module_options[] = 
 71 { { 'a', NULL, "target all nodes", DSH | PCP, (optFunc) machines_opt_a },
 72   PDSH_OPT_TABLE_END
 73 };
 74
 75/* 
 76 * Machines module info 
 77 */
 78struct pdsh_module pdsh_module_info = {
 79  "misc",
 80  "machines",
 81  "Jim Garlick <garlick@llnl.gov>",
 82  "Read list of all nodes from a machines file",
 83  DSH | PCP, 
 84
 85  &machines_module_ops,
 86  &machines_rcmd_ops,
 87  &machines_module_options[0],
 88};
 89
 90static int machines_opt_a(opt_t *pdsh_opt, int opt, char *arg)
 91{
 92    allnodes = true;
 93    return 0;
 94}
 95
 96static hostlist_t read_machines(opt_t *opt)
 97{
 98    if (!allnodes)
 99        return NULL;
100
101    if (opt->wcoll)
102        errx("Do not specify both -w and -a");
103
104    return read_wcoll(_PATH_MACHINES, NULL);
105}
106
107/*
108 * vi: tabstop=4 shiftwidth=4 expandtab
109 */