"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cobbler/settings.py" between
cobbler-2.8.4.tar.gz and cobbler-3.0.0.tar.gz

About: cobbler is a Linux installation and deployment server that allows for rapid setup of network installation environments. It can help with installation, DNS, DHCP, package updates, power management, configuration management orchestration, and much more.

settings.py  (cobbler-2.8.4):settings.py  (cobbler-3.0.0)
skipping to change at line 22 skipping to change at line 22
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA 02110-1301 USA
""" """
import sys
import utils from builtins import str
from utils import _ from builtins import object
import os.path
import glob import glob
import os.path
import re import re
TESTMODE = False from . import utils
from .utils import _
# defaults is to be used if the config file doesn't contain the value TESTMODE = False
# we need.
# defaults is to be used if the config file doesn't contain the value we need
DEFAULTS = { DEFAULTS = {
"anamon_enabled" : [0,"bool"], "allow_duplicate_hostnames": [0, "bool"],
"allow_duplicate_hostnames" : [0,"bool"], "allow_duplicate_ips": [0, "bool"],
"allow_duplicate_macs" : [0,"bool"], "allow_duplicate_macs": [0, "bool"],
"allow_duplicate_ips" : [0,"bool"], "allow_dynamic_settings": [0, "bool"],
"allow_dynamic_settings" : [0,"bool"], "always_write_dhcp_entries": [0, "bool"],
"always_write_dhcp_entries" : [0,"bool"], "anamon_enabled": [0, "bool"],
"auth_token_expiration" : [3600,"int"], "auth_token_expiration": [3600, "int"],
"bind_chroot_path" : ["","str"], "authn_pam_service": ["login", "str"],
"bind_master" : ["127.0.0.1","str"], "autoinstall_snippets_dir": ["/var/lib/cobbler/snippets", "str"],
"build_reporting_enabled" : [0,"bool"], "autoinstall_templates_dir": ["/var/lib/cobbler/templates", "str"],
"build_reporting_to_address" : ["","str"], "bind_chroot_path": ["", "str"],
"build_reporting_sender" : ["","str"], "bind_master": ["127.0.0.1", "str"],
"build_reporting_subject" : ["","str"], "boot_loader_conf_template_dir": ["/etc/cobbler/boot_loader_conf", "str"],
"build_reporting_smtp_server" : ["localhost","str"], "bootloaders_dir": ["/var/lib/cobbler/loaders", "str"],
"build_reporting_ignorelist" : ["","str"], "grubconfig_dir": ["/var/lib/cobbler/grub_config", "str"],
"buildisodir" : ["/var/cache/cobbler/buildiso","str" "build_reporting_enabled": [0, "bool"],
], "build_reporting_ignorelist": ["", "str"],
"cheetah_import_whitelist" : [["re", "random", "time"],"list"], "build_reporting_sender": ["", "str"],
"client_use_localhost" : ["","str"], "build_reporting_smtp_server": ["localhost", "str"],
"cobbler_master" : ["","str"], "build_reporting_subject": ["", "str"],
"consoles" : ["/var/consoles","str"], "buildisodir": ["/var/cache/cobbler/buildiso", "str"],
"createrepo_flags" : ["-c cache -s sha","str"], "cheetah_import_whitelist": [["re", "random", "time"], "list"],
"default_deployment_method" : ["ssh","str"], "client_use_https": [0, "bool"],
"default_kickstart" : ["/var/lib/cobbler/kickstarts/defaul "client_use_localhost": [0, "bool"],
t.ks","str"], "cobbler_master": ["", "str"],
"default_name_servers" : [[],"list"], "createrepo_flags": ["-c cache -s sha", "str"],
"default_name_servers_search" : [[],"list"], "default_autoinstall": ["/var/lib/cobbler/templates/default.ks", "str"],
"default_password_crypted" : ["\$1\$mF86/UHC\$WvcIcX2t6crBz2onWxy "default_name_servers": [[], "list"],
ac.","str"], "default_name_servers_search": [[], "list"],
"default_template_type" : ["cheetah","str"], "default_ownership": [["admin"], "list"],
"default_virt_bridge" : ["xenbr0","str"], "default_password_crypted": [r"\$1\$mF86/UHC\$WvcIcX2t6crBz2onWxyac.", "str"
"default_virt_type" : ["auto","str"], ],
"default_virt_file_size" : [5,"int"], "default_template_type": ["cheetah", "str"],
"default_virt_disk_driver" : ["raw","str"], "default_virt_bridge": ["xenbr0", "str"],
"default_virt_ram" : [512,"int"], "default_virt_disk_driver": ["raw", "str"],
"default_ownership" : [["admin"],"list"], "default_virt_file_size": [5, "int"],
"enable_gpxe" : [0,"bool"], "default_virt_ram": [512, "int"],
"enable_menu" : [1,"bool"], "default_virt_type": ["auto", "str"],
"func_master" : ["overlord.example.org","str"], "enable_gpxe": [0, "bool"],
"func_auto_setup" : [0,"bool"], "enable_menu": [1, "bool"],
"http_port" : [80,"int"], "http_port": [80, "int"],
"isc_set_host_name" : [0,"bool"], "include": [["/etc/cobbler/settings.d/*.settings"], "list"],
"iso_template_dir" : ["/etc/cobbler/iso","str"], "iso_template_dir": ["/etc/cobbler/iso", "str"],
"kerberos_realm" : ["EXAMPLE.COM","str"], "kernel_options": [{}, "dict"],
"kernel_options" : [{"lang":" ", "text":None, "ksdevice "ldap_anonymous_bind": [1, "bool"],
":"eth0"},"dict"], "ldap_base_dn": ["DC=devel,DC=redhat,DC=com", "str"],
"kernel_options_s390x" : [{},"dict"], "ldap_port": [389, "int"],
"ldap_server" : ["grimlock.devel.redhat.com","str"], "ldap_search_bind_dn": ["", "str"],
"ldap_base_dn" : ["DC=devel,DC=redhat,DC=com","str"], "ldap_search_passwd": ["", "str"],
"ldap_port" : [389,"int"], "ldap_search_prefix": ['uid=', "str"],
"ldap_tls" : ["on","str"], "ldap_server": ["grimlock.devel.redhat.com", "str"],
"ldap_anonymous_bind" : [1,"bool"], "ldap_tls": ["on", "str"],
"ldap_management_default_type" : ["authconfig","str"], "ldap_tls_cacertfile": ["", "str"],
"ldap_search_bind_dn" : ["","str"], "ldap_tls_certfile": ["", "str"],
"ldap_search_passwd" : ["","str"], "ldap_tls_keyfile": ["", "str"],
"ldap_search_prefix" : ['uid=',"str"], "bind_manage_ipmi": [0, "bool"],
"ldap_tls_cacertfile" : ["", "str"], "manage_dhcp": [0, "bool"],
"ldap_tls_keyfile" : ["", "str"], "manage_dns": [0, "bool"],
"ldap_tls_certfile" : ["", "str"], "manage_forward_zones": [[], "list"],
"manage_dhcp" : [0,"bool"], "manage_reverse_zones": [[], "list"],
"manage_dns" : [0,"bool"], "manage_genders": [0, "bool"],
"manage_genders" : [0,"bool"], "manage_rsync": [0, "bool"],
"manage_tftp" : [1,"bool"], "manage_tftp": [1, "bool"],
"manage_tftpd" : [1,"bool"], "manage_tftpd": [1, "bool"],
"manage_rsync" : [0,"bool"], "mgmt_classes": [[], "list"],
"manage_forward_zones" : [[],"list"], "mgmt_parameters": [{}, "dict"],
"manage_reverse_zones" : [[],"list"], "next_server": ["127.0.0.1", "str"],
"mgmt_classes" : [[],"list"], "nsupdate_enabled": [0, "bool"],
"mgmt_parameters" : [{},"dict"], "power_management_default_type": ["ipmitool", "str"],
"next_server" : ["127.0.0.1","str"], "power_template_dir": ["/etc/cobbler/power", "str"],
"power_management_default_type" : ["ipmitool","str"], "proxy_url_ext": ["", "str"],
"power_template_dir" : ["/etc/cobbler/power","str"], "proxy_url_int": ["", "str"],
"proxy_url_ext" : ["", "str"], "puppet_auto_setup": [0, "bool"],
"proxy_url_int" : ["", "str"], "puppet_parameterized_classes": [1, "bool"],
"puppet_auto_setup" : [0,"bool"], "puppet_server": ["puppet", "str"],
"puppet_parameterized_classes" : [1,"bool"], "puppet_version": [2, "int"],
"puppet_server" : ["puppet","str"], "puppetca_path": ["/usr/bin/puppet", "str"],
"puppet_version" : [2,"int"], "pxe_just_once": [1, "bool"],
"pxe_just_once" : [0,"bool"], "nopxe_with_triggers": [1, "bool"],
"pxe_template_dir" : ["/etc/cobbler/pxe","str"], "redhat_management_permissive": [0, "bool"],
"redhat_management_permissive" : [0,"bool"], "redhat_management_server": ["xmlrpc.rhn.redhat.com", "str"],
"redhat_management_type" : ["off","str"], "redhat_management_key": ["", "str"],
"redhat_management_key" : ["","str"], "register_new_installs": [0, "bool"],
"redhat_management_server" : ["xmlrpc.rhn.redhat.com","str"], "remove_old_puppet_certs_automatically": [0, "bool"],
"register_new_installs" : [0,"bool"], "replicate_repo_rsync_options": ["-avzH", "str"],
"remove_old_puppet_certs_automatically": [0,"bool"], "replicate_rsync_options": ["-avzH", "str"],
"replicate_rsync_options" : ["-avzH", "str"], "reposync_flags": ["-l -m -d", "str"],
"replicate_repo_rsync_options" : ["-avzH", "str"], "restart_dhcp": [1, "bool"],
"reposync_flags" : ["-l -m -d","str"], "restart_dns": [1, "bool"],
"restart_dns" : [1,"bool"], "run_install_triggers": [1, "bool"],
"restart_dhcp" : [1,"bool"], "scm_track_enabled": [0, "bool"],
"restart_xinetd" : [1,"bool"], "scm_track_mode": ["git", "str"],
"run_install_triggers" : [1,"bool"], "scm_track_author": ["cobbler <cobbler@localhost>", "str"],
"scm_track_enabled" : [0,"bool"], "scm_push_script": ["/bin/true", "str"],
"scm_track_mode" : ["git","str"], "serializer_pretty_json": [0, "bool"],
"serializer_pretty_json" : [0,"bool"], "server": ["127.0.0.1", "str"],
"server" : ["127.0.0.1","str"], "sign_puppet_certs_automatically": [0, "bool"],
"sign_puppet_certs_automatically" : [0,"bool"], "signature_path": ["/var/lib/cobbler/distro_signatures.json", "str"],
"signature_path" : ["/var/lib/cobbler/distro_signatures "signature_url": ["https://cobbler.github.io/signatures/3.0.x/latest.json",
.json","str"], "str"],
"signature_url" : ["https://cobbler.github.io/signatur "tftpboot_location": ["/srv/tftpboot", "str"],
es/2.8.x/latest.json","str"], "virt_auto_boot": [0, "bool"],
"snippetsdir" : ["/var/lib/cobbler/snippets","str"], "webdir": ["/var/www/cobbler", "str"],
"template_remote_kickstarts" : [0,"bool"], "webdir_whitelist": [".link_cache", "misc", "distro_mirror", "images", "link
"virt_auto_boot" : [0,"bool"], s", "localmirror", "pub", "rendered", "repo_mirror", "repo_profile", "repo_syste
"webdir" : ["/var/www/cobbler","str"], m", "svc", "web", "webui"],
"xmlrpc_port" : [25151,"int"], "xmlrpc_port": [25151, "int"],
"yum_post_install_mirror" : [1,"bool"], "yum_distro_priority": [1, "int"],
"yum_distro_priority" : [1,"int"], "yum_post_install_mirror": [1, "bool"],
"yumdownloader_flags" : ["--resolve","str"], "yumdownloader_flags": ["--resolve", "str"],
} }
FIELDS = [ FIELDS = [
["name","","","Name",True,"Ex: server",0,"str"], ["name", "", "", "Name", True, "Ex: server", 0, "str"],
["value","","","Value",True,"Ex: 127.0.0.1",0,"str"], ["value", "", "", "Value", True, "Ex: 127.0.0.1", 0, "str"],
] ]
if os.path.exists("/srv/www/"): if os.path.exists("/srv/www/"):
DEFAULTS["webdir"] = "/srv/www/cobbler" DEFAULTS["webdir"] = "/srv/www/cobbler"
# Autodetect bind chroot configuration # Autodetect bind chroot configuration
# RHEL/Fedora # RHEL/Fedora
if os.path.exists("/etc/sysconfig/named"): if os.path.exists("/etc/sysconfig/named"):
bind_config_filename = "/etc/sysconfig/named" bind_config_filename = "/etc/sysconfig/named"
# Debian # Debian
skipping to change at line 166 skipping to change at line 168
bind_config_filename = None bind_config_filename = None
bind_config_files = glob.glob("/etc/default/bind*") bind_config_files = glob.glob("/etc/default/bind*")
for filename in bind_config_files: for filename in bind_config_files:
if os.path.exists(filename): if os.path.exists(filename):
bind_config_filename = filename bind_config_filename = filename
# Parse the config file # Parse the config file
if bind_config_filename: if bind_config_filename:
bind_config = {} bind_config = {}
# When running as a webapp we can't access this, but don't need it # When running as a webapp we can't access this, but don't need it
try: try:
bind_config_file = open(bind_config_filename,"r") bind_config_file = open(bind_config_filename, "r")
except (IOError, OSError): except (IOError, OSError):
pass pass
else: else:
for line in bind_config_file: for line in bind_config_file:
if re.match("[a-zA-Z]+=", line): if re.match(r"[a-zA-Z]+=", line):
(name, value) = line.rstrip().split("=") (name, value) = line.rstrip().split("=")
bind_config[name] = value.strip('"') bind_config[name] = value.strip('"')
# RHEL, SysV Fedora # RHEL, SysV Fedora
if "ROOTDIR" in bind_config: if "ROOTDIR" in bind_config:
DEFAULTS["bind_chroot_path"] = bind_config["ROOTDIR"] DEFAULTS["bind_chroot_path"] = bind_config["ROOTDIR"]
# Debian, Systemd Fedora # Debian, Systemd Fedora
if "OPTIONS" in bind_config: if "OPTIONS" in bind_config:
rootdirmatch = re.search("-t ([/\w]+)", bind_config["OPTIONS"]) rootdirmatch = re.search(r"-t ([/\w]+)", bind_config["OPTIONS"])
if rootdirmatch is not None: if rootdirmatch is not None:
DEFAULTS["bind_chroot_path"] = rootdirmatch.group(1) DEFAULTS["bind_chroot_path"] = rootdirmatch.group(1)
class Settings: class Settings(object):
def collection_type(self): def collection_type(self):
return "settings" return "settings"
def __init__(self): def __init__(self):
""" """
Constructor. Constructor.
""" """
self.clear() self._clear()
if (self.manage_tftp or self.manage_tftpd) and not os.path.isdir(self.tf
def clear(self): tpboot_location):
""" print("TFTP directory '{}' not found".format(self.tftpboot_location)
Reset this object to reasonable default values. , file=sys.stderr)
""" sys.exit(1)
self.__dict__ = {}
for key in DEFAULTS.keys(): def _clear(self):
self.__dict__[key] = DEFAULTS[key][0] self.__dict__ = {}
for key in list(DEFAULTS.keys()):
def set(self,name,value): self.__dict__[key] = DEFAULTS[key][0]
return self.__setattr__(name,value)
def set(self, name, value):
def printable(self): return self.__setattr__(name, value)
buf = ""
buf = buf + _("defaults\n") def to_string(self):
buf = buf + _("kernel options : %s\n") % self.__dict__['kernel_options'] buf = ""
return buf buf += _("defaults\n")
buf += _("kernel options : %s\n") % self.__dict__['kernel_options']
def to_datastruct(self): return buf
"""
Return an easily serializable representation of the config. def to_dict(self):
""" """
return self.__dict__ Return an easily serializable representation of the config.
"""
def from_datastruct(self,datastruct): return self.__dict__
"""
Modify this object to load values in datastruct. def from_dict(self, _dict):
""" """
if datastruct is None: Modify this object to load values in dictionary.
print _("warning: not loading empty structure for %s") % self.filename """
() if _dict is None:
return print(_("warning: not loading empty structure for %s") % self.filena
me())
self.clear() return
self.__dict__.update(datastruct)
self._clear()
return self self.__dict__.update(_dict)
def __setattr__(self,name,value): return self
if DEFAULTS.has_key(name):
try: def __setattr__(self, name, value):
if DEFAULTS[name][1] == "str": if name in DEFAULTS:
value = str(value) try:
elif DEFAULTS[name][1] == "int": if DEFAULTS[name][1] == "str":
value = int(value) value = str(value)
elif DEFAULTS[name][1] == "bool": elif DEFAULTS[name][1] == "int":
if utils.input_boolean(value): value = int(value)
value = 1 elif DEFAULTS[name][1] == "bool":
else: if utils.input_boolean(value):
value = 0 value = 1
elif DEFAULTS[name][1] == "float": else:
value = float(value) value = 0
elif DEFAULTS[name][1] == "list": elif DEFAULTS[name][1] == "float":
value = utils.input_string_or_list(value) value = float(value)
elif DEFAULTS[name][1] == "dict": elif DEFAULTS[name][1] == "list":
value = utils.input_string_or_hash(value)[1] value = utils.input_string_or_list(value)
except: elif DEFAULTS[name][1] == "dict":
raise AttributeError, "failed to set %s to %s" % (name,str(value) value = utils.input_string_or_dict(value)[1]
) except:
raise AttributeError
self.__dict__[name] = value
if not utils.update_settings_file(self.to_datastruct()): self.__dict__[name] = value
raise AttributeError, "failed to save the settings file!" if not utils.update_settings_file(self.to_dict()):
raise AttributeError
return 0
else: return 0
raise AttributeError, name else:
# FIXME. Not sure why __dict__ is part of name
def __getattr__(self,name): # workaround applied, ignore exception
try: # raise AttributeError
if name == "kernel_options": pass
# backwards compatibility -- convert possible string value to has
h def __getattr__(self, name):
(success, result) = utils.input_string_or_hash(self.__dict__[name try:
], " ",allow_multiples=False) if name == "kernel_options":
self.__dict__[name] = result # backwards compatibility -- convert possible string value to di
return result ct
return self.__dict__[name] (success, result) = utils.input_string_or_dict(self.__dict__[nam
except: e], allow_multiples=False)
if DEFAULTS.has_key(name): self.__dict__[name] = result
lookup = DEFAULTS[name][0] return result
self.__dict__[name] = lookup return self.__dict__[name]
return lookup except:
else: if name in DEFAULTS:
raise AttributeError, name lookup = DEFAULTS[name][0]
self.__dict__[name] = lookup
return lookup
else:
raise AttributeError
 End of changes. 13 change blocks. 
126 lines changed or deleted 126 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)