]> andersk Git - moira.git/commitdiff
client support for get_host_by_owner
authorzacheiss <zacheiss>
Thu, 30 Mar 2000 21:59:52 +0000 (21:59 +0000)
committerzacheiss <zacheiss>
Thu, 30 Mar 2000 21:59:52 +0000 (21:59 +0000)
clients/moira/cluster.c
clients/moira/f_defs.h
clients/moira/menus.c

index 07f1d792527b6a14b63aa99075ace04ccffd3ec8..e960a4f23644a947001e51c1deecc4e5c6d479c8 100644 (file)
@@ -41,7 +41,9 @@
 #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,6 +237,20 @@ static char *PrintMachInfo(char **info)
   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.
@@ -1720,3 +1736,68 @@ int MachineToClusterMap(int argc, char **argv)
   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 ab632984381db00e1be7d631bd3d12121b69474c..13a3cce34d95cc3d75e87cacbcfcb5e41b73967c 100644 (file)
@@ -46,6 +46,7 @@ int AttachHelp(void);
 
 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 84d5211add4f68ffab4e39bb86ba060503a0856a..9e1749515246b48e034ae378b27785508d18137d 100644 (file)
@@ -450,7 +450,7 @@ Menu machine_menu = {
   NULLFUNC,
   NULLFUNC,
   "Machine Menu",
-  7,
+  8,
   {
     { ShowMachineInfo, NULLMENU, 2, {
       {"show", "Get machine information"},
@@ -463,6 +463,7 @@ Menu machine_menu = {
       {"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: "},
This page took 0.05365 seconds and 5 git commands to generate.