def validate_existing_size()

in files/validate_config.py [0:0]


    def validate_existing_size(self):
        """This method checks for existing private volume size and new
        values in the config.json"""
        if "vmsizes" not in self.config:
            raise ValidationError('Private volume sizes ("vmsizes") are not defined in config.json')
        if "sd_app" not in self.config["vmsizes"]:
            raise ValidationError("Private volume size of sd-app must be defined in config.json")
        if "sd_log" not in self.config["vmsizes"]:
            raise ValidationError("Private volume size of sd-log must be defined in config.json")

        if not isinstance(self.config["vmsizes"]["sd_app"], int):
            raise ValidationError("Private volume size of sd-app must be an integer value.")
        if not isinstance(self.config["vmsizes"]["sd_log"], int):
            raise ValidationError("Private volume size of sd-log must be an integer value.")

        app = Qubes()
        if "sd-app" in app.domains:
            vm = app.domains["sd-app"]
            vol = vm.volumes["private"]
            if not (vol.size <= self.config["vmsizes"]["sd_app"] * 1024 * 1024 * 1024):
                raise ValidationError("sd-app private volume is already bigger than configuration.")

        if "sd-log" in app.domains:
            vm = app.domains["sd-log"]
            vol = vm.volumes["private"]
            if not (vol.size <= self.config["vmsizes"]["sd_log"] * 1024 * 1024 * 1024):
                raise ValidationError("sd-log private volume is already bigger than configuration.")