Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:jason_wong
clusterit
clusterit_patch_001_role_option.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File clusterit_patch_001_role_option.patch of Package clusterit
diff -Naur clusterit-2.4/common/common.c clusterit-2.4-new/common/common.c --- clusterit-2.4/common/common.c 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/common/common.c 2007-10-29 16:33:49.000000000 +0800 @@ -403,3 +403,88 @@ progname, file, line, strerror(errno), errno); _exit(EXIT_FAILURE); } + +/* + * get a list of ip address from the role name + */ +char **chess_query_hosts( char *rolearg ) { + char cmd[ CHESS_CMD_MAX ] ; + char hostname[ 255 ] ; + char **ret ; + FILE *fp ; + int ind ; + int len ; + int available ; + char *s ; + char *p ; + + ind = 0 ; + ret = (char **)malloc( sizeof(char *) ); + if ( ! ret ) + return NULL ; + ret[ind] = NULL ; + + (void)strncpy( cmd, CHESS_QUERY_IP_BY_ROLES, CHESS_CMD_MAX - 1 ); + available = CHESS_CMD_MAX - 1 - strlen(CHESS_QUERY_IP_BY_ROLES) ; + + /* + * append each comma delimited rolename + */ + p = rolearg ; + while ( p && ( available>0 ) ) { + s = (char *)strsep(&p, ","); + if ( s && ( available>0 ) ) { + strncat( cmd, " ", available ); + strncat( cmd, s, available-1 ); + available -= strlen(s) + 1; + } + } + + fp = popen( cmd, "r" ); + if ( !fp ){ + fprintf( stderr, "Failed to execute command %s\n", cmd ); + return NULL ; + } + s = fgets( hostname, 255, fp ); + while ( s ){ + len = strlen( s ); + if ( len > 0 && s[len-1] == '\n' ){ + s[len-1] = 0 ; + } + ret = (char **)realloc( ret, sizeof(char *)*(ind+2)); + if ( ! ret ) { + fprintf( stderr, "out of memory\n"); + return NULL ; + } + ret[ind] = (char *)malloc( strlen(s) + 1 ); + if ( ! ret[ind] ){ + fprintf( stderr, "out of memory\n"); + return NULL ; + } + strcpy( ret[ind], s ); + ind++ ; + ret[ind] = NULL ; + + s = fgets( hostname, 255, fp ); + } + pclose( fp ); + + return ret ; +} + +/* + * free a list of hostnames + */ +void chess_free_hosts( char **arg ){ + char **p = arg ; + int i ; + if ( !p ) + return ; + i = 0 ; + while( p[i] ){ + free( p[i] ); + i++; + } + free( p ); +} + diff -Naur clusterit-2.4/common/common.h clusterit-2.4-new/common/common.h --- clusterit-2.4/common/common.h 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/common/common.h 2007-10-29 16:33:13.000000000 +0800 @@ -119,3 +119,9 @@ extern int debug; extern char *progname; + +#define CHESS_QUERY_IP_BY_ROLES "@PREFIX@/bin/query-node" +#define CHESS_CMD_MAX 1024 +char **chess_query_hosts( char *rolearg ); +void chess_free_hosts( char **arg ); + diff -Naur clusterit-2.4/dsh/dsh.1 clusterit-2.4-new/dsh/dsh.1 --- clusterit-2.4/dsh/dsh.1 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/dsh/dsh.1 2007-10-29 14:45:43.000000000 +0800 @@ -44,6 +44,7 @@ .Op Fl o Ar porttimeout .Op Fl p Ar portnum .Op Fl w Ar node1,...,nodeN +.Op Fl R Ar role1,...,roleN .Op Fl x Ar node1,...,nodeN .Op Ar command ... .Sh DESCRIPTION @@ -150,6 +151,17 @@ runs on the nodes listed in the file pointed to by the .Ev CLUSTER environment variable. +.It Fl R +If the +.Fl R +option is specified, followed by a comma delimited list of role names, +the +.Ar command +will be run on each node of the roles. Without this option, +.Nm +runs on the nodes listed in the file pointed to by the +.Ev CLUSTER +environment variable. .It Fl x The .Fl x diff -Naur clusterit-2.4/dsh/dsh.c clusterit-2.4-new/dsh/dsh.c --- clusterit-2.4/dsh/dsh.c 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/dsh/dsh.c 2007-10-30 09:14:25.000000000 +0800 @@ -82,6 +82,8 @@ char **exclude, **grouptemp; struct rlimit limit; node_t *nodeptr; + char **chesshosts ; + int hostindex ; someflag = showflag = fanflag = 0; exclusion = debug = errorflag = 0; @@ -109,9 +111,9 @@ } progname = q; #if defined(__linux__) - while ((ch = getopt(argc, argv, "+?deiqtf:g:l:o:p:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "+?deiqtf:g:l:o:p:vw:x:R:")) != -1) #else - while ((ch = getopt(argc, argv, "?deiqtf:g:l:o:p:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "?deiqtf:g:l:o:p:vw:x:R:")) != -1) #endif switch (ch) { case 'd': /* we want to debug dsh (hidden)*/ @@ -198,11 +200,29 @@ (void)nodealloc(nodename); } break; + case 'R': /* perform operation on these roles */ + someflag = 1; + chesshosts = chess_query_hosts( optarg ); + if (!chesshosts){ + fprintf(stderr, + "Failed to get hosts from roles\n"); + return(EXIT_FAILURE); + } + + hostindex = 0 ; + while( chesshosts[hostindex] ){ + (void)nodealloc( chesshosts[hostindex] ); + hostindex++ ; + } + chess_free_hosts( chesshosts ); + + break; case '?': /* you blew it */ (void)fprintf(stderr, "usage: %s [-eiqtv] [-f fanout] [-p portnum] [-o timeout]" "[-g rungroup1,...,rungroupN] [-l username] " "[-x node1,...,nodeN] [-w node1,..,nodeN] " + "[-R role1,role2,...,roleN] " "[command ...]\n", progname); return(EXIT_FAILURE); /*NOTREACHED*/ diff -Naur clusterit-2.4/dvt/dvt.1 clusterit-2.4-new/dvt/dvt.1 --- clusterit-2.4/dvt/dvt.1 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/dvt/dvt.1 2007-10-29 14:28:32.000000000 +0800 @@ -42,6 +42,7 @@ .Op Fl g Ar rungroup1,...,rungroupN .Op Fl l Ar username .Op Fl w Ar node1,...,nodeN +.Op Fl R Ar role1,...,roleN .Op Fl x Ar node1,...,nodeN .Sh DESCRIPTION The @@ -125,6 +126,17 @@ open windows to all the nodes listed in the file pointed to by the .Ev CLUSTER environment variable. +.It Fl R +If the +.Fl R +option is specified, followed by a comma delimited list of role names, +the +.Ar command +will be run on each node of the roles. Without this option, +.Nm +runs on the nodes listed in the file pointed to by the +.Ev CLUSTER +environment variable. .It Fl x The .Fl x diff -Naur clusterit-2.4/dvt/dvt.c clusterit-2.4-new/dvt/dvt.c --- clusterit-2.4/dvt/dvt.c 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/dvt/dvt.c 2007-10-29 14:25:59.000000000 +0800 @@ -112,6 +112,8 @@ char **exclude, **grouptemp; struct rlimit limit; node_t *nodeptr; + char **chesshosts; + int hostindex; someflag = showflag = fanflag = 0; exclusion = debug = errorflag = 0; @@ -139,9 +141,9 @@ progname = q; #if defined(__linux__) - while ((ch = getopt(argc, argv, "+?deiqf:g:l:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "+?deiqf:g:l:vw:x:R:")) != -1) #else - while ((ch = getopt(argc, argv, "?deiqf:g:l:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "?deiqf:g:l:vw:x:R:")) != -1) #endif switch (ch) { case 'd': /* we want to debug dvt (hidden)*/ @@ -219,10 +221,29 @@ (void)printf("%s: %s\n", progname, version); exit(EXIT_SUCCESS); break; + case 'R': /* perform operation on these roles */ + someflag = 1; + + chesshosts = chess_query_hosts( optarg ); + if (!chesshosts){ + fprintf(stderr, + "Failed to get hosts from roles\n"); + return(EXIT_FAILURE); + } + + hostindex = 0 ; + while( chesshosts[hostindex] ){ + (void)nodealloc( chesshosts[hostindex] ); + hostindex++ ; + } + chess_free_hosts( chesshosts ); + break; + case '?': /* you blew it */ (void)fprintf(stderr, "usage: %s [-eiqv] [-f fanout] [-g rungroup1,...,rungroupN] " "[-l username] [-x node1,...,nodeN] [-w node1,..,nodeN]\n", + "[-R role1,role2,...,roleN]\n", progname); return(EXIT_FAILURE); /*NOTREACHED*/ diff -Naur clusterit-2.4/jsd/jsd.1 clusterit-2.4-new/jsd/jsd.1 --- clusterit-2.4/jsd/jsd.1 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/jsd/jsd.1 2007-10-29 17:13:07.000000000 +0800 @@ -44,6 +44,7 @@ .Op Fl p Ar port .Op Fl o Ar port .Op Fl w Ar node1,...,nodeN +.Op Fl R Ar role1,...,roleN .Op Fl x Ar node1,...,nodeN .Op Ar command ... .Sh DESCRIPTION @@ -152,6 +153,17 @@ runs on the nodes listed in the file pointed to by the .Ev CLUSTER environment variable. +.It Fl R +If the +.Fl R +option is specified, followed by a comma delimited list of role names, +the +.Ar command +will be run on each node of the roles. Without this option, +.Nm +runs on the nodes listed in the file pointed to by the +.Ev CLUSTER +environment variable. .It Fl x The .Fl x diff -Naur clusterit-2.4/jsd/jsd.c clusterit-2.4-new/jsd/jsd.c --- clusterit-2.4/jsd/jsd.c 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/jsd/jsd.c 2007-10-30 09:15:01.000000000 +0800 @@ -86,6 +86,8 @@ char **grouptemp, **exclude; struct rlimit limit; pid_t pid; + char **chesshosts ; + int hostindex ; someflag = showflag = fanflag = 0; exclusion = debug = 0; @@ -111,9 +113,9 @@ progname = q; #if defined(__linux__) - while ((ch = getopt(argc, argv, "+?diqf:g:l:vw:x:o:p:")) != -1) + while ((ch = getopt(argc, argv, "+?diqf:g:l:vw:x:o:p:R:")) != -1) #else - while ((ch = getopt(argc, argv, "?diqf:g:l:vw:x:o:p:")) != -1) + while ((ch = getopt(argc, argv, "?diqf:g:l:vw:x:o:p:R:")) != -1) #endif switch (ch) { case 'd': /* we want to debug jsd (hidden)*/ @@ -184,6 +186,24 @@ (void)nodealloc(nodename); } break; + case 'R': /* perform operation on these roles */ + someflag = 1; + + chesshosts = chess_query_hosts( optarg ); + if (!chesshosts){ + fprintf(stderr, + "Failed to get hosts from roles\n"); + return(EXIT_FAILURE); + } + + hostindex = 0 ; + while( chesshosts[hostindex] ){ + (void)nodealloc( chesshosts[hostindex] ); + hostindex++ ; + } + chess_free_hosts( chesshosts ); + + break; case 'o': /* port to listen to requests on */ oportnum = atoi(optarg); break; @@ -198,6 +218,7 @@ (void)fprintf(stderr, "usage: jsd [-iqv] [-f fanout] [-g rungroup1,...,rungroupN] " "[-l username] [-p port] [-o port] [-w node1,..,nodeN] " + "[-R role1,role2,...,roleN] " "[-x node1,...,nodeN] [command ...]\n"); return(EXIT_FAILURE); /*NOTREACHED*/ diff -Naur clusterit-2.4/pcp/pcp.1 clusterit-2.4-new/pcp/pcp.1 --- clusterit-2.4/pcp/pcp.1 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/pcp/pcp.1 2007-10-29 14:47:14.000000000 +0800 @@ -43,6 +43,7 @@ .Op Fl f Ar fanout .Op Fl g Ar rungroup1,...,rungroupN .Op Fl w Ar node1,...,nodeN +.Op Fl R Ar role1,...,roleN .Op Fl x Ar node1,...,nodeN .Ar source_file1 .Op source_file2 ... source_fileN @@ -136,6 +137,17 @@ runs on the nodes listed in the file pointed to by the .Ev CLUSTER environment variable. +.It Fl R +If the +.Fl R +option is specified, followed by a comma delimited list of role names, +the +.Ar command +will be run on each node of the roles. Without this option, +.Nm +runs on the nodes listed in the file pointed to by the +.Ev CLUSTER +environment variable. .It Fl x The .Fl x diff -Naur clusterit-2.4/pcp/pcp.c clusterit-2.4-new/pcp/pcp.c --- clusterit-2.4/pcp/pcp.c 2006-02-02 02:07:16.000000000 +0800 +++ clusterit-2.4-new/pcp/pcp.c 2007-10-29 14:47:14.000000000 +0800 @@ -78,6 +78,8 @@ char *p, *q, *nodename, *username, *group; char **exclude, **grouptemp; node_t *nodeptr; + char **chesshosts ; + int hostindex ; fanout = 0; quiet = 1; @@ -108,9 +110,9 @@ progname = q; #if defined(__linux__) - while ((ch = getopt(argc, argv, "+?cdeprf:g:l:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "+?cdeprf:g:l:vw:x:R:")) != -1) #else - while ((ch = getopt(argc, argv, "?cdeprf:g:l:vw:x:")) != -1) + while ((ch = getopt(argc, argv, "?cdeprf:g:l:vw:x:R:")) != -1) #endif switch (ch) { case 'c': /* set concurrent mode */ @@ -191,10 +193,31 @@ (void)printf("%s: %s\n", progname, version); exit(EXIT_SUCCESS); break; + case 'R': + someflag = 1; + i = 0; + p = optarg ; + + chesshosts = chess_query_hosts( optarg ); + if (!chesshosts){ + fprintf(stderr, + "Failed to get hosts from roles\n"); + return(EXIT_FAILURE); + } + + hostindex = 0 ; + while( chesshosts[hostindex] ){ + (void)nodealloc( chesshosts[hostindex] ); + hostindex++ ; + } + chess_free_hosts( chesshosts ); + + break; case '?': (void)fprintf(stderr, "usage: %s [-ceprv] [-f fanout] [-g rungroup1,...,rungroupN] " "[-l username] [-x node1,...,nodeN] [-w node1,..,nodeN] " + "[-R role1,role2,...,roleN] " "source_file1 [source_file2 ... source_fileN] " "[desitination_file]\n", progname); return(EXIT_FAILURE); @@ -276,7 +299,7 @@ rcp = getenv("RCP_CMD"); if (rcp == NULL) - rcp = strdup("rcp"); + rcp = strdup("scp"); if (rcp == NULL) bailout(); (void)snprintf(args, 64, " ");
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor