コード例 #1
0
ファイル: utils_test.py プロジェクト: openSUSE/cobbler
def test_get_host_ip():
    # Arrange

    # Act
    result = utils.get_host_ip("10.0.0.1")

    # Assert
    assert result == "0A000001"
コード例 #2
0
ファイル: system.py プロジェクト: bruncsak/cobbler
    def get_config_filename(self,
                            interface: str,
                            loader: Optional[str] = None):
        """
        The configuration file for each system pxe uses is either
        a form of the MAC address of the hex version of the IP.  If none
        of that is available, just use the given name, though the name
        given will be unsuitable for PXE configuration (For this, check
        system.is_management_supported()). This same file is used to store
        system config information in the Apache tree, so it's still relevant.

        :param interface: Name of the interface.
        :param loader: Bootloader type.
        """

        boot_loaders = self.get_boot_loaders()
        if loader is None:
            if "grub" in boot_loaders or len(boot_loaders) < 1:
                loader = "grub"
            else:
                loader = boot_loaders[0]

        if interface not in self.interfaces:
            return None

        if self.name == "default":
            if loader == "grub":
                return None
            return "default"

        mac = self.get_mac_address(interface)
        ip = self.get_ip_address(interface)
        if mac is not None and mac != "":
            if loader == "grub":
                return mac.lower()
            else:
                return "01-" + "-".join(mac.split(":")).lower()
        elif ip is not None and ip != "":
            return utils.get_host_ip(ip)
        else:
            return self.name
コード例 #3
0
ファイル: item_system.py プロジェクト: andrewwyatt/cobbler
    def get_config_filename(self, interface, loader=None):
        """
        The configuration file for each system pxe uses is either
        a form of the MAC address of the hex version of the IP.  If none
        of that is available, just use the given name, though the name
        given will be unsuitable for PXE configuration (For this, check
        system.is_management_supported()). This same file is used to store
        system config information in the Apache tree, so it's still relevant.

        :param loader: Bootloader type.
        :type loader: str
        :param interface: Name of the interface.
        :type interface: str
        """

        if loader is None:
            loader = self.boot_loader

        if interface not in self.interfaces:
            return None

        if self.name == "default":
            if loader == "grub":
                return None
            return "default"

        mac = self.get_mac_address(interface)
        ip = self.get_ip_address(interface)
        if mac is not None and mac != "":
            if loader == "grub":
                return mac.lower()
            else:
                return "01-" + "-".join(mac.split(":")).lower()
        elif ip is not None and ip != "":
            return utils.get_host_ip(ip)
        else:
            return self.name