diff options
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/commands.py | 14 | ||||
-rw-r--r-- | cobbler/modules/cli_distro.py | 4 | ||||
-rw-r--r-- | cobbler/modules/cli_profile.py | 5 | ||||
-rw-r--r-- | cobbler/modules/cli_repo.py | 4 | ||||
-rw-r--r-- | cobbler/modules/cli_system.py | 3 |
5 files changed, 28 insertions, 2 deletions
diff --git a/cobbler/commands.py b/cobbler/commands.py index 6bb0419..2dc627b 100644 --- a/cobbler/commands.py +++ b/cobbler/commands.py @@ -241,6 +241,10 @@ class CobblerFunction: Boilerplate for objects that offer add/edit/delete/remove/copy functionality. """ + clobber = False + if "add" in self.args: + clobber = options.clobber + if "copy" in self.args: # or "rename" in self.args: if self.options.newname: obj = obj.make_clone() @@ -267,10 +271,16 @@ class CobblerFunction: if "add" in self.args: if obj.COLLECTION_TYPE == "system": # duplicate names and netinfo are both bad. - rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=True, check_for_duplicate_netinfo=True) + if not clobber: + rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=True, check_for_duplicate_netinfo=True) + else: + rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=False, check_for_duplicate_netinfo=True) else: # duplicate names are bad - rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=True, check_for_duplicate_netinfo=False) + if not clobber: + rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=True, check_for_duplicate_netinfo=False) + else: + rc = collect_fn().add(obj, save=True, with_sync=opt_sync, with_triggers=opt_triggers, check_for_duplicate_names=False, check_for_duplicate_netinfo=False) else: # editing or copying (but not renaming), so duplicate netinfo # CAN be bad, duplicate names are already handled, though diff --git a/cobbler/modules/cli_distro.py b/cobbler/modules/cli_distro.py index 9e0637f..8c7b70f 100644 --- a/cobbler/modules/cli_distro.py +++ b/cobbler/modules/cli_distro.py @@ -40,6 +40,9 @@ class DistroFunction(commands.CobblerFunction): if not self.matches_args(args,["remove","report","list"]): p.add_option("--arch", dest="arch", help="ex: x86, x86_64, ia64") p.add_option("--breed", dest="breed", help="ex: redhat, debian, suse") + if self.matches_args(args,["add"]): + p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true") + if not self.matches_args(args,["remove","report","list"]): p.add_option("--initrd", dest="initrd", help="absolute path to initrd.img (REQUIRED)") p.add_option("--kernel", dest="kernel", help="absolute path to vmlinuz (REQUIRED)") p.add_option("--kopts", dest="kopts", help="ex: 'noipv6'") @@ -48,6 +51,7 @@ 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"]): diff --git a/cobbler/modules/cli_profile.py b/cobbler/modules/cli_profile.py index 9912607..0bf4b8c 100644 --- a/cobbler/modules/cli_profile.py +++ b/cobbler/modules/cli_profile.py @@ -36,6 +36,11 @@ class ProfileFunction(commands.CobblerFunction): return [ "add", "edit", "copy", "rename", "remove", "list", "report" ] def add_options(self, p, args): + + if self.matches_args(args,["add"]): + p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true") + + if not self.matches_args(args,["remove","report","list"]): p.add_option("--distro", dest="distro", help="ex: 'RHEL-5-i386' (REQUIRED)") diff --git a/cobbler/modules/cli_repo.py b/cobbler/modules/cli_repo.py index 88e45dd..e8ec04a 100644 --- a/cobbler/modules/cli_repo.py +++ b/cobbler/modules/cli_repo.py @@ -37,9 +37,13 @@ class RepoFunction(commands.CobblerFunction): def add_options(self, p, args): + if not self.matches_args(args,["remove","report","list"]): p.add_option("--arch", dest="arch", help="overrides repo arch if required") + if self.matches_args(args,["add"]): + p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true") + if not self.matches_args(args,["remove","report","list"]): p.add_option("--createrepo-flags", dest="createrepo_flags", help="additional flags for createrepo") p.add_option("--keep-updated", dest="keep_updated", help="update on each reposync, yes/no") diff --git a/cobbler/modules/cli_system.py b/cobbler/modules/cli_system.py index b173b4b..34c8886 100644 --- a/cobbler/modules/cli_system.py +++ b/cobbler/modules/cli_system.py @@ -37,6 +37,9 @@ class SystemFunction(commands.CobblerFunction): def add_options(self, p, args): + if self.matches_args(args,["add"]): + p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true") + if not self.matches_args(args,["remove","report","list"]): p.add_option("--dhcp-tag", dest="dhcp_tag", help="for use in advanced DHCP configurations") p.add_option("--gateway", dest="gateway", help="for static IP / templating usage") |