Source code for lago.paths

#
# Copyright 2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#
import os


[docs]class Paths(object): """ A Paths object contains methods for getting the paths to the directories and files which composes the prefix. Attributes: _prefix_path (str): Path to the directory of the prefix """ def __init__(self, prefix_path): """ Args: prefix_path (str): Path to the directory of the prefix """ # self._prefix should be dropped in lago ver 0.44 self.prefix = prefix_path self._prefix_path = prefix_path
[docs] def prefixed(self, *args): return os.path.join(self._prefix_path, *args)
[docs] def prefix_path(self): return self._prefix_path
[docs] def uuid(self): return self.prefixed('uuid')
[docs] def ssh_id_rsa(self): return self.prefixed('id_rsa')
[docs] def ssh_id_rsa_pub(self): return self.prefixed('id_rsa.pub')
[docs] def images(self, *path): return self.prefixed('images', *path)
[docs] def virt(self, *path): return self.prefixed('virt', *path)
[docs] def logs(self): return self.prefixed('logs')
[docs] def metadata(self): return self.prefixed('metadata')
[docs] def prefix_lagofile(self): "This file represents a prefix that's initialized" return self.prefixed('initialized')
[docs] def scripts(self, *args): return self.prefixed('scripts', *args)