/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. #if HAVE_CONFIG_H
  27. # include "config.h"
  28. #endif
  29. #include "src/pdsh/wcoll.h"
  30. #include "src/pdsh/mod.h"
  31. #include "src/common/hostlist.h"
  32. #include "src/common/err.h"
  33. #if STATIC_MODULES
  34. # define pdsh_module_info machines_module_info
  35. # define pdsh_module_priority machines_module_priority
  36. #endif
  37. int pdsh_module_priority = DEFAULT_MODULE_PRIORITY;
  38. static hostlist_t read_machines(opt_t *opt);
  39. static int machines_opt_a(opt_t *, int, char *);
  40. static bool allnodes = false;
  41. /*
  42. * Export pdsh module operations structure
  43. */
  44. struct pdsh_module_operations machines_module_ops = {
  45. (ModInitF) NULL,
  46. (ModExitF) NULL,
  47. (ModReadWcollF) read_machines,
  48. (ModPostOpF) NULL,
  49. };
  50. /*
  51. * Export rcmd module operations
  52. */
  53. struct pdsh_rcmd_operations machines_rcmd_ops = {
  54. (RcmdInitF) NULL,
  55. (RcmdSigF) NULL,
  56. (RcmdF) NULL,
  57. };
  58. /*
  59. * Export module options
  60. */
  61. struct pdsh_module_option machines_module_options[] =
  62. { { 'a', NULL, "target all nodes", DSH | PCP, (optFunc) machines_opt_a },
  63. PDSH_OPT_TABLE_END
  64. };
  65. /*
  66. * Machines module info
  67. */
  68. struct pdsh_module pdsh_module_info = {
  69. "misc",
  70. "machines",
  71. "Jim Garlick <garlick@llnl.gov>",
  72. "Read list of all nodes from a machines file",
  73. DSH | PCP,
  74. &machines_module_ops,
  75. &machines_rcmd_ops,
  76. &machines_module_options[0],
  77. };
  78. static int machines_opt_a(opt_t *pdsh_opt, int opt, char *arg)
  79. {
  80. allnodes = true;
  81. return 0;
  82. }
  83. static hostlist_t read_machines(opt_t *opt)
  84. {
  85. if (!allnodes)
  86. return NULL;
  87. if (opt->wcoll)
  88. errx("Do not specify both -w and -a");
  89. return read_wcoll(_PATH_MACHINES, NULL);
  90. }
  91. /*
  92. * vi: tabstop=4 shiftwidth=4 expandtab
  93. */