コード例 #1
0
def run(api, args) -> int:
    """
    The method runs the trigger, meaning this logs that an installation has ended.

    The list of args should have three elements:
        - 0: system or profile
        - 1: the name of the system or profile
        - 2: the ip or a "?"

    :param api: This parameter is unused currently.
    :param args: An array of three elements. Type (system/profile), name and ip. If no ip is present use a ``?``.
    :return: Always 0
    """
    objtype = args[0]
    name = args[1]
    ip = args[2]

    if not validate.validate_obj_type(objtype):
        return 1

    if not api.find_items(objtype, name=name, return_list=False):
        return 1

    if not (ip == "?" or validate.ipv4_address(ip) or validate.ipv6_address(ip)):
        return 1

    # FIXME: use the logger

    with open("/var/log/cobbler/install.log", "a+") as fd:
        fd.write("%s\t%s\t%s\tstop\t%s\n" % (objtype, name, ip, time.time()))

    return 0
コード例 #2
0
ファイル: pre_log.py プロジェクト: holmesb/cobbler
def run(api, args: list) -> int:
    """
    The method runs the trigger, meaning this logs that an installation has started.

    The list of args should have three elements:
        - 0: system or profile
        - 1: the name of the system or profile
        - 2: the ip or a "?"

    :param api: This parameter is currently unused.
    :param args: Already described above.
    :return: A "0" on success.
    """
    objtype = args[0]
    name = args[1]
    ip = args[2]

    if not validate.validate_obj_type(objtype):
        return 1

    if not api.find_items(objtype, name=name, return_list=False):
        return 1

    if not (ip == "?" or validate.ipv4_address(ip) or validate.ipv6_address(ip)):
        return 1

    # FIXME: use the logger

    with open("/var/log/cobbler/install.log", "a+") as fd:
        fd.write("%s\t%s\t%s\tstart\t%s\n" % (objtype, name, ip, time.time()))

    return 0
コード例 #3
0
    def next_server_v6(self, server: str = ""):
        """
        Setter for the next server value.

        :param server: The address of the IPv6 next server. Must be a string or ``enums.VALUE_INHERITED``.
        :raises TypeError: In case server is no string.
        """
        if not isinstance(server, str):
            raise TypeError("Server must be a string.")
        if server == enums.VALUE_INHERITED:
            self._next_server_v6 = enums.VALUE_INHERITED
        else:
            self._next_server_v6 = validate.ipv6_address(server)
コード例 #4
0
ファイル: system.py プロジェクト: nodeg/cobbler
    def ipv6_address(self, address: str):
        """
        Set IPv6 address on interface.

        :param address: IP address
        :raises CX
        """
        address = validate.ipv6_address(address)
        if address != "" and self.__api.settings(
        ).allow_duplicate_ips is False:
            matched = self.__api.find_items("system",
                                            {"ipv6_address": address})
            if len(matched) > 0:
                raise CX("IP address duplicated: %s" % address)
        self._ipv6_address = address
コード例 #5
0
ファイル: item_system.py プロジェクト: inthecloud247/cobbler
    def set_ipv6_address(self, address, interface):
        """
        Set IPv6 address on interface.

        @param: str address (ip address)
        @param: str interface (interface name)
        @returns: True or CX
        """
        address = validate.ipv6_address(address)
        if address != "" and utils.input_boolean(self.collection_mgr._settings.allow_duplicate_ips) is False:
            matched = self.collection_mgr.api.find_items("system", {"ipv6_address": address})
            for x in matched:
                if x.name != self.name:
                    raise CX("IP address duplicated: %s" % address)

        intf = self.__get_interface(interface)
        intf["ipv6_address"] = address
コード例 #6
0
ファイル: item_system.py プロジェクト: wujcheng/cobbler-1
    def set_ipv6_address(self, address, interface):
        """
        Set IPv6 address on interface.

        @param: str address (ip address)
        @param: str interface (interface name)
        @returns: True or CX
        """
        address = validate.ipv6_address(address)
        if address != "" and utils.input_boolean(self.collection_mgr._settings.allow_duplicate_ips) is False:
            matched = self.collection_mgr.api.find_items("system", {"ipv6_address": address})
            for x in matched:
                if x.name != self.name:
                    raise CX("IP address duplicated: %s" % address)

        intf = self.__get_interface(interface)
        intf["ipv6_address"] = address
コード例 #7
0
ファイル: system.py プロジェクト: LeoDemoniac/cobbler
    def set_ipv6_address(self, address: str, interface: str):
        """
        Set IPv6 address on interface.

        :param address: IP address
        :param interface: interface name
        :returns: True or CX
        """
        address = validate.ipv6_address(address)
        if address != "" and self.collection_mgr.settings(
        ).allow_duplicate_ips is False:
            matched = self.collection_mgr.api.find_items(
                "system", {"ipv6_address": address})
            for x in matched:
                if x.name != self.name:
                    raise CX("IP address duplicated: %s" % address)

        intf = self.__get_interface(interface)
        intf["ipv6_address"] = address