#NEWLINE# def new_chain( table = 'filter' , chain = None , table_type = None , hook = None , priority = None , family = 'ipv4' ) : #NEWLINE# #INDENT# "\n    .. versionadded:: 2014.7.0\n\n    Create new chain to the specified table.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' nftables.new_chain filter input\n\n        salt '*' nftables.new_chain filter input \\\n                table_type=filter hook=input priority=0\n\n        salt '*' nftables.new_chain filter foo\n\n        IPv6:\n        salt '*' nftables.new_chain filter input family=ipv6\n\n        salt '*' nftables.new_chain filter input \\\n                table_type=filter hook=input priority=0 family=ipv6\n\n        salt '*' nftables.new_chain filter foo family=ipv6\n    " #NEWLINE# if ( not chain ) : #NEWLINE# #INDENT# return 'Error: Chain needs to be specified' #NEWLINE# #UNINDENT# if ( not check_table ( family , family = family ) ) : #NEWLINE# #INDENT# return 'Error: table {0} in family {1} does not exist' . format ( table , family ) #NEWLINE# #UNINDENT# if check_chain ( table , chain , family = family ) : #NEWLINE# #INDENT# return 'Error: chain {0} in table {1} in family {2} already exists' . format ( chain , table , family ) #NEWLINE# #UNINDENT# nft_family = _NFTABLES_FAMILIES [ family ] #NEWLINE# cmd = '{0} add chain {1} {2} {3}' . format ( _nftables_cmd ( ) , nft_family , table , chain ) #NEWLINE# if ( table_type or hook or priority ) : #NEWLINE# #INDENT# if ( table_type and hook and str ( priority ) ) : #NEWLINE# #INDENT# cmd = '{0} \\{{ type {1} hook {2} priority {3}\\; \\}}' . format ( cmd , table_type , hook , priority ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 'Error: table_type hook and priority required' #NEWLINE# #UNINDENT# #UNINDENT# out = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) #NEWLINE# if ( not out ) : #NEWLINE# #INDENT# out = True #NEWLINE# #UNINDENT# return out