Blueprint: hyper-v-testing-serialization-improvements This patchset contains a major refactoring of the Hyper-V driver. The main reason for this refactoring is to provide proper component abstraction and decoupling, thus replacing almost entirely the remaining pre-Essex code previously available. This leads to a considerable semplification of the testing framework, which is now entirely based on stubs and mocks (mox), without any serialized stub / mock. From an architectural perspective, the main driver class delegates operations to "ops" classes (e.g. VMOps, VolumeOps, etc) which contain the main logic and delegate OS specific actions to "utils" classes (e.g. VMUtils, LiveMigrationUtils, etc) where the WMI and Win32 API OS specific code resides. Additional attention has been put also into a better PEP8 code formatting, including compliance with not mandatory checks like E121 through E128. Change-Id: I900719c02b7c6b48d44ca68903813a1dcd023f9f
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2013 Cloudbase Solutions Srl
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
import io
|
|
import os
|
|
|
|
|
|
class PathUtils(object):
|
|
def open(self, path, mode):
|
|
return io.BytesIO(b'fake content')
|
|
|
|
def get_instances_path(self):
|
|
return 'C:\\FakePath\\'
|
|
|
|
def get_instance_path(self, instance_name):
|
|
return os.path.join(self.get_instances_path(), instance_name)
|
|
|
|
def get_vhd_path(self, instance_name):
|
|
instance_path = self.get_instance_path(instance_name)
|
|
return os.path.join(instance_path, instance_name + ".vhd")
|
|
|
|
def get_base_vhd_path(self, image_name):
|
|
base_dir = os.path.join(self.get_instances_path(), '_base')
|
|
return os.path.join(base_dir, image_name + ".vhd")
|
|
|
|
def make_export_path(self, instance_name):
|
|
export_folder = os.path.join(self.get_instances_path(), "export",
|
|
instance_name)
|
|
return export_folder
|
|
|
|
def vhd_exists(self, path):
|
|
return False
|