Revision cc412b78 snf-pithos-backend/pithos/backends/lib/sqlite/node.py

b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py
384 384
        self.execute(q, (node,))
385 385
        return True
386 386

  
387
    def node_accounts(self, accounts=()):
388
        q = ("select path, node from nodes where node != 0 and parent == 0 ")
389
        args = []
390
        if accounts:
391
            placeholders = ','.join('?' for a in accounts)
392
            q += ("and path in (%s)" % placeholders)
393
            args += accounts
394
        return self.execute(q, args).fetchall()
395

  
396
    def node_account_usage(self, account_node, cluster):
397
        select_children = ("select node from nodes where parent = ?")
398
        select_descedents = ("select node from nodes "
399
                             "where parent in (%s) "
400
                             "or node in (%s) ") % ((select_children,)*2)
401
        args = [account_node]*2
402
        q = ("select sum(v.size) from versions v, nodes n "
403
             "where v.node = n.node "
404
             "and n.node in (%s) "
405
             "and v.cluster = ?") % select_descedents
406
        args += [cluster]
407

  
408
        self.execute(q, args)
409
        return self.fetchone()[0]
410

  
387 411
    def policy_get(self, node):
388 412
        q = "select key, value from policy where node = ?"
389 413
        self.execute(q, (node,))

Also available in: Unified diff