1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
5 /* This is the file cluster.c for the MOIRA Client, which allows a nieve
6 * user to quickly and easily maintain most parts of the MOIRA database.
10 * By: Chris D. Peterson
16 * Copyright 1988 by the Massachusetts Institute of Technology.
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
22 /* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
27 #include <moira_site.h>
30 #include "mit-copyright.h"
40 #define M_DEFAULT_TYPE DEFAULT_NONE
42 #define C_DEFAULT_DESCRIPT DEFAULT_NONE
43 #define C_DEFAULT_LOCATION DEFAULT_NONE
45 #define CD_DEFAULT_LABEL DEFAULT_NONE
46 #define CD_DEFAULT_DATA DEFAULT_NONE
48 /* -------------------- Set Defaults -------------------- */
50 /* Function Name: SetMachineDefaults
51 * Description: sets machine defaults.
52 * Arguments: info - an array to put the defaults into.
53 * name - Canonacalized name of the machine.
54 * Returns: info - the array.
58 SetMachineDefaults(info, name)
61 info[M_NAME] = Strsave(name);
62 info[M_TYPE] = Strsave(M_DEFAULT_TYPE);
63 info[M_MODBY] = info[M_MODTIME] = info[M_MODWITH] = info[M_END] = NULL;
67 /* Function Name: SetClusterDefaults
68 * Description: sets Cluster defaults.
69 * Arguments: info - an array to put the defaults into.
70 * name - name of the Cluster.
71 * Returns: info - the array.
75 SetClusterDefaults(info, name)
78 info[C_NAME] = Strsave(name);
79 info[C_DESCRIPT] = Strsave(C_DEFAULT_DESCRIPT);
80 info[C_LOCATION] = Strsave(C_DEFAULT_LOCATION);
81 info[C_MODBY] = info[C_MODTIME] = info[C_MODWITH] = info[C_END] = NULL;
85 /* -------------------- General Functions -------------------- */
87 /* Function Name: PrintMachInfo
88 * Description: This function Prints out the Machine info in
90 * Arguments: info - array of information about a machine.
91 * Returns: The name of the Machine
101 sprintf(buf, "Machine: %-30s Type: %s", info[M_NAME], info[M_TYPE]);
103 sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
105 return(info[M_NAME]);
108 /* Function Name: PrintClusterInfo
109 * Description: This function Prints out the cluster info
110 * in a coherent form.
111 * Arguments: info - array of information about a cluster.
112 * Returns: The name of the cluster.
116 PrintClusterInfo(info)
122 sprintf(buf, "Cluster: %s", info[C_NAME]);
124 sprintf(buf, "Description: %s", info[C_DESCRIPT]);
126 sprintf(buf, "Location: %s", info[C_LOCATION]);
128 sprintf(buf, MOD_FORMAT, info[C_MODBY], info[C_MODTIME], info[C_MODWITH]);
130 return(info[C_NAME]);
133 /* Function Name: PrintClusterData
134 * Description: Prints the Data on a cluster
135 * Arguments: info a pointer to the data array.
136 * Returns: The name of the cluster.
140 PrintClusterData(info)
146 sprintf(buf, "Cluster: %-20s Label: %-15s Data: %s",
147 info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
149 return(info[CD_NAME]);
152 /* Function Name: PrintMCMap
153 * Description: Prints the data about a machine to cluster mapping.
154 * Arguments: info a pointer to the data array.
163 sprintf(buf, "Cluster: %-30s Machine: %-20s",
164 info[MAP_CLUSTER], info[MAP_MACHINE]);
166 return(""); /* Used by QueryLoop(). */
169 /* Function Name: GetMCInfo.
170 * Description: This function stores info about a machine.
171 * type - type of data we are trying to retrieve.
172 * name1 - the name of argv[0] for the call.
173 * name2 - the name of argv[1] for the call.
174 * Returns: the top element of a queue containing the data or NULL.
178 GetMCInfo(type, name1, name2)
180 char * name1, *name2;
184 struct qelem * elem = NULL;
189 if ( (stat = do_mr_query("get_machine", 1, &name1,
190 StoreInfo, (char *)&elem)) != 0) {
191 if (stat == MR_NO_MATCH) {
193 sprintf(buf, "Machine '%s' is not in the database.", name1);
196 com_err(program_name, stat, " in get_machine.");
201 if ( (stat = do_mr_query("get_cluster", 1, &name1,
202 StoreInfo, (char *)&elem)) != 0) {
203 com_err(program_name, stat, " in get_cluster.");
208 args[MAP_MACHINE] = name1;
209 args[MAP_CLUSTER] = name2;
210 if ( (stat = do_mr_query("get_machine_to_cluster_map", 2, args,
211 StoreInfo, (char *)&elem)) != 0) {
212 com_err(program_name, stat, " in get_machine_to_cluster_map.");
217 args[CD_NAME] = name1;
218 args[CD_LABEL] = name2;
219 if ( (stat = do_mr_query("get_cluster_data", 2, args,
220 StoreInfo, (char *)&elem)) != 0) {
221 com_err(program_name, stat, " in get_cluster_data.");
225 return(QueueTop(elem));
228 /* Function Name: AskMCDInfo.
229 * Description: This function askes the user for information about a
230 * machine and saves it into a structure.
231 * Arguments: info - a pointer the information to ask about
232 * type - type of information - MACHINE
235 * name - T/F : change the name of this type.
240 AskMCDInfo(info, type, name)
245 char temp_buf[BUFSIZ], *newname, *oldnewname;
249 sprintf(temp_buf, "Setting the information for the Machine %s.",
253 sprintf(temp_buf, "Setting the information for the Cluster %s.",
257 sprintf(temp_buf, "Setting the Data for the Cluster %s.",
261 Put_message(temp_buf);
266 newname = Strsave(info[M_NAME]);
267 if (GetValueFromUser("The new name for this machine? ", &newname) ==
270 oldnewname = Strsave(newname);
271 newname = canonicalize_hostname(newname);
272 if (strcasecmp(newname, oldnewname) && *oldnewname != '"') {
273 sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'\n",
274 oldnewname, newname);
275 Put_message(temp_buf);
280 newname = Strsave(info[C_NAME]);
281 if (GetValueFromUser("The new name for this cluster? ",
282 &newname) == SUB_ERROR)
286 Put_message("Unknown type in AskMCDInfo, programmer botch");
293 if (GetTypeFromUser("Machine's Type", "mac_type", &info[M_TYPE]) ==
296 FreeAndClear(&info[M_MODTIME], TRUE);
297 FreeAndClear(&info[M_MODBY], TRUE);
298 FreeAndClear(&info[M_MODWITH], TRUE);
301 if (GetValueFromUser("Cluster's Description:", &info[C_DESCRIPT]) ==
304 if (GetValueFromUser("Cluster's Location:", &info[C_LOCATION]) ==
307 FreeAndClear(&info[C_MODTIME], TRUE);
308 FreeAndClear(&info[C_MODBY], TRUE);
309 FreeAndClear(&info[C_MODWITH], TRUE);
312 if (GetValueFromUser("Label defining this data?", &info[CD_LABEL]) ==
315 if (GetValueFromUser("The data itself ? ", &info[CD_DATA]) == SUB_ERROR)
321 * Slide the newname into the #2 slot, this screws up all future references
325 SlipInNewName(info, newname);
330 /* ----------- Machine Menu ----------- */
332 /* Function Name: ShowMachineInfo
333 * Description: This function shows the information about a machine.
334 * Arguments: argc, argv - the name of the machine in argv[1].
335 * Returns: DM_NORMAL.
340 ShowMachineInfo(argc, argv)
347 tmpname = canonicalize_hostname(strsave(argv[1]));
348 top = GetMCInfo(MACHINE, tmpname, (char *) NULL);
349 Loop(top, ( (void *) PrintMachInfo) );
354 /* Function Name: AddMachine
355 * Description: This function adds a new machine to the database.
356 * Arguments: argc, argv - the name of the machine in argv[1].
357 * Returns: DM_NORMAL.
362 AddMachine(argc, argv)
366 char **args, *info[MAX_ARGS_SIZE], *name, buf[256];
369 if (!ValidName(argv[1])) /* Checks for wildcards. */
372 * Check to see if this machine already exists.
374 name = canonicalize_hostname(strsave(argv[1]));
376 if ( (stat = do_mr_query("get_machine", 1, &name, NullFunc, NULL)) == 0) {
377 sprintf(buf, "The machine '%s' already exists.", name);
382 else if (stat != MR_NO_MATCH) {
383 com_err(program_name, stat,
384 " while checking machine '%s' in AddMachine.", name);
389 if ((args = AskMCDInfo(SetMachineDefaults(info, name), MACHINE, FALSE)) ==
391 Put_message("Aborted.");
396 * Actually create the new Machine.
399 if ( (stat = do_mr_query("add_machine", CountArgs(args),
400 args, Scream, NULL)) != 0)
401 com_err(program_name, stat, " in AddMachine.");
408 /* Function Name: RealUpdateMachine
409 * Description: Performs the actual update of the machine data.
410 * Arguments: info - the information on the machine to update.
411 * junk - an UNUSED Boolean.
417 RealUpdateMachine(info, junk)
422 char ** args = AskMCDInfo(info, MACHINE, TRUE);
424 Put_message("Aborted.");
427 if ( (stat = do_mr_query("update_machine", CountArgs(args),
428 args, Scream, NULL)) != 0)
429 com_err(program_name, stat, " in UpdateMachine.");
431 Put_message("Machine sucessfully updated.");
434 /* Function Name: UpdateMachine
435 * Description: This function adds a new machine to the database.
436 * Arguments: argc, argv - the name of the machine in argv[1].
437 * Returns: DM_NORMAL.
442 UpdateMachine(argc, argv)
449 tmpname = canonicalize_hostname(strsave(argv[1]));
450 top = GetMCInfo( MACHINE, tmpname, (char *) NULL);
451 QueryLoop(top, NullPrint, RealUpdateMachine, "Update the machine");
458 /* Function Name: CheckAndRemoveFromCluster
459 * Description: This func tests to see if a machine is in a cluster.
460 * and if so then removes it
461 * Arguments: name - name of the machine (already Canonocalized).
462 * ask_user- query the user before removing if from clusters?
463 * Returns: MR_ERROR if machine left in a cluster, or mr_error.
467 CheckAndRemoveFromCluster(name, ask_user)
471 register int stat, ret_value;
473 char *args[10], temp_buf[BUFSIZ], *ptr;
474 struct qelem *top, *elem = NULL;
476 ret_value = SUB_NORMAL; /* initialize ret_value. */
479 stat = do_mr_query("get_machine_to_cluster_map", 2, args,
480 StoreInfo, (char *)&elem);
481 if (stat && stat != MR_NO_MATCH) {
482 com_err(program_name, stat, " in get_machine_to_cluster_map.");
485 if (stat == MR_SUCCESS) {
486 elem = top = QueueTop(elem);
488 sprintf(temp_buf, "%s is assigned to the following clusters.",
490 Put_message(temp_buf);
491 Loop(top, (void *) PrintMCMap);
492 ptr = "Remove this machine from ** ALL ** these clusters?";
493 if (YesNoQuestion(ptr, FALSE) == TRUE) /* may return -1. */
496 Put_message("Aborting...");
505 while (elem != NULL) {
506 char **info = (char **) elem->q_data;
507 if ( (stat = do_mr_query( "delete_machine_from_cluster",
508 2, info, Scream, NULL)) != 0) {
509 ret_value = SUB_ERROR;
510 com_err(program_name, stat,
511 " in delete_machine_from_cluster.");
513 "Machine %s ** NOT ** removed from cluster %s.",
514 info[MAP_MACHINE], info[MAP_CLUSTER]);
515 Put_message(temp_buf);
524 /* Function Name: RealDeleteMachine
525 * Description: Actually Deletes the Machine.
526 * Arguments: info - nescessary information stored as an array of char *'s
527 * one_machine - a boolean, true if there is only one item in
533 RealDeleteMachine(info, one_machine)
538 char temp_buf[BUFSIZ];
540 sprintf(temp_buf, "Are you sure you want to delete the machine %s (y/n)? ",
542 if(!one_machine || Confirm(temp_buf)) {
543 if (CheckAndRemoveFromCluster(info[M_NAME], TRUE) != SUB_ERROR) {
544 if ( (stat = do_mr_query("delete_machine", 1,
545 &info[M_NAME], Scream, NULL)) != 0) {
546 com_err(program_name, stat, " in DeleteMachine.");
547 sprintf(temp_buf, "%s ** NOT ** deleted.",
549 Put_message(temp_buf);
552 sprintf(temp_buf, "%s successfully Deleted.", info[M_NAME]);
553 Put_message(temp_buf);
559 /* Function Name: DeleteMachine
560 * Description: This function removes a machine from the data base.
561 * Arguments: argc, argv - the machines name int argv[1].
562 * Returns: DM_NORMAL.
565 /* Perhaps we should remove the cluster if it has no machine now. */
569 DeleteMachine(argc, argv)
576 tmpname = canonicalize_hostname(strsave(argv[1]));
577 top = GetMCInfo(MACHINE, tmpname, (char *) NULL);
578 QueryLoop(top, PrintMachInfo, RealDeleteMachine, "Delete the machine");
584 /* Function Name: AddMachineToCluster
585 * Description: This function adds a machine to a cluster
586 * Arguments: argc, argv - The machine name is argv[1].
587 * The cluster name in argv[2].
588 * Returns: DM_NORMAL.
593 AddMachineToCluster(argc, argv)
598 char *machine, *cluster, temp_buf[BUFSIZ], *args[10];
599 Bool add_it, one_machine, one_cluster;
600 struct qelem * melem, *mtop, *celem, *ctop;
602 machine = canonicalize_hostname(strsave(argv[1]));
603 if (strcasecmp(machine, argv[1]) && *argv[1] != '"') {
604 sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
606 Put_message(temp_buf);
610 celem = ctop = GetMCInfo(CLUSTER, cluster, (char *) NULL);
611 melem = mtop = GetMCInfo(MACHINE, machine, (char *) NULL);
614 one_machine = (QueueCount(mtop) == 1);
615 one_cluster = (QueueCount(ctop) == 1);
617 /* No good way to use QueryLoop() here, sigh */
619 while (melem != NULL) {
620 char ** minfo = (char **) melem->q_data;
621 while (celem != NULL) {
622 char ** cinfo = (char **) celem->q_data;
623 if (one_machine && one_cluster)
626 sprintf(temp_buf,"Add machine %s to cluster %s (y/n/q) ?",
627 minfo[M_NAME], cinfo[C_NAME]);
628 switch (YesNoQuitQuestion(temp_buf, FALSE)) {
636 Put_message("Aborting...");
643 args[0] = minfo[M_NAME];
644 args[1] = cinfo[C_NAME];
645 stat = do_mr_query("add_machine_to_cluster", 2, args,
651 sprintf(temp_buf, "%s is already in cluster %s",
652 minfo[M_NAME], cinfo[C_NAME]);
653 Put_message(temp_buf);
656 com_err(program_name, stat, " in AddMachineToCluster.");
660 celem = celem->q_forw;
662 celem = ctop; /* reset cluster element. */
663 melem = melem->q_forw;
670 /* Function Name: RealRemoveMachineFromCluster
671 * Description: This function actually removes the machine from its
673 * Arguments: info - all information nescessary to perform the removal.
674 * one_map - True if there is only one case, and we should
680 RealRemoveMachineFromCluster(info, one_map)
684 char temp_buf[BUFSIZ];
687 sprintf(temp_buf, "Remove %s from the cluster %s",
688 info[MAP_MACHINE], info[MAP_CLUSTER]);
689 if (!one_map || Confirm(temp_buf)) {
690 if ( (stat = do_mr_query("delete_machine_from_cluster", 2,
691 info, Scream, NULL)) != 0 )
692 com_err(program_name, stat, " in delete_machine_from_cluster");
694 sprintf(temp_buf, "%s has been removed from the cluster %s.",
695 info[MAP_MACHINE], info[MAP_CLUSTER]);
696 Put_message(temp_buf);
700 Put_message("Machine not removed.");
703 /* Function Name: RemoveMachineFromCluster
704 * Description: Removes this machine form a specific cluster.
705 * Arguments: argc, argv - Name of machine in argv[1].
706 * Name of cluster in argv[2].
712 RemoveMachineFromCluster(argc, argv)
716 struct qelem *elem = NULL;
717 char buf[BUFSIZ], * args[10];
720 args[MAP_MACHINE] = canonicalize_hostname(strsave(argv[1]));
721 if (strcasecmp(args[MAP_MACHINE], argv[1]) && *argv[1] != '"') {
722 sprintf(buf, "Warning: '%s' canonicalized to '%s'.",
723 argv[1], args[MAP_MACHINE]);
726 args[MAP_CLUSTER] = argv[2];
727 args[MAP_END] = NULL;
729 stat = do_mr_query("get_machine_to_cluster_map", CountArgs(args), args,
730 StoreInfo, (char *)&elem);
731 if (stat == MR_NO_MATCH) {
732 sprintf(buf, "The machine %s is not is the cluster %s.",
733 args[MAP_MACHINE], args[MAP_CLUSTER]);
735 free(args[MAP_MACHINE]);
738 if (stat != MR_SUCCESS)
739 com_err(program_name, stat, " in delete_machine_from_cluster");
741 elem = QueueTop(elem);
742 QueryLoop(elem, PrintMCMap, RealRemoveMachineFromCluster,
743 "Remove this machine from this cluster");
746 free(args[MAP_MACHINE]);
750 /* ---------- Cluster Menu -------- */
752 /* Function Name: ShowClusterInfo
753 * Description: Gets information about a cluser given its name.
754 * Arguments: argc, argc - the name of the cluster in in argv[1].
755 * Returns: DM_NORMAL.
760 ShowClusterInfo(argc, argv)
766 top = GetMCInfo(CLUSTER, argv[1], (char *) NULL);
767 Loop(top, (void *) PrintClusterInfo);
772 /* Function Name: AddCluster
773 * Description: Creates a new cluster.
774 * Arguments: argc, argv - the name of the new cluster is argv[1].
775 * Returns: DM_NORMAL.
780 AddCluster(argc, argv)
784 char **args, *info[MAX_ARGS_SIZE], *name = argv[1];
787 * Check to see if this cluster already exists.
789 if (!ValidName(name))
792 if ( (stat = do_mr_query("get_cluster", 1, &name,
793 NullFunc, NULL)) == MR_SUCCESS) {
794 Put_message("This cluster already exists.");
797 else if (stat != MR_NO_MATCH) {
798 com_err(program_name, stat, " in AddCluster.");
801 if ((args = AskMCDInfo(SetClusterDefaults(info, name), CLUSTER, FALSE)) ==
803 Put_message("Aborted.");
809 * Actually create the new Cluster.
811 if ( (stat = do_mr_query("add_cluster", CountArgs(args),
812 args, Scream, NULL)) != 0)
813 com_err(program_name, stat, " in AddCluster.");
819 /* Function Name: RealUpdateCluster
820 * Description: This function actually performs the cluster update.
821 * Arguments: info - all information nesc. for updating the cluster.
822 * junk - an UNUSED boolean.
828 RealUpdateCluster(info, junk)
833 char ** args = AskMCDInfo(info, CLUSTER, TRUE);
835 Put_message("Aborted.");
838 if ( (stat = do_mr_query("update_cluster", CountArgs(args),
839 args, Scream, NULL)) != 0)
840 com_err(program_name, stat, " in UpdateCluster.");
842 Put_message("Cluster successfully updated.");
845 /* Function Name: UpdateCluster
846 * Description: This Function Updates a cluster
847 * Arguments: name of the cluster in argv[1].
848 * Returns: DM_NORMAL.
853 UpdateCluster(argc, argv)
858 top = GetMCInfo( CLUSTER, argv[1], (char *) NULL );
859 QueryLoop(top, NullPrint, RealUpdateCluster, "Update the cluster");
865 /* Function Name: CheckAndRemoveMachine
866 * Description: This function checks and removes all machines from a
868 * Arguments: name - name of the cluster.
869 * ask_first - if TRUE, then we will query the user, before
871 * Returns: SUB_ERROR if all machines not removed.
875 CheckAndRemoveMachines(name, ask_first)
879 register int stat, ret_value;
881 char *args[10], temp_buf[BUFSIZ], *ptr;
882 struct qelem *top, *elem = NULL;
884 ret_value = SUB_NORMAL;
885 args[MAP_MACHINE] = "*";
886 args[MAP_CLUSTER] = name;
887 stat = do_mr_query("get_machine_to_cluster_map", 2, args,
888 StoreInfo, (char *)&elem);
889 if (stat && stat != MR_NO_MATCH) {
890 com_err(program_name, stat, " in get_machine_to_cluster_map.");
894 elem = top = QueueTop(elem);
897 "The cluster %s has the following machines in it:",
899 Put_message(temp_buf);
900 while (elem != NULL) {
901 char **info = (char **) elem->q_data;
902 Print(1, &info[MAP_MACHINE], (char *) NULL);
905 ptr = "Remove ** ALL ** these machines from this cluster?";
907 if (YesNoQuestion(ptr, FALSE) == TRUE) /* may return -1. */
910 Put_message("Aborting...");
921 char **info = (char **) elem->q_data;
922 if ( (stat = do_mr_query("delete_machine_from_cluster",
923 2, info, Scream, NULL)) != 0) {
924 ret_value = SUB_ERROR;
925 com_err(program_name, stat,
926 " in delete_machine_from_cluster.");
928 "Machine %s ** NOT ** removed from cluster %s.",
929 info[MAP_MACHINE], info[MAP_CLUSTER]);
930 Put_message(temp_buf);
939 /* Function Name: RealDeleteCluster
940 * Description: Actually performs the cluster deletion.
941 * Arguments: info - all information about this cluster.
942 * one_cluster - If true then there was only one cluster in
943 * the queue, and we should confirm.
948 RealDeleteCluster(info, one_cluster)
953 char temp_buf[BUFSIZ];
956 "Are you sure the you want to delete the cluster %s (y/n) ?",
958 if (!one_cluster || Confirm(temp_buf)) {
959 if (CheckAndRemoveMachines(info[C_NAME], TRUE) != SUB_ERROR) {
960 if ( (stat = do_mr_query("delete_cluster", 1,
961 &info[C_NAME], Scream, NULL)) != 0) {
962 com_err(program_name, stat, " in delete_cluster.");
963 sprintf(temp_buf, "Cluster %s ** NOT ** deleted.",
965 Put_message(temp_buf);
968 sprintf(temp_buf, "cluster %s sucesfully deleted.",
970 Put_message(temp_buf);
976 /* Function Name: DeleteCluster
977 * Description: This function removes a cluster from the database.
978 * Arguments: argc, argv - the name of the cluster is stored in argv[1].
979 * Returns: DM_NORMAL.
984 DeleteCluster(argc, argv)
990 top = GetMCInfo( CLUSTER, argv[1], (char *) NULL );
991 QueryLoop(top, PrintClusterInfo, RealDeleteCluster, "Delete the cluster");
997 /* ----------- Cluster Data Menu -------------- */
999 /* Function Name: ShowClusterData
1000 * Description: This function shows the services for one cluster.
1001 * Arguments: argc, argv - The name of the cluster is argv[1].
1002 * The label of the data in argv[2].
1003 * Returns: DM_NORMAL.
1008 ShowClusterData(argc, argv)
1012 struct qelem *elem, *top;
1015 top = elem = GetMCInfo(DATA, argv[1], argv[2]);
1016 while (elem != NULL) {
1017 info = (char **) elem->q_data;
1018 PrintClusterData(info);
1019 elem = elem->q_forw;
1025 /* Function Name: AddClusterData
1026 * Description: This function adds some data to the cluster.
1027 * Arguments: argv, argc: argv[1] - the name of the cluster.
1028 * argv[2] - the label of the data.
1029 * argv[3] - the data.
1030 * Returns: DM_NORMAL.
1035 AddClusterData(argc, argv)
1041 if( (stat = do_mr_query("add_cluster_data", 3, argv + 1,
1042 Scream, (char *) NULL)) != 0)
1043 com_err(program_name, stat, " in AddClusterData.");
1047 /* Function Name: RealRemoveClusterData
1048 * Description: actually removes the cluster data.
1049 * Arguments: info - all info necessary to remove the cluster, in an array
1051 * one_item - if true then the queue has only one elem and we
1057 RealRemoveClusterData(info, one_item)
1065 temp_ptr = "Are you sure that you want to remove this cluster data (y/n) ?";
1066 PrintClusterData(info);
1067 if (!one_item || Confirm(temp_ptr)) {
1068 if( (stat = do_mr_query("delete_cluster_data", 3, info,
1069 Scream, (char *) NULL)) != 0) {
1070 com_err(program_name, stat, " in DeleteClusterData.");
1071 Put_message("Data not removed.");
1074 Put_message("Removal sucessful.");
1078 /* Function Name: RemoveClusterData
1079 * Description: This function removes data on a given cluster.
1080 * Arguments: argv, argc: argv[1] - the name of the cluster.
1081 * argv[2] - the label of the data.
1082 * argv[3] - the data.
1083 * Returns: DM_NORMAL.
1088 RemoveClusterData(argc, argv)
1094 top = GetMCInfo(DATA, argv[1], argv[2]);
1095 QueryLoop(top, PrintClusterData, RealRemoveClusterData,
1096 "Remove data from cluster");
1102 /* Function Name: MachineToClusterMap
1103 * Description: This Retrieves the mapping between machine and cluster
1104 * Arguments: argc, argv - argv[1] -> machine name or wildcard.
1105 * argv[2] -> cluster name or wildcard.
1111 MachineToClusterMap(argc,argv)
1115 struct qelem *elem, *top;
1116 char *tmpname, temp_buf[256];
1118 tmpname = canonicalize_hostname(strsave(argv[1]));
1119 if (strcasecmp(tmpname, argv[1]) && *argv[1] != '"') {
1120 sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
1122 Put_message(temp_buf);
1124 top = elem = GetMCInfo(MAP, tmpname, argv[2]);
1126 Put_message(""); /* blank line on screen */
1127 while (elem != NULL) {
1128 char ** info = (char **) elem->q_data;
1130 elem = elem->q_forw;