]> andersk Git - moira.git/commitdiff
hesiod.pc: generate cluster info by both short name and FQDN
authordanw <danw>
Sun, 8 Feb 1998 17:27:48 +0000 (17:27 +0000)
committerdanw <danw>
Sun, 8 Feb 1998 17:27:48 +0000 (17:27 +0000)
hosts.pc: don't put machines in subdomains into the hosts.out

gen/hesiod.pc
gen/hosts.pc

index f4f624ed8ef2e1567896c27835c8936f87312b57..d014ad99a15152b116287698d399860a82c3d86d 100644 (file)
@@ -666,7 +666,7 @@ sqlerr:
 int do_cluster(void)
 {
   FILE *out;
-  char outf[64], outft[64], *mach, machbuf[41], *p;
+  char outf[64], outft[64], *mach, machbuf[64], clubuf[64], *p;
   struct stat sb;
   time_t ftime;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -674,7 +674,6 @@ int do_cluster(void)
   char name[41], label2[17], data[33];
   EXEC SQL END DECLARE SECTION;
   set_mask **machs, *ms, *ps;
-  int oneclu;
 
   sprintf(outf, "%s/cluster.db", hesiod_dir);
 
@@ -739,7 +738,7 @@ int do_cluster(void)
       ms = machs[mid];
       if (nbitsset(ms) > 1)
        {
-         oneclu = 0;
+         sprintf(clubuf, "mrinternal-%d", mid);
          for (cid = 1; cid < maxclu; cid++)
            {
              if (SET_ISSET(cid, ms))
@@ -756,8 +755,8 @@ int do_cluster(void)
                        break;
                      strtrim(label2);
                      strtrim(data);
-                     fprintf(out, "mrinternal-%d.cluster\t%s %s \"%s %s\"\n",
-                             mid, HCLASS, HTYPE, label2, data);
+                     fprintf(out, "%s.cluster\t%s %s \"%s %s\"\n",
+                             clubuf, HCLASS, HTYPE, label2, data);
                    }
                  EXEC SQL CLOSE d_cursor;
                }
@@ -765,29 +764,26 @@ int do_cluster(void)
        }
       else
        {
-         oneclu = 1;
          for (cid = 1; cid < maxclu; cid++)
            if (SET_ISSET(cid, ms))
              break;
 
          EXEC SQL SELECT name INTO :name FROM clusters WHERE clu_id = :cid;
          strtrim(name);
+         strcpy(clubuf, name);
        }
 
       if ((mach = hash_lookup(machines, mid)))
        {
+         fprintf(out, "%s.cluster\t%s CNAME %s.cluster\n",
+                 mach, HCLASS, clubuf);
          for (p = machbuf; *mach && *mach != '.'; mach++)
            *p++ = *mach;
-         *p = '\0';
-         if (oneclu)
+         if (!strcasecmp(mach, ".mit.edu"))
            {
+             *p = '\0';
              fprintf(out, "%s.cluster\t%s CNAME %s.cluster\n",
-                     machbuf, HCLASS, name);
-           }
-         else
-           {
-             fprintf(out, "%s.cluster\t%s CNAME mrinternal-%d.cluster\n",
-                     machbuf, HCLASS, mid);
+                     machbuf, HCLASS, clubuf);
            }
        }
       for (id = mid + 1; id < maxmach; id++)
@@ -798,19 +794,15 @@ int do_cluster(void)
              machs[id] = NULL;
              if ((mach = hash_lookup(machines, id)))
                {
+                 fprintf(out, "%s.cluster\t%s CNAME %s.cluster\n",
+                         mach, HCLASS, clubuf);
                  for (p = machbuf; *mach && *mach != '.'; mach++)
                    *p++ = *mach;
-                 *p = '\0';
-                 if (oneclu)
+                 if (!strcasecmp(mach, ".mit.edu"))
                    {
+                     *p = '\0';
                      fprintf(out, "%s.cluster\t%s CNAME %s.cluster\n",
-                             machbuf, HCLASS, name);
-                   }
-                 else
-                   {
-                     fprintf(out,
-                             "%s.cluster\t%s CNAME mrinternal-%d.cluster\n",
-                             machbuf, HCLASS, mid);
+                             machbuf, HCLASS, clubuf);
                    }
                }
            }
index d3f66b903d534c24ae29a9e0ffab07c26b4618a9..c8dd7792a4b28a376b70f10f68171503f76db4de 100644 (file)
@@ -97,9 +97,10 @@ int main(int argc, char **argv)
        continue;
       if (!*strtrim(name))
        continue;
-      if ((i = strlen(name)) < 9 || strcmp(&name[i - 8], ".MIT.EDU"))
+      if ((i = strlen(name)) < 9 || !strchr(name, '.') ||
+         strcmp(strchr(name, '.'), ".MIT.EDU"))
        {
-         fprintf(stderr, "Name %s not in MIT domain\n", name);
+         fprintf(stderr, "Ignoring alias %s\n", name);
          continue;
        }
       else
@@ -127,8 +128,12 @@ int main(int argc, char **argv)
        continue;
       if (!*strtrim(name))
        continue;
-      if ((i = strlen(name)) < 9 || strcmp(&name[i - 8], ".MIT.EDU"))
-       continue;
+      if ((i = strlen(name)) < 9 || !strchr(name, '.') ||
+         strcmp(strchr(name, '.'), ".MIT.EDU"))
+       {
+         fprintf(stderr, "Ignoring machine %s\n", name);
+         continue;
+       }
       else
        name[i - 8] = 0;
       strtrim(vendor);
This page took 0.069053 seconds and 5 git commands to generate.