How to use the cobbler.utils._ 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 / cobbler / items / distro.py View on Github external
def set_initrd(self, initrd):
        """
        Specifies an initrd image.  Path search works as in set_kernel.
        File must be named appropriately.
        """
        if initrd is None or initrd == "":
            raise CX("initrd not specified")
        if utils.find_initrd(initrd):
            self.initrd = initrd
            return
        raise CX(_("initrd not found"))
github cobbler / cobbler / cobbler / collections / collection.py View on Github external
ref.enable_menu = 0
                    self.lite_sync.add_single_profile(ref.name)
                elif isinstance(ref, distro.Distro):
                    self.lite_sync.add_single_distro(ref.name)
                elif isinstance(ref, image.Image):
                    self.lite_sync.add_single_image(ref.name)
                elif isinstance(ref, repo.Repo):
                    pass
                elif isinstance(ref, mgmtclass.Mgmtclass):
                    pass
                elif isinstance(ref, package.Package):
                    pass
                elif isinstance(ref, file.File):
                    pass
                else:
                    print(_("Internal error. Object type not recognized: %s") % type(ref))
            if not with_sync and quick_pxe_update:
                if isinstance(ref, system.System):
                    self.lite_sync.update_system_netboot_status(ref.name)

            # save the tree, so if neccessary, scripts can examine it.
            if with_triggers:
                utils.run_triggers(self.api, ref, "/var/lib/cobbler/triggers/change/*", [], logger)
                utils.run_triggers(self.api, ref, "/var/lib/cobbler/triggers/add/%s/post/*" % self.collection_type(), [], logger)

        # update children cache in parent object
        parent = ref.get_parent()
        if parent is not None:
            parent.children[ref.name] = ref
github cobbler / cobbler / cobbler / items / repo.py View on Github external
def set_environment(self, options):
        """
        Yum can take options from the environment.  This puts them there before
        each reposync.
        """
        (success, value) = utils.input_string_or_dict(options, allow_multiples=False)
        if not success:
            raise CX(_("invalid environment options"))
        else:
            self.environment = value
github cobbler / cobbler / cobbler / items / system.py View on Github external
def set_ipv6_default_gateway(self, address, interface):
        intf = self.__get_interface(interface)
        if address == "" or utils.is_ip(address):
            intf["ipv6_default_gateway"] = address.strip()
            return
        raise CX(_("invalid format for IPv6 IP address (%s)") % address)
github cobbler / cobbler / cobbler / items / repo.py View on Github external
["mirror_locally", True, 0, "Mirror locally", True, "Copy files or just reference the repo externally?", 0, "bool"],
    ["name", "", 0, "Name", True, "Ex: f10-i386-updates", 0, "str"],
    ["owners", "SETTINGS:default_ownership", 0, "Owners", True, "Owners list for authz_ownership (space delimited)", [], "list"],
    ["priority", 99, 0, "Priority", True, "Value for yum priorities plugin, if installed", 0, "int"],
    ["proxy", "<>", 0, "Proxy information", True, "http://example.com:8080, or <> to use proxy_url_ext from settings, blank or <> for no proxy", [], "str"],
    ["rpm_list", [], 0, "RPM List", True, "Mirror just these RPMs (yum only)", 0, "list"],
    ["yumopts", {}, 0, "Yum Options", True, "Options to write to yum config file", 0, "dict"],
]


class Repo(item.Item):
    """
    A Cobbler repo object.
    """

    TYPE_NAME = _("repo")
    COLLECTION_TYPE = "repo"

    def __init__(self, *args, **kwargs):
        super(Repo, self).__init__(*args, **kwargs)
        self.breed = None
        self.arch = None
        self.environment = None
        self.yumopts = None

    #
    # override some base class methods first (item.Item)
    #

    def make_clone(self):

        _dict = self.to_dict()
github cobbler / cobbler / cobbler / items / profile.py View on Github external
["virt_bridge", "SETTINGS:default_virt_bridge", '<>', "Virt Bridge", True, "", 0, "str"],
    ["virt_cpus", 1, '<>', "Virt CPUs", True, "integer", 0, "int"],
    ["virt_disk_driver", "SETTINGS:default_virt_disk_driver", '<>', "Virt Disk Driver Type", True, "The on-disk format for the virtualization disk", validate.VIRT_DISK_DRIVERS, "str"],
    ["virt_file_size", "SETTINGS:default_virt_file_size", '<>', "Virt File Size(GB)", True, "", 0, "int"],
    ["virt_path", "", '<>', "Virt Path", True, "Ex: /directory OR VolGroup00", 0, "str"],
    ["virt_ram", "SETTINGS:default_virt_ram", '<>', "Virt RAM (MB)", True, "", 0, "int"],
    ["virt_type", "SETTINGS:default_virt_type", '<>', "Virt Type", True, "Virtualization technology to use", validate.VIRT_TYPES, "str"],
]


class Profile(item.Item):
    """
    A Cobbler profile object.
    """

    TYPE_NAME = _("profile")
    COLLECTION_TYPE = "profile"

    def __init__(self, *args, **kwargs):
        super(Profile, self).__init__(*args, **kwargs)
        self.kernel_options = {}
        self.kernel_options_post = {}
        self.autoinstall_meta = {}
        self.fetchable_files = {}
        self.boot_files = {}
        self.template_files = {}

    #
    # override some base class methods first (item.Item)
    #

    def make_clone(self):
github cobbler / cobbler / cobbler / items / distro.py View on Github external
def set_boot_loader(self, name):
        try:
            # If we have already loaded the supported boot loaders from
            # the signature, use that data
            supported_distro_boot_loaders = self.supported_boot_loaders
        except:
            # otherwise, refresh from the signatures / defaults
            self.supported_boot_loaders = utils.get_supported_distro_boot_loaders(self)
            supported_distro_boot_loaders = self.supported_boot_loaders
        if name not in supported_distro_boot_loaders:
            raise CX(_("Invalid boot loader name: %s. Supported boot loaders are: %s" %
                       (name, ' '.join(supported_distro_boot_loaders))))
        self.boot_loader = name
github cobbler / cobbler / cobbler / modules / managers / manage_bind.py View on Github external
tokens.reverse()
                arpa = '.'.join(tokens) + '.in-addr.arpa'
                #
            metadata['reverse_zones'].append((zone, arpa))
            txt = """
zone "%(arpa)s." {
    type master;
    file "%(zone)s";
};
""" % {'arpa': arpa, 'zone': zone}
            metadata['zone_include'] = metadata['zone_include'] + txt

        try:
            f2 = open(template_file, "r")
        except:
            raise CX(_("error reading template from file: %s") % template_file)
        template_data = ""
        template_data = f2.read()
        f2.close()

        if self.logger is not None:
            self.logger.info("generating %s" % settings_file)
        self.templar.render(template_data, metadata, settings_file, None)
github cobbler / cobbler / cobbler / settings.py View on Github external
def from_dict(self, _dict):
        """
        Modify this object to load values in dictionary.
        """
        if _dict is None:
            print(_("warning: not loading empty structure for %s") % self.filename())
            return

        self._clear()
        self.__dict__.update(_dict)

        return self
github cobbler / cobbler / cobbler / collections / collection.py View on Github external
match = self.api.find_distro(ref.name)
            elif isinstance(ref, repo.Repo):
                match = self.api.find_repo(ref.name)
            elif isinstance(ref, image.Image):
                match = self.api.find_image(ref.name)
            elif isinstance(ref, mgmtclass.Mgmtclass):
                match = self.api.find_mgmtclass(ref.name)
            elif isinstance(ref, package.Package):
                match = self.api.find_package(ref.name)
            elif isinstance(ref, file.File):
                match = self.api.find_file(ref.name)
            else:
                raise CX("internal error, unknown object type")

            if match:
                raise CX(_("An object already exists with that name.  Try 'edit'?"))

        # the duplicate mac/ip checks can be disabled.
        if not check_for_duplicate_netinfo:
            return

        if isinstance(ref, system.System):
            for (name, intf) in list(ref.interfaces.items()):
                match_ip = []
                match_mac = []
                match_hosts = []
                input_mac = intf["mac_address"]
                input_ip = intf["ip_address"]
                input_dns = intf["dns_name"]
                if not self.api.settings().allow_duplicate_macs and input_mac is not None and input_mac != "":
                    match_mac = self.api.find_system(mac_address=input_mac, return_list=True)
                if not self.api.settings().allow_duplicate_ips and input_ip is not None and input_ip != "":