src/dird/ua_output.c
bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
{
   POOL_DBR pr;

   bmemset(&pr, 0, sizeof(POOL_DBR));
   set_jcr_defaults(jcr, job);
   if (pool) {
      jcr->pool = pool;               /* override */
   }
   if (jcr->db) {
      Dmsg0(100, "complete_jcr close db\n");
      db_close_database(jcr, jcr->db);
      jcr->db = NULL;
   }

   Dmsg0(100, "complete_jcr open db\n");
   jcr->db = db_init_database(jcr, jcr->catalog->db_driver, jcr->catalog->db_name,
                jcr->catalog->db_user,
                jcr->catalog->db_password, jcr->catalog->db_address,
                jcr->catalog->db_port, jcr->catalog->db_socket,
                jcr->catalog->db_ssl_mode, jcr->catalog->db_ssl_key,
                jcr->catalog->db_ssl_cert, jcr->catalog->db_ssl_ca,
                jcr->catalog->db_ssl_capath, jcr->catalog->db_ssl_cipher,
                jcr->catalog->mult_db_connections,
                jcr->catalog->disable_batch_insert);
   if (!jcr->db || !db_open_database(jcr, jcr->db)) {
      Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
                 jcr->catalog->db_name);
      if (jcr->db) {
         Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
         db_close_database(jcr, jcr->db);
         jcr->db = NULL;
      }
      return false;
   }
   bstrncpy(pr.Name, jcr->pool->name(), sizeof(pr.Name));
   while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */
      /* Try to create the pool */
      if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
         Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name,
            db_strerror(jcr->db));
         if (jcr->db) {
            db_close_database(jcr, jcr->db);
            jcr->db = NULL;
         }
         return false;
      } else {
         Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
      }
   }
   jcr->jr.PoolId = pr.PoolId;
   return true;
}
/*
 * Fill in the remaining fields of the jcr as if it
 *  is going to run the job.
 */
Fill in the remaining fields of the jcr as if it
is going to run the job.
Fill in the remaining fields of the jcr as if it is going to run the job .
bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
{
   POOL_DBR pr;
   bmemset(&pr, 0, sizeof(POOL_DBR));
   set_jcr_defaults(jcr, job);
   if (pool) {
      jcr->pool = pool;               
   }
   if (jcr->db) {
      Dmsg0(100, "complete_jcr close db\n");
      db_close_database(jcr, jcr->db);
      jcr->db = NULL;
   }
   Dmsg0(100, "complete_jcr open db\n");
   jcr->db = db_init_database(jcr, jcr->catalog->db_driver, jcr->catalog->db_name,
                jcr->catalog->db_user,
                jcr->catalog->db_password, jcr->catalog->db_address,
                jcr->catalog->db_port, jcr->catalog->db_socket,
                jcr->catalog->db_ssl_mode, jcr->catalog->db_ssl_key,
                jcr->catalog->db_ssl_cert, jcr->catalog->db_ssl_ca,
                jcr->catalog->db_ssl_capath, jcr->catalog->db_ssl_cipher,
                jcr->catalog->mult_db_connections,
                jcr->catalog->disable_batch_insert);
   if (!jcr->db || !db_open_database(jcr, jcr->db)) {
      Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
                 jcr->catalog->db_name);
      if (jcr->db) {
         Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
         db_close_database(jcr, jcr->db);
         jcr->db = NULL;
      }
      return false;
   }
   bstrncpy(pr.Name, jcr->pool->name(), sizeof(pr.Name));
   while (!db_get_pool_record(jcr, jcr->db, &pr)) { 
      if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
         Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name,
            db_strerror(jcr->db));
         if (jcr->db) {
            db_close_database(jcr, jcr->db);
            jcr->db = NULL;
         }
         return false;
      } else {
         Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name);
      }
   }
   jcr->jr.PoolId = pr.PoolId;
   return true;
}
bool complete_jcr_for_job ( JCR * jcr , JOB * job , POOL * pool ) { POOL_DBR pr ; bmemset ( & pr , 0 , sizeof ( POOL_DBR ) ) ; set_jcr_defaults ( jcr , job ) ; if ( pool ) { jcr -> pool = pool ; } if ( jcr -> db ) { Dmsg0 ( 100 , " \n " ) ; db_close_database ( jcr , jcr -> db ) ; jcr -> db = NULL ; } Dmsg0 ( 100 , " \n " ) ; jcr -> db = db_init_database ( jcr , jcr -> catalog -> db_driver , jcr -> catalog -> db_name , jcr -> catalog -> db_user , jcr -> catalog -> db_password , jcr -> catalog -> db_address , jcr -> catalog -> db_port , jcr -> catalog -> db_socket , jcr -> catalog -> db_ssl_mode , jcr -> catalog -> db_ssl_key , jcr -> catalog -> db_ssl_cert , jcr -> catalog -> db_ssl_ca , jcr -> catalog -> db_ssl_capath , jcr -> catalog -> db_ssl_cipher , jcr -> catalog -> mult_db_connections , jcr -> catalog -> disable_batch_insert ) ; if ( ! jcr -> db || ! db_open_database ( jcr , jcr -> db ) ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " \" \" \n " ) , jcr -> catalog -> db_name ) ; if ( jcr -> db ) { Jmsg ( jcr , M_FATAL , 0 , " " , db_strerror ( jcr -> db ) ) ; db_close_database ( jcr , jcr -> db ) ; jcr -> db = NULL ; } return false ; } bstrncpy ( pr . Name , jcr -> pool -> name ( ) , sizeof ( pr . Name ) ) ; while ( ! db_get_pool_record ( jcr , jcr -> db , & pr ) ) { if ( create_pool ( jcr , jcr -> db , jcr -> pool , POOL_OP_CREATE ) < 0 ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " " ) , pr . Name , db_strerror ( jcr -> db ) ) ; if ( jcr -> db ) { db_close_database ( jcr , jcr -> db ) ; jcr -> db = NULL ; } return false ; } else { Jmsg ( jcr , M_INFO , 0 , _ ( " \n " ) , pr . Name ) ; } } jcr -> jr . PoolId = pr . PoolId ; return true ; }
Fill in the remaining fields of the jcr as if it
  is going to run the job.
Fill in the remaining fields of the jcr as if it is going to run the job .
/* override */ /* get by Name */ /* Try to create the pool */