From 8d45912995082eae90ae6c4feac7e3a5a86bfccb Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 7 Jan 2013 16:03:05 +0100
Subject: [PATCH] Add "use_locking" parameter to network query opcode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This was extracted from a patch by Dimitris Aragiorgis with the subject
β€œAdd locking to _NetworkQuery”. The rest of the patch did no longer
apply and will require more work.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py                  | 2 +-
 lib/opcodes.py                 | 1 +
 src/Ganeti/OpCodes.hs          | 2 +-
 test/hs/Test/Ganeti/OpCodes.hs | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 98d0a7217..753120cd1 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -16530,7 +16530,7 @@ class LUNetworkQuery(NoHooksLU):
 
   def CheckArguments(self):
     self.nq = _NetworkQuery(qlang.MakeSimpleFilter("name", self.op.names),
-                            self.op.output_fields, False)
+                            self.op.output_fields, self.op.use_locking)
 
   def ExpandNames(self):
     self.nq.ExpandNames(self)
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 887b7bb01..2c88363b1 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -2152,6 +2152,7 @@ class OpNetworkQuery(OpCode):
   """Compute the list of networks."""
   OP_PARAMS = [
     _POutputFields,
+    _PUseLocking,
     ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
      "Empty list to query all groups, group names otherwise"),
     ]
diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs
index 8285e9300..ec9a34f86 100644
--- a/src/Ganeti/OpCodes.hs
+++ b/src/Ganeti/OpCodes.hs
@@ -537,7 +537,7 @@ $(genOpCode "OpCode"
      , pNetworkName
      , pIpConflictsCheck
      ])
-  , ("OpNetworkQuery", dOldQueryNoLocking)
+  , ("OpNetworkQuery", dOldQuery)
   , ("OpRestrictedCommand",
      [ pUseLocking
      , pRequiredNodes
diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs
index aa0756839..cf345d19b 100644
--- a/test/hs/Test/Ganeti/OpCodes.hs
+++ b/test/hs/Test/Ganeti/OpCodes.hs
@@ -335,7 +335,7 @@ instance Arbitrary OpCodes.OpCode where
       "OP_NETWORK_DISCONNECT" ->
         OpCodes.OpNetworkDisconnect <$> genNameNE <*> genNameNE <*> arbitrary
       "OP_NETWORK_QUERY" ->
-        OpCodes.OpNetworkQuery <$> genFieldsNE <*> genNamesNE
+        OpCodes.OpNetworkQuery <$> genFieldsNE <*> genNamesNE <*> arbitrary
       "OP_RESTRICTED_COMMAND" ->
         OpCodes.OpRestrictedCommand <$> arbitrary <*> genNodeNamesNE <*>
           genNameNE
-- 
GitLab