diff --git a/lib/hypervisor/hv_fake.py b/lib/hypervisor/hv_fake.py index bf4a654a8c5f2ee91e35270ee0819eebeb966de8..850e568926dbb929758c28e106a8e76a00b33625 100644 --- a/lib/hypervisor/hv_fake.py +++ b/lib/hypervisor/hv_fake.py @@ -61,7 +61,7 @@ class FakeHypervisor(hv_base.BaseHypervisor): @return: tuple of (name, id, memory, vcpus, stat, times) """ - file_name = "%s/%s" % (self._ROOT_DIR, instance_name) + file_name = self._InstanceFile(instance_name) if not os.path.exists(file_name): return None try: @@ -88,7 +88,7 @@ class FakeHypervisor(hv_base.BaseHypervisor): data = [] for file_name in os.listdir(self._ROOT_DIR): try: - fh = open(self._ROOT_DIR + "/" + file_name, "r") + fh = open(utils.PathJoin(self._ROOT_DIR, file_name), "r") inst_id = "-1" memory = 0 vcpus = 1 @@ -107,12 +107,12 @@ class FakeHypervisor(hv_base.BaseHypervisor): raise errors.HypervisorError("Failed to list instances: %s" % err) return data - - def _InstanceFile(self, instance_name): + @classmethod + def _InstanceFile(cls, instance_name): """Compute the instance file for an instance name. """ - return self._ROOT_DIR + "/%s" % instance_name + return utils.PathJoin(cls._ROOT_DIR, instance_name) def _IsAlive(self, instance_name): """Checks if an instance is alive.