"""
An Resource is a serializable thing that can appear in a Collection
"""
from cobbler.cexceptions import CX
from cobbler.items import item
[docs]class Resource(item.Item):
"""
Base Class for management resources.
"""
[docs] def set_action(self, action):
"""
All management resources have an action. Action determine
weather a most resources should be created or removed, and
if packages should be installed or un-installed.
"""
action = action.lower()
valid_actions = ['create', 'remove']
if action not in valid_actions:
raise CX('%s is not a valid action' % action)
self.action = action
[docs] def set_group(self, group):
"""
Unix group ownership of a file or directory.
"""
self.group = group
[docs] def set_mode(self, mode):
"""
Unix file permission mode ie: '0644' assigned to
file and directory resources.
"""
self.mode = mode
[docs] def set_owner(self, owner):
"""
Unix owner of a file or directory
"""
self.owner = owner
[docs] def set_path(self, path):
"""
File path used by file and directory resources. Normally
a absolute path of the file or directory to create or
manage.
"""
self.path = path
[docs] def set_template(self, template):
"""
Path to cheetah template on cobbler's local file system.
Used to generate file data shipped to koan via json. All
templates have access to flatten autoinstall_meta data.
"""
self.template = template