From 0f023d11b208fe78d1a6aaffd93496e261236102 Mon Sep 17 00:00:00 2001 From: Michael Ablassmeier Date: Sun, 16 Apr 2023 10:20:44 +0200 Subject: [PATCH] version 1.9.23 --- .github/workflows/ci-ubuntu-latest.yml | 10 ++++ Changelog | 5 ++ README.md | 26 +++++----- libvirtnbdbackup/__init__.py | 2 +- libvirtnbdbackup/common.py | 4 +- libvirtnbdbackup/exceptions.py | 8 +-- libvirtnbdbackup/metadata.py | 2 +- libvirtnbdbackup/nbdcli/__init__.py | 1 + libvirtnbdbackup/nbdcli/context.py | 38 +++++++++++++++ libvirtnbdbackup/output/exceptions.py | 2 +- libvirtnbdbackup/output/stream.py | 35 ++++++++++++++ libvirtnbdbackup/output/target.py | 22 +++++++-- libvirtnbdbackup/sparsestream/streamer.py | 2 +- libvirtnbdbackup/ssh/client.py | 2 +- libvirtnbdbackup/virt/client.py | 6 +-- libvirtnbdbackup/virt/exceptions.py | 6 +-- libvirtnbdbackup/virt/xml.py | 2 +- man/virtnbdbackup.1 | 4 +- man/virtnbdmap.1 | 2 +- man/virtnbdrestore.1 | 4 +- virtnbdbackup | 59 ++++------------------- virtnbdmap | 2 +- virtnbdrestore | 8 +-- 23 files changed, 157 insertions(+), 95 deletions(-) create mode 100644 libvirtnbdbackup/nbdcli/context.py create mode 100644 libvirtnbdbackup/output/stream.py diff --git a/.github/workflows/ci-ubuntu-latest.yml b/.github/workflows/ci-ubuntu-latest.yml index 5daec4aa..2473f626 100644 --- a/.github/workflows/ci-ubuntu-latest.yml +++ b/.github/workflows/ci-ubuntu-latest.yml @@ -10,6 +10,16 @@ jobs: steps: - uses: actions/checkout@v2 - uses: abbbi/github-actions-tune@v1 + - name: codespell + run: | + sudo apt-get update + sudo apt-get install codespell -y + codespell libvirtnbdbackup + codespell virtnbdbackup + codespell virtnbdrestore + codespell virtnbdmap + codespell virtnbd-nbdkit-plugin + codespell README.md - name: Python code format test run: | sudo pip3 install black==22.3 diff --git a/Changelog b/Changelog index 26e09fd6..88ca6bd4 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +Version 1.9.23 +--------- + * Code cleanups + * Spelling fixes, run codespell during CI + Version 1.9.22 --------- * Code cleanups, pylint warning diff --git a/README.md b/README.md index 14208feb..f92bb4a8 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ with qcow(v3) based disk images. If you are using older image versions, you can only create `copy` backups, or consider converting the images to a newer format using `qemu-img`. -By default `virtnbdbackup` will exclude all disks with format `raw` aswell +By default `virtnbdbackup` will exclude all disks with format `raw` as well as direct attached (passthrough) disks such as LVM or ZVOL and ISCSI volumes. These type of disks do not support storing checkpoint/bitmap metadata. @@ -291,7 +291,7 @@ During restore, these files can be copied "as is" from the backup folder and must not be processed using `virtnbdrestore`. `Note:` -> The backup data for raw disks will only be crash consistant, be aware +> The backup data for raw disks will only be crash consistent, be aware > that this might result in inconsistent filesystems after restoring! @@ -412,7 +412,7 @@ virtnbdbackup -d vm1 -l inc -o /tmp/backupset -p `Note:` > Not all libvirt versions support the flag required to read the checkpoint -> size. If the estimated checkpoint size is allways 0, your libvirt version +> size. If the estimated checkpoint size is always 0, your libvirt version > might miss the required features. ## Backup threshold @@ -440,7 +440,7 @@ has attached, it might make sense to try a different amount of workers to see which amount your hardware can handle best. If standard output (`-`) is defined as backup target, the amount of workers is -allways limited to 1, to ensure a valid Zip file format. +always limited to 1, to ensure a valid Zip file format. ## Compression @@ -460,7 +460,7 @@ block and original data are enabled. ## Remote Backup -It is also possible to backup remote libvirt systems. The most convinient way +It is also possible to backup remote libvirt systems. The most convenient way is to use ssh for initiating the libvirt connection (key authentication mandatory). @@ -558,7 +558,7 @@ During restore unzip the data from both zip files into a single directory: If an domain has configured custom kernel, initrd, loader or nvram images (usually the case if the domain boots from OVM UEFI BIOS), these files will be -saved to the backup folder aswell. +saved to the backup folder as well. # Restore examples @@ -607,8 +607,8 @@ in the output directory `/tmp/restore` `Note`: > The restore utility will copy the latest virtual machine config to the -> target directory, but wont alter its contents. You have to adjust the config -> file for the new pathes and/or excluded disks to be able to define and run it. +> target directory, but won't alter its contents. You have to adjust the config +> file for the new paths and/or excluded disks to be able to define and run it. ## Process only specific disks during restore @@ -646,11 +646,11 @@ restore accordingly, the following changes are done: * UUID of the virtual machine is removed from the config file * Name of the virtual machine is prefixed with "restore_" (use option `--name` to specify desired vm name) - * The disk pathes to the virtual machine are changed to the new target directory. + * The disk paths to the virtual machine are changed to the new target directory. * If virtual machine was operating on snapshots/backing store images, the references to the configured backing stores will be removed. - * Raw devices are removed from VM config if `--raw` is not specified, aswell - as floppy or cdrom devices (which arent part of the backup). + * Raw devices are removed from VM config if `--raw` is not specified, as well + as floppy or cdrom devices (which aren't part of the backup). `Note:` > If missing, Kernel, UEFI or NVRAM files are restored to their original @@ -863,13 +863,13 @@ See [past issues](https://github.com/abbbi/virtnbdbackup/issues?q=label%3Aopenne Both `virtnbdbackup` and `virtnbdrestore` commands support authenticating against libvirtd with the usual URIs. Consider using the following options: - `-U`: Specify an arbitary connection URI to use against libvirt + `-U`: Specify an arbitrary connection URI to use against libvirt `--user`: Username to use for the specified connection URI `--password`: Password to use for the specified connection URI. -It is also possible to specifiy the credentials stored as authentication file +It is also possible to specify the credentials stored as authentication file like it would be possible using the `virsh -c` option: ``` diff --git a/libvirtnbdbackup/__init__.py b/libvirtnbdbackup/__init__.py index 826ef3bc..375eeaf1 100644 --- a/libvirtnbdbackup/__init__.py +++ b/libvirtnbdbackup/__init__.py @@ -15,4 +15,4 @@ along with this program. If not, see . """ -__version__ = "1.9.22" +__version__ = "1.9.23" diff --git a/libvirtnbdbackup/common.py b/libvirtnbdbackup/common.py index a1bfccb7..627fb4eb 100644 --- a/libvirtnbdbackup/common.py +++ b/libvirtnbdbackup/common.py @@ -156,7 +156,7 @@ def getLatest(targetDir: str, search: str, key=None) -> List[str]: def hasQcowDisks(diskList: List[Any]) -> bool: """Check if the list of attached disks includes at least one qcow image based disk, else checkpoint handling can be - skipped and backup modue falls back to type copy""" + skipped and backup module falls back to type copy""" for disk in diskList: if disk.format.startswith("qcow"): return True @@ -202,7 +202,7 @@ def killProc(pid: int) -> bool: def getIdent(args: Namespace) -> Union[str, int]: - """Used to get an uniqe identifier for target files, + """Used to get an unique identifier for target files, usually checkpoint name is used, but if no checkpoint is created, we use timestamp""" try: diff --git a/libvirtnbdbackup/exceptions.py b/libvirtnbdbackup/exceptions.py index bda69679..a38de690 100644 --- a/libvirtnbdbackup/exceptions.py +++ b/libvirtnbdbackup/exceptions.py @@ -8,22 +8,22 @@ class CheckpointException(Exception): class NoCheckpointsFound(CheckpointException): - """Inc or differencial backup attempted but + """Inc or differential backup attempted but no existing checkpoints are found.""" class RedefineCheckpointError(CheckpointException): """During redefining existing checkpoints after - vm relocate, an error occured""" + vm relocate, an error occurred""" class ReadCheckpointsError(CheckpointException): - """Cant read checkpoint file""" + """Can't read checkpoint file""" class RemoveCheckpointError(CheckpointException): """During removal of existing checkpoints after - an error occured""" + an error occurred""" class SaveCheckpointError(CheckpointException): diff --git a/libvirtnbdbackup/metadata.py b/libvirtnbdbackup/metadata.py index 737dc853..abd7cb29 100644 --- a/libvirtnbdbackup/metadata.py +++ b/libvirtnbdbackup/metadata.py @@ -81,7 +81,7 @@ def backupBootConfig(args: Namespace) -> None: def backupAutoStart(args: Namespace) -> None: - """Save information wether if virtual machine was marked + """Save information if virtual machine was marked for autostart during system boot""" log.info("Autostart setting configured for virtual machine.") autoStartFile = f"{args.output}/autostart.{lib.getIdent(args)}" diff --git a/libvirtnbdbackup/nbdcli/__init__.py b/libvirtnbdbackup/nbdcli/__init__.py index 254a97cc..89c78647 100644 --- a/libvirtnbdbackup/nbdcli/__init__.py +++ b/libvirtnbdbackup/nbdcli/__init__.py @@ -19,3 +19,4 @@ __version__ = "0.1" from .client import client, Unix, TCP +from . import context diff --git a/libvirtnbdbackup/nbdcli/context.py b/libvirtnbdbackup/nbdcli/context.py new file mode 100644 index 00000000..179fde22 --- /dev/null +++ b/libvirtnbdbackup/nbdcli/context.py @@ -0,0 +1,38 @@ +""" + Copyright (C) 2023 Michael Ablassmeier + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" +import logging +from argparse import Namespace +from libvirtnbdbackup.virt.client import DomainDisk + +log = logging.getLogger("nbdctx") + + +def get(args: Namespace, disk: DomainDisk) -> str: + """Get required meta context string passed to nbd server based on + backup type""" + metaContext = "" + if args.level not in ("inc", "diff"): + return metaContext + + if args.offline is True: + metaContext = f"qemu:dirty-bitmap:{args.cpt.name}" + else: + metaContext = f"qemu:dirty-bitmap:backup-{disk.target}" + + logging.info("Using NBD meta context [%s]", metaContext) + + return metaContext diff --git a/libvirtnbdbackup/output/exceptions.py b/libvirtnbdbackup/output/exceptions.py index 8cb5adcf..f739dc93 100644 --- a/libvirtnbdbackup/output/exceptions.py +++ b/libvirtnbdbackup/output/exceptions.py @@ -12,4 +12,4 @@ class OutputOpenException(OutputException): class OutputCreateDirectory(OutputException): - """Cant create output directory""" + """Can't create output directory""" diff --git a/libvirtnbdbackup/output/stream.py b/libvirtnbdbackup/output/stream.py new file mode 100644 index 00000000..34a9ebb4 --- /dev/null +++ b/libvirtnbdbackup/output/stream.py @@ -0,0 +1,35 @@ +""" + Copyright (C) 2023 Michael Ablassmeier + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" +from argparse import Namespace +from typing import Union +from libvirtnbdbackup import output + + +def get( + args: Namespace, repository: output.target +) -> Union[output.target.Directory, output.target.Zip]: + """Get filehandle for output files based on output + mode""" + fileStream: Union[output.target.Directory, output.target.Zip] + if args.stdout is False: + fileStream = repository.Directory(args.output) + else: + fileStream = repository.Zip() + args.output = "./" + args.worker = 1 + + return fileStream diff --git a/libvirtnbdbackup/output/target.py b/libvirtnbdbackup/output/target.py index 9ce5fe88..f2fa8008 100644 --- a/libvirtnbdbackup/output/target.py +++ b/libvirtnbdbackup/output/target.py @@ -46,7 +46,7 @@ def __init__(self, targetDir: str) -> None: self._makeDir() def _makeDir(self) -> None: - """Create output directoy on init""" + """Create output directory on init""" if os.path.exists(self.targetDir): if not os.path.isdir(self.targetDir): raise exceptions.OutputCreateDirectory( @@ -83,6 +83,16 @@ def flush(self): """Flush wrapper""" return self.fileHandle.flush() + def truncate(self, size: int) -> None: + """Truncate target file""" + try: + self.fileHandle.truncate(size) + self.fileHandle.seek(0) + except OSError as e: + raise exceptions.OutputException( + f"Failed to truncate target file: [{e}]" + ) from e + def close(self): """Close wrapper""" return self.fileHandle.close() @@ -135,10 +145,14 @@ def open(self, fileName: str, mode: Literal["w"] = "w") -> IO[bytes]: return False - def close(self): - """Close wrapper""" - return self.zipFileStream.close() + def truncate(self, size: int) -> None: + """Truncate target file""" + raise RuntimeError("Not implemented") def write(self, data): """Write wrapper""" return self.zipFileStream.write(data) + + def close(self): + """Close wrapper""" + return self.zipFileStream.close() diff --git a/libvirtnbdbackup/sparsestream/streamer.py b/libvirtnbdbackup/sparsestream/streamer.py index 726be100..75e3899f 100644 --- a/libvirtnbdbackup/sparsestream/streamer.py +++ b/libvirtnbdbackup/sparsestream/streamer.py @@ -44,7 +44,7 @@ def dumpMetadata( disk, ): """First block in backup stream is Meta data information - about virtual size of the disk being backed up, aswell + about virtual size of the disk being backed up, as well as various information regarding backup. Dumps Metadata frame to be written at start of stream in json format. diff --git a/libvirtnbdbackup/ssh/client.py b/libvirtnbdbackup/ssh/client.py index d5ed037c..37d8ef1a 100644 --- a/libvirtnbdbackup/ssh/client.py +++ b/libvirtnbdbackup/ssh/client.py @@ -75,7 +75,7 @@ def connect(self) -> SSHClient: ) except Exception as e: log.exception(e) - raise exceptions.sshError(f"Unknown exception occured: {e}") + raise exceptions.sshError(f"Unknown exception occurred: {e}") @property def sftp(self) -> SFTPClient: diff --git a/libvirtnbdbackup/virt/client.py b/libvirtnbdbackup/virt/client.py index 4d36a8d0..01ada985 100644 --- a/libvirtnbdbackup/virt/client.py +++ b/libvirtnbdbackup/virt/client.py @@ -117,7 +117,7 @@ def _isSsh(uri: str) -> bool: return uri.startswith("qemu+ssh") def _useAuth(self, args: Namespace) -> bool: - """Check wether we want to use advanced auth method""" + """Check if we want to use advanced auth method""" if args.uri.startswith("qemu+"): return True if self._reqAuth(args.uri): @@ -285,7 +285,7 @@ def adjustDomainConfig( self, args: Namespace, restoreDisk: DomainDisk, vmConfig: str, targetFile: str ) -> bytes: """Adjust virtual machine configuration after restoring. Changes - the pathes to the virtual machine disks and attempts to remove + the paths to the virtual machine disks and attempts to remove components excluded during restore.""" tree = xml.asTree(vmConfig) @@ -329,7 +329,7 @@ def adjustDomainConfig( continue backingStore = disk.xpath("backingStore") if backingStore: - log.info("Removing existant backing store settings") + log.info("Removing existent backing store settings") disk.remove(backingStore[0]) originalFile = disk.xpath("source")[0].get("file") diff --git a/libvirtnbdbackup/virt/exceptions.py b/libvirtnbdbackup/virt/exceptions.py index decf8454..c30c7433 100644 --- a/libvirtnbdbackup/virt/exceptions.py +++ b/libvirtnbdbackup/virt/exceptions.py @@ -8,12 +8,12 @@ class virtHelperError(Exception): class domainNotFound(virtHelperError): - """Cant find domain""" + """Can't find domain""" class connectionFailed(virtHelperError): - """Cant connect libvirtd domain""" + """Can't connect libvirtd domain""" class startBackupFailed(virtHelperError): - """Cant start backup operation""" + """Can't start backup operation""" diff --git a/libvirtnbdbackup/virt/xml.py b/libvirtnbdbackup/virt/xml.py index 1c5fc20e..837e221e 100644 --- a/libvirtnbdbackup/virt/xml.py +++ b/libvirtnbdbackup/virt/xml.py @@ -33,7 +33,7 @@ def indent(top: _Element) -> str: except ElementTree.ParseError as errmsg: log.debug("Failed to parse xml: [%s]", errmsg) except AttributeError: - # older ElementTree verisons dont have the + # older ElementTree versions dont have the # indent method, skip silently and use # non formatted string pass diff --git a/man/virtnbdbackup.1 b/man/virtnbdbackup.1 index e9cc4588..6d85de75 100644 --- a/man/virtnbdbackup.1 +++ b/man/virtnbdbackup.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.1. -.TH VIRTNBDBACKUP "1" "March 2023" "virtnbdbackup 1.9.22" "User Commands" +.TH VIRTNBDBACKUP "1" "April 2023" "virtnbdbackup 1.9.23" "User Commands" .SH NAME virtnbdbackup \- backup utility for libvirt .SH DESCRIPTION @@ -48,7 +48,7 @@ Backup only disk with target dev name (\fB\-i\fR vda) Exclude disk(s) with target dev name (\fB\-x\fR vda,vdb) .TP \fB\-f\fR SOCKETFILE, \fB\-\-socketfile\fR SOCKETFILE -Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.65893\/\fP) +Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.35855\/\fP) .TP \fB\-n\fR, \fB\-\-noprogress\fR Disable progress bar diff --git a/man/virtnbdmap.1 b/man/virtnbdmap.1 index 3247438e..f167e0fa 100644 --- a/man/virtnbdmap.1 +++ b/man/virtnbdmap.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.1. -.TH VIRTNBDMAP "1" "March 2023" "virtnbdmap 1.9.22" "User Commands" +.TH VIRTNBDMAP "1" "April 2023" "virtnbdmap 1.9.23" "User Commands" .SH NAME virtnbdmap \- map virtnbdbackup image files to nbd devices .SH DESCRIPTION diff --git a/man/virtnbdrestore.1 b/man/virtnbdrestore.1 index 1e2b745b..35ebd38a 100644 --- a/man/virtnbdrestore.1 +++ b/man/virtnbdrestore.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.1. -.TH VIRTNBDRESTORE "1" "March 2023" "virtnbdrestore 1.9.22" "User Commands" +.TH VIRTNBDRESTORE "1" "April 2023" "virtnbdrestore 1.9.23" "User Commands" .SH NAME virtnbdrestore \- restore utility for libvirt .SH DESCRIPTION @@ -40,7 +40,7 @@ Process only disk matching target dev name. (default: None) Disable progress bar .TP \fB\-f\fR SOCKETFILE, \fB\-\-socketfile\fR SOCKETFILE -Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.65899\/\fP) +Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.35860\/\fP) .TP \fB\-r\fR, \fB\-\-raw\fR Copy raw images as is during restore. (default: False) diff --git a/virtnbdbackup b/virtnbdbackup index 2f5d28a3..21727987 100755 --- a/virtnbdbackup +++ b/virtnbdbackup @@ -37,6 +37,7 @@ from libvirtnbdbackup import virt from libvirtnbdbackup.virt.client import DomainDisk from libvirtnbdbackup.virt import checkpoint from libvirtnbdbackup import output +from libvirtnbdbackup.output import stream from libvirtnbdbackup import common as lib from libvirtnbdbackup.processinfo import processInfo from libvirtnbdbackup.logcount import logCount @@ -60,7 +61,7 @@ from libvirtnbdbackup.output.exceptions import OutputException def setOfflineArguments(args: Namespace, domObj: virDomain) -> None: """Check if to be saved VM is offline and set - propper options/overwrite backup mode""" + proper options/overwrite backup mode""" args.offline = False if domObj.isActive() == 0: if args.level == "full": @@ -70,22 +71,6 @@ def setOfflineArguments(args: Namespace, domObj: virDomain) -> None: args.offline = True -def getFileStream( - args: Namespace, repository: output.target -) -> Union[output.target.Directory, output.target.Zip]: - """Get filehandle for output files based on output - mode""" - fileStream: Union[output.target.Directory, output.target.Zip] - if args.stdout is False: - fileStream = repository.Directory(args.output) - else: - fileStream = repository.Zip() - args.output = "./" - args.worker = 1 - - return fileStream - - def startBackupJob( args: Namespace, virtClient: virt.client, @@ -303,9 +288,9 @@ def main() -> None: args.diskInfo = [] try: - fileStream = getFileStream(args, repository) + fileStream = stream.get(args, repository) except OutputException as e: - logging.error("Cant open output file: [%s]", e) + logging.error("Can't open output file: [%s]", e) sys.exit(1) if args.worker is not None and args.worker < 1: @@ -337,7 +322,7 @@ def main() -> None: elif not lib.targetIsEmpty(args) and args.level == "auto": if not lib.hasFullBackup(args): logging.error( - "Cant execute switch to auto incremental backup: " + "Can't execute switch to auto incremental backup: " "target folder seems not to include full backup." ) sys.exit(1) @@ -350,7 +335,7 @@ def main() -> None: if args.raw is True and args.level in ("inc", "diff"): logging.warning( - "Raw disks cant be included during incremental or differential backup." + "Raw disks can't be included during incremental or differential backup." ) logging.warning("Excluding raw disks.") args.raw = False @@ -378,7 +363,7 @@ def main() -> None: logging.error("%s", e) sys.exit(1) except connectionFailed as e: - logging.error("Cant connect libvirt daemon: [%s]", e) + logging.error("Can't connect libvirt daemon: [%s]", e) sys.exit(1) logging.info("Libvirt library version: [%s]", virtClient.libvirtVersion) @@ -544,21 +529,6 @@ def main() -> None: logging.info("Finished successfully") -def setMetaContext(args: Namespace, disk: DomainDisk) -> str: - """Set meta context passed to nbd server based on - backup type""" - metaContext = "" - if args.level in ("inc", "diff"): - if args.offline is True: - metaContext = f"qemu:dirty-bitmap:{args.cpt.name}" - else: - metaContext = f"qemu:dirty-bitmap:backup-{disk.target}" - - logging.info("INC/DIFF backup: set context to [%s]", metaContext) - - return metaContext - - def setStreamType(args: Namespace, disk: DomainDisk) -> str: """Set target stream type based on disk format""" streamType = "raw" @@ -646,17 +616,6 @@ def startOfflineNBD( return nbdProc -def truncate(writer, size: int) -> None: - """Truncate raw image""" - try: - writer.truncate(size) - writer.seek(0) - except OSError as e: - raise exceptions.DiskBackupWriterException( - f"Failed to truncate target file: [{e}]" - ) from e - - def connectNbd( args: Namespace, disk: DomainDisk, @@ -698,7 +657,7 @@ def backupDisk( sTypes = types.SparseStreamTypes() current_thread().name = disk.target streamType = setStreamType(args, disk) - metaContext = setMetaContext(args, disk) + metaContext = nbdcli.context.get(args, disk) nbdProc: processInfo remoteIP: str = virtClient.remoteHost port: int = args.nbd_port @@ -738,7 +697,7 @@ def backupDisk( if streamType == "raw": logging.info("Creating full provisioned raw backup image") - truncate(writer, diskSize) + writer.truncate(diskSize) else: logging.info("Creating thin provisioned stream backup image") header = stream.dumpMetadata( diff --git a/virtnbdmap b/virtnbdmap index 2d7f4dbe..22aef0f5 100755 --- a/virtnbdmap +++ b/virtnbdmap @@ -51,7 +51,7 @@ def checkRequirements(): def checkDevice(args: Namespace, device: str) -> None: """Check if /dev/nbdX exists, otherwise it is likely - nbd module isnt loaded on the system""" + nbd module isn't loaded on the system""" if not device.startswith("/dev/nbd"): logging.error("Target device [%s] seems not to be a ndb device?", device) diff --git a/virtnbdrestore b/virtnbdrestore index 553d0f64..a41b55df 100755 --- a/virtnbdrestore +++ b/virtnbdrestore @@ -118,7 +118,7 @@ def restoreData( try: kind, start, length = stream.readFrame(reader) except exceptions.StreamFormatException as err: - logging.error("Cant read stream at pos: [%s]: [%s]", reader.tell(), err) + logging.error("Can't read stream at pos: [%s]: [%s]", reader.tell(), err) raise RestoreError from err if kind == sTypes.ZERO: logging.debug("Zero segment from [%s] length: [%s]", start, length) @@ -295,7 +295,7 @@ def createDiskFile(args: Namespace, meta: Dict[str, str], targetFile: str, sshCl options = getQcowConfig(args, meta) if lib.exists(args, targetFile): - logging.error("Target file already exists: [%s], wont overwrite.", targetFile) + logging.error("Target file already exists: [%s], won't overwrite.", targetFile) raise RestoreError qFh = qemu.util(meta["diskName"]) @@ -304,7 +304,7 @@ def createDiskFile(args: Namespace, meta: Dict[str, str], targetFile: str, sshCl targetFile, int(meta["virtualSize"]), meta["diskFormat"], options, sshClient ) except ProcessError as e: - logging.error("Cant create restore target: [%s]", e) + logging.error("Can't create restore target: [%s]", e) raise RestoreError from e @@ -355,7 +355,7 @@ def readConfig(ConfigFile: str) -> str: try: return output.openfile(ConfigFile, "rb").read().decode() except: - logging.error("Cant read config file: [%s]", ConfigFile) + logging.error("Can't read config file: [%s]", ConfigFile) raise