def addKSTree(self, username, password, channel_label, ks_label, path, install_type, tree_type, clear, files, pkgs, ignore_lint_errors, commit): log_debug(3) self._auth(username, password) # channel = rhnChannel.channel_info(channel_label) # if channel is '': # raise rhnFault(40, 'Could not lookup channel ' + channel_label) # # channel_id = channel['id'] kstree = rhnKickstart.lookup_tree(ks_label, pkgs) if kstree != None and clear: kstree.delete_tree() kstree = None if kstree == None: boot_image = ks_label kstree = rhnKickstart.create_tree(ks_label, channel_label, path, boot_image, tree_type, install_type, pkgs) # Firstly, we should lint the tree, and if we're not set to ignore linting errors # we error. lint_results = kstree.lint_tree() if lint_results != None and not ignore_lint_errors: rhnSQL.rollback() raise rhnFault (2102, """ The following packages in the kickstart tree were not found in the channel: %s """ % lint_results, explain=0) kstree.clear_files() for file in files: if kstree.has_file(file): continue else: log_debug(3, 'trying to insert ' + file['last_modified'] + ' as last_modified') kstree.add_file(file) if commit: rhnSQL.commit() message = 'Success. Committing transaction.' else: rhnSQL.rollback() message = 'Success. Rolling back transaction. --commit not specified' return message
def delKSTree(self, username, password, ks_label, commit): log_debug(3) self._auth(username, password) kstree = rhnKickstart.lookup_tree(ks_label) if not isinstance(kstree, rhnKickstart.Kickstart): message = 'Kickstart tree not found' return message else: kstree.delete_tree() if commit: rhnSQL.commit() message = 'Success. Committing transaction.' else: rhnSQL.rollback() message = 'Success. Rolling back transaction. --commit not specified' return message