1. 05 Sep, 2012 1 commit
    • Iustin Pop's avatar
      Add some unittests for node queries · b9bdc10e
      Iustin Pop authored
      
      
      These new tests check that:
      
      - no known fields return unknown
      - any unknown field returns unknown
      - the type of the fields is consistent between the getters and the
        field definition
      - the length of each result row corresponds with the number of fields
        queried, and the length of the field definitions returned
      - the length of the rows corresponds to the number of nodes
      - querying fields on empty fields returns all fields
      
      Finally this patch found a bug, in that the pinst_list/sinst_list
      fields were declared as QFTNumber (copy-paste error from
      pinst_cnt/sinst_cnt), yay!
      
      I also changed genEmptyCluster to ensure that it generates unique node
      names, so that the number of result rows is consistent with what we
      requested, and switched ResultEntry from a normal constructor to
      record syntax, so that we can extract the fields without having to use
      pattern matching.
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      b9bdc10e
  2. 04 Sep, 2012 5 commits
  3. 03 Sep, 2012 2 commits
    • Iustin Pop's avatar
      Add Query support for Nodes (no filtering, no RPC) · 046fe3f5
      Iustin Pop authored
      
      
      This is the initial support for Query2: basic infrastructure (except
      filtering) and node query support (without RPC).
      
      It implements all the fields (tests by comparison with list-fields on
      the Python side), except that:
      
      - filter is not done
      - since RPC is not integrated yet, the runtime gathering/computing is
        simply stubbed out
      
      However, the infrastructure seems pretty reasonable, so I'm sending as
      is.
      
      Note that I've split the functions/declarations into multiple files,
      to keep each file clean and readable.
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      046fe3f5
    • Iustin Pop's avatar
      Stub query2 call integration into QueryD · 4cbe9bda
      Iustin Pop authored
      This patch corrects the definitions in Qlang.hs to match what Python
      expects on the wire; this means replacing some manual data type
      definitions with 'buildObject' so that we get serialisation (and field
      names) for free, adding (manually) JSON instances for types which are
      not represented as objects in JSON, etc. Due to more TH usage, I had
      to shift some definitions around, since TH breaks the "define in any
      order" property (
      
      ).
      
      After that, we simply add a call into the stub Query/Query.hs module
      which, for all queries, responds with "query not supported". The
      reason for the deep directory structure is because I want to separate
      the functionality into multiple submodules, for smaller module size
      and readability.
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      4cbe9bda
  4. 28 Aug, 2012 4 commits
    • Iustin Pop's avatar
      Reduce some more code duplication and split code · 62377cf5
      Iustin Pop authored
      
      
      The Qlang module defines ResultStatus, but it was already defined in
      Ganeti/Luxi.hs; let's remove the duplicate definition from there since
      the proper place is in the newer module.
      
      Also, in order to ease testing, we split some confd functions into a
      separate module; this can be imported easily into QC for testing.
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      62377cf5
    • Iustin Pop's avatar
      Remove obsolete QrViaLuxi type · 8a9ee1e9
      Iustin Pop authored
      
      
      The actual query definitions are now in Qlang.hs, so let's use the
      ItemType from there instead of luxi-defined type (which is also
      incomplete).
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      8a9ee1e9
    • Iustin Pop's avatar
      Rename Query2.hs to Qlang.hs · dc6a0f82
      Iustin Pop authored
      
      
      While starting to use the new filter types, I realised that what is
      currently implemented is the equivalent of `lib/qlang.py', not
      `lib/query.py', since we only deal with data types for now and not the
      actual query runtime functionality (RPC, config, etc.).
      
      Let's rename the file to be more consistent with the Python code base.
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      dc6a0f82
    • Iustin Pop's avatar
      Implement Query2 filter JSON (de)serialisation · e8a25d62
      Iustin Pop authored
      
      
      This adds support for encoding/decoding Query2 filters to/from JSON,
      in (hopefully) the same format as the Python code generates.
      
      It also adds a simple unit-test to check that this conversion is
      idempotent. Of note here is that, since the Filter data type is
      recursive, we have to manually ensure that the generator for it
      correctly "shrinks" at each step (first version crashed hard my
      workstation after eating ~8GB of ram :).
      
      Compared to the current Query2 implementation, the following changes
      were done:
      
      - style: shortened some names to match the Python ones (LessEqualThan
        → LE, etc.)
      - changed FilterValue from string to an ADT that can encode both
        quoted strings and numeric values, since this is actually what
        qlang.py generates
      - added support for EmptyField, which in hindsight it's an obvious
        missing part :)
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      e8a25d62
  5. 06 Jul, 2012 1 commit
  6. 14 Jun, 2012 1 commit
  7. 12 Jun, 2012 1 commit