Skip to content
Snippets Groups Projects
Commit 3b80eb2c authored by Iustin Pop's avatar Iustin Pop
Browse files

hv_fake: remove hard-coded path constructs


This changes to hv_fake to PathJoin.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 6b0391b3
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment