On Fri, Jan 9, 2015 at 1:21 PM, 'Aaron Karper' via ganeti-devel
<[email protected]> wrote:
> The _VerifyNodeDrbd method produces a map of minor numbers -> ganeti
> relevant information, which can be tested and documented in
> isolation.
> This was a regression on a development branch and this test catches
> the problem.
>
> Signed-off-by: Aaron Karper <[email protected]>
> ---
>  lib/cmdlib/cluster/verify.py       | 37 +++++++++++++++++++++++++++----------
>  test/py/cmdlib/cluster_unittest.py | 13 +++++++++++++
>  2 files changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/lib/cmdlib/cluster/verify.py b/lib/cmdlib/cluster/verify.py
> index 5d381be..5e8ca86 100644
> --- a/lib/cmdlib/cluster/verify.py
> +++ b/lib/cmdlib/cluster/verify.py
> @@ -1179,28 +1179,24 @@ class LUClusterVerifyGroup(LogicalUnit, 
> _VerifyErrors):
>          self._ErrorIf(test, constants.CV_ENODEDRBDHELPER, ninfo.name,
>                        "wrong drbd usermode helper: %s", payload)
>
> -  def _VerifyNodeDrbd(self, ninfo, nresult, instanceinfo, disks_info,
> -                      drbd_helper, drbd_map):
> -    """Verifies and the node DRBD status.
> +  @staticmethod
> +  def _ComputeDrbdMinors(ninfo, instanceinfo, disks_info, drbd_map, 
> error_if):
> +    """Gives the DRBD information in a map for a node.
>
>      @type ninfo: L{objects.Node}
>      @param ninfo: the node to check
> -    @param nresult: the remote results for the node
>      @param instanceinfo: the dict of instances
>      @param disks_info: the dict of disks
> -    @param drbd_helper: the configured DRBD usermode helper
>      @param drbd_map: the DRBD map as returned by
>          L{ganeti.config.ConfigWriter.ComputeDRBDMap}

error_if is undocumented.

> +    @return: dict from minor number to (disk_uuid, instance_uuid, active)
>
>      """
> -    self._VerifyNodeDrbdHelper(ninfo, nresult, drbd_helper)
> -
> -    # compute the DRBD minors
>      node_drbd = {}
>      for minor, disk_uuid in drbd_map[ninfo.uuid].items():
>        test = disk_uuid not in disks_info
> -      self._ErrorIf(test, constants.CV_ECLUSTERCFG, None,
> -                    "ghost disk '%s' in temporary DRBD map", disk_uuid)
> +      error_if(test, constants.CV_ECLUSTERCFG, None,
> +               "ghost disk '%s' in temporary DRBD map", disk_uuid)
>          # ghost disk should not be active, but otherwise we
>          # don't give double warnings (both ghost disk and
>          # unallocated minor in use)
> @@ -1215,6 +1211,27 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
>              disk_instance = inst_uuid
>              break
>          node_drbd[minor] = (disk_uuid, disk_instance, disk_active)
> +    return node_drbd
> +
> +  def _VerifyNodeDrbd(self, ninfo, nresult, instanceinfo, disks_info,
> +                      drbd_helper, drbd_map):
> +    """Verifies and the node DRBD status.
> +
> +    @type ninfo: L{objects.Node}
> +    @param ninfo: the node to check
> +    @param nresult: the remote results for the node
> +    @param instanceinfo: the dict of instances
> +    @param disks_info: the dict of disks
> +    @param drbd_helper: the configured DRBD usermode helper
> +    @param drbd_map: the DRBD map as returned by
> +        L{ganeti.config.ConfigWriter.ComputeDRBDMap}
> +
> +    """
> +    self._VerifyNodeDrbdHelper(ninfo, nresult, drbd_helper)
> +
> +    # compute the DRBD minors
> +    node_drbd = self._ComputeDrbdMinors(ninfo, instanceinfo, disks_info,
> +                                        drbd_map, self._ErrorIf)
>
>      # and now check them
>      used_minors = nresult.get(constants.NV_DRBDLIST, [])
> diff --git a/test/py/cmdlib/cluster_unittest.py 
> b/test/py/cmdlib/cluster_unittest.py
> index 136b7ed..f9016f5 100644
> --- a/test/py/cmdlib/cluster_unittest.py
> +++ b/test/py/cmdlib/cluster_unittest.py
> @@ -1165,6 +1165,19 @@ class TestLUClusterVerifyGroup(CmdlibTestCase):
>
>      self.ExecOpCode(op)
>
> +  def testVerifyNodeDrbdSuccess(self):
> +    ninfo = self.cfg.AddNewNode()
> +    disk = self.cfg.CreateDisk(dev_type=constants.DT_DRBD8,
> +                                primary_node=self.master,
> +                                secondary_node=ninfo)
> +    instance = self.cfg.AddNewInstance(disks=[disk])
> +    instanceinfo = self.cfg.GetAllInstancesInfo()
> +    disks_info = self.cfg.GetAllDisksInfo()
> +    drbd_map = {ninfo.uuid: {0: disk.uuid}}
> +    minors = verify.LUClusterVerifyGroup._ComputeDrbdMinors(
> +      ninfo, instanceinfo, disks_info, drbd_map, lambda *args: None)
> +    self.assertEquals(minors, {0: (disk.uuid, instance.uuid, False)})
> +
>
>  class TestLUClusterVerifyClientCerts(CmdlibTestCase):
>
> --
> 2.2.0.rc0.207.ga3a616c
>

Rest LGTM,
thanks.

Michele

-- 
Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to