]> andersk Git - moira.git/blobdiff - dbck/phase2.qc
check for ingres errors in more places
[moira.git] / dbck / phase2.qc
index 2f5a2c01d289dc30612efc4a11d6e7790ec918a6..1b50b3438707499d8a63eaa1e2b1cac9d6d088a9 100644 (file)
@@ -10,6 +10,9 @@
 #include <sms.h>
 #include "dbck.h"
 
+static char phase2_qc_rcsid[] = "$Header$";
+
+
 show_mcm_mach(id)
 int id;
 ##{
@@ -82,6 +85,7 @@ int id;
       printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not removed\n");
+    modified("users");
 ##}
 
 show_svc(id)
@@ -136,6 +140,7 @@ int id;
       printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not fixed\n");
+    modified("list");
 ##}
 
 
@@ -218,6 +223,7 @@ int id;
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not deleted\n");
+    modified("members");
 ##}
 
 ##del_mem_list(id)
@@ -232,6 +238,7 @@ int id;
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not deleted\n");
+    modified("members");
 ##}
 
 ##del_mem_str(id)
@@ -246,6 +253,7 @@ int id;
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not deleted\n");
+    modified("members");
 ##}
 
 
@@ -274,6 +282,7 @@ int id;
       printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
     else
       printf("Not deleted\n");
+    modified("serverhosts");
 ##}
 
 
@@ -313,6 +322,7 @@ int hint;
                  printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
                else
                  printf("Not fixed\n");
+               modified("filesys");
                f->mach_id = 0;
            }
        }
@@ -349,6 +359,7 @@ int hint;
                    printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
                  else
                    printf("Not fixed\n");
+                 modified("filesys");
                } else {
                    printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
                    if (single_fix("Create", 0)) {
@@ -379,6 +390,7 @@ int hint;
                                 rowcount==1?"y":"ies");
                        else
                          printf("Not created\n");
+                       modified("nfsphys");
                        n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
                        strcpy(n->dir, dir);
                        n->mach_id = id3;
@@ -387,13 +399,14 @@ int hint;
                        n->count = 0;
                        hash_store(nfsphys, id1, n);
 ##                     replace filesys (phys_id = id1)
-##                       where filesys.filsys_id = id
+##                       where filesys.filsys_id = id2
 ##                     inquire_equel(rowcount = "rowcount")
                        if (rowcount > 0)
                          printf("%d filesys entr%s fixed\n", rowcount,
                                 rowcount==1?"y":"ies");
                        else
                          printf("Not fixed\n");
+                       modified("filesys");
                    }
                }
            }
@@ -415,6 +428,77 @@ int hint;
     }
 }
 
+##show_fsg_missing(id)
+##int id;
+##{
+##  int id1, found = 1;
+    struct filesys *f;
+
+##  retrieve (id1 = fsgroup.filsys_id) where fsgroup.group_id = id {
+      found = 0;
+      if (f = (struct filesys *) hash_lookup(filesys, id1))
+       printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
+      else
+       printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
+##  }
+    return(found);
+##}
+
+show_fsg_type(f)
+struct filesys *f;
+{
+    char *t;
+
+    switch (f->type) {
+    case 'N':
+       t = "NFS";
+       break;
+    case 'R':
+       t = "RVD";
+       break;
+    case 'E':
+       t = "ERR";
+       break;
+    case 'F':
+       t = "FSGROUP";
+       break;
+    default:
+       t = "???";
+    }
+    printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
+    return(0);
+}
+
+fix_fsg_type(f)
+struct filesys *f;
+##{
+##  int rowcount, id = f->filsys_id;
+
+##  replace filesys (type = "FSGROUP") where filesys.filsys_id = id
+##  inquire_equel(rowcount = "rowcount")
+    if (rowcount > 0)
+      printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
+    else
+      printf("Not fixed\n");
+    modified("filesys");
+##}
+
+##show_fsg_nomember(id)
+##int id;
+##{
+##  int id1, found = 1;
+    struct filesys *f;
+
+##  retrieve (id1 = fsgroup.group_id) where fsgroup.filsys_id = id {
+      found = 0;
+      if (f = (struct filesys *) hash_lookup(filesys, id1))
+       printf("FSGroup %s has missing member %d\n", f->name, id);
+      else
+       printf("FSGroup %d has missing member %d\n", id1, id);
+##  }
+    return(found);
+##}
+
 ##show_quota_nouser(id)
 ##int id;
 ##{
@@ -481,9 +565,69 @@ fix_quota_nofs(id)
       printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
     else
       printf("Not fixed\n");
+    modified("nfsquota");
+##}
+
+##show_srv_user(id)
+##int id;
+##{
+##  char name[33];
+    int found = 1;
+
+##  retrieve (name = s.#name) where s.acl_type = "USER" and s.acl_id = id {
+       strtrim(name);
+       printf("Service %s has acl non-existant user %d\n", name, id);
+       found = 0;
+##  }
+    return(found);
+##}
+
+##show_srv_list(id)
+##int id;
+##{
+##  char name[33];
+    int found = 1;
+
+##  retrieve (name = s.#name) where s.acl_type = "LIST" and s.acl_id = id {
+       strtrim(name);
+       printf("Service %s has acl non-existant list %d\n", name, id);
+       found = 0;
+##  }
+    return(found);
+##}
+
+##zero_srv_user(id)
+##int id;
+##{
+##  int rowcount;
+
+##  replace servers (acl_id = 0) where servers.acl_id = id and
+##     servers.acl_type = "USER"
+##  inquire_equel(rowcount = "rowcount")
+    if (rowcount > 0)
+      printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
+    else
+      printf("Not fixed\n");
+    modified("servers");
+##}
+
+##zero_srv_list(id)
+##int id;
+##{
+##  int rowcount;
+
+##  replace servers (acl_id = 0) where servers.acl_id = id and
+##     servers.acl_type = "LIST"
+##  inquire_equel(rowcount = "rowcount")
+    if (rowcount > 0)
+      printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
+    else
+      printf("Not fixed\n");
+    modified("servers");
 ##}
 
 
+
 phase2()
 ##{
 ##  int id1, id2, id3, id4, id5;
@@ -507,7 +651,7 @@ phase2()
          sq_save_unique_data(sq1, id1);
        if (!hash_lookup(clusters, id2))
          sq_save_unique_data(sq2, id2);
-       m->clucount++;
+       if (m) m->clucount++;
 ##  }
     generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
     generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
@@ -533,7 +677,8 @@ phase2()
        strtrim(type);
        if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
          sq_save_unique_data(sq1, id1);
-       l->members++;
+       else
+         l->members++;
        if (!strcmp(type, "USER") && !hash_lookup(users, id2))
          sq_save_unique_data(sq2, id2);
        else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
@@ -547,14 +692,19 @@ phase2()
     generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
 
     dprintf("Checking servers...\n");
+    sq1 = sq_create();
+    sq2 = sq_create();
 ##  range of s is servers
 ##  retrieve (name = s.#name, type = s.acl_type, id1 = s.acl_id) {
        strtrim(type);
-       if (!strcmp(type, "USER") && !hash_lookup(users, id1))
-         printf("Service %s has acl non-existant user %d\n", name, id1);
-       else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1))
-         printf("Service %s has acl non-existant list %d\n", name, id1);
+       if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
+           sq_save_data(sq1, id1);
+       } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
+           sq_save_data(sq2, id1);
+       }
 ##  }
+    generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
+    generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
 
     dprintf("Checking servershosts...\n");
     sq = sq_create();
@@ -562,7 +712,7 @@ phase2()
        if (!hash_lookup(machines, id1))
          sq_save_data(sq, id1);
 ##  }
-    generic_fix(sq, show_sh, "Delete", del_sh_mach, 1);
+    generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
 
     dprintf("Checking nfsphys...\n");
     hash_step(nfsphys, check_nfsphys, NULL);
@@ -570,6 +720,22 @@ phase2()
     dprintf("Checking filesys...\n");
     hash_step(filesys, check_fs, NULL);
 
+    dprintf("Checking filesystem groups...\n");
+    sq1 = sq_create();
+    sq2 = sq_create();
+    sq3 = sq_create();
+##  retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) {
+       if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
+         sq_save_data(sq1, id1);
+       if (f->type  != 'F')
+         sq_save_data(sq2, f);
+       if (!hash_lookup(filesys, id2))
+         sq_save_data(sq3, id2);
+##  }
+    generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
+    generic_fix(sq2, show_fsg_type, "Change to \"FSTYPE\"", fix_fsg_type, 0);
+    generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
+
     dprintf("Checking nfsquota...\n");
     sq1 = sq_create();
     sq2 = sq_create();
@@ -597,18 +763,25 @@ phase2()
 ##  range of h is hostaccess
 ##  retrieve (id1 = h.mach_id, type = h.acl_type, id2 = h.acl_id) {
        strtrim(type);
-       if (!hash_lookup(machines, id1))
-         printf("Hostaccess for non-existant host %d\n", id1);
-       if (!strcmp(type, "USER") && !hash_lookup(users, id2))
-         printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
-       else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2))
-         printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
+       if (!hash_lookup(machines, id1)) {
+           printf("Hostaccess for non-existant host %d\n", id1);
+           printf("Not fixing this error\n");
+       }
+       if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
+           printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
+           printf("Not fixing this error\n");
+       } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
+           printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
+           printf("Not fixing this error\n");
+       }
 ##  }
 
     dprintf("Checking capacls...\n");
 ##  retrieve (id1 = capacls.list_id, name = capacls.tag) {
-       if (!hash_lookup(lists, id1))
-         printf("Capacl for %s is non-existant list %d\n", name, id1);
+       if (!hash_lookup(lists, id1)) {
+           printf("Capacl for %s is non-existant list %d\n", name, id1);
+           printf("Not fixing this error\n");
+       }
 ##  }
 
 ##}
This page took 0.095402 seconds and 4 git commands to generate.