Merge branch 'devel-2.7'
authorIustin Pop <iustin@google.com>
Fri, 15 Feb 2013 11:53:30 +0000 (12:53 +0100)
committerIustin Pop <iustin@google.com>
Fri, 15 Feb 2013 13:04:13 +0000 (14:04 +0100)
* devel-2.7:
  Rename lib/objectutils to outils.py
  Fix typo in gnt-group manpage
  Fix wrong type in a docstring of the RAPI subsystem
  Finish the remote‚Üírestricted commands rename
  Enable use of the priority option in hbal
  Add CLI-level option to override the priority
  Add functions to parse CLI-level format of priorities
  Add a function to change an OpCode's priority
  Make hbal opcode annotation more generic
  Add unit tests for RADOSBLockDevice
  Fix rbd showmapped output parsing
  Change default xen root path to /dev/xvda1
  Removes check for conflicts from NetworkDisconnect
  If _UnlockedLookupNetwork() fails raise error
  Force conflicts check in LUNetworkDisconnect

Also updated objects.py with more outils renames.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

1  2 
Makefile.am
lib/constants.py
lib/objects.py
lib/opcodes.py
lib/outils.py
src/Ganeti/HTools/CLI.hs
src/Ganeti/Types.hs
test/py/ganeti.outils_unittest.py

diff --cc Makefile.am
Simple merge
Simple merge
diff --cc lib/objects.py
@@@ -406,7 -447,7 +406,7 @@@ class ConfigData(ConfigObject)
      mydict = super(ConfigData, self).ToDict()
      mydict["cluster"] = mydict["cluster"].ToDict()
      for key in "nodes", "instances", "nodegroups", "networks":
-       mydict[key] = objectutils.ContainerToDicts(mydict[key])
 -      mydict[key] = self._ContainerToDicts(mydict[key])
++      mydict[key] = outils.ContainerToDicts(mydict[key])
  
      return mydict
  
      """
      obj = super(ConfigData, cls).FromDict(val)
      obj.cluster = Cluster.FromDict(obj.cluster)
-     obj.nodes = objectutils.ContainerFromDicts(obj.nodes, dict, Node)
 -    obj.nodes = cls._ContainerFromDicts(obj.nodes, dict, Node)
 -    obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
 -    obj.nodegroups = cls._ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
 -    obj.networks = cls._ContainerFromDicts(obj.networks, dict, Network)
++    obj.nodes = outils.ContainerFromDicts(obj.nodes, dict, Node)
 +    obj.instances = \
-       objectutils.ContainerFromDicts(obj.instances, dict, Instance)
++      outils.ContainerFromDicts(obj.instances, dict, Instance)
 +    obj.nodegroups = \
-       objectutils.ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
-     obj.networks = objectutils.ContainerFromDicts(obj.networks, dict, Network)
++      outils.ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
++    obj.networks = outils.ContainerFromDicts(obj.networks, dict, Network)
      return obj
  
    def HasAnyDiskOfType(self, dev_type):
@@@ -732,7 -771,7 +732,7 @@@ class Disk(ConfigObject)
      for attr in ("children",):
        alist = bo.get(attr, None)
        if alist:
-         bo[attr] = objectutils.ContainerToDicts(alist)
 -        bo[attr] = self._ContainerToDicts(alist)
++        bo[attr] = outils.ContainerToDicts(alist)
      return bo
  
    @classmethod
      """
      obj = super(Disk, cls).FromDict(val)
      if obj.children:
-       obj.children = objectutils.ContainerFromDicts(obj.children, list, Disk)
 -      obj.children = cls._ContainerFromDicts(obj.children, list, Disk)
++      obj.children = outils.ContainerFromDicts(obj.children, list, Disk)
      if obj.logical_id and isinstance(obj.logical_id, list):
        obj.logical_id = tuple(obj.logical_id)
      if obj.physical_id and isinstance(obj.physical_id, list):
@@@ -1100,7 -1139,7 +1100,7 @@@ class Instance(TaggableObject)
      for attr in "nics", "disks":
        alist = bo.get(attr, None)
        if alist:
-         nlist = objectutils.ContainerToDicts(alist)
 -        nlist = self._ContainerToDicts(alist)
++        nlist = outils.ContainerToDicts(alist)
        else:
          nlist = []
        bo[attr] = nlist
      if "admin_up" in val:
        del val["admin_up"]
      obj = super(Instance, cls).FromDict(val)
-     obj.nics = objectutils.ContainerFromDicts(obj.nics, list, NIC)
-     obj.disks = objectutils.ContainerFromDicts(obj.disks, list, Disk)
 -    obj.nics = cls._ContainerFromDicts(obj.nics, list, NIC)
 -    obj.disks = cls._ContainerFromDicts(obj.disks, list, Disk)
++    obj.nics = outils.ContainerFromDicts(obj.nics, list, NIC)
++    obj.disks = outils.ContainerFromDicts(obj.disks, list, Disk)
      return obj
  
    def UpgradeConfig(self):
@@@ -1314,12 -1353,12 +1314,12 @@@ class Node(TaggableObject)
  
      hv_state = data.get("hv_state", None)
      if hv_state is not None:
-       data["hv_state"] = objectutils.ContainerToDicts(hv_state)
 -      data["hv_state"] = self._ContainerToDicts(hv_state)
++      data["hv_state"] = outils.ContainerToDicts(hv_state)
  
      disk_state = data.get("disk_state", None)
      if disk_state is not None:
        data["disk_state"] = \
-         dict((key, objectutils.ContainerToDicts(value))
 -        dict((key, self._ContainerToDicts(value))
++        dict((key, outils.ContainerToDicts(value))
               for (key, value) in disk_state.items())
  
      return data
      obj = super(Node, cls).FromDict(val)
  
      if obj.hv_state is not None:
 -      obj.hv_state = cls._ContainerFromDicts(obj.hv_state, dict, NodeHvState)
 +      obj.hv_state = \
-         objectutils.ContainerFromDicts(obj.hv_state, dict, NodeHvState)
++        outils.ContainerFromDicts(obj.hv_state, dict, NodeHvState)
  
      if obj.disk_state is not None:
        obj.disk_state = \
-         dict((key, objectutils.ContainerFromDicts(value, dict, NodeDiskState))
 -        dict((key, cls._ContainerFromDicts(value, dict, NodeDiskState))
++        dict((key, outils.ContainerFromDicts(value, dict, NodeDiskState))
               for (key, value) in obj.disk_state.items())
  
      return obj
@@@ -1906,7 -1933,7 +1906,7 @@@ class _QueryResponseBase(ConfigObject)
  
      """
      mydict = super(_QueryResponseBase, self).ToDict()
-     mydict["fields"] = objectutils.ContainerToDicts(mydict["fields"])
 -    mydict["fields"] = self._ContainerToDicts(mydict["fields"])
++    mydict["fields"] = outils.ContainerToDicts(mydict["fields"])
      return mydict
  
    @classmethod
  
      """
      obj = super(_QueryResponseBase, cls).FromDict(val)
 -    obj.fields = cls._ContainerFromDicts(obj.fields, list, QueryFieldDefinition)
 +    obj.fields = \
-       objectutils.ContainerFromDicts(obj.fields, list, QueryFieldDefinition)
++      outils.ContainerFromDicts(obj.fields, list, QueryFieldDefinition)
      return obj
  
  
diff --cc lib/opcodes.py
Simple merge
diff --cc lib/outils.py
Simple merge
Simple merge
Simple merge
@@@ -46,62 -46,5 +46,62 @@@ class TestAutoSlot(unittest.TestCase)
      slotted = AutoSlotted()
      self.assertEqual(slotted.__slots__, AutoSlotted.SLOTS)
  
 +
 +class TestContainerToDicts(unittest.TestCase):
 +  def testUnknownType(self):
 +    for value in [None, 19410, "xyz"]:
 +      try:
-         objectutils.ContainerToDicts(value)
++        outils.ContainerToDicts(value)
 +      except TypeError, err:
 +        self.assertTrue(str(err).startswith("Unknown container type"))
 +      else:
 +        self.fail("Exception was not raised")
 +
 +  def testEmptyDict(self):
 +    value = {}
-     self.assertFalse(type(value) in objectutils._SEQUENCE_TYPES)
-     self.assertEqual(objectutils.ContainerToDicts(value), {})
++    self.assertFalse(type(value) in outils._SEQUENCE_TYPES)
++    self.assertEqual(outils.ContainerToDicts(value), {})
 +
 +  def testEmptySequences(self):
 +    for cls in [list, tuple, set, frozenset]:
-       self.assertEqual(objectutils.ContainerToDicts(cls()), [])
++      self.assertEqual(outils.ContainerToDicts(cls()), [])
 +
 +
 +class _FakeWithFromDict:
 +  def FromDict(self, _):
 +    raise NotImplemented
 +
 +
 +class TestContainerFromDicts(unittest.TestCase):
 +  def testUnknownType(self):
 +    for cls in [str, int, bool]:
 +      try:
-         objectutils.ContainerFromDicts(None, cls, NotImplemented)
++        outils.ContainerFromDicts(None, cls, NotImplemented)
 +      except TypeError, err:
 +        self.assertTrue(str(err).startswith("Unknown container type"))
 +      else:
 +        self.fail("Exception was not raised")
 +
 +      try:
-         objectutils.ContainerFromDicts(None, cls(), NotImplemented)
++        outils.ContainerFromDicts(None, cls(), NotImplemented)
 +      except TypeError, err:
 +        self.assertTrue(str(err).endswith("is not a type"))
 +      else:
 +        self.fail("Exception was not raised")
 +
 +  def testEmptyDict(self):
 +    value = {}
-     self.assertFalse(type(value) in objectutils._SEQUENCE_TYPES)
-     self.assertEqual(objectutils.ContainerFromDicts(value, dict,
++    self.assertFalse(type(value) in outils._SEQUENCE_TYPES)
++    self.assertEqual(outils.ContainerFromDicts(value, dict,
 +                                                    NotImplemented),
 +                     {})
 +
 +  def testEmptySequences(self):
 +    for cls in [list, tuple, set, frozenset]:
-       self.assertEqual(objectutils.ContainerFromDicts([], cls,
++      self.assertEqual(outils.ContainerFromDicts([], cls,
 +                                                      _FakeWithFromDict),
 +                       cls())
 +
 +
  if __name__ == "__main__":
    testutils.GanetiTestProgram()