On Thu, Jul 24, 2014 at 2:31 AM, Yuto KAWAMURA(kawamuray) < [email protected]> wrote:
> Instance stash file is used to keep information that is necessary to > The instance stash ... > complete instance destruction, until the instance is stopped. > Shouldn't it be "after the instance is stopped"? > At this point, the name of loopback device allocated to create the block > device partition mapping, is a concrete example of this kind of > Surplus comma - what is between the commas cannot stand on its own, and you are breaking up the subject-verb formation. > information. > > Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]> > --- > lib/hypervisor/hv_lxc.py | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py > index 1442372..c21a4df 100644 > --- a/lib/hypervisor/hv_lxc.py > +++ b/lib/hypervisor/hv_lxc.py > @@ -32,6 +32,7 @@ from ganeti import errors # pylint: disable=W0611 > from ganeti import utils > from ganeti import objects > from ganeti import pathutils > +from ganeti import serializer > from ganeti.hypervisor import hv_base > from ganeti.errors import HypervisorError > > @@ -118,6 +119,41 @@ class LXCHypervisor(hv_base.BaseHypervisor): > return utils.PathJoin(cls._ROOT_DIR, instance_name + ".log") > > @classmethod > + def _InstanceStashFilePath(cls, instance_name): > + """Return the stash file path for an instance. > + > + Stash file is used to keep information that needs to complete > The stash file ... s/that needs/needed/ > + instance destruction during instance life. > Perhaps say: ... needed to clean up after the destruction of the instance. > + > + """ > + return utils.PathJoin(cls._ROOT_DIR, instance_name + ".stash") > + > + def _SaveInstanceStash(self, instance_name, data): > + """Save data to instance stash file in serialized format. > ... to the instance ... > + > + """ > + stash_file = self._InstanceStashFilePath(instance_name) > + serialized = serializer.Dump(data) > + try: > + utils.WriteFile(stash_file, data=serialized, > + mode=constants.SECURE_FILE_MODE) > + except EnvironmentError, err: > + raise HypervisorError("Failed to save instance stash file %s : %s" % > + (stash_file, err)) > + > + def _LoadInstanceStash(self, instance_name): > + """Load information stashed in file which was created by > + L{_SaveInstanceStash}. > + > + """ > + stash_file = self._InstanceStashFilePath(instance_name) > + try: > + return serializer.Load(utils.ReadFile(stash_file)) > + except EnvironmentError, err: > Are you sure only an EnvironmentError can occur here? This is signed JSON, after all, so expect parsing errors and others. > + raise HypervisorError("Failed to load instance stash file %s : %s" % > + (stash_file, err)) > + > + @classmethod > def _GetCgroupMountPoint(cls): > for _, mountpoint, fstype, _ in utils.GetMounts(): > if fstype == "cgroup": > -- > 1.8.5.5 > > Hrvoje Ribicic 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
