]> andersk Git - moira.git/commitdiff
Add contact and account_number fields to subnet table.
authorzacheiss <zacheiss>
Wed, 22 Aug 2001 08:07:17 +0000 (08:07 +0000)
committerzacheiss <zacheiss>
Wed, 22 Aug 2001 08:07:17 +0000 (08:07 +0000)
In access_host(), make sure user has given valid account number for
UPDATE case as well.

In setup_asnt(), requite private subnets to have a valid account number
associated with them at creation and update time.

server/qaccess.pc
server/qfollow.pc
server/qsetup.pc
server/queries2.c

index 21fcf19612e2c29cbb35173c97cc5ee1f8cc2734..9adb3591841dea1ceb3c81c05a1f87f32b14cebb 100644 (file)
@@ -450,6 +450,7 @@ int access_host(struct query *q, char *argv[], client *cl)
        WHERE s.snet_id = :id;
       mid = 0;
 
+      /* Non query owner must provide valid billing information. */
       if (q->version >= 8)
        {
          if (subnet_status == SNET_STATUS_BILLABLE)
@@ -479,14 +480,27 @@ int access_host(struct query *q, char *argv[], client *cl)
       id = *(int *)argv[0];
       EXEC SQL SELECT m.name, m.use, m.contact, m.billing_contact, m.status, 
        m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, m.snet_id,
-       s.owner_type, s.owner_id INTO :name, :use, :contact, :billing_contact,
-       :status, :address, :mtype, :mid, :acomment, :ocomment, :snid, :stype
-       :sid
+       s.owner_type, s.owner_id, s.status INTO :name, :use, :contact, 
+       :billing_contact, :status, :address, :mtype, :mid, :acomment
+       :ocomment, :snid, :stype, :sid, :subnet_status
        FROM machine m, subnet s
        WHERE m.mach_id = :id AND s.snet_id = m.snet_id;
       if (dbms_errno)
        return mr_errcode;
 
+      /* Non query owner must provide valid billing information. */
+      if (q->version >= 8)
+       {
+         if (subnet_status == SNET_STATUS_BILLABLE)
+           {
+             account_number = argv[8];
+             EXEC SQL SELECT account_number FROM accountnumbers 
+               WHERE account_number = :account_number;
+             if (sqlca.sqlcode == SQL_NO_MATCH)
+               return MR_ACCOUNT_NUMBER;
+           }
+       }
+
       /* non-query-owner cannot change use or ocomment */
       if ((use != atoi(argv[7 + idx])) || (ocomment != *(int *)argv[14 + idx]))
        return MR_PERM;
index e27955234b85e8984730673c6ecd14383350167a..4f7d344daa17fb064cbc1e842caeff175103562d 100644 (file)
@@ -531,7 +531,7 @@ int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
   if (q->version < 8)
     idx = 0;
   else
-    idx = 1;
+    idx = 3;
 
   while (sq_get_data(sq, &argv))
     {
index 173fbda6e21b5d6bfa147dbdb637d1f1cd875e0a..4935b3875a306721462ee398ef7e6b9e0af8a90e 100644 (file)
@@ -236,7 +236,8 @@ int setup_dmac(struct query *q, char *argv[], client *cl)
 
 int setup_asnt(struct query *q, char *argv[], client *cl)
 {
-  int high, low, row;
+  int high, low, row, status;
+  char *account_number;
 
   /* Check for asnt or usnt. */
   if (q->type == APPEND)
@@ -244,9 +245,22 @@ int setup_asnt(struct query *q, char *argv[], client *cl)
   else
     row = 1;
 
-  low = atoi(argv[row + 5]);
-  high = atoi(argv[row + 6]);
-
+  low = atoi(argv[row + 7]);
+  high = atoi(argv[row + 8]);
+  status = atoi(argv[row + 2]);
+  account_number = argv[row + 4];
+  
+  /* Don't allow Private subnets to be created without a valid billing
+   * number.
+   */
+  if (status == SNET_STATUS_PRIVATE)
+    {
+      EXEC SQL SELECT account_number FROM accountnumbers
+       WHERE account_number = :account_number;
+      if (sqlca.sqlcode == SQL_NO_MATCH)
+       return MR_ACCOUNT_NUMBER;
+    }
+      
   /* Special case 0.0.0.0 and 255.255.255.255 */
   if (!(low == 0 || low == -1 || high == 0 || high == -1))
     if (low > high)
index a5be68bba8799d879ca08262a4ce751b34e48e24..3103c5819133bf60c0ce5fd7ce903d85517ac3c3 100644 (file)
@@ -1151,8 +1151,9 @@ static char *gsnt2_fields[] = {
 
 static char *gsnt_fields[] = {
   "name",
-  "name", "description", "status", "address", "mask", "low", "high", "prefix",
-  "ace_type", "ace_name", "modtime", "modby", "modwith"
+  "name", "description", "status", "contact", "account_number", "address", 
+  "mask", "low", "high", "prefix", "ace_type", "ace_name", "modtime", 
+  "modby", "modwith"
 };
 
 static struct validate gsnt_validate = {
@@ -1198,27 +1199,29 @@ static struct validate asnt2_validate =
 };
 
 static char *asnt_fields[] = {
-  "name", "description", "status", "address", "mask", "low", "high", "prefix",
-  "ace_type", "ace_name",
+  "name", "description", "status", "contact", "account_number", "address", 
+  "mask", "low", "high", "prefix", "ace_type", "ace_name",
 };
 
 static struct valobj asnt_valobj[] = {
   {V_CHAR, 0, SUBNET_TABLE, "name"},
   {V_LEN, 1, SUBNET_TABLE, "description"},
   {V_NUM, 2},
-  {V_NUM, 3},
-  {V_NUM, 4},
+  {V_CHAR, 3, SUBNET_TABLE, "contact"},
+  {V_CHAR, 4, SUBNET_TABLE, "account_number"},
   {V_NUM, 5},
   {V_NUM, 6},
-  {V_LEN, 7, SUBNET_TABLE, "prefix"},
-  {V_TYPE, 8, 0, "ace_type", 0, MR_ACE},
-  {V_TYPEDATA, 9, 0, 0, 0, MR_ACE},
+  {V_NUM, 7},
+  {V_NUM, 8},
+  {V_LEN, 9, SUBNET_TABLE, "prefix"},
+  {V_TYPE, 10, 0, "ace_type", 0, MR_ACE},
+  {V_TYPEDATA, 11, 0, 0, 0, MR_ACE},
 };
 
 static struct validate asnt_validate =
 {
   asnt_valobj,
-  10,
+  12,
   "name",
   "name = UPPER('%s')",
   1,
@@ -1262,8 +1265,8 @@ static struct validate usnt2_validate =
 
 static char *usnt_fields[] = {
   "name",
-  "newname", "description", "status", "address", "mask", "low", "high", 
-  "prefix", "ace_type", "ace_name",
+  "newname", "description", "status", "contact", "account_number", "address", 
+  "mask", "low", "high", "prefix", "ace_type", "ace_name",
 };
 
 static struct valobj usnt_valobj[] = {
@@ -1271,19 +1274,21 @@ static struct valobj usnt_valobj[] = {
   {V_RENAME, 1, SUBNET_TABLE, "name", "snet_id", MR_NOT_UNIQUE},
   {V_LEN, 2, SUBNET_TABLE, "description"},
   {V_NUM, 3},
-  {V_NUM, 4},
-  {V_NUM, 5},
+  {V_CHAR, 4, SUBNET_TABLE, "contact"},
+  {V_CHAR, 5, SUBNET_TABLE, "account_number"},
   {V_NUM, 6},
   {V_NUM, 7},
-  {V_LEN, 8, SUBNET_TABLE, "prefix"},
-  {V_TYPE, 9, 0, "ace_type", 0, MR_ACE},
-  {V_TYPEDATA, 10, 0, 0, 0, MR_ACE},
+  {V_NUM, 8},
+  {V_NUM, 9},
+  {V_LEN, 10, SUBNET_TABLE, "prefix"},
+  {V_TYPE, 11, 0, "ace_type", 0, MR_ACE},
+  {V_TYPEDATA, 12, 0, 0, 0, MR_ACE},
 };
 
 static struct validate usnt_validate =
 {
   usnt_valobj,
-  11,
+  13,
   "name",
   "snet_id = %d",
   1,
@@ -4738,9 +4743,9 @@ struct query Queries[] = {
     RETRIEVE,
     "s",
     SUBNET_TABLE,
-    "name, description, status, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet",
+    "name, description, status, contact, account_number, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet",
     gsnt_fields,
-    13,
+    15,
     "name LIKE UPPER('%s')",
     1,
     "name",
@@ -4772,9 +4777,9 @@ struct query Queries[] = {
     APPEND,
     "s",
     SUBNET_TABLE,
-    "INTO subnet (name, description, status, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, %d, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)",
+    "INTO subnet (name, description, status, contact, account_number, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), %s, %s, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)",
     asnt_fields,
-    10,
+    12,
     0,
     0,
     NULL,
@@ -4806,9 +4811,9 @@ struct query Queries[] = {
     UPDATE,
     "s",
     SUBNET_TABLE,
-    "subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), status = %s, saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d",
+    "subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), status = %s, contact = NVL('%s', CHR(0)), account_number = NVL('%s', CHR(0)), saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d",
     usnt_fields,
-    10,
+    12,
     "snet_id = %d",
     1,
     NULL,
This page took 0.938556 seconds and 5 git commands to generate.