#NEWLINE# def append( table = 'filter' , chain = None , rule = None , family = 'ipv4' ) : #NEWLINE# #INDENT# "\n    Append a rule to the specified table & chain.\n\n    This function accepts a rule in a standard nftables command format,\n        starting with the chain. Trying to force users to adapt to a new\n        method of creating rules would be irritating at best, and we\n        already have a parser that can handle it.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' nftables.append filter input \\\n            rule='input tcp dport 22 log accept'\n\n        IPv6:\n        salt '*' nftables.append filter input \\\n            rule='input tcp dport 22 log accept' \\\n            family=ipv6\n    " #NEWLINE# if ( not chain ) : #NEWLINE# #INDENT# return 'Error: Chain needs to be specified' #NEWLINE# #UNINDENT# if ( not rule ) : #NEWLINE# #INDENT# return 'Error: Rule needs to be specified' #NEWLINE# #UNINDENT# if ( not check_table ( table , family = family ) ) : #NEWLINE# #INDENT# return 'Error: table {0} in family {1} does not exist' . format ( table , family ) #NEWLINE# #UNINDENT# if ( not check_chain ( table , chain , family = family ) ) : #NEWLINE# #INDENT# return 'Error: chain {0} in table {1} in family {2} does not exist' . format ( chain , table , family ) #NEWLINE# #UNINDENT# if check ( table , chain , rule , family = family ) : #NEWLINE# #INDENT# return 'Error: rule {0} chain {1} in table {2} in family {3} already exists' . format ( rule , chain , table , family ) #NEWLINE# #UNINDENT# nft_family = _NFTABLES_FAMILIES [ family ] #NEWLINE# cmd = '{0} add rule {1} {2} {3} {4}' . format ( _nftables_cmd ( ) , nft_family , table , chain , rule ) #NEWLINE# out = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) #NEWLINE# if ( len ( out ) == 0 ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return False