Type: implement explorer_dir, remote_explorer_dir

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-07 12:49:30 +02:00
parent 3012afeb31
commit 9473a3a19e

View file

@ -25,6 +25,8 @@ import os
import cdist import cdist
# FIXME: i should not have to care about prefix directory, local, remote and such.
# I know what my internals look like, the outside is none of my business.
class Type(object): class Type(object):
"""Represents a cdist type. """Represents a cdist type.
@ -51,6 +53,28 @@ class Type(object):
except KeyError as e: except KeyError as e:
raise cdist.MissingEnvironmentVariableError(e.args[0]) raise cdist.MissingEnvironmentVariableError(e.args[0])
@staticmethod
def remote_base_dir():
"""Return the absolute path to the top level directory where types
are kept on the remote/target host.
Requires the environment variable '__cdist_remote_base_dir' to be set.
"""
try:
return os.path.join(
os.environ['__cdist_remote_base_dir'],
'conf',
'type'
)
except KeyError as e:
raise cdist.MissingEnvironmentVariableError(e.args[0])
# FIXME: probably wrong place for this
@property
def remote_explorer_dir(self):
return os.path.join(self.remote_path, "explorer")
@classmethod @classmethod
def list_types(cls): def list_types(cls):
"""Return a list of type instances""" """Return a list of type instances"""
@ -80,6 +104,13 @@ class Type(object):
self.base_dir(), self.base_dir(),
self.name self.name
) )
# FIXME: prefix directory should not leak into me
@property
def remote_path(self):
return os.path.join(
self.remote_base_dir(),
self.name
)
@property @property
def is_singleton(self): def is_singleton(self):