[1908] in Moira

home help back first fref pref prev next nref lref last post

MACHINEs on lists, 1 of 3

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Fri Dec 14 00:31:54 2001

Message-Id: <200112140531.AAA30202@cutter-john.mit.edu>
To: moiradev@MIT.EDU
Date: Fri, 14 Dec 2001 00:31:54 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>

	These are the server changes needed to add MACHINE members to
lists, as requested by Pismere.  These have been running on ttsp for
ages now.  Not shown are the rows in the alias table that need to be added.

Garry

Index: increment.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/increment.pc,v
retrieving revision 2.12
diff -u -r2.12 increment.pc
--- increment.pc	2001/08/28 14:26:01	2.12
+++ increment.pc	2001/11/12 13:29:40
@@ -216,6 +216,12 @@
 	  EXEC SQL SELECT list_id INTO :before[9] FROM list
 	    WHERE name = :name;
 	}
+      else if (!strcmp(before[1], "MACHINE"))
+	{
+	  id_to_name(id, MACHINE_TABLE, &name2);
+	  EXEC SQL SELECT mach_id INTO :before[9] FROM machine
+	    WHERE name = :name;
+	}
       strcpy(before[2], name2);
       free(name);
       free(name2);
@@ -371,6 +377,12 @@
 	{
 	  id_to_name(id, STRINGS_TABLE, &name2);
 	  EXEC SQL SELECT list_id INTO :after[9] FROM list
+	    WHERE name = :name;
+	}
+      else if (!strcmp(after[1], "MACHINE"))
+	{
+	  id_to_name(id, MACHINE_TABLE, &name2);
+	  EXEC SQL SELECT mach_id INTO :after[9] FROM machine
 	    WHERE name = :name;
 	}
       strcpy(after[2], name2);
Index: qsetup.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qsetup.pc,v
retrieving revision 2.47
diff -u -r2.47 qsetup.pc
--- qsetup.pc	2001/10/17 21:34:06	2.47
+++ qsetup.pc	2001/12/14 05:12:04
@@ -224,6 +224,10 @@
     WHERE mach_id = :id;
   if (cnt > 0)
     return MR_IN_USE;
+  EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
+    WHERE member_type = 'MACHINE' and member_id = :id;
+  if (cnt > 0)
+    return MR_IN_USE;
 
   EXEC SQL DELETE FROM mcmap WHERE mach_id = :id;
   if (dbms_errno)
Index: qsupport.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qsupport.pc,v
retrieving revision 2.39
diff -u -r2.39 qsupport.pc
--- qsupport.pc	2001/10/17 21:34:06	2.39
+++ qsupport.pc	2001/11/12 13:45:46
@@ -272,6 +272,9 @@
 	    case 'K':
 	      dtypes[dcount] = "KERBEROS";
 	      break;
+	    case 'M':
+	      dtypes[dcount] = "MACHINE";
+	      break;
 	    default:
 	      error++;
 	      break;
@@ -444,6 +447,9 @@
 	    case 'K':
 	      dtypes[dcount] = "KERBEROS";
 	      break;
+	    case 'M':
+	      dtypes[dcount] = "MACHINE";
+	      break;
 	    default:
 	      error++;
 	      break;
@@ -1036,10 +1042,11 @@
 
 /* get_lists_of_member - given a type and a name, return the name and flags
  * of all of the lists of the given member.  The member_type is one of
- * "LIST", "USER", "STRING", "RLIST", "RUSER", or "RSTRING" in argv[0],
- * and argv[1] will contain the ID of the entity in question.  The R*
- * types mean to recursively look at every containing list, not just
- * when the object in question is a direct member.
+ * "LIST", "USER", "STRING", "KERBEROS", "MACHINE", "RLIST", "RUSER", 
+ * "RSTRING", "RKERBEROS", or "RMACHINE" in argv[0], and argv[1] will contain 
+ * the ID of the entity in question.  The R* types mean to recursively look 
+ * at every containing list, not just when the object in question is a direct 
+ * member.
  */
 
 int get_lists_of_member(struct query *q, char *argv[], client *cl,
@@ -1076,6 +1083,11 @@
       atype = "KERBEROS";
       direct = 0;
     }
+  if (!strcmp(atype, "RMACHINE"))
+    {
+      atype = "MACHINE";
+      direct = 0;
+    }
 
   rargv[0] = name;
   rargv[1] = active;
@@ -1266,6 +1278,28 @@
       (*action)(targc, targv, actarg);
     }
   EXEC SQL CLOSE csr122;
+  if (dbms_errno)
+    return mr_errcode;
+
+  targv[0] = "MACHINE";
+  EXEC SQL DECLARE csr123 CURSOR FOR
+    SELECT m.name, s.string FROM machine m, imembers im, strings s
+    WHERE im.list_id = :list_id AND im.member_type = 'MACHINE'
+    AND im.member_id = m.mach_id AND im.direct > :direct
+    AND s.string_id = im.tag ORDER BY 1;
+  if (dbms_errno)
+    return mr_errcode;
+  EXEC SQL OPEN csr123;
+  if (dbms_errno)
+    return mr_errcode;
+  while (1)
+    {
+      EXEC SQL FETCH csr123 INTO :member_name, :tag;
+      if (sqlca.sqlcode)
+	break;
+      (*action)(targc, targv, actarg);
+    }
+  EXEC SQL CLOSE csr123;
   if (dbms_errno)
     return mr_errcode;
 

home help back first fref pref prev next nref lref last post