[1480] in Moira
ghbo: client changes
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu Mar 23 16:27:42 2000
Message-Id: <200003232127.QAA01016@wing-commander.mit.edu>
To: moiradev@MIT.EDU
Date: Thu, 23 Mar 2000 16:27:37 EST
From: Garry Zacheiss <zacheiss@MIT.EDU>
Index: cluster.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/cluster.c,v
retrieving revision 1.39
diff -c -r1.39 cluster.c
*** cluster.c 2000/03/15 22:44:02 1.39
--- cluster.c 2000/03/23 21:15:18
***************
*** 40,46 ****
--- 40,48 ----
#include <string.h>
void PrintAliases(char **info);
+ void PrintMachine(char **info);
struct mqelem *GetMCInfo(int type, char *name1, char *name2);
+ struct mqelem *GetMachineByOwner(char *type, char *name);
char **AskMCDInfo(char **info, int type, Bool name);
int CheckAndRemoveFromCluster(char *name, Bool ask_user);
int CheckAndRemoveMachines(char *name, Bool ask_first);
***************
*** 235,240 ****
--- 237,256 ----
return info[M_NAME];
}
+ /* Function Name: PrintMachine
+ * Description: Prints the name of a machine record
+ * Arguments: info - array of information about the machine.
+ * Returns: nothing.
+ */
+
+ static void PrintMachine(char **info)
+ {
+ char buf[BUFSIZ];
+
+ sprintf(buf, "Machine: %s", info[M_NAME]);
+ Put_message(buf);
+ }
+
/* Function Name: PrintCname
* Description: Prints the Data on a host alias
* Arguments: info a pointer to the data array.
***************
*** 1761,1764 ****
--- 1777,1845 ----
FreeQueue(top);
free(tmpname);
return DM_NORMAL;
+ }
+
+ /* Function Name: MachineByOwner
+ * Description: This function prints all machines which are owned by
+ * a given user or group.
+ * Arguments: none.
+ * Returns: DM_NORMAL.
+ */
+
+ int MachineByOwner(int argc, char **argv)
+ {
+ char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
+ struct mqelem *top;
+
+ type = strdup("USER");
+ if (GetTypeFromUser("Type of owner", "ace_type", &type) == SUB_ERROR)
+ return DM_NORMAL;
+
+ sprintf(buf, "Name of %s", type);
+ name = strdup(user);
+ if (GetValueFromUser(buf, &name) == SUB_ERROR)
+ return DM_NORMAL;
+
+ switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE))
+ {
+ case TRUE:
+ sprintf(temp_buf, "R%s", type); /* "USER to "RUSER", etc. */
+ free(type);
+ type = strdup(temp_buf);
+ break;
+ case FALSE:
+ break;
+ default:
+ return DM_NORMAL;
+ }
+
+ top = GetMachineByOwner(type, name);
+ Loop(top, PrintMachine);
+
+ FreeQueue(top);
+ return DM_NORMAL;
+ }
+
+ /* Function Name: GetMachineByOwner
+ * Description: This function stores information retrieved by
+ * the get_host_by_owner query
+ * Arguments: type - an ace_type, argv[0] for the query
+ * name - name of machine, argv[1] for the query
+ * Returns: the top element of a queue returning the data, or NULL.
+ */
+
+ struct mqelem *GetMachineByOwner(char *type, char *name)
+ {
+ char *args[2];
+ struct mqelem *elem = NULL;
+ int status;
+
+ args[0] = type;
+ args[1] = name;
+ if ((status = do_mr_query("get_host_by_owner", 2, args, StoreInfo, &elem)))
+ {
+ com_err(program_name, status, " in get_host_by_owner");
+ return NULL;
+ }
+ return QueueTop(elem);
}
Index: f_defs.h
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/f_defs.h,v
retrieving revision 1.30
diff -c -r1.30 f_defs.h
*** f_defs.h 2000/01/28 00:31:53 1.30
--- f_defs.h 2000/03/23 19:23:07
***************
*** 46,51 ****
--- 46,52 ----
int ShowMachineInfo(int argc, char **argv);
int ShowMachineQuery(int argc, char **argv);
+ int MachineByOwner(int argc, char **argv);
int AddMachine(int argc, char **argv);
int UpdateMachine(int argc, char **argv);
int DeleteMachine(int argc, char **argv);
Index: menus.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/menus.c,v
retrieving revision 1.40
diff -c -r1.40 menus.c
*** menus.c 2000/01/28 00:31:53 1.40
--- menus.c 2000/03/23 19:46:35
***************
*** 450,456 ****
NULLFUNC,
NULLFUNC,
"Machine Menu",
! 7,
{
{ ShowMachineInfo, NULLMENU, 2, {
{"show", "Get machine information"},
--- 450,456 ----
NULLFUNC,
NULLFUNC,
"Machine Menu",
! 8,
{
{ ShowMachineInfo, NULLMENU, 2, {
{"show", "Get machine information"},
***************
*** 463,468 ****
--- 463,469 ----
{"location", "Location (or leave empty to match any): "},
{"network", "Network (or leave empty to match any): "}
} },
+ SIMPLEFUNC("owner", "Lookup machines by owner", MachineByOwner),
{ AddMachine, NULLMENU, 2, {
{"add", "Add a new machine"},
{"network", "Network assignment: "},