from fb_tools.handler import BaseHandler
+from . import print_section_start, print_section_end
+
from .config import CrTplConfiguration
from .xlate import XLATOR
profile = self.config.cobbler_profile
LOG.info(_("Ensuring profile {!r} ...").format(profile))
+ print_section_start(
+ 'cobbler_ensure_profile', 'Ensuring profile.', collapsed=True)
profile_list = self.get_profile_list()
else:
self.add_profile()
+ print_section_end('cobbler_ensure_profile')
+
# -------------------------------------------------------------------------
def change_profile(self):
"""Ensure correctnes of an existing profile."""
remote_ks = self.config.system_ks
LOG.info(_("Ensuring currentness of system kickstart script {!r}.").format(
str(remote_ks)))
+ print_section_start(
+ 'ensure_system_ks', 'Ensuring currentness of system kickstart script', collapsed=True)
self.ensure_remote_file(local_ks, remote_ks)
+ print_section_end('ensure_system_ks')
# -------------------------------------------------------------------------
def ensure_snippets(self):
LOG.info(_("Ensuring currentness of snippets below {!r}.").format(
str(self.config.snippets_dir)))
+ print_section_start('ensure_snippets', "Ensuring currentness of snippets", collapsed=True)
for local_snippet in local_snippets_dir.glob('*'):
remote_snippet = self.config.snippets_dir / local_snippet.name
loc=str(local_snippet), rem=str(remote_snippet)))
self.ensure_remote_file(local_snippet, remote_snippet, check_parent=False)
+ print_section_end('ensure_snippets')
+
# -------------------------------------------------------------------------
def ensure_bashrc(self):
remote_dir = docroot / self.config.system_status
LOG.info(_("Ensuring currentness of bashrc files."))
+ print_section_start(
+ 'ensure_bashrc', 'Ensuring currentness of bashrc files.', collapsed=True)
for local_rc_file in files_dir.glob('bashrc*'):
remote_rc_file = remote_dir / local_rc_file.name
loc=str(local_rc_file), rem=str(remote_rc_file)))
self.ensure_remote_file(local_rc_file, remote_rc_file, check_parent=False)
+ print_section_end('ensure_bashrc')
+
# -------------------------------------------------------------------------
def ensure_vimrc(self):
remote_dir = docroot / self.config.system_status
LOG.info(_("Ensuring currentness of vimrc files."))
+ print_section_start(
+ 'ensure_vimrc', "Ensuring currentness of vimrc files.", collapsed=True)
for local_rc_file in files_dir.glob('vimrc*'):
remote_rc_file = remote_dir / local_rc_file.name
loc=str(local_rc_file), rem=str(remote_rc_file)))
self.ensure_remote_file(local_rc_file, remote_rc_file, check_parent=False)
+ print_section_end('ensure_vimrc')
+
# -------------------------------------------------------------------------
def ensure_logrotate_files(self):
remote_dir = docroot / self.config.system_status
LOG.info(_("Ensuring currentness of logrotate files."))
+ print_section_start(
+ 'ensure_logrotate_files', "Ensuring currentness of logrotate files.",
+ collapsed=True)
for local_file in files_dir.glob('logrotate*'):
remote_file = remote_dir / local_file.name
loc=str(local_file), rem=str(remote_file)))
self.ensure_remote_file(local_file, remote_file, check_parent=False)
+ print_section_end('ensure_logrotate_files')
+
# -------------------------------------------------------------------------
def ensure_create_motd(self):
remote_script = remote_dir / local_script.name
LOG.info(_("Ensuring currentness of create-motd.sh."))
+ print_section_start('ensure_create_motd', "Ensuring currentness of create-motd.sh.")
LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
loc=str(local_script), rem=str(remote_script)))
self.ensure_remote_file(local_script, remote_script, check_parent=False)
+ print_section_end('ensure_create_motd')
+
# -------------------------------------------------------------------------
def add_system(self, name, fqdn, mac_address, comment=None):
"""Creating a new system."""
os_id = self.config.os_id
LOG.info(_("Creating new system {!r} ...").format(name))
+ print_section_start('add_system', "Creating new system ...", collapsed=True)
if not comment:
comment = "VMWare template for creating a {} system.".format(os_id)
err = proc.stdout
msg = _("Error creating a cobbler system - returncode was {rc}: {err}").format(
rc=proc.returncode, err=err)
+ print_section_end('add_system')
raise ExpectedCobblerError(msg)
+ print_section_end('add_system')
self.sync()
# -------------------------------------------------------------------------
"""Removing the given system."""
LOG.info(_("Removing system {!r} ...").format(name))
+ print_section_start('remove_system', "Creating new system ...", collapsed=True)
args = ['system', 'remove']
args.append('--name')
err = proc.stdout
msg = _("Error removing the cobbler system {n!r} - returncode was {rc}: {err}").format(
n=name, rc=proc.returncode, err=err)
+ print_section_end('remove_system')
raise ExpectedCobblerError(msg)
+ print_section_end('remove_system')
self.sync()
# -------------------------------------------------------------------------
LOG.info(_("Ensuring currentness of authorized_keys file of root {!r}.").format(
str(remote_file)))
+ print_section_start(
+ 'ensure_keys', "Ensuring authorized_keys of root.", collapsed=True)
self.ensure_remote_directory(remote_dir)
self.ensure_remote_file(auth_keys_file, remote_file, check_parent=False)
+ print_section_end('ensure_keys')
# -------------------------------------------------------------------------
def ensure_repo_files(self):
remote_dir = docroot / self.config.system_status / 'repos'
LOG.info(_("Ensuring currentness of repo files below {!r}.").format(str(files_dir)))
+ print_section_start(
+ 'ensure_repo_files', "Ensuring repo files.", collapsed=True)
for local_repo_dir in files_dir.glob('repos-*'):
if not local_repo_dir.is_dir():
self.ensure_remote_file(local_repo_file, remote_file, check_parent=False)
LOG.debug(_("Finished with repo files."))
+ print_section_end('ensure_repo_files')
# -------------------------------------------------------------------------
def ensure_postfix_files(self):
remote_dir = docroot / self.config.system_status / 'postfix'
LOG.info(_("Ensuring currentness of postfix files below {!r}.").format(str(files_dir)))
+ print_section_start(
+ 'ensure_postfix_files', "Ensuring postfix files.", collapsed=True)
self.ensure_remote_directory(remote_dir)
for local_file in files_dir.glob('*'):
self.ensure_remote_file(local_file, remote_file, check_parent=False)
LOG.debug(_("Finished with postfix files."))
+ print_section_end('ensure_postfix_files')
# -------------------------------------------------------------------------
def get_dhcp_ip(self, mac_address):