]> andersk Git - moira.git/commitdiff
Implement support for new machine and subnet table columns.
authorzacheiss <zacheiss>
Tue, 21 Aug 2001 04:42:09 +0000 (04:42 +0000)
committerzacheiss <zacheiss>
Tue, 21 Aug 2001 04:42:09 +0000 (04:42 +0000)
clients/moira/cluster.c
clients/moira/defs.h

index 3ef90f8c9dced063b9a699170356866f24adbe0b..3ef7590e40e9cf77c98ba98f351a809795b1d23b 100644 (file)
@@ -83,6 +83,14 @@ static char *states[] = {
   "Deleted (3)"
 };
 
+static char *subnet_states[] = {
+  "Reserved (0)",
+  "Billable (1)",
+  "Private (2)",
+  "Resnet (3)",
+  "Infrastructure (4)"
+};
+
 static char *MacState(int state)
 {
   static char buf[BUFSIZ];
@@ -95,7 +103,17 @@ static char *MacState(int state)
   return states[state];
 }
 
+static char *SubnetState(int state)
+{
+  static char buf[BUFSIZ];
 
+  if (state < 0 || state > 4)
+    {
+      sprintf(buf, "Unknown (%d)", state);
+      return buf;
+    }
+  return subnet_states[state];
+}
 
 /* -------------------- Set Defaults -------------------- */
 
@@ -115,6 +133,7 @@ static char **SetMachineDefaults(char **info, char *name)
   info[M_LOC] = strdup(M_DEFAULT_TYPE);
   info[M_CONTACT] = strdup(M_DEFAULT_TYPE);
   info[M_BILL_CONTACT] = strdup(M_DEFAULT_TYPE);
+  info[M_ACCT_NUMBER] = strdup("");
   info[M_USE] = strdup("0");
   info[M_STAT] = strdup("1");
   info[M_SUBNET] = strdup("NONE");
@@ -169,8 +188,9 @@ static char **SetSubnetDefaults(char **info, char *name)
 {
   char buf[256];
 
-  info[C_NAME] = strdup(name);
+  info[SN_NAME] = strdup(name);
   info[SN_DESC] = strdup("");
+  info[SN_STATUS] = strdup("1");
   sprintf(buf, "%ld", ntohl(inet_addr("18.255.0.0")));
   info[SN_ADDRESS] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr("255.255.0.0")));
@@ -244,7 +264,6 @@ static char *PrintMachInfo(char **info)
          MacState(atoi(info[M_STAT])), info[M_STAT_CHNG]);
   Put_message(buf);
   Put_message("");
-
   sprintf(buf, "Vendor:   %-16s    Location:        %s", info[M_VENDOR], 
          info[M_LOC]);
   Put_message(buf);
@@ -254,8 +273,8 @@ static char *PrintMachInfo(char **info)
   sprintf(buf, "OS:       %-16s    Billing Contact: %s", info[M_OS],
          info[M_BILL_CONTACT]);
   Put_message(buf);
-  Put_message("");
-  sprintf(buf, "Opt: %s", info[M_USE]);
+  sprintf(buf, "Opt:      %-16s    Account Number:  %s", info[M_USE],
+         info[M_ACCT_NUMBER]);
   Put_message(buf);
   Put_message("");
   sprintf(buf, "Adm cmt: %s", info[M_ACOMMENT]);
@@ -371,6 +390,8 @@ static char *PrintSubnetInfo(char **info)
   Put_message(buf);
   sprintf(buf, "    Description:  %s", info[SN_DESC]);
   Put_message(buf);
+  sprintf(buf, "         Status:  %s", SubnetState(atoi(info[SN_STATUS])));
+  Put_message(buf);
   addr.s_addr = htonl(atoi(info[SN_ADDRESS]));
   mask.s_addr = htonl(atoi(info[SN_MASK]));
   low.s_addr = htonl(atoi(info[SN_LOW]));
@@ -598,6 +619,9 @@ char **AskMCDInfo(char **info, int type, Bool name)
       if (GetValueFromUser("Machine's billing contact", 
                           &info[M_BILL_CONTACT]) == SUB_ERROR)
        return NULL;
+      if (GetValueFromUser("Machine's billing account number",
+                          &info[M_ACCT_NUMBER]) == SUB_ERROR)
+       return NULL;
       while (1)
        {
          int i;
@@ -622,59 +646,71 @@ char **AskMCDInfo(char **info, int type, Bool name)
       if (name)
        {
          /* info did not come from SetMachineDefaults(), which does not
-          * initialize entry 8 (M_STAT_CHNG), therefore we can
+          * initialize entry 10 (M_STAT_CHNG), therefore we can
           * free it.
           */
          /* This is an update of an existing machine and the structure
           * was filled in thru a query to the db which does fill in this
           * field.
           */
-         free(info[9]);
+         free(info[10]);
        }
 
-      info[9] = info[M_SUBNET];
-      info[10] = info[M_ADDR];
-      info[11] = info[M_OWNER_TYPE];
-      info[12] = info[M_OWNER_NAME];
-      info[13] = info[M_ACOMMENT];
-      info[14] = info[M_OCOMMENT];
+      info[10] = info[M_SUBNET];
+      info[11] = info[M_ADDR];
+      info[12] = info[M_OWNER_TYPE];
+      info[13] = info[M_OWNER_NAME];
+      info[14] = info[M_ACOMMENT];
+      info[15] = info[M_OCOMMENT];
 
       if (name)
        {
-         if (GetValueFromUser("Machine's network (or 'none')", &info[9])
+         if (GetValueFromUser("Machine's network (or 'none')", &info[10])
              == SUB_ERROR)
            return NULL;
        }
       if (GetValueFromUser("Machine's address (or 'unassigned' or 'unique')",
-                          &info[10]) == SUB_ERROR)
+                          &info[11]) == SUB_ERROR)
        return NULL;
-      if (GetTypeFromUser("Machine's owner type", "ace_type", &info[11]) ==
+      if (GetTypeFromUser("Machine's owner type", "ace_type", &info[12]) ==
          SUB_ERROR)
        return NULL;
-      if (strcmp(info[11], "NONE") &&
-         GetValueFromUser("Owner's Name", &info[12]) == SUB_ERROR)
+      if (strcmp(info[12], "NONE") &&
+         GetValueFromUser("Owner's Name", &info[13]) == SUB_ERROR)
        return NULL;
-      if (!strcmp(info[11], "KERBEROS"))
+      if (!strcmp(info[12], "KERBEROS"))
          {
            char *canon;
 
-           mrcl_validate_kerberos_member(info[12], &canon);
+           mrcl_validate_kerberos_member(info[13], &canon);
            if (mrcl_get_message())
              Put_message(mrcl_get_message());
-           free(info[12]);
-           info[12] = canon;
+           free(info[13]);
+           info[13] = canon;
          }
-      if (GetValueFromUser("Administrative comment", &info[13]) == SUB_ERROR)
+      if (GetValueFromUser("Administrative comment", &info[14]) == SUB_ERROR)
        return NULL;
-      if (GetValueFromUser("Operational comment", &info[14]) == SUB_ERROR)
+      if (GetValueFromUser("Operational comment", &info[15]) == SUB_ERROR)
        return NULL;
-      info[15] = NULL;
-      FreeAndClear(&info[16], TRUE);
+      info[16] = NULL;
       FreeAndClear(&info[17], TRUE);
+      FreeAndClear(&info[18], TRUE);
       break;
     case SUBNET:
       if (GetValueFromUser("Network description", &info[SN_DESC]) == SUB_ERROR)
        return NULL;
+      while (1)
+       {
+         int i;
+         if (GetValueFromUser("Network's status (? for help)",
+                              &info[SN_STATUS]) == SUB_ERROR)
+           return NULL;
+         if (isdigit(info[SN_STATUS][0]))
+           break;
+         Put_message("Valid status numbers:");
+         for (i = 0; i < 5; i++)
+           Put_message(subnet_states[i]);
+       }
       if (GetAddressFromUser("Network address", &info[SN_ADDRESS]) == SUB_ERROR)
        return NULL;
       if (GetAddressFromUser("Network mask", &info[SN_MASK]) == SUB_ERROR)
@@ -2054,7 +2090,6 @@ static char *PrintContainer(char **info)
 
   sprintf(buf, "Container: %s", info[CON_NAME]);
   Put_message(buf);
-  return "";
 }
 
 static char *PrintMContMap(char **info)
@@ -2463,18 +2498,3 @@ int GetMachinesOfContainer(int argc, char **argv)
   FreeQueue(top);
   return DM_NORMAL;
 }
-
-int GetTopLevelCont(int argc, char **argv)
-{
-  int status;
-  struct mqelem *elem = NULL;
-  if (status = do_mr_query("get_toplevel_containers", 0, NULL, StoreInfo, 
-                          &elem))
-    {
-      com_err(program_name, status, " in get_toplevel_containers");
-      return DM_NORMAL;
-    }
-  Loop(QueueTop(elem), (void(*)(char **)) PrintContainer);
-  FreeQueue(elem);
-  return DM_NORMAL;
-}
index eb07a5be239c804b1a58c487901027506151ca00..ca27e1c39a3c2c58a837a391773bbc47b55a0eb9 100644 (file)
@@ -50,7 +50,7 @@ typedef int Bool;
 
 /* What version of the queries are we asking for? */
 
-#define QUERY_VERSION 7
+#define QUERY_VERSION 8
 
 /* This is unimplemented in the menu stuff, but would be nice. */
 
This page took 0.083375 seconds and 5 git commands to generate.