commit 588fa31dd22a1e9320a9bf355c66ca1b837ff586
Merge: fd55874 20c2aec
Author: Brian Foley <[email protected]>
Date: Thu Jul 7 12:12:35 2016 +0100
Merge branch 'stable-2.16' into stable-2.17
* stable-2.16
Fix some trivial pep8/pylint errors
Make executeRpcCall only compute rpcCallData once
Remove storage unit selection from rpcCallData
Only import needed functions from Ganeti.JSON
Special case WaitForJobChange to reduce heap use
* stable-2.15
Cleanup more pylint/pep8/apidoc errors
KVM: handle gracefully too old/too new psutil versions
Fix small typo in opcode tests
Fix line-too long errors
Manually update import lists to fix compile errors, and fix trivial
pep8 whitespace warning.
Signed-off-by: Brian Foley <[email protected]>
diff --cc src/Ganeti/Config.hs
index f67aff1,4d0e5a0..5687b54
--- a/src/Ganeti/Config.hs
+++ b/src/Ganeti/Config.hs
@@@ -101,9 -99,8 +101,9 @@@ import System.I
import Ganeti.BasicTypes
import qualified Ganeti.Constants as C
+import qualified Ganeti.ConstantUtils as CU
import Ganeti.Errors
- import Ganeti.JSON
+ import Ganeti.JSON (fromJResult, fromContainer, GenericContainer(..))
import Ganeti.Objects
import Ganeti.Types
import qualified Ganeti.Utils.MultiMap as MM
diff --cc src/Ganeti/HTools/Backend/IAlloc.hs
index e431947,3a67c2d..e40c3d7
--- a/src/Ganeti/HTools/Backend/IAlloc.hs
+++ b/src/Ganeti/HTools/Backend/IAlloc.hs
@@@ -65,7 -65,7 +65,7 @@@ import Ganeti.HTools.AlgorithmParams (A
import Ganeti.HTools.CLI
import Ganeti.HTools.Loader
import Ganeti.HTools.Types
- import Ganeti.JSON
-import Ganeti.JSON (maybeFromObj, JSRecord, tryFromObj, toArray,
asObjectList, readEitherString, fromJResult, fromObj, fromObjWithDefault,
asJSObject)
++import Ganeti.JSON (maybeFromObj, JSRecord, tryFromObj, toArray,
asObjectList, readEitherString, fromJResult, fromObj, fromObjWithDefault,
asJSObject, emptyContainer)
import Ganeti.Types ( EvacMode(ChangePrimary, ChangeSecondary)
, adminStateFromRaw, AdminState(..))
import Ganeti.Utils
diff --cc src/Ganeti/HTools/Backend/Luxi.hs
index be81a3c,53b0794..639d74d
--- a/src/Ganeti/HTools/Backend/Luxi.hs
+++ b/src/Ganeti/HTools/Backend/Luxi.hs
@@@ -51,8 -51,7 +51,9 @@@ import Ganeti.HTools.Type
import qualified Ganeti.HTools.Group as Group
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
- import Ganeti.JSON
- import Ganeti.Objects as O
-import Ganeti.JSON (fromObj, fromJVal, tryFromObj, arrayMaybeFromJVal)
++import Ganeti.JSON (fromJVal, tryFromObj, arrayMaybeFromJVal,
++ getKeysFromContainer, Container)
++import Ganeti.Objects (PartialNicParams)
{-# ANN module "HLint: ignore Eta reduce" #-}
diff --cc src/Ganeti/HTools/Backend/Rapi.hs
index 03d158c,7d76751..218411c
--- a/src/Ganeti/HTools/Backend/Rapi.hs
+++ b/src/Ganeti/HTools/Backend/Rapi.hs
@@@ -53,7 -53,7 +53,7 @@@ import System.FilePat
import Ganeti.BasicTypes
import Ganeti.HTools.Loader
import Ganeti.HTools.Types
- import Ganeti.JSON
-import Ganeti.JSON (loadJSArray, JSRecord, tryFromObj, fromJVal,
maybeFromObj, fromJResult, tryArrayMaybeFromObj, readEitherString,
fromObjWithDefault, asJSObject)
++import Ganeti.JSON (loadJSArray, JSRecord, tryFromObj, fromJVal,
maybeFromObj, fromJResult, tryArrayMaybeFromObj, readEitherString,
fromObjWithDefault, asJSObject, emptyContainer)
import qualified Ganeti.HTools.Group as Group
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
diff --cc src/Ganeti/Luxi.hs
index 4439cef,f763eee..831e859
--- a/src/Ganeti/Luxi.hs
+++ b/src/Ganeti/Luxi.hs
@@@ -73,7 -71,7 +73,7 @@@ import Text.JSON.Type
import Ganeti.BasicTypes
import Ganeti.Constants
import Ganeti.Errors
- import Ganeti.JSON
-import Ganeti.JSON (fromJResult, fromJVal, Tuple5(..), MaybeForJSON(..),
TimeAsDoubleJSON(..))
++import Ganeti.JSON (fromJResult, fromJVal, fromObj, Tuple5(..),
MaybeForJSON(..), TimeAsDoubleJSON(..))
import Ganeti.UDSServer
import Ganeti.Objects
import Ganeti.OpParams (pTagsObject)
diff --cc src/Ganeti/Objects.hs
index 4b92561,59abc5c..065aaa8
--- a/src/Ganeti/Objects.hs
+++ b/src/Ganeti/Objects.hs
@@@ -130,13 -124,11 +130,13 @@@ import qualified Text.JSON as
import qualified AutoConf
import qualified Ganeti.Constants as C
import qualified Ganeti.ConstantUtils as ConstantUtils
- import Ganeti.JSON
+ import Ganeti.JSON (DictObject(..), Container, emptyContainer,
GenericContainer)
import Ganeti.Objects.BitArray (BitArray)
import Ganeti.Objects.Disk
+import Ganeti.Objects.Maintenance
import Ganeti.Objects.Nic
import Ganeti.Objects.Instance
+import Ganeti.Objects.HvState
import Ganeti.Query.Language
import Ganeti.PartialParams
import Ganeti.Types
diff --cc src/Ganeti/Query/Node.hs
index 698e209,9d36c74..f431ade
--- a/src/Ganeti/Query/Node.hs
+++ b/src/Ganeti/Query/Node.hs
@@@ -38,12 -38,9 +38,11 @@@ module Ganeti.Query.Nod
, collectLiveData
) where
-import Control.Applicative
-import Data.List
+import Prelude ()
+import Ganeti.Prelude
+
+import Data.List (intercalate)
import Data.Maybe
- import qualified Data.Map as Map
import qualified Text.JSON as J
import Ganeti.Config
diff --cc test/py/testutils_ssh.py
index fa3b35d,a38304d..e700e47
--- a/test/py/testutils_ssh.py
+++ b/test/py/testutils_ssh.py
@@@ -529,47 -508,8 +529,47 @@@ class FakeSshFileManager(object)
if constants.SSHS_SSH_PUBLIC_KEYS in data:
instructions_pub = data[constants.SSHS_SSH_PUBLIC_KEYS]
self._HandlePublicKeys(instructions_pub, node)
+ if constants.SSHS_GENERATE in data:
+ instructions_generate = data[constants.SSHS_GENERATE]
+ self._GenerateNewKey(instructions_generate, node)
# pylint: enable=W0613
+ def _GenerateNewKey(self, instructions_generate, node):
+ """Generates a new key for the given node.
+
+ Note that this is a very rudimentary generation of a new key. The key is
+ always generated with the same pattern, starting with 'new_key'. That
+ means if you run it twice, it will actually produce the same key. However,
+ for what we want to test, this is sufficient.
+ The 'suffix' instruction is also ignored and the key is directly
overriden.
+ This works so far, but simplifies the tests a bit. It might be extended
+ in case it becomes necessary.
+
+ @type instructions_generate: tuple of (string, integer, string)
+ @param instructions_generate: an instructions tuple for generating a new
+ SSH key. This has to comply to the C{_DATA_CHECK} description in
+ C{ssh_update.py}.
+ @type node: string
+ @param node: name of node
+ """
+ (key_type, key_bits, suffix) = instructions_generate
+ assert key_type in constants.SSHK_ALL
+ assert key_bits > 0
+ assert isinstance(suffix, str)
+
+ new_key = "new_key_%s" % node
+ old_node_data = self._all_node_data[node]
+
+ new_node_data = self._NodeInfo(
+ uuid=old_node_data.uuid,
+ key=new_key,
+ is_potential_master_candidate=old_node_data
- .is_potential_master_candidate,
++ .is_potential_master_candidate,
+ is_master_candidate=old_node_data.is_master_candidate,
+ is_master=old_node_data.is_master)
+
+ self._all_node_data[node] = new_node_data
+
def _EnsureAuthKeyFile(self, file_node_name):
if file_node_name not in self._authorized_keys:
self._authorized_keys[file_node_name] = set()