IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42387


Ignore:
Timestamp:
Feb 8, 2023, 12:14:39 PM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. add safety to pxadmin to prevent drop of ops dbs, add fpcamera, more flexibility in ippadmin for testing; prevent pzgetexp from trying to download too many exposures

Location:
trunk/ippTools
Files:
11 edited
14 copied

Legend:

Unmodified
Added
Removed
  • trunk/ippTools

  • trunk/ippTools/scripts/ippadmin

    r20933 r42387  
    66
    77if ("$1" == "init") then
    8   if ($#argv != 4) goto usage;
     8  if ($#argv != 5) goto usage;
    99  set dbserver = $2
    10   set dbuser = $3
    11   set dbpass = $4
     10  set rootuser = $3
     11  set dbuser = $4
     12  set dbpass = $5
    1213
    13   mysql -h $dbserver -u root -p <<EOF
     14  mysql -h $dbserver -u $rootuser -p <<EOF
    1415  create database $IPPADMIN;
    1516  use $IPPADMIN;
     
    1718  create table cookies (cookie_id BIGINT AUTO_INCREMENT, username char(255) not null, cookie varchar(255), primary key (cookie_id));
    1819  create table projects (proj_id BIGINT AUTO_INCREMENT, projname char(255) not null, primary key (proj_id));
    19   grant all on *.* to $dbuser@localhost identified by '$dbpass';
     20  create user '$dbuser'@'$dbserver' identified by '$dbpass';
     21  grant all on *.* to '$dbuser'@'$dbserver';
     22  flush privileges;
     23EOF
     24    exit 0;
     25endif
     26
     27if ("$1" == "project") then
     28  if ($#argv != 4) goto usage;
     29  set dbserver = $2
     30  set dbuser = $3
     31  set dbname = $4
     32
     33  mysql -h $dbserver -u $dbuser -p $IPPADMIN <<EOF
     34   insert into projects (projname) values ('$dbname');
     35   create database $dbname;
     36EOF
     37    exit 0;
     38endif
     39
     40if ("$1" == "user") then
     41  if ($#argv != 5) goto usage;
     42  set dbserver = $2
     43  set dbuser = $3
     44  set user = $4
     45  set pass = $5
     46
     47  mysql -h $dbserver -u $dbuser -p $IPPADMIN <<EOF
     48  insert into users (username, password) values ('$user', '$pass');
    2049EOF
    2150    exit 0;
     
    3564endif
    3665
    37 if ("$1" == "user") then
    38   if ($#argv != 5) goto usage;
    39   set dbserver = $2
    40   set dbuser = $3
    41   set user = $4
    42   set pass = $5
    43 
    44   mysql -h $dbserver -u $dbuser -p $IPPADMIN <<EOF
    45   insert into users (username, password) values ('$user', '$pass');
    46 EOF
    47     exit 0;
    48 endif
    49 
    50 if ("$1" == "project") then
    51   if ($#argv != 4) goto usage;
    52   set dbserver = $2
    53   set dbuser = $3
    54   set dbname = $4
    55 
    56   mysql -h $dbserver -u $dbuser -p $IPPADMIN <<EOF
    57    insert into projects (projname) values ('$dbname');
    58    create database $dbname;
    59 EOF
    60     exit 0;
    61 endif
    62 
    63 if ("$1" == "upgrade") then
    64   echo "$#argv"
    65  
    66   if ($#argv != 3) goto usage;
    67   set dbserver = $2
    68   set stage = $3
    69 
    70   if ("$stage" == "1") then
    71     mysql -h $dbserver -u root -p $IPPADMIN <<EOF
    72     ALTER TABLE users add column user_id BIGINT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (user_id);
    73     ALTER TABLE users change column username username varchar(255);
    74 
    75     ALTER TABLE cookies add column cookie_id BIGINT AUTO_INCREMENT FIRST, ADD PRIMARY KEY (cookie_id);
    76     ALTER TABLE cookies change column username username varchar(255);
    77 
    78     ALTER TABLE projects add column proj_id BIGINT AUTO_INCREMENT FIRST, ADD PRIMARY KEY (proj_id);
    79     ALTER TABLE projects change column projname projname varchar(255);
    80 EOF
    81       exit 0;
    82   endif
    83 
    84   echo "unknown upgrade stage $stage"
    85   exit 1;
    86 endif
    87 
    8866usage:
    8967  echo "USAGE: ippadmin (options)"
    9068  echo ""
    91   echo "  ippadmin init (dbserver) (dbuser) (dbpassword)"
    92   echo "      creates admin tables, basic db user -- requires root password"
     69  echo "  ippadmin init (dbserver) (rootuser) (dbuser) (dbpassword)"
     70  echo "      creates admin tables, basic db user -- requires mysql (rootuser) password"
     71  echo "      (rootuser) is a mysql user with global privileges"
    9372  echo ""
    94   echo "  ippadmin upgrade (dbserver) (stage)"
    95   echo "      upgrade existing database for given stage [1] -- requires root password"
     73  echo "  ippadmin project (dbserver) (dbuser) (dbname)"
     74  echo "      create a new ipp project (database)"
     75  echo "      (need to run pxadmin -create after it is created)"
     76  echo ""
     77  echo "  ippadmin user (dbserver) (dbuser) (username) (password)"
     78  echo "      create a new www user and password"
    9679  echo ""
    9780  echo "  ippadmin client (dbserver) (dbuser) (dbpassword) (client)"
    9881  echo "      add client name or regex"
    9982  echo ""
    100   echo "  ippadmin user (dbserver) (dbuser) (username) (password)"
    101   echo "      create a new www user and password"
    102   echo ""
    103   echo "  ippadmin project (dbserver) (dbuser) (dbname)"
    104   echo "      create a new ipp project (database)"
    105   echo ""
    10683  exit 2
  • trunk/ippTools/share

  • trunk/ippTools/share/Makefile.am

    r42097 r42387  
    543543        remotetool_listcomponent.sql \
    544544        remotetool_doneprep.sql \
    545         remotetool_updatepoll.sql
     545        remotetool_updatepoll.sql \
     546        fpcamtool_find_cam_and_chip_id.sql \
     547        fpcamtool_find_cam_id.sql \
     548        fpcamtool_find_processedexp.sql \
     549        fpcamtool_pendingexp.sql \
     550        fpcamtool_inputchips.sql \
     551        fpcamtool_inputastrom.sql \
     552        fpcamtool_queue_cam_id.sql \
     553        fpcamtool_revertprocessedexp.sql \
     554        fpcamtool_revertupdatedexp.sql
     555
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r42097 r42387  
    24272427) ENGINE=innodb DEFAULT CHARSET=latin1;
    24282428
     2429CREATE TABLE fpcamRun (
     2430    fpcam_id      BIGINT AUTO_INCREMENT,
     2431    cam_id        BIGINT,
     2432    chip_id       BIGINT,
     2433    state         VARCHAR(64),
     2434    workdir       VARCHAR(255),
     2435    workdir_state VARCHAR(64),
     2436    label         VARCHAR(64),
     2437    data_group    VARCHAR(64),
     2438    dist_group    VARCHAR(64),
     2439    reduction     VARCHAR(64),
     2440    dvodb         VARCHAR(255),
     2441    software_ver  VARCHAR(16),
     2442    note          VARCHAR(255),
     2443    PRIMARY KEY(fpcam_id),
     2444    KEY(cam_id),
     2445    KEY(chip_id),
     2446    KEY(state),
     2447    KEY(label),
     2448    INDEX(chip_id, cam_id),
     2449    FOREIGN KEY (cam_id) REFERENCES camRun(cam_id),
     2450    FOREIGN KEY (chip_id) REFERENCES chipRun(chip_id))
     2451ENGINE=innodb DEFAULT CHARSET=latin1;
     2452
     2453CREATE TABLE fpcamProcessedExp (
     2454    fpcam_id     BIGINT,
     2455    path_base    VARCHAR(255),
     2456
     2457    zpt_obs      FLOAT,
     2458    zpt_stdev    FLOAT,
     2459    zpt_lq       FLOAT,
     2460    zpt_uq       FLOAT,
     2461
     2462    dtime_script FLOAT,
     2463
     2464    hostname     VARCHAR(64),
     2465    n_stars      INT,
     2466    fault        SMALLINT NOT NULL,
     2467    epoch        TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     2468
     2469    software_ver VARCHAR(16),
     2470
     2471    deteff_obs   FLOAT,
     2472    deteff_err   FLOAT,
     2473    deteff_lq    FLOAT,
     2474    deteff_uq    FLOAT,
     2475
     2476    quality      SMALLINT,
     2477
     2478    PRIMARY KEY(fpcam_id),
     2479    KEY(fault),
     2480    FOREIGN KEY (fpcam_id) REFERENCES fpcamRun(fpcam_id)
     2481) ENGINE=innodb DEFAULT CHARSET=latin1;
     2482
    24292483-- These comment lines are here to avoid an empty query error.
    24302484-- Another way to avoid that problem is to omit the semicolon above but I think that is untidy.
  • trunk/ippTools/share/pxadmin_drop_tables.sql

    r38157 r42387  
    129129DROP TABLE IF EXISTS remoteComponent;
    130130DROP TABLE IF EXISTS remoteRun;
    131 
     131DROP TABLE IF EXISTS fpcamProcessedExp;
     132DROP TABLE IF EXISTS fpcamRun;
    132133
    133134SET FOREIGN_KEY_CHECKS=1
  • trunk/ippTools/src

  • trunk/ippTools/src/Makefile.am

    r36511 r42387  
    3535        releasetool \
    3636        fftool \
     37        fpcamtool \
    3738        remotetool
    3839
     
    5556        pxtoolsErrorCodes.h \
    5657        pxtree.h \
     58        pxfpcam.h \
    5759        pxwarp.h
    5860
     
    9193        releasetool.h \
    9294        fftool.h \
     95        fpcamtool.h \
    9396        remotetool.h
    9497
     
    116119        pxtoolsErrorCodes.c \
    117120        pxtree.c \
     121        pxfpcam.c \
    118122        pxwarp.c
    119123
     
    174178    camtool.c \
    175179    camtoolConfig.c
     180
     181fpcamtool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS)
     182fpcamtool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la
     183fpcamtool_SOURCES = \
     184    fpcamtool.c \
     185    fpcamtoolConfig.c
    176186
    177187faketool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS)
  • trunk/ippTools/src/pxadmin.c

    r26981 r42387  
    184184        psString dbName = name->data.str;
    185185
     186        // if name is e.g., gpc1, strcasecmp returns FALSE
     187        bool allowDelete = true;
     188        allowDelete = allowDelete && strcasecmp(dbName, "gpc1"); 
     189        allowDelete = allowDelete && strcasecmp(dbName, "gpc2"); 
     190        allowDelete = allowDelete && strcasecmp(dbName, "nebulous"); 
     191        allowDelete = allowDelete && strcasecmp(dbName, "isp"); 
     192        allowDelete = allowDelete && strcasecmp(dbName, "ssp"); 
     193        allowDelete = allowDelete && strcasecmp(dbName, "uic"); 
     194        allowDelete = allowDelete && strcasecmp(dbName, "hsc_v1"); 
     195        allowDelete = allowDelete && strcasecmp(dbName, "megacam_v1"); 
     196
     197        if (!allowDelete) {
     198            fprintf (stdout, "**** WARNING: not allowed to delete database %s.\n", dbName);
     199            return false;
     200        }
     201
    186202        fprintf(stdout, "*** delete the tables from database %s? ***\n", dbName);
    187203        fprintf(stdout, "*** to delete the tables, answer YES, and give password ***\n");
  • trunk/ippTools/src/pxcam.c

    r41213 r42387  
    174174                         "new", // state
    175175                         workdir  ? workdir  : "NULL",
    176                          "dirty", //workdir_state
     176                         "dirty", // workdir_state
    177177                         label    ? label    : "NULL",
    178178                         data_group ? data_group : "NULL",
  • trunk/ippTools/src/pzgetexp.c

    r31038 r42387  
    136136    psFree(cmdOutput);
    137137    if (!newSummitExps) {
    138         // XXX not nessicarily an error
     138        // XXX not necessarily an error?
    139139        psError(PS_ERR_UNKNOWN, true, "no new fileSet/exp IDs");
    140140        return false;
     
    145145        return true;
    146146    }
     147    // If we supply an unknown last_fileset (exposure name) to the summit datastore,
     148    // it will return all filesets it knows about.  This can cause problems (table overflow)
     149    // if this is too large a number.  Raise an error and let the user fix the underlying
     150    // problem (last exposure not known to the summit datastore)
     151    // Do we need to be able to configure this number?
     152    if (psArrayLength(newSummitExps) > 10000) {
     153        psError(PS_ERR_UNKNOWN, true, "too many new fileSet/exp IDs? unknown exposure? problem with summitExp table?");
     154        return false;
     155    }
    147156
    148157    // start a transaction so it's all rows or nothing
     
    153162    }
    154163
    155     // increase memory table size limits; deafult is 16MB
    156     {
     164    // increase memory table size limits; default is 16MB, but our current (2022) config
     165    // in /etc/mysql/my.cnf sets to default to 1024M.
     166    // This command sets the max_heap_table_size within the transaction, and does not
     167    // apparently stick.  But this is not really needed, so we are deactivating it.
     168    if (0) {
    157169        // 512MB
    158170        char *query = "SET max_heap_table_size = 1024*1024*512";
Note: See TracChangeset for help on using the changeset viewer.