#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);
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.
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);
+}
NULLFUNC,
NULLFUNC,
"Machine Menu",
- 7,
+ 8,
{
{ ShowMachineInfo, NULLMENU, 2, {
{"show", "Get machine information"},
{"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: "},