from .distro import CobblerDistro
from .files import CobblerFiles
from .profile import CobblerProfile
+from .system import CobblerSystem
from .. import print_section_start, print_section_end
from ..xlate import XLATOR
-__version__ = '0.11.2'
+__version__ = '0.11.3'
LOG = logging.getLogger(__name__)
# =============================================================================
-class Cobbler(BaseHandler, CobblerDistro, CobblerFiles, CobblerProfile):
+class Cobbler(BaseHandler, CobblerDistro, CobblerFiles, CobblerProfile, CobblerSystem):
"""
A handler class for executing cobbler actions.
"""
return data
- # -------------------------------------------------------------------------
- def ensure_system_ks(self):
-
- local_ks_base = 'template-' + self.cfg.os_id + '.ks'
- local_ks = self.base_dir / 'kickstart' / local_ks_base
- remote_ks = self.cfg.system_ks
- LOG.info(_("Ensuring currentness of system kickstart script {!r}.").format(
- str(remote_ks)))
-
- jinja_env = jinja2.Environment(
- loader=jinja2.FileSystemLoader(str(self.base_dir / 'templates')),
- autoescape=jinja2.select_autoescape(),
- )
- ks_template = jinja_env.get_template('el-standard.ks')
- ks_content = ks_template.render(distro=self.cfg.current_distro)
- if self.verbose > 1:
- LOG.debug(_("Generated kickstart file content:") + '\n' + ks_content)
-
- return
- 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):
-
- local_snippets_dir = self.base_dir / 'snippets'
- self.ensure_remote_directory(self.cfg.snippets_dir)
-
- LOG.info(_("Ensuring currentness of snippets below {!r}.").format(
- str(self.cfg.snippets_dir)))
- print_section_start('ensure_snippets', "Ensuring currentness of snippets", collapsed=True)
-
- for local_snippet in local_snippets_dir.glob('*'):
- remote_snippet = self.cfg.snippets_dir / local_snippet.name
- LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
- 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):
-
- files_dir = self.base_dir / 'files'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.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
- LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
- 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):
-
- files_dir = self.base_dir / 'files'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.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
- LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
- 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):
-
- files_dir = self.base_dir / 'files'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.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
- LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
- 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):
-
- local_script = self.base_dir / 'bin' / 'create-motd.sh'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.system_status
- 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."""
-
- profile = self.cfg.cobbler_profile
- os_id = self.cfg.os_id
-
- LOG.info(_("Creating new system {!r} ...").format(name))
-
- if not comment:
- comment = "VMWare template for creating a {} system.".format(os_id)
- status = self.cfg.system_status
-
- ks_meta_list = []
- ks_meta_list.append("ROOT_PWD_HASH={}".format(self.cfg.get_root_pwd_hash()))
- ks_meta_list.append("SWAP_SIZE_MB={}".format(self.cfg.swap_size_mb))
- ks_meta_list.append("SYSTEM_STATUS={}".format(status))
- ks_meta_list.append("WS_REL_FILESDIR={}".format(self.cfg.cobbler_ws_rel_filesdir))
- ks_meta_list.append("COBBLER_URL=http://{}".format(self.cfg.cobbler_host))
-
- ks_meta = None
- if ks_meta_list:
- ks_meta = ' '.join(ks_meta_list)
-
- args = ['system', 'add']
- args.append('--name')
- args.append(name)
- args.append('--profile')
- args.append(profile)
- args.append('--status')
- args.append(status)
- args.append('--comment')
- args.append(comment)
- if ks_meta:
- if self.cfg.cobbler_major_version == 3:
- args.append('--autoinstall-meta')
- else:
- args.append('--ksmeta')
- args.append(ks_meta)
- args.append('--power-type')
- args.append('apc')
- args.append('--hostname')
- args.append(fqdn)
- args.append('--mac-address')
- args.append(mac_address)
- args.append('--interface')
- args.append('eth0')
- args.append('--management')
- args.append('true')
-
- proc = self.exec_cobbler(args)
-
- if proc.returncode:
- err = _('No error message')
- if proc.stderr:
- err = proc.stderr
- elif proc.stdout:
- err = proc.stdout
- msg = _("Error creating a cobbler system - returncode was {rc}: {err}").format(
- rc=proc.returncode, err=err)
- raise ExpectedCobblerError(msg)
-
- self.sync()
-
- # -------------------------------------------------------------------------
- def remove_system(self, name):
- """Removing the given system."""
-
- LOG.info(_("Removing system {!r} ...").format(name))
- print_section_start('remove_system', "Removing system ...", collapsed=True)
-
- args = ['system', 'remove']
- args.append('--name')
- args.append(name)
-
- proc = self.exec_cobbler(args)
-
- if proc.returncode:
- err = _('No error message')
- if proc.stderr:
- err = proc.stderr
- elif proc.stdout:
- 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)
-
- self.sync()
- print_section_end('remove_system')
-
# -------------------------------------------------------------------------
def sync(self):
"""Executing 'cobbler sync' to apply environment, especially DHCPD configuration."""
if proc.stderr:
LOG.debug(_("Output on {}:").format('STDERR') + '\n' + proc.stderr)
- # -------------------------------------------------------------------------
- def ensure_keys(self, tmp_auth_keys_file=None):
-
- local_keys_dir = self.base_dir / 'keys'
- if tmp_auth_keys_file:
- auth_keys_file = tmp_auth_keys_file
- else:
- auth_keys_file = local_keys_dir / "auth_keys_pp_betrieb"
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.system_status / 'keys'
- remote_file = remote_dir / "auth_keys_pp_betrieb"
-
- 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):
-
- files_dir = self.base_dir / 'files'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.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():
- LOG.warn(_("Local path {!r} is not a directory.").format(str(local_repo_dir)))
- continue
- dirname = str(local_repo_dir.name)
- os_id = dirname.replace('repos-', '', 1)
- LOG.debug(_("Ensuring repo files for {}.").format(os_id))
- remote_dir_os = remote_dir / os_id
- self.ensure_remote_directory(remote_dir_os)
- for local_repo_file in local_repo_dir.glob('*.repo'):
- remote_file = remote_dir_os / local_repo_file.name
- 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):
-
- files_dir = self.base_dir / 'files' / 'postfix'
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- remote_dir = docroot / self.cfg.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('*'):
- remote_file = remote_dir / local_file.name
- 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):
return ips
- # -------------------------------------------------------------------------
- def ensure_webroot(self):
-
- docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
- webroot = docroot / self.cfg.system_status
- desc = _("Webroot directory")
- LOG.info(_("Ensuring existence of {what} {dir!r}...").format(
- what=desc, dir=str(webroot)))
-
- self.ensure_remote_directory(webroot, desc)
-
# =============================================================================
if __name__ == "__main__":
@author: Frank Brehm
@contact: frank.brehm@pixelpark.com
@copyright: © 2023 by Frank Brehm, Berlin
-@summary: A mixin module for the Cobbler class for files dependend methods.
+@summary: A mixin module for the Cobbler class for file and directory dependend methods.
"""
from __future__ import absolute_import, print_function
# =============================================================================
class CobblerFiles():
"""
- A mixin class for extending the Cobbler class for files dependend methods.
+ A mixin class for extending the Cobbler class for file and directory dependend methods.
"""
# -------------------------------------------------------------------------
print_section_end('ensure_rsyslog_cfg_files')
+ # -------------------------------------------------------------------------
+ def ensure_snippets(self):
+
+ local_snippets_dir = self.base_dir / 'snippets'
+ self.ensure_remote_directory(self.cfg.snippets_dir)
+
+ LOG.info(_("Ensuring currentness of snippets below {!r}.").format(
+ str(self.cfg.snippets_dir)))
+ print_section_start('ensure_snippets', "Ensuring currentness of snippets", collapsed=True)
+
+ for local_snippet in local_snippets_dir.glob('*'):
+ remote_snippet = self.cfg.snippets_dir / local_snippet.name
+ LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
+ 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):
+
+ files_dir = self.base_dir / 'files'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.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
+ LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
+ 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):
+
+ files_dir = self.base_dir / 'files'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.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
+ LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
+ 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):
+
+ files_dir = self.base_dir / 'files'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.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
+ LOG.debug(_("Ensuring {loc!r} => {rem!r}.").format(
+ 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):
+
+ local_script = self.base_dir / 'bin' / 'create-motd.sh'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.system_status
+ 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 ensure_keys(self, tmp_auth_keys_file=None):
+
+ local_keys_dir = self.base_dir / 'keys'
+ if tmp_auth_keys_file:
+ auth_keys_file = tmp_auth_keys_file
+ else:
+ auth_keys_file = local_keys_dir / "auth_keys_pp_betrieb"
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.system_status / 'keys'
+ remote_file = remote_dir / "auth_keys_pp_betrieb"
+
+ 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):
+
+ files_dir = self.base_dir / 'files'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.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():
+ LOG.warn(_("Local path {!r} is not a directory.").format(str(local_repo_dir)))
+ continue
+ dirname = str(local_repo_dir.name)
+ os_id = dirname.replace('repos-', '', 1)
+ LOG.debug(_("Ensuring repo files for {}.").format(os_id))
+ remote_dir_os = remote_dir / os_id
+ self.ensure_remote_directory(remote_dir_os)
+ for local_repo_file in local_repo_dir.glob('*.repo'):
+ remote_file = remote_dir_os / local_repo_file.name
+ 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):
+
+ files_dir = self.base_dir / 'files' / 'postfix'
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ remote_dir = docroot / self.cfg.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('*'):
+ remote_file = remote_dir / local_file.name
+ self.ensure_remote_file(local_file, remote_file, check_parent=False)
+
+ LOG.debug(_("Finished with postfix files."))
+ print_section_end('ensure_postfix_files')
+
+ # -------------------------------------------------------------------------
+ def ensure_webroot(self):
+
+ docroot = self.cfg.cobbler_ws_docroot / self.cfg.cobbler_ws_rel_filesdir
+ webroot = docroot / self.cfg.system_status
+ desc = _("Webroot directory")
+ LOG.info(_("Ensuring existence of {what} {dir!r}...").format(
+ what=desc, dir=str(webroot)))
+
+ self.ensure_remote_directory(webroot, desc)
+
# =============================================================================
if __name__ == "__main__":
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2023 by Frank Brehm, Berlin
+@summary: A mixin module for the Cobbler class for system dependend methods.
+"""
+from __future__ import absolute_import, print_function
+
+# Standard modules
+import logging
+import os
+import tempfile
+
+from pathlib import Path
+
+# Third party modules
+import jinja2
+
+from six.moves import configparser
+
+from fb_tools.common import pp, to_str, is_sequence, to_bool
+from fb_tools.xlate import format_list
+
+# Own modules
+from .. import print_section_start, print_section_end
+from ..errors import CobblerError, ExpectedCobblerError
+from ..xlate import XLATOR
+
+__version__ = '0.1.0'
+
+LOG = logging.getLogger(__name__)
+
+_ = XLATOR.gettext
+ngettext = XLATOR.ngettext
+
+# =============================================================================
+class CobblerSystem():
+ """
+ A mixin class for extending the Cobbler class for system dependend methods.
+ """
+
+ # -------------------------------------------------------------------------
+ def ensure_system_ks(self):
+
+ local_ks_base = 'template-' + self.cfg.os_id + '.ks'
+ local_ks = self.base_dir / 'kickstart' / local_ks_base
+ remote_ks = self.cfg.system_ks
+ LOG.info(_("Ensuring currentness of system kickstart script {!r}.").format(
+ str(remote_ks)))
+
+ jinja_env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader(str(self.base_dir / 'templates')),
+ autoescape=jinja2.select_autoescape(),
+ )
+ ks_template = jinja_env.get_template('el-standard.ks')
+ ks_content = ks_template.render(distro=self.cfg.current_distro)
+ if self.verbose > 1:
+ LOG.debug(_("Generated kickstart file content:") + '\n' + ks_content)
+
+ return
+ 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 add_system(self, name, fqdn, mac_address, comment=None):
+ """Creating a new system."""
+
+ profile = self.cfg.cobbler_profile
+ os_id = self.cfg.os_id
+
+ LOG.info(_("Creating new system {!r} ...").format(name))
+
+ if not comment:
+ comment = "VMWare template for creating a {} system.".format(os_id)
+ status = self.cfg.system_status
+
+ ks_meta_list = []
+ ks_meta_list.append("ROOT_PWD_HASH={}".format(self.cfg.get_root_pwd_hash()))
+ ks_meta_list.append("SWAP_SIZE_MB={}".format(self.cfg.swap_size_mb))
+ ks_meta_list.append("SYSTEM_STATUS={}".format(status))
+ ks_meta_list.append("WS_REL_FILESDIR={}".format(self.cfg.cobbler_ws_rel_filesdir))
+ ks_meta_list.append("COBBLER_URL=http://{}".format(self.cfg.cobbler_host))
+
+ ks_meta = None
+ if ks_meta_list:
+ ks_meta = ' '.join(ks_meta_list)
+
+ args = ['system', 'add']
+ args.append('--name')
+ args.append(name)
+ args.append('--profile')
+ args.append(profile)
+ args.append('--status')
+ args.append(status)
+ args.append('--comment')
+ args.append(comment)
+ if ks_meta:
+ if self.cfg.cobbler_major_version == 3:
+ args.append('--autoinstall-meta')
+ else:
+ args.append('--ksmeta')
+ args.append(ks_meta)
+ args.append('--power-type')
+ args.append('apc')
+ args.append('--hostname')
+ args.append(fqdn)
+ args.append('--mac-address')
+ args.append(mac_address)
+ args.append('--interface')
+ args.append('eth0')
+ args.append('--management')
+ args.append('true')
+
+ proc = self.exec_cobbler(args)
+
+ if proc.returncode:
+ err = _('No error message')
+ if proc.stderr:
+ err = proc.stderr
+ elif proc.stdout:
+ err = proc.stdout
+ msg = _("Error creating a cobbler system - returncode was {rc}: {err}").format(
+ rc=proc.returncode, err=err)
+ raise ExpectedCobblerError(msg)
+
+ self.sync()
+
+ # -------------------------------------------------------------------------
+ def remove_system(self, name):
+ """Removing the given system."""
+
+ LOG.info(_("Removing system {!r} ...").format(name))
+ print_section_start('remove_system', "Removing system ...", collapsed=True)
+
+ args = ['system', 'remove']
+ args.append('--name')
+ args.append(name)
+
+ proc = self.exec_cobbler(args)
+
+ if proc.returncode:
+ err = _('No error message')
+ if proc.stderr:
+ err = proc.stderr
+ elif proc.stdout:
+ 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)
+
+ self.sync()
+ print_section_end('remove_system')
+
+
+# =============================================================================
+if __name__ == "__main__":
+
+ pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list