]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_label.c
Fix and document new queries
[bacula/bacula] / bacula / src / dird / ua_label.c
index ce609da878cf327c10a936aa87b43b52f384ce73..83a1e7563f0ba3c981547f86feb5cebc3d92f798 100644 (file)
@@ -1026,13 +1026,18 @@ void status_slots(UAContext *ua, STORE *store_r)
    POOL_DBR pr;
    vol_list_t *vl, *vol_list = NULL;
    MEDIA_DBR mr;
+   char ed1[50], ed2[50], ed3[50];
    char *slot_list;
    int max_slots;
    int drive;
    int i=1;
    /* output format */
-   const char *slot_api_empty_format="%i|||||\n";
-   const char *slot_api_full_format="%i|%i|%s|%s|%s|%s|\n";
+   const char *slot_api_empty_format="%i||||||||\n";
+
+   /* Slot|RealSlot|Volume|Bytes|Status|MediaType|Pool|LastW|Expire */
+   const char *slot_api_full_format="%i|%i|%s|%s|%s|%s|%s|%s|%s\n";
+
+   /* Slot | Volume | Status | MediaType | Pool */
    const char *slot_hformat=" %4i%c| %16s | %9s | %20s | %18s |\n";
 
    if (!open_client_db(ua)) {
@@ -1063,8 +1068,8 @@ void status_slots(UAContext *ua, STORE *store_r)
       goto bail_out;
    }
    if (!ua->api) {
-      ua->info_msg(_(" Slot |   Volume Name    |   Status  |     Media Type       |      Pool          |\n"));
-      ua->info_msg(_("------+------------------+-----------+----------------------+--------------------|\n"));
+      ua->send_msg(_(" Slot |   Volume Name    |   Status  |     Media Type       |      Pool          |\n"));
+      ua->send_msg(_("------+------------------+-----------+----------------------+--------------------|\n"));
    }
 
    /* Walk through the list getting the media records */
@@ -1084,12 +1089,13 @@ void status_slots(UAContext *ua, STORE *store_r)
 
       if (!vl->VolName) {
          Dmsg1(100, "No VolName for Slot=%d.\n", vl->Slot);
-         if (!ua->api) {
-            ua->info_msg(slot_hformat,
+         if (ua->api) {
+            ua->send_msg(slot_api_empty_format, vl->Slot);
+
+         } else {
+            ua->send_msg(slot_hformat,
                          vl->Slot, '*',
                          "?", "?", "?", "?");
-         } else {
-            ua->info_msg(slot_api_empty_format, vl->Slot);
          }
          continue;
       }
@@ -1097,11 +1103,12 @@ void status_slots(UAContext *ua, STORE *store_r)
       /* Hope that slots are ordered */
       for (; i < vl->Slot; i++) {
          if (slot_list[i]) {
-            if (!ua->api) {
-               ua->info_msg(slot_hformat,
-                            i, ' ', "", "", "", "");
+            if (ua->api) {
+               ua->send_msg(slot_api_empty_format, i);
+
             } else {
-               ua->info_msg(slot_api_empty_format, i);
+               ua->send_msg(slot_hformat,
+                            i, ' ', "", "", "", "");
             }       
             slot_list[i]=0;
          }
@@ -1116,24 +1123,32 @@ void status_slots(UAContext *ua, STORE *store_r)
          if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
             strcpy(pr.Name, "?");
          }
+         db_unlock(ua->db);
 
-         if (!ua->api) {
+         if (ua->api) {
+            ua->send_msg(slot_api_full_format,
+                         vl->Slot, mr.Slot, mr.VolumeName, 
+                         edit_uint64(mr.VolBytes, ed1), 
+                         mr.VolStatus, mr.MediaType, pr.Name, 
+                         edit_uint64(mr.LastWritten, ed2),
+                         edit_uint64(mr.LastWritten+mr.VolRetention, ed3));
+         } else {
             /* Print information */
-            ua->info_msg(slot_hformat,
+            ua->send_msg(slot_hformat,
                          vl->Slot, ((vl->Slot==mr.Slot)?' ':'*'),
                          mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name);
-         } else {
-            ua->info_msg(slot_api_full_format,
-                         vl->Slot, mr.Slot, mr.VolumeName, mr.VolStatus, 
-                         mr.MediaType, pr.Name);
          }
 
-         db_unlock(ua->db);
          continue;
       } else {                  /* TODO: get information from catalog  */
-         ua->info_msg(slot_hformat,
-                      vl->Slot, '*',
-                      mr.VolumeName, "?", "?", "?");
+         if (ua->api) {
+            ua->send_msg(slot_api_empty_format, vl->Slot);
+
+         } else {
+            ua->send_msg(slot_hformat,
+                         vl->Slot, '*',
+                         mr.VolumeName, "?", "?", "?");
+         }
       }
       db_unlock(ua->db);
    }
@@ -1143,10 +1158,11 @@ void status_slots(UAContext *ua, STORE *store_r)
    for (; i <= max_slots; i++) {
       if (slot_list[i]) {
          if (!ua->api) {
-            ua->info_msg(slot_hformat,
-                         i, ' ', "", "", "", "");
+            ua->send_msg(slot_api_empty_format, i);
+
          } else {
-            ua->info_msg(slot_api_empty_format, i);
+            ua->send_msg(slot_hformat,
+                         i, ' ', "", "", "", "");
          } 
          slot_list[i]=0;
       }