[1889] in Moira Commits

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

/svn/moira r4030 - in trunk/moira: clients/eunice clients/moira gen

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Fri Mar 4 16:01:21 2011

Date: Fri, 4 Mar 2011 16:01:15 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201103042101.p24L1FQ2008046@drugstore.mit.edu>
To: moira-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2011-03-04 16:01:14 -0500 (Fri, 04 Mar 2011)
New Revision: 4030

Modified:
   trunk/moira/clients/eunice/eunice.c
   trunk/moira/clients/moira/printer.c
   trunk/moira/gen/cups-cluster.pc
   trunk/moira/gen/cups-print.pc
   trunk/moira/gen/dhcp.pc
   trunk/moira/gen/hesiod.pc
   trunk/moira/gen/print-accounting.gen
   trunk/moira/gen/print.pc
   trunk/moira/gen/sapprint.gen
   trunk/moira/gen/spwatch.gen
Log:
Use printer status 2 for printers that should be bootp'ed/dhcp'ed but not have IP acls.

Modified: trunk/moira/clients/eunice/eunice.c
===================================================================
--- trunk/moira/clients/eunice/eunice.c	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/clients/eunice/eunice.c	2011-03-04 21:01:14 UTC (rev 4030)
@@ -68,7 +68,7 @@
 static char *states[] = {
   "Reserved (0)",
   "Active (1)",
-  "None (2)",
+  "Active, No IP ACL (2)",
   "Deleted (3)"
 };
 

Modified: trunk/moira/clients/moira/printer.c
===================================================================
--- trunk/moira/clients/moira/printer.c	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/clients/moira/printer.c	2011-03-04 21:01:14 UTC (rev 4030)
@@ -47,7 +47,7 @@
 static char *states[] = {
   "Reserved (0)",
   "Active (1)",
-  "None (2)",
+  "Active, No IP ACL (2)",
   "Deleted (3)"
 };
 

Modified: trunk/moira/gen/cups-cluster.pc
===================================================================
--- trunk/moira/gen/cups-cluster.pc	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/cups-cluster.pc	2011-03-04 21:01:14 UTC (rev 4030)
@@ -156,7 +156,7 @@
     pr.ac, pr.lpc_acl, pr.duplexdefault, pr.holddefault
     FROM printers pr, machine m
     WHERE pr.rm = :rm AND m.mach_id = pr.mach_id
-    AND pr.status = 1 AND m.status != 3
+    AND (pr.status = 1 OR pr.status = 2) AND m.status != 3
     AND (pr.type = 'DORM' or pr.type = 'CLUSTER');
   EXEC SQL OPEN csr_printers;
   while (1)
@@ -241,7 +241,7 @@
     pr.ac, pr.lpc_acl, m.name as cupshosts
     FROM printers pr, machine m, machine m2, serverhosts sh
     WHERE pr.rm = m.mach_id AND pr.rm <> :rm
-    AND pr.status = 1 AND pr.mach_id = m2.mach_id AND m2.status !=3
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m2.mach_id AND m2.status !=3
     AND (pr.type = 'CLUSTER' or pr.type = 'DORM') AND m.name <> :spoolhost AND
     m.mach_id = sh.mach_id AND (sh.service = 'CUPS-PRINT' OR sh.service = 'CUPS-CLUSTER') AND 
     sh.enable = 1 AND m.mach_id = sh.mach_id;
@@ -320,7 +320,7 @@
     pr.ac, pr.lpc_acl, m.name, pr.duplexdefault as cupshosts
     FROM printers pr, machine m, machine m2, serverhosts sh
     WHERE pr.rm = m.mach_id
-    AND pr.status = 1 AND pr.mach_id = m2.mach_id AND m2.status != 3
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m2.mach_id AND m2.status != 3
     AND sh.service = 'PRINT' AND m.mach_id = sh.mach_id
     AND (pr.type = 'DORM' or pr.type = 'CLUSTER');
 
@@ -388,7 +388,7 @@
     pr.type as prtype, pr.ac, sh.service, pr.duplexdefault
     FROM printers pr, machine m, machine m2, serverhosts sh
     WHERE pr.rm = m.mach_id 
-    AND pr.status = 1 and pr.mach_id = m2.mach_id AND m2.status !=3
+    AND (pr.status = 1 OR pr.status = 2) and pr.mach_id = m2.mach_id AND m2.status !=3
     AND m.mach_id = sh.mach_id AND sh.enable = 1
     AND (pr.type = 'DORM' or pr.type = 'CLUSTER')
     AND (sh.service = 'CUPS-PRINT' OR sh.service = 'PRINT' OR sh.service = 'CUPS-CLUSTER');
@@ -597,7 +597,7 @@
     SELECT UNIQUE pr.rp, pr.ka, pr.ac, pr.lpc_acl
      FROM printers pr, machine m
      WHERE (pr.ac != 0 OR pr.lpc_acl != 0) 
-     AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3
+     AND (pr.status = 1 OR pr.status = 2) and pr.mach_id = m.mach_id AND m.status !=3
      AND pr.rm in (SELECT m.mach_id FROM machine m, serverhosts sh
      WHERE m.mach_id = sh.mach_id AND (sh.service = 'CUPS-PRINT' or sh.service = 'CUPS-CLUSTER')
      AND sh.enable = 1 and m.status != 3);

Modified: trunk/moira/gen/cups-print.pc
===================================================================
--- trunk/moira/gen/cups-print.pc	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/cups-print.pc	2011-03-04 21:01:14 UTC (rev 4030)
@@ -159,7 +159,7 @@
     pr.ac, pr.lpc_acl, pr.duplexdefault, pr.holddefault
     FROM printers pr, machine m
     WHERE pr.rm = :rm AND m.mach_id = pr.mach_id
-    AND pr.status = 1 AND m.status !=3
+    AND (pr.status = 1 OR pr.status = 2) AND m.status !=3
     AND pr.type != 'ALIAS';
   EXEC SQL OPEN csr_printers;
   while (1)
@@ -244,7 +244,7 @@
     pr.ac, pr.lpc_acl, m.name as cupshosts, pr.duplexdefault
     FROM printers pr, machine m, machine m2, serverhosts sh
     WHERE pr.rm = m.mach_id AND pr.rm <> :rm
-    AND pr.status = 1 AND pr.mach_id = m2.mach_id AND m2.status !=3
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m2.mach_id AND m2.status !=3
     AND pr.type != 'ALIAS' AND m.name <> :spoolhost AND
     m.mach_id = sh.mach_id AND (sh.service = 'CUPS-PRINT' OR sh.service = 'CUPS-CLUSTER')
     AND sh.enable = 1 AND m.mach_id = sh.mach_id;
@@ -324,7 +324,7 @@
     pr.ac, pr.lpc_acl, m.name, pr.duplexdefault as cupshosts
     FROM printers pr, machine m, machine m2, printservers ps
     WHERE pr.rm = m.mach_id AND ps.kind <> 'CUPS' AND m.mach_id = ps.mach_id 
-    AND pr.status = 1 AND pr.mach_id = m2.mach_id AND m2.status != 3
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m2.mach_id AND m2.status != 3
     AND pr.type != 'ALIAS';
 
   EXEC SQL OPEN csr_lprng_printers;
@@ -391,7 +391,7 @@
     pr.type as prtype, pr.ac, sh.service, pr.duplexdefault
     FROM printers pr, machine m, machine m2, serverhosts sh
     WHERE pr.rm = m.mach_id 
-    AND pr.status = 1 AND pr.mach_id = m2.mach_id AND m2.status !=3
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m2.mach_id AND m2.status !=3
     AND m.mach_id = sh.mach_id AND sh.enable = 1 
     AND (sh.service = 'CUPS-PRINT' OR sh.service = 'PRINT' OR sh.service = 'CUPS-CLUSTER');
   EXEC SQL OPEN csr_duplexqs;
@@ -600,7 +600,7 @@
     SELECT UNIQUE pr.rp, pr.ka, pr.ac, pr.lpc_acl
     FROM printers pr, machine m
     WHERE (pr.ac != 0 OR pr.lpc_acl != 0) 
-    AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3
+    AND (pr.status = 1 OR pr.status = 2) and pr.mach_id = m.mach_id AND m.status !=3
     AND pr.rm in (SELECT m.mach_id FROM machine m, serverhosts sh
     WHERE m.mach_id = sh.mach_id AND (sh.service = 'CUPS-PRINT' OR sh.service = 'CUPS-CLUSTER')
     AND sh.enable = 1);

Modified: trunk/moira/gen/dhcp.pc
===================================================================
--- trunk/moira/gen/dhcp.pc	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/dhcp.pc	2011-03-04 21:01:14 UTC (rev 4030)
@@ -44,7 +44,7 @@
   char modtime[PRINTERS_MODTIME_SIZE], type[PRINTERS_TYPE_SIZE];
   char *unixtime_fmt = UNIXTIME_FMT;
   char host[MACHINE_ADDRESS_SIZE], types[SERVERHOSTS_VALUE3_SIZE];
-  int mid, alcount;
+  int mid, alcount, status;
   EXEC SQL END DECLARE SECTION;
   char shortname[MACHINE_NAME_SIZE], net[MACHINE_ADDRESS_SIZE];
   char filename[MAXPATHLEN];
@@ -105,7 +105,7 @@
     FROM printers pr, machine m, machine m2, hwaddrmap hw
     WHERE pr.type != 'ALIAS' AND pr.mach_id != 0
     AND pr.mach_id = m.mach_id AND m.mach_id = hw.mach_id AND m.status != 3
-    AND pr.loghost = m2.mach_id AND pr.status = 1
+    AND pr.loghost = m2.mach_id AND (pr.status = 1 OR pr.status = 2)
     ORDER BY hw.hwaddr, m.name;
   EXEC SQL OPEN csr_boot;
   while (1)
@@ -162,17 +162,17 @@
   /* Now generate /var/boot/hp/ files */
   EXEC SQL DECLARE csr_boot2 CURSOR FOR
     SELECT LOWER(m.name), hw.hwaddr, m2.address, m3.address, pr.type,
-    pr.location, pr.contact, TO_CHAR(pr.modtime, :unixtime_fmt)
+    pr.location, pr.contact, TO_CHAR(pr.modtime, :unixtime_fmt), pr.status
     FROM printers pr, machine m, machine m2, machine m3, hwaddrmap hw
     WHERE pr.hwtype LIKE 'HP%' AND pr.mach_id != 0
     AND pr.mach_id = m.mach_id AND m.mach_id = hw.mach_id AND m.status != 3
     AND pr.rm = m2.mach_id AND pr.loghost = m3.mach_id AND pr.type != 'ALIAS'
-    AND pr.status = 1;
+    AND (pr.status = 1 OR pr.status = 2);
   EXEC SQL OPEN csr_boot2;
   while (1)
     {
       EXEC SQL FETCH csr_boot2 INTO :name, :hwaddr, :addr, :logaddr,
-	:type, :location, :contact, :modtime;
+	:type, :location, :contact, :modtime, :status;
       if (sqlca.sqlcode)
 	break;
 
@@ -200,34 +200,44 @@
       fprintf(out, "name: %s\nlocation: %s\ncontact: %s\n\n", shortname,
 	      *location ? location : "unknown",
 	      *contact ? contact : "unknown");
-      if (*logaddr)
-	fprintf(out, "trap-dest: %s\nallow: %s\n", logaddr, logaddr);
-      fprintf(out, "allow: %s\n", addr);
-      typelen = strlen(type);
-      for (i = allows = 0; i < alcount && allows < 9; i++)
-	{
-	  char *p;
 
-	  /* Don't list the spoolhost twice. */
-	  if (!strcmp(allowlist[i].host, addr))
-	    continue;
 
-	  p = strstr(allowlist[i].types, type);
-	  if (!p)
-	    continue;
+      if (*logaddr)
+	fprintf(out, "trap-dest: %s\n", logaddr);
 
-	  /* Make sure the match was real, and not just because one type
-	   * is a substring of another type.
-	   */
-	  if (p != allowlist[i].types && *(p - 1) != ',' && *(p - 1) != ' ')
-	    continue;
-	  p += typelen;
-	  if (*p && *p != ',' && *p != ' ')
-	    continue;
-
-	  fprintf(out, "allow: %s\n", allowlist[i].host);
-	  allows++;
+      /* Don't output any allow: lines for status 2 printers; they should be unrestricted. */
+      if (status == 1)
+	{
+	  if (*logaddr)
+	    fprintf(out, "allow: %s\n", logaddr);
+	  fprintf(out, "allow: %s\n", addr);
+	  typelen = strlen(type);
+	  for (i = allows = 0; i < alcount && allows < 9; i++)
+	    {
+	      char *p;
+	      
+	      /* Don't list the spoolhost twice. */
+	      if (!strcmp(allowlist[i].host, addr))
+		continue;
+	      
+	      p = strstr(allowlist[i].types, type);
+	      if (!p)
+		continue;
+	      
+	      /* Make sure the match was real, and not just because one type
+	       * is a substring of another type.
+	       */
+	      if (p != allowlist[i].types && *(p - 1) != ',' && *(p - 1) != ' ')
+		continue;
+	      p += typelen;
+	      if (*p && *p != ',' && *p != ' ')
+		continue;
+	      
+	      fprintf(out, "allow: %s\n", allowlist[i].host);
+	      allows++;
+	    }
 	}
+	 
       /* Rest of data is same for all printers and is appended from a
        * a file on the boot server.
        */
@@ -245,7 +255,7 @@
   int f = 0, t = 0;
   int mod = 2;
 
-  for (f = 0 ; f < MACHINE_HWADDR_SIZE - 1 ; )
+  for (f = 0 ; f < HWADDRMAP_HWADDR_SIZE - 1 ; )
     {
       to[t++] = from[f++];
       if (f % mod == 0)

Modified: trunk/moira/gen/hesiod.pc
===================================================================
--- trunk/moira/gen/hesiod.pc	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/hesiod.pc	2011-03-04 21:01:14 UTC (rev 4030)
@@ -880,7 +880,7 @@
   EXEC SQL DECLARE p_cursor2 CURSOR FOR
     SELECT p.name, p.duplexname, p.type, p.rp, p.rm, p.ka, p.mc, ps.kind
     FROM printers p, printservers ps, machine m
-    WHERE p.rm = ps.mach_id AND p.status = 1 AND p.mach_id = m.mach_id
+    WHERE p.rm = ps.mach_id AND (p.status = 1 OR p.status = 2) AND p.mach_id = m.mach_id
     AND m.status != 3;
   EXEC SQL OPEN p_cursor2;
   while (1)

Modified: trunk/moira/gen/print-accounting.gen
===================================================================
--- trunk/moira/gen/print-accounting.gen	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/print-accounting.gen	2011-03-04 21:01:14 UTC (rev 4030)
@@ -15,7 +15,7 @@
 
 
 $sth = $dbh->prepare("SELECT p.name, l.name FROM list l, printers p " .
-		     "WHERE p.status = 1 AND p.report_list = l.list_id AND l.maillist = 1 AND l.active = 1 " .
+		     "WHERE (p.status = 1 OR p.status = 2) AND p.report_list = l.list_id AND l.maillist = 1 AND l.active = 1 " .
 		     "ORDER BY p.name")
     || exit $MR_DBMS_ERR;
 

Modified: trunk/moira/gen/print.pc
===================================================================
--- trunk/moira/gen/print.pc	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/print.pc	2011-03-04 21:01:14 UTC (rev 4030)
@@ -94,7 +94,7 @@
     m.name, pr.banner, pr.location, pr.contact
     FROM printers pr, machine m
     WHERE pr.rm = :rm AND m.mach_id = pr.mach_id
-    AND pr.status = 1 AND m.status != 3
+    AND (pr.status = 1 OR pr.status = 2) AND m.status != 3
     AND pr.type != 'ALIAS'
     AND ( pr.hwtype LIKE 'HP%' OR pr.hwtype LIKE 'LPR%' );
   EXEC SQL OPEN csr_printcap;
@@ -177,7 +177,7 @@
   EXEC SQL DECLARE csr_lpc CURSOR FOR
     SELECT pr.rp, pr.duplexname FROM printers pr, machine m
     WHERE pr.rm = :rm AND pr.lpc_acl != 0
-    AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3;
+    AND (pr.status = 1 OR pr.status = 2) and pr.mach_id = m.mach_id AND m.status !=3;
   EXEC SQL OPEN csr_lpc;
   while (1)
     {
@@ -198,7 +198,7 @@
   EXEC SQL DECLARE csr_ac CURSOR FOR
     SELECT pr.rp, pr.duplexname, pr.ka FROM printers pr, machine m
     WHERE pr.rm = :rm AND pr.ac != 0
-    AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3;
+    AND (pr.status = 1 OR pr.status = 2) and pr.mach_id = m.mach_id AND m.status !=3;
   EXEC SQL OPEN csr_ac;
   while (1)
     {
@@ -244,7 +244,7 @@
   EXEC SQL DECLARE csr_kq CURSOR FOR
     SELECT pr.rp, pr.duplexname FROM printers pr, machine m
     WHERE pr.rm = :rm AND pr.ka = 1
-    AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3;
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m.mach_id AND m.status !=3;
   EXEC SQL OPEN csr_kq;
   while (1)
     {
@@ -265,7 +265,7 @@
     SELECT UNIQUE pr.rp, pr.ka, pr.ac, pr.lpc_acl
     FROM printers pr, machine m
     WHERE pr.rm = :rm AND ( pr.ac != 0 OR pr.lpc_acl != 0)
-    AND pr.status = 1 and pr.mach_id = m.mach_id AND m.status !=3;
+    AND (pr.status = 1 OR pr.status = 2) AND pr.mach_id = m.mach_id AND m.status !=3;
   EXEC SQL OPEN csr_spool;
   while (1)
     {

Modified: trunk/moira/gen/sapprint.gen
===================================================================
--- trunk/moira/gen/sapprint.gen	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/sapprint.gen	2011-03-04 21:01:14 UTC (rev 4030)
@@ -16,7 +16,8 @@
 
 $sth = $dbh->prepare("SELECT p.name, p.hwtype, p.location, p.duplexname, p.rp, m.name ".
 		     "FROM printers p, machine m ".
-		     "WHERE p.rm=m.mach_id AND p.type='SAP' AND m.status !=3 AND p.status = 1")
+		     "WHERE p.rm=m.mach_id AND p.type='SAP' AND m.status !=3 AND " .
+		     "(p.status = 1 OR p.status = 2)")
   || exit $MR_DBMS_ERR;
 
 $sth->execute || exit $MR_DBMS_ERR;

Modified: trunk/moira/gen/spwatch.gen
===================================================================
--- trunk/moira/gen/spwatch.gen	2011-03-03 21:21:15 UTC (rev 4029)
+++ trunk/moira/gen/spwatch.gen	2011-03-04 21:01:14 UTC (rev 4030)
@@ -15,7 +15,8 @@
 
 $sth = $dbh->prepare("SELECT m.name FROM printers p, ".
 		     "machine m WHERE p.type = 'SAP' AND p.mach_id = ".
-		     "m.mach_id ORDER BY m.name") || exit $MR_DBMS_ERR;
+		     "m.mach_id AND (p.status = 1 OR p.status = 2) AND m.status != 3 " .
+		     "ORDER BY m.name") || exit $MR_DBMS_ERR;
 
 $sth->execute || exit $MR_DBMS_ERR;
 


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