Skip to content
  • Iustin Pop's avatar
    Implement job summary in gnt-job list · 60dd1473
    Iustin Pop authored
    It is not currently possibly to show a summary of the job in the output
    of “gnt-job list”. The closes is listing the whole opcode(s), but that
    is too verbose. Also, the default output (id, status) is not very
    useful, unless one looks for (and knows about) an exact job ID.
    
    The patch adds a “summary” description of a job composed of the list of
    OP_ID of the individual opcodes. Moreover, if an opcode has a ‘logical’
    target in a certain opcode field (e.g. start instance has the instance
    name as the target), then it is included in the formatting also. It's
    easier to explain via a sample output:
    
    gnt-job list
    ID Status  Summary
    1  error   NODE_QUERY
    2  success NODE_ADD(gnta2)
    3  success CLUSTER_QUERY
    4  success NODE_REMOVE(gnta2.example.com)
    5  error   NODE_QUERY
    6  success NODE_ADD(gnta2)
    7  success NODE_QUERY
    8  success OS_DIAGNOSE
    9  success INSTANCE_CREATE(instance1.example.com)
    10 success INSTANCE_REMOVE(instance1.example.com)
    11 error   INSTANCE_CREATE(instance1.example.com)
    12 success INSTANCE_CREATE(instance1.example.com)
    13 success INSTANCE_SHUTDOWN(instance1.example.com)
    14 success INSTANCE_ACTIVATE_DISKS(instance1.example.com)
    15 error   INSTANCE_CREATE(instance2.example.com)
    16 error   INSTANCE_CREATE(instance2.example.com)
    17 success INSTANCE_CREATE(instance2.example.com)
    18 success INSTANCE_ACTIVATE_DISKS(instance1.example.com)
    19 success INSTANCE_ACTIVATE_DISKS(instance2.example.com)
    20 success INSTANCE_SHUTDOWN(instance1.example.com)
    21 success INSTANCE_SHUTDOWN(instance2.example.com)
    
    This is done by a simple change to the opcode classes, which allows an
    opcode to format itself. The additional function is small enough that it
    can go in opcodes.py, where it could also be used by a client if needed.
    
    Reviewed-by: imsnah
    60dd1473