+ args[MAP_CLUSTER] = argv[2];
+ args[MAP_END] = NULL;
+
+ stat = do_mr_query("get_machine_to_cluster_map", CountArgs(args), args,
+ StoreInfo, (char *)&elem);
+ if (stat == MR_NO_MATCH)
+ {
+ sprintf(buf, "The machine %s is not is the cluster %s.",
+ args[MAP_MACHINE], args[MAP_CLUSTER]);
+ Put_message(buf);
+ free(args[MAP_MACHINE]);
+ return DM_NORMAL;
+ }
+ if (stat != MR_SUCCESS)
+ com_err(program_name, stat, " in delete_machine_from_cluster");
+
+ elem = QueueTop(elem);
+ QueryLoop(elem, PrintMCMap, RealRemoveMachineFromCluster,
+ "Remove this machine from this cluster");
+
+ FreeQueue(elem);
+ free(args[MAP_MACHINE]);
+ return DM_NORMAL;
+}
+
+/* ---------- Subnet Menu -------- */
+
+/* Function Name: ShowSubnetInfo
+ * Description: Gets information about a subnet given its name.
+ * Arguments: argc, argc - the name of the subnet in in argv[1].
+ * Returns: DM_NORMAL.
+ */
+
+int ShowSubnetInfo(int argc, char **argv)
+{
+ struct qelem *top;
+
+ top = GetMCInfo(SUBNET, argv[1], (char *) NULL);
+ Loop(top, (void *) PrintSubnetInfo);
+ FreeQueue(top);
+ return DM_NORMAL;
+}
+
+/* Function Name: AddSubnet
+ * Description: Creates a new subnet.
+ * Arguments: argc, argv - the name of the new subnet is argv[1].
+ * Returns: DM_NORMAL.
+ */
+
+int AddSubnet(int argc, char **argv)
+{
+ char **args, *info[MAX_ARGS_SIZE], *name = argv[1];
+ int stat;
+
+ /*
+ * Check to see if this subnet already exists.
+ */
+ if (!ValidName(name))
+ return DM_NORMAL;
+
+ if ((stat = do_mr_query("get_subnet", 1, &name,
+ NullFunc, NULL)) == MR_SUCCESS)
+ {
+ Put_message("This subnet already exists.");
+ return DM_NORMAL;
+ }
+ else if (stat != MR_NO_MATCH)
+ {
+ com_err(program_name, stat, " in AddSubnet.");
+ return DM_NORMAL;
+ }
+ if (!(args = AskMCDInfo(SetSubnetDefaults(info, name), SUBNET, FALSE)))
+ {
+ Put_message("Aborted.");
+ FreeInfo(info);
+ return DM_NORMAL;
+ }
+
+ /*
+ * Actually create the new Subnet.
+ */
+ if ((stat = do_mr_query("add_subnet", CountArgs(args),
+ args, Scream, NULL)))
+ com_err(program_name, stat, " in AddSubnet.");
+
+ FreeInfo(info);
+ return DM_NORMAL;
+}
+
+/* Function Name: RealUpdateSubnet
+ * Description: This function actually performs the subnet update.
+ * Arguments: info - all information nesc. for updating the subnet.
+ * junk - an UNUSED boolean.
+ * Returns: none.
+ */
+
+static void RealUpdateSubnet(char **info, Bool junk)
+{
+ int stat;
+ char **args = AskMCDInfo(info, SUBNET, TRUE);
+ if (!args)
+ {
+ Put_message("Aborted.");
+ return;
+ }
+ if ((stat = do_mr_query("update_subnet", CountArgs(args),
+ args, Scream, NULL)))
+ com_err(program_name, stat, " in UpdateSubnet.");
+ else
+ Put_message("Subnet successfully updated.");
+}
+
+/* Function Name: UpdateSubnet
+ * Description: This Function Updates a subnet
+ * Arguments: name of the subnet in argv[1].
+ * Returns: DM_NORMAL.
+ */
+
+int UpdateSubnet(int argc, char **argv)
+{
+ struct qelem *top;
+ top = GetMCInfo(SUBNET, argv[1], NULL);
+ QueryLoop(top, NullPrint, RealUpdateSubnet, "Update the subnet");
+
+ FreeQueue(top);
+ return DM_NORMAL;
+}
+
+/* Function Name: RealDeleteSubnet
+ * Description: Actually performs the subnet deletion.
+ * Arguments: info - all information about this subnet.
+ * one_subnet - If true then there was only one subnet in
+ * the queue, and we should confirm.
+ * Returns: none.
+ */
+
+static void RealDeleteSubnet(char **info, Bool one_subnet)
+{
+ int stat;
+ char temp_buf[BUFSIZ];
+
+ sprintf(temp_buf,
+ "Are you sure the you want to delete the subnet %s (y/n) ?",
+ info[C_NAME]);
+ if (!one_subnet || Confirm(temp_buf))
+ {
+ if ((stat = do_mr_query("delete_subnet", 1,
+ &info[C_NAME], Scream, NULL)))
+ {
+ com_err(program_name, stat, " in delete_subnet.");
+ sprintf(temp_buf, "Subnet %s ** NOT ** deleted.", info[C_NAME]);
+ Put_message(temp_buf);
+ }
+ else
+ {
+ sprintf(temp_buf, "subnet %s successfully deleted.",
+ info[C_NAME]);
+ Put_message(temp_buf);
+ }
+ }
+}