diff options
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/action_check.py | 5 | ||||
-rw-r--r-- | cobbler/action_litesync.py | 8 | ||||
-rw-r--r-- | cobbler/action_sync.py | 23 | ||||
-rw-r--r-- | cobbler/item.py | 12 | ||||
-rw-r--r-- | cobbler/item_distro.py | 9 | ||||
-rw-r--r-- | cobbler/item_profile.py | 10 | ||||
-rw-r--r-- | cobbler/item_repo.py | 5 | ||||
-rw-r--r-- | cobbler/item_system.py | 7 | ||||
-rw-r--r-- | cobbler/modules/cli_distro.py | 5 | ||||
-rw-r--r-- | cobbler/modules/cli_profile.py | 5 | ||||
-rw-r--r-- | cobbler/modules/cli_repo.py | 5 | ||||
-rw-r--r-- | cobbler/modules/cli_system.py | 4 | ||||
-rw-r--r-- | cobbler/settings.py | 6 | ||||
-rw-r--r-- | cobbler/utils.py | 16 | ||||
-rw-r--r-- | cobbler/webui/master.py | 4 |
15 files changed, 92 insertions, 32 deletions
diff --git a/cobbler/action_check.py b/cobbler/action_check.py index a4a09f6..1fb4734 100644 --- a/cobbler/action_check.py +++ b/cobbler/action_check.py @@ -141,8 +141,9 @@ class BootCheck: """ Check if cobbler.conf's tftpboot directory exists """ - if not os.path.exists(self.settings.tftpboot): - status.append(_("please create directory: %(dirname)s") % { "dirname" : self.settings.tftpboot }) + bootloc = utils.tftpboot_location() + if not os.path.exists(bootloc): + status.append(_("please create directory: %(dirname)s") % { "dirname" : bootloc }) def check_tftpd_conf(self,status): diff --git a/cobbler/action_litesync.py b/cobbler/action_litesync.py index 457f3af..9200a3e 100644 --- a/cobbler/action_litesync.py +++ b/cobbler/action_litesync.py @@ -66,12 +66,13 @@ class BootLiteSync: self.add_single_profile(k.name) def remove_single_distro(self, name): + bootloc = utils.tftpboot_location() # delete distro YAML file in distros/$name in webdir self.sync.rmfile(os.path.join(self.settings.webdir, "distros", name)) # delete contents of images/$name directory in webdir self.sync.rmtree(os.path.join(self.settings.webdir, "images", name)) # delete contents of images/$name in tftpboot - self.sync.rmtree(os.path.join(self.settings.tftpboot, "images", name)) + self.sync.rmtree(os.path.join(bootloc, "images", name)) # delete potential symlink to tree in webdir/links self.sync.rmfile(os.path.join(self.settings.webdir, "links", name)) @@ -127,6 +128,7 @@ class BootLiteSync: self.sync.retemplate_yum_repos(system,False) def remove_single_system(self, name): + bootloc = utils.tftpboot_location() system_record = self.systems.find(name=name) # rebuild system_list file in webdir self.sync.write_listings() @@ -152,7 +154,7 @@ class BootLiteSync: if distro is not None and distro in [ "ia64", "IA64"]: itanic = True if not itanic: - self.sync.rmfile(os.path.join(self.settings.tftpboot, "pxelinux.cfg", filename)) + self.sync.rmfile(os.path.join(bootloc, "pxelinux.cfg", filename)) else: - self.sync.rmfile(os.path.join(self.settings.tftpboot, filename)) + self.sync.rmfile(os.path.join(bootloc, filename)) diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index 2596906..8a0eadf 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -57,14 +57,15 @@ class BootSync: self.repos = config.repos() self.blend_cache = {} self.load_snippet_cache() + self.bootloc = utils.tftpboot_location() def run(self): """ Syncs the current configuration file with the config tree. Using the Check().run_ functions previously is recommended """ - if not os.path.exists(self.settings.tftpboot): - raise CX(_("cannot find directory: %s") % self.settings.tftpboot) + if not os.path.exists(self.bootloc): + raise CX(_("cannot find directory: %s") % self.bootloc) # run pre-triggers... utils.run_triggers(None, "/var/lib/cobbler/triggers/sync/pre/*") @@ -104,9 +105,9 @@ class BootSync: for loader in self.settings.bootloaders.keys(): path = self.settings.bootloaders[loader] newname = os.path.basename(path) - destpath = os.path.join(self.settings.tftpboot, newname) + destpath = os.path.join(self.bootloc, newname) self.copyfile(path, destpath) - self.copyfile("/var/lib/cobbler/menu.c32", os.path.join(self.settings.tftpboot, "menu.c32")) + self.copyfile("/var/lib/cobbler/menu.c32", os.path.join(self.bootloc, "menu.c32")) def write_dhcp_file(self): """ @@ -278,8 +279,8 @@ class BootSync: if x in ["kickstarts","kickstarts_sys","images","systems","distros","profiles","repo_profile","repo_system"]: # clean out directory contents self.rmtree_contents(path) - self.rmtree_contents(os.path.join(self.settings.tftpboot, "pxelinux.cfg")) - self.rmtree_contents(os.path.join(self.settings.tftpboot, "images")) + self.rmtree_contents(os.path.join(self.bootloc, "pxelinux.cfg")) + self.rmtree_contents(os.path.join(self.bootloc, "images")) def copy_distros(self): """ @@ -297,7 +298,7 @@ class BootSync: self.copy_single_distro_files(d) def copy_single_distro_files(self, d): - for dirtree in [self.settings.tftpboot, self.settings.webdir]: + for dirtree in [self.bootloc, self.settings.webdir]: distros = os.path.join(dirtree, "images") distro_dir = os.path.join(distros,d.name) self.mkdir(distro_dir) @@ -763,7 +764,7 @@ class BootSync: # for tftp only ... if distro.arch in [ "x86", "x86_64", "standard"]: # pxelinux wants a file named $name under pxelinux.cfg - f2 = os.path.join(self.settings.tftpboot, "pxelinux.cfg", f1) + f2 = os.path.join(self.bootloc, "pxelinux.cfg", f1) if distro.arch == "ia64": # elilo expects files to be named "$name.conf" in the root # and can not do files based on the MAC address @@ -771,7 +772,7 @@ class BootSync: print _("Warning: Itanium system object (%s) needs an IP address to PXE") % system.name filename = "%s.conf" % utils.get_config_filename(system,interface=name) - f2 = os.path.join(self.settings.tftpboot, filename) + f2 = os.path.join(self.bootloc, filename) f3 = os.path.join(self.settings.webdir, "systems", f1) @@ -798,7 +799,7 @@ class BootSync: if default is not None: return - fname = os.path.join(self.settings.tftpboot, "pxelinux.cfg", "default") + fname = os.path.join(self.bootloc, "pxelinux.cfg", "default") # read the default template file template_src = open("/etc/cobbler/pxedefault.template") @@ -820,7 +821,7 @@ class BootSync: # save the template. metadata = { "pxe_menu_items" : pxe_menu_items } - outfile = os.path.join(self.settings.tftpboot, "pxelinux.cfg", "default") + outfile = os.path.join(self.bootloc, "pxelinux.cfg", "default") self.apply_template(template_data, metadata, outfile) template_src.close() diff --git a/cobbler/item.py b/cobbler/item.py index dadcd23..f51f959 100644 --- a/cobbler/item.py +++ b/cobbler/item.py @@ -51,7 +51,7 @@ class Item(serializable.Serializable): self.clear(is_subobject) # reset behavior differs for inheritance cases self.parent = '' # all objects by default are not subobjects self.children = {} # caching for performance reasons, not serialized - + self.owners = [] self.log_func = self.config.api.log def clear(self): @@ -117,6 +117,16 @@ class Item(serializable.Serializable): self.name = name return True + def set_owners(self,data): + """ + The owners field is a comment unless using an authz module that pays attention to it, + like authz_ownership, which ships with Cobbler but is off by default. Consult the Wiki + docs for more info on CustomizableAuthorization. + """ + owners = utils.input_string_or_list(data) + self.owners = owners + return True + def set_kernel_options(self,options): """ Kernel options are a space delimited list, diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py index f52ad0b..c40f002 100644 --- a/cobbler/item_distro.py +++ b/cobbler/item_distro.py @@ -32,6 +32,7 @@ class Distro(item.Item): Reset this object. """ self.name = None + self.owners = [] self.kernel = (None, '<<inherit>>')[is_subobject] self.initrd = (None, '<<inherit>>')[is_subobject] self.kernel_options = ({}, '<<inherit>>')[is_subobject] @@ -60,6 +61,7 @@ class Distro(item.Item): """ self.parent = self.load_item(seed_data,'parent') self.name = self.load_item(seed_data,'name') + self.owners = self.load_item(seed_data,'owners',[]) self.kernel = self.load_item(seed_data,'kernel') self.initrd = self.load_item(seed_data,'initrd') self.kernel_options = self.load_item(seed_data,'kernel_options') @@ -165,7 +167,8 @@ class Distro(item.Item): 'breed' : self.breed, 'source_repos' : self.source_repos, 'parent' : self.parent, - 'depth' : self.depth + 'depth' : self.depth, + 'owners' : self.owners } def printable(self): @@ -181,6 +184,7 @@ class Distro(item.Item): buf = buf + _("architecture : %s\n") % self.arch buf = buf + _("ks metadata : %s\n") % self.ks_meta buf = buf + _("breed : %s\n") % self.breed + buf = buf + _("owners : %s\n") % self.owners return buf def remote_methods(self): @@ -191,7 +195,8 @@ class Distro(item.Item): 'kopts' : self.set_kernel_options, 'arch' : self.set_arch, 'ksmeta' : self.set_ksmeta, - 'breed' : self.set_breed + 'breed' : self.set_breed, + 'owners' : self.set_owners } diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py index f229d4c..3145b82 100644 --- a/cobbler/item_profile.py +++ b/cobbler/item_profile.py @@ -34,6 +34,7 @@ class Profile(item.Item): Reset this object. """ self.name = None + self.owners = [] # should not be inheritable self.distro = (None, '<<inherit>>')[is_subobject] self.kickstart = (self.settings.default_kickstart , '<<inherit>>')[is_subobject] self.kernel_options = ({}, '<<inherit>>')[is_subobject] @@ -57,6 +58,7 @@ class Profile(item.Item): self.parent = self.load_item(seed_data,'parent','') self.name = self.load_item(seed_data,'name') + self.owners = self.load_item(seed_data,'owners',[]) self.distro = self.load_item(seed_data,'distro') self.kickstart = self.load_item(seed_data,'kickstart') self.kernel_options = self.load_item(seed_data,'kernel_options') @@ -328,6 +330,7 @@ class Profile(item.Item): """ return { 'name' : self.name, + 'owners' : self.owners, 'distro' : self.distro, 'kickstart' : self.kickstart, 'kernel_options' : self.kernel_options, @@ -342,7 +345,8 @@ class Profile(item.Item): 'virt_type' : self.virt_type, 'virt_path' : self.virt_path, 'dhcp_tag' : self.dhcp_tag, - 'server' : self.server + 'server' : self.server, + } def printable(self): @@ -366,6 +370,7 @@ class Profile(item.Item): buf = buf + _("repos : %s\n") % self.repos buf = buf + _("dhcp tag : %s\n") % self.dhcp_tag buf = buf + _("server : %s\n") % self.server + buf = buf + _("owners : %s\n") % self.owners return buf def remote_methods(self): @@ -385,6 +390,7 @@ class Profile(item.Item): 'virt-bridge' : self.set_virt_bridge, 'virt-cpus' : self.set_virt_cpus, 'dhcp-tag' : self.set_dhcp_tag, - 'server' : self.set_server + 'server' : self.set_server, + 'owners' : self.set_owners } diff --git a/cobbler/item_repo.py b/cobbler/item_repo.py index a7b1f3b..d65d09b 100644 --- a/cobbler/item_repo.py +++ b/cobbler/item_repo.py @@ -161,6 +161,7 @@ class Repo(item.Item): def to_datastruct(self): return { 'name' : self.name, + 'owners' : self.owners, 'mirror' : self.mirror, 'keep_updated' : self.keep_updated, 'priority' : self.priority, @@ -174,6 +175,7 @@ class Repo(item.Item): def printable(self): buf = _("repo : %s\n") % self.name + buf = buf + _("owners : %s\n") % self.owners buf = buf + _("mirror : %s\n") % self.mirror buf = buf + _("keep updated : %s\n") % self.keep_updated buf = buf + _("priority : %s\n") % self.priority @@ -210,6 +212,7 @@ class Repo(item.Item): 'priority' : self.set_priority, 'rpm-list' : self.set_rpm_list, 'createrepo-flags' : self.set_createrepo_flags, - 'yumopts' : self.set_yumopts + 'yumopts' : self.set_yumopts, + 'owners' : self.set_owners } diff --git a/cobbler/item_system.py b/cobbler/item_system.py index 936f1dd..51dd063 100644 --- a/cobbler/item_system.py +++ b/cobbler/item_system.py @@ -30,6 +30,7 @@ class System(item.Item): def clear(self,is_subobject=False): self.name = None + self.owners = None self.profile = None self.kernel_options = {} self.ks_meta = {} @@ -80,6 +81,7 @@ class System(item.Item): self.parent = self.load_item(seed_data, 'parent') self.name = self.load_item(seed_data, 'name') + self.owners = self.load_item(seed_data, 'owners') self.profile = self.load_item(seed_data, 'profile') self.kernel_options = self.load_item(seed_data, 'kernel_options', {}) self.ks_meta = self.load_item(seed_data, 'ks_meta', {}) @@ -336,6 +338,7 @@ class System(item.Item): def to_datastruct(self): return { 'name' : self.name, + 'owners' : self.set_owners, 'profile' : self.profile, 'kernel_options' : self.kernel_options, 'ks_meta' : self.ks_meta, @@ -360,6 +363,7 @@ class System(item.Item): buf = buf + _("virt type : %s\n") % self.virt_type buf = buf + _("virt path : %s\n") % self.virt_path buf = buf + _("server : %s\n") % self.server + buf = buf + _("owners : %s\n") % self.owners counter = 0 for (name,x) in self.interfaces.iteritems(): @@ -405,6 +409,7 @@ class System(item.Item): 'virt-type' : self.set_virt_type, 'modify-interface' : self.modify_interface, 'delete-interface' : self.delete_interface, - 'server' : self.set_server + 'server' : self.set_server, + 'owners' : self.set_owners } diff --git a/cobbler/modules/cli_distro.py b/cobbler/modules/cli_distro.py index 35f5a4b..9e0637f 100644 --- a/cobbler/modules/cli_distro.py +++ b/cobbler/modules/cli_distro.py @@ -47,12 +47,15 @@ class DistroFunction(commands.CobblerFunction): p.add_option("--name", dest="name", help="ex: 'RHEL-5-i386' (REQUIRED)") + if self.matches_args(args,["copy","rename"]): p.add_option("--newname", dest="newname", help="for copy/rename commands") if not self.matches_args(args,["remove","report","list"]): p.add_option("--no-sync", action="store_true", dest="nosync", help="suppress sync for speed") if not self.matches_args(args,["report","list"]): p.add_option("--no-triggers", action="store_true", dest="notriggers", help="suppress trigger execution") + if not self.matches_args(args,["remove","report","list"]): + p.add_option("--owners", dest="owners", help="specify owners for authz_ownership module") if self.matches_args(args,["remove"]): p.add_option("--recursive", action="store_true", dest="recursive", help="also delete child objects") @@ -73,6 +76,8 @@ class DistroFunction(commands.CobblerFunction): obj.set_ksmeta(self.options.ksmeta) if self.options.breed: obj.set_breed(self.options.breed) + if self.options.owners: + obj.set_owners(self.options.owners) return self.object_manipulator_finish(obj, self.api.distros, self.options) diff --git a/cobbler/modules/cli_profile.py b/cobbler/modules/cli_profile.py index e9d1d23..9912607 100644 --- a/cobbler/modules/cli_profile.py +++ b/cobbler/modules/cli_profile.py @@ -46,6 +46,7 @@ class ProfileFunction(commands.CobblerFunction): p.add_option("--kopts", dest="kopts", help="ex: 'noipv6'") p.add_option("--name", dest="name", help="a name for the profile (REQUIRED)") + if "copy" in args or "rename" in args: p.add_option("--newname", dest="newname") @@ -53,6 +54,7 @@ class ProfileFunction(commands.CobblerFunction): p.add_option("--no-sync", action="store_true", dest="nosync", help="suppress sync for speed") if not self.matches_args(args,["report", "list"]): p.add_option("--no-triggers", action="store_true", dest="notriggers", help="suppress trigger execution") + p.add_option("--owners", dest="owners", help="specify owners for authz_ownership module") if self.matches_args(args,["remove"]): p.add_option("--recursive", action="store_true", dest="recursive", help="also delete child objects") @@ -93,6 +95,9 @@ class ProfileFunction(commands.CobblerFunction): if self.options.dhcp_tag: obj.set_dhcp_tag(self.options.dhcp_tag) if self.options.server_override: obj.set_server(self.options.server) + if self.options.owners: + obj.set_owners(self.options.owners) + return self.object_manipulator_finish(obj, self.api.profiles, self.options) diff --git a/cobbler/modules/cli_repo.py b/cobbler/modules/cli_repo.py index 96afa6f..88e45dd 100644 --- a/cobbler/modules/cli_repo.py +++ b/cobbler/modules/cli_repo.py @@ -59,6 +59,8 @@ class RepoFunction(commands.CobblerFunction): p.add_option("--no-sync", action="store_true", dest="nosync", help="suppress sync for speed") if not self.matches_args(args,["report","list"]): p.add_option("--no-triggers", action="store_true", dest="notriggers", help="suppress trigger execution") + if not self.matches_args(args,["remove","report","list"]): + p.add_option("--owners", dest="owners", help="specify owners for authz_ownership module") def run(self): @@ -75,6 +77,9 @@ class RepoFunction(commands.CobblerFunction): if self.options.mirror: obj.set_mirror(self.options.mirror) if self.options.yumopts: obj.set_yumopts(self.options.yumopts) + if self.options.owners: + obj.set_owners(self.options.owners) + return self.object_manipulator_finish(obj, self.api.repos, self.options) diff --git a/cobbler/modules/cli_system.py b/cobbler/modules/cli_system.py index c463b8c..01ead35 100644 --- a/cobbler/modules/cli_system.py +++ b/cobbler/modules/cli_system.py @@ -63,6 +63,7 @@ class SystemFunction(commands.CobblerFunction): if not self.matches_args(args,["remove","report","list"]): + p.add_option("--owners", dest="owners", help="specify owners for authz_ownership module") p.add_option("--profile", dest="profile", help="name of cobbler profile (REQUIRED)") p.add_option("--server-override", dest="server_override", help="overrides server value in settings file") p.add_option("--subnet", dest="subnet", help="for static IP / templating usage") @@ -99,6 +100,9 @@ class SystemFunction(commands.CobblerFunction): if self.options.dhcp_tag: obj.set_dhcp_tag(self.options.dhcp_tag, my_interface) if self.options.virt_bridge: obj.set_virt_bridge(self.options.virt_bridge, my_interface) + if self.options.owners: + obj.set_owners(self.options.owners) + return self.object_manipulator_finish(obj, self.api.systems, self.options) diff --git a/cobbler/settings.py b/cobbler/settings.py index 495a4b5..e3d8a46 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -58,7 +58,6 @@ DEFAULTS = { "server" : "127.0.0.1", "snippetsdir" : "/var/lib/cobbler/snippets", "syslog_port" : 25150, - "tftpboot" : -1, # special, see note below "tftpd_bin" : "/usr/sbin/in.tftpd", "tftpd_conf" : "/etc/xinetd.d/tftp", "webdir" : "/var/www/cobbler", @@ -109,11 +108,6 @@ class Settings(serializable.Serializable): self._attributes = datastruct - # this last attribute is special. In F9, the tftpboot location moves, so - # what we have in settings is not (neccessarily) correct. So instead - # of using settings we determine it by looking at the OS. - self._attributes["tftpboot"] = utils.tftpboot_location() - return self def __getattr__(self,name): diff --git a/cobbler/utils.py b/cobbler/utils.py index 86ff41d..9c770d0 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -230,6 +230,20 @@ def find_kickstart(url): return url return None +def input_string_or_list(options,delim=","): + """ + Accepts a delimited list of stuff or a list, but always returns a list. + """ + if options is None or options == "delete": + return [] + elif type(options) == list: + return options + elif type(options) == str: + tokens = options.split(",") + return tokens + else: + raise CX(_("invalid input type")) + def input_string_or_hash(options,delim=","): """ Older cobbler files stored configurations in a flat way, such that all values for strings. @@ -261,7 +275,7 @@ def input_string_or_hash(options,delim=","): options.pop('',None) return (True, options) else: - raise CX(_("Foreign options type")) + raise CX(_("invalid input type")) def grab_tree(api_handle, obj): """ diff --git a/cobbler/webui/master.py b/cobbler/webui/master.py index b2abf09..157b156 100644 --- a/cobbler/webui/master.py +++ b/cobbler/webui/master.py @@ -33,8 +33,8 @@ VFN=valueForName currentTime=time.time __CHEETAH_version__ = '2.0.1' __CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0) -__CHEETAH_genTime__ = 1205174715.425076 -__CHEETAH_genTimestamp__ = 'Mon Mar 10 14:45:15 2008' +__CHEETAH_genTime__ = 1206550188.6649311 +__CHEETAH_genTimestamp__ = 'Wed Mar 26 12:49:48 2008' __CHEETAH_src__ = 'webui_templates/master.tmpl' __CHEETAH_srcLastModified__ = 'Fri Feb 15 14:47:43 2008' __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine' |