How to use the cobbler.commands.CobblerFunction function in cobbler

To help you get started, we’ve selected a few cobbler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cobbler / cobbler / obsolete / cli_system.py View on Github external
"""

import distutils.sysconfig
import sys

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

import utils
import cobbler.item_system as item_system
import cobbler.commands as commands
from cexceptions import *


class SystemFunction(commands.CobblerFunction):

    def help_me(self):
        return commands.HELP_FORMAT % ("cobbler system"," [ARGS]")

    def command_name(self):
        return "system"

    def subcommands(self):
        return ["add","copy","dumpvars","edit","find","getks","poweroff","poweron","list","reboot","remove","rename","report"]

    def add_options(self, p, args):
        # FIXME: must create per-interface fields also.  Do this manually?
        rc = utils.add_options_from_fields(p, item_system.FIELDS, args)
        p.add_option("--interface",dest="interface",help="which interface(s) to add/edit?",default="eth0")
        p.add_option("--delete-interface",dest="delete_interface",help="delete named interface(s) from the system object")
        return rc
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
########################################################

class ValidateKsFunction(commands.CobblerFunction):

    def help_me(self):
        return HELP_FORMAT % ("cobbler validateks","")

    def command_name(self):
        return "validateks"
 
    def run(self):
        return self.api.validateks()

########################################################

class BuildIsoFunction(commands.CobblerFunction):

    def add_options(self,p,args): 
        p.add_option("--iso",      dest="isoname",  help="(OPTIONAL) output ISO to this path")
        p.add_option("--profiles", dest="profiles", help="(OPTIONAL) use these profiles only")
        p.add_option("--systems",  dest="systems",  help="(OPTIONAL) use these systems only")
        p.add_option("--tempdir",  dest="tempdir",  help="(OPTIONAL) working directory")
        p.add_option("--distro",   dest="distro",   help="(OPTIONAL) used with --standalone to create a distro-based ISO including all associated profiles/systems")
        p.add_option("--standalone", dest="standalone", action="store_true", help="(OPTIONAL) creates a standalone ISO with all required distro files on it")
        p.add_option("--source",   dest="source",   help="(OPTIONAL) used with --standalone to specify a source for the distribution files")
        p.add_option("--exclude-dns", dest="exclude_dns", action="store_true", help="(OPTIONAL) prevents addition of name server addresses to the kernel boot options")

    def help_me(self):
       return HELP_FORMAT % ("cobbler buildiso","[ARGS]")
    
    def command_name(self):
       return "buildiso"
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
return HELP_FORMAT % ("cobbler reposync","[ARGS]")

    def command_name(self):
        return "reposync"

    def add_options(self, p, args):
        p.add_option("--only",           dest="only",             help="update only this repository name")
        p.add_option("--tries",          dest="tries",            help="try each repo this many times", default=1)
        p.add_option("--no-fail",        dest="nofail",           help="don't stop reposyncing if a failure occurs", action="store_true")

    def run(self):
        return self.api.reposync(self.options.only, tries=self.options.tries, nofail=self.options.nofail)

########################################################

class ValidateKsFunction(commands.CobblerFunction):

    def help_me(self):
        return HELP_FORMAT % ("cobbler validateks","")

    def command_name(self):
        return "validateks"
 
    def run(self):
        return self.api.validateks()

########################################################

class BuildIsoFunction(commands.CobblerFunction):

    def add_options(self,p,args): 
        p.add_option("--iso",      dest="isoname",  help="(OPTIONAL) output ISO to this path")
github cobbler / cobbler / obsolete / cli_network.py View on Github external
"""

import distutils.sysconfig
import sys

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

from utils import _, _IP, _CIDR
import utils
import cobbler.commands as commands
from cexceptions import *
import cobbler.item_network as item_network

class NetworkFunction(commands.CobblerFunction):

    def help_me(self):
        return commands.HELP_FORMAT % ("cobbler network"," [ARGS]")

    def command_name(self):
        return "network"

    def subcommands(self):
        return [ "add", "copy", "dumpvars", "edit", "find", "list", "remove", "rename", "report" ]

    def add_options(self, p, args):
        return utils.add_options_from_fields(p, item_network.FIELDS, args)

    def run(self):
        if self.args and "find" in self.args:
            items = self.api.find_network(return_list=True, no_errors=True, **self.options.__dict__)
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
class ReserializeFunction(commands.CobblerFunction):

    def help_me(self):
        return "" # hide

    def command_name(self):
        return "reserialize"

    def run(self):
        # already deserialized when API is instantiated
        # this just saves files in new config format (if any)
        return self.api.serialize()

########################################################

class ListFunction(commands.CobblerFunction):

    def help_me(self):
        return HELP_FORMAT % ("cobbler list","[ARGS]")

    def command_name(self):
        return "list"

    def add_options(self, p, args):
        p.add_option("--what",              dest="what",          default="all", help="all/distros/profiles/systems/repos")
     
    def run(self):
        if self.options.what not in [ "all", "distros", "profiles", "systems", "repos", "images" ]:
            raise CX(_("invalid value for --what"))
        if self.options.what in ["all"]:
            self.list_tree(self.api.distros(),0)
            self.list_tree(self.api.repos(),0)
github cobbler / cobbler / obsolete / cli_image.py View on Github external
"""

import distutils.sysconfig
import sys

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

import utils
import cobbler.item_image as item_image
import cobbler.commands as commands
import cexceptions


class ImageFunction(commands.CobblerFunction):

    def help_me(self):
        return commands.HELP_FORMAT % ("cobbler image"," [ARGS]")

    def command_name(self):
        return "image"

    def subcommands(self):
        return [ "add", "copy", "dumpvars", "edit", "find", "list", "remove", "rename", "report" ]

    def add_options(self, p, args):
        return utils.add_options_from_fields(p, item_image.FIELDS, args)

    def run(self):

        if self.args and "find" in self.args:
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
def help_me(self):
       return HELP_FORMAT % ("cobbler get-loaders","")

   def command_name(self):
       return "get-loaders"
    
   def add_options(self, p, args):
       p.add_option("--force", dest="force", action="store_true", help="overwrite any existing content in /var/lib/cobbler/loaders")

   def run(self):
       status = self.api.dlcontent(force=self.options.force)
       return status

########################################################

class ImportFunction(commands.CobblerFunction):
    
    def help_me(self):
        return HELP_FORMAT % ("cobbler import","[ARGS]")

    def command_name(self):
        return "import"

    def add_options(self, p, args):
        p.add_option("--arch",               dest="arch",               help="explicitly specify the architecture being imported (RECOMENDED)")
        p.add_option("--breed",              dest="breed",              help="explicitly specify the breed being imported (RECOMENDED)")
        p.add_option("--os-version",         dest="os_version",         help="explicitly specify the version being imported (RECOMENDED)")
        p.add_option("--path",               dest="mirror",             help="local path or rsync location (REQUIRED)")
        p.add_option("--mirror",             dest="mirror_alt",         help="alias for --path")
        p.add_option("--name",               dest="name",               help="name, ex 'RHEL-5', (REQUIRED)")
        p.add_option("--available-as",       dest="available_as",       help="do not mirror, use this as install tree base")
        p.add_option("--kickstart",          dest="kickstart_file",     help="use the kickstart file specified as the profile's kickstart file, do not auto-assign")
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
def add_options(self, p, args):
        p.add_option("--verbose", dest="verbose", action="store_true", help="run sync with more output")
     
    def help_me(self):
        return HELP_FORMAT % ("cobbler sync","")

    def command_name(self):
        return "sync"

    def run(self):
        return self.api.sync(verbose=self.options.verbose)

########################################################

class RepoSyncFunction(commands.CobblerFunction):

    def help_me(self):
        return HELP_FORMAT % ("cobbler reposync","[ARGS]")

    def command_name(self):
        return "reposync"

    def add_options(self, p, args):
        p.add_option("--only",           dest="only",             help="update only this repository name")
        p.add_option("--tries",          dest="tries",            help="try each repo this many times", default=1)
        p.add_option("--no-fail",        dest="nofail",           help="don't stop reposyncing if a failure occurs", action="store_true")

    def run(self):
        return self.api.reposync(self.options.only, tries=self.options.tries, nofail=self.options.nofail)

########################################################
github cobbler / cobbler / obsolete / cli_misc.py View on Github external
"""

import distutils.sysconfig
import sys
import time

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

from utils import _
import cobbler.commands as commands
from cexceptions import *
HELP_FORMAT = commands.HELP_FORMAT

class HardLinkFunction(commands.CobblerFunction):
    def help_me(self):
        return HELP_FORMAT % ("cobbler hardlink","")

    def command_name(self):
        return "hardlink"

    def add_options(self, p, args):
        pass

    def run(self):
        self.api.hardlink()

########################################################

class CheckFunction(commands.CobblerFunction):
github cobbler / cobbler / obsolete / cli_report.py View on Github external
"""

import distutils.sysconfig
import sys

plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
sys.path.insert(0, mod_path)

from utils import _, get_random_mac
import cobbler.commands as commands
from cexceptions import *
HELP_FORMAT = commands.HELP_FORMAT


class ReportFunction(commands.CobblerFunction):
    
    def help_me(self):
        return HELP_FORMAT % ("cobbler report","[ARGS]")

    def command_name(self):
        return "report"

    def add_options(self, p, args):
        p.add_option("--what",              dest="what",      default="all",   help="distros/profiles/systems/repos")
        p.add_option("--name",              dest="name",                       help="report on just this object")
        p.add_option("--format",            dest="type",      default="text",  help="text/csv/trac/doku/mediawiki")
        p.add_option("--fields",            dest="fields",    default="all" ,  help="what fields to display")
        p.add_option("--no-headers",         dest="noheaders", help="don't output headers", action='store_true', default=False)


    def run(self):