On Mon, Sep 23, 2013 at 04:02:05PM +0200, Thomas Thrainer wrote:
> I forgot to recursively remove the physical_id from the whole disk
> structure, so I'd like to include the following interdiff:
> 
> diff --git a/tools/cfgupgrade b/tools/cfgupgrade
> index b280185..648d732 100755
> --- a/tools/cfgupgrade
> +++ b/tools/cfgupgrade
> @@ -173,6 +173,14 @@ def GetExclusiveStorageValue(config_data):
>    return ret
> 
> 
> +def RemovePhysicalId(disk):
> +  if "children" in disk:
> +    for d in disk["children"]:
> +      RemovePhysicalId(d)
> +  if "physical_id" in disk:
> +    del disk["physical_id"]
> +
> +
>  def UpgradeInstances(config_data):
>    network2uuid = dict((n["name"], n["uuid"])
>                        for n in config_data["networks"].values())
> @@ -194,8 +202,7 @@ def UpgradeInstances(config_data):
>        raise Error("Instance '%s' doesn't have a disks entry?!" % instance)
>      disks = iobj["disks"]
>      for idx, dobj in enumerate(disks):
> -      if "physical_id" in dobj:
> -        del dobj["physical_id"]
> +      RemovePhysicalId(dobj)
> 
>        expected = "disk/%s" % idx
>        current = dobj.get("iv_name", "")
> 
> 
> Thanks,
> Thomas
> 
> 
> On Mon, Sep 23, 2013 at 2:36 PM, Jose A. Lopes <[email protected]> wrote:
> 
> > On Fri, Sep 20, 2013 at 07:41:06PM +0200, Thomas Thrainer wrote:
> > > The physical_id field is no longer supported in disk objects, so remove
> > > it during upgrades.
> > >
> > > Signed-off-by: Thomas Thrainer <[email protected]>
> > > ---
> > >  test/py/cfgupgrade_unittest.py | 6 ++++++
> > >  tools/cfgupgrade               | 3 +++
> > >  2 files changed, 9 insertions(+)
> > >
> > > diff --git a/test/py/cfgupgrade_unittest.py
> > b/test/py/cfgupgrade_unittest.py
> > > index 47ebd9d..09b16c4 100755
> > > --- a/test/py/cfgupgrade_unittest.py
> > > +++ b/test/py/cfgupgrade_unittest.py
> > > @@ -392,6 +392,12 @@ class TestCfgupgrade(unittest.TestCase):
> > >      _RunUpgrade(self.tmpdir, False, True, downgrade=True)
> > >      oldconf = self._LoadTestDataConfig(oldconfname)
> > >      newconf = self._LoadConfig()
> > > +
> > > +    # downgrade from 2.10 to 2.9 does not add physical_id to disks,
> > which is ok
> > > +    for inst in oldconf["instances"].values():
> > > +      for disk in inst["disks"]:
> > > +        del disk["physical_id"]
> > > +
> > >      self.assertEqual(oldconf, newconf)
> > >
> > >    def testDowngradeFullConfigBackwardFrom_2_7(self):
> > > diff --git a/tools/cfgupgrade b/tools/cfgupgrade
> > > index 0054d20..b280185 100755
> > > --- a/tools/cfgupgrade
> > > +++ b/tools/cfgupgrade
> > > @@ -194,6 +194,9 @@ def UpgradeInstances(config_data):
> > >        raise Error("Instance '%s' doesn't have a disks entry?!" %
> > instance)
> > >      disks = iobj["disks"]
> > >      for idx, dobj in enumerate(disks):
> > > +      if "physical_id" in dobj:
> > > +        del dobj["physical_id"]
> > > +
> > >        expected = "disk/%s" % idx
> > >        current = dobj.get("iv_name", "")
> > >        if current != expected:
> > > --
> > > 1.8.4
> > >
> >
> > LGTM.
> >
> > Thanks,
> > Jose
> >
> > --
> > Jose Antonio Lopes
> > Ganeti Engineering
> > 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
> > Steuernummer: 48/725/00206
> > Umsatzsteueridentifikationsnummer: DE813741370
> >
> 
> 
> 
> -- 
> Thomas Thrainer | Software Engineer | [email protected] |
> 
> 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

LGTM.

Thanks,
Jose

-- 
Jose Antonio Lopes
Ganeti Engineering
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
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370

Reply via email to