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
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
def set_gateway(self, gateway): """ Set a gateway IPv4 address. @param: str gateway (ip address) @returns: True or CX """ self.gateway = validate.ipv4_address(gateway)
def set_gateway(self, gateway: str): """ Set a gateway IPv4 address. :param gateway: IP address :returns: True or CX """ self.gateway = validate.ipv4_address(gateway)
def if_gateway(self, gateway: str): """ Set the per-interface gateway. :param gateway: IPv4 address for the gateway :returns: True or CX """ self._if_gateway = validate.ipv4_address(gateway)
def set_next_server(self, server): if server in [None, ""]: self.next_server = "<<inherit>>" else: server = server.strip() if server != "<<inherit>>": self.next_server = validate.ipv4_address(server) else: self.next_server = server
def set_if_gateway(self, gateway, interface): """ Set the per-interface gateway. @param: str gateway (ipv4 address for the gateway) @param: str interface (interface name) @returns: True or CX """ intf = self.__get_interface(interface) intf["if_gateway"] = validate.ipv4_address(gateway)
def set_if_gateway(self, gateway: str, interface: str): """ Set the per-interface gateway. :param gateway: IPv4 address for the gateway :param interface: interface name :returns: True or CX """ intf = self.__get_interface(interface) intf["if_gateway"] = validate.ipv4_address(gateway)
def ip_address(self, address: str): """ Set IPv4 address on interface. :param address: IP address :raises ValueError: In case the IP address is already existing inside Cobbler. """ address = validate.ipv4_address(address) if address != "" and not self.__api.settings().allow_duplicate_ips: matched = self.__api.find_items("system", {"ip_address": address}) if len(matched) > 0: raise ValueError("IP address duplicated: %s" % address) self._ip_address = address
def next_server_v4(self, server: str = ""): """ Setter for the next server value. :param server: The address of the IPv4 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_v4 = enums.VALUE_INHERITED else: self._next_server_v4 = validate.ipv4_address(server)
def set_next_server(self, server): """ Setter for the next server value. :param server: If this is None or an emtpy string this will be reset to be inherited from the parent object. """ if server in [None, ""]: self.next_server = "<<inherit>>" else: server = server.strip() if server != "<<inherit>>": self.next_server = validate.ipv4_address(server) else: self.next_server = server
def set_ip_address(self, address, interface): """ Set IPv4 address on interface. @param: str address (ip address) @param: str interface (interface name) @returns: True or CX """ address = validate.ipv4_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", {"ip_address": address}) for x in matched: if x.name != self.name: raise CX("IP address duplicated: %s" % address) intf = self.__get_interface(interface) intf["ip_address"] = address
def set_ip_address(self, address: str, interface: str): """ Set IPv4 address on interface. :param address: IP address :param interface: interface name :returns: True or CX """ address = validate.ipv4_address(address) if address != "" and self.collection_mgr.settings( ).allow_duplicate_ips is False: matched = self.collection_mgr.api.find_items( "system", {"ip_address": address}) for x in matched: if x.name != self.name: raise CX("IP address duplicated: %s" % address) intf = self.__get_interface(interface) intf["ip_address"] = address
def set_next_server(self, server): if server is None or server == "" or server == "<<inherit>>": self.next_server = "<<inherit>>" else: server = server.strip() self.next_server = validate.ipv4_address(server)
def set_next_server(self, server): if server is None or server == "": self.next_server = "<<inherit>>" else: self.next_server = validate.ipv4_address(server)