Alexander Gordeev d74e6dc103 [IBP] Compare image checksums
If checksum and size provided in image meta data, fuel-agent will do
checksum comparing to ensure that data written on disk and downloaded
image are identical.

Partially implements blueprint: ibp-image-checksums
Depends on: Ia9c8325a2f71af2a1af2ad54a1ae414edf49a7c6
Change-Id: Id120848537cfc4ed908b9e524624855fb7308603
2015-03-12 14:38:26 +03:00

45 lines
1.5 KiB
Python

# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from fuel_agent import errors
class Image(object):
SUPPORTED_CONTAINERS = ['raw', 'gzip']
def __init__(self, uri, target_device,
format, container, size=None, md5=None):
# uri is something like
# http://host:port/path/to/image.img or
# file:///tmp/image.img
self.uri = uri
self.target_device = target_device
# this must be one of 'iso9660', 'ext[234]', 'xfs'
self.format = format
if container not in self.SUPPORTED_CONTAINERS:
raise errors.WrongImageDataError(
'Error while image initialization: '
'unsupported image container')
self.container = container
self.size = size
self.md5 = md5
class ImageScheme(object):
def __init__(self, images=None):
self.images = images or []
def add_image(self, **kwargs):
self.images.append(Image(**kwargs))