Re: [PATCH nft 2/4] py: add missing output flags.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 22, 2019 at 09:58:53PM +0100, Jeremy Sowden wrote:
> `terse` and `numeric_time` are missing from the `output_flags` dict.
> Add them and getters and setters for them.

LGTM.

@Phil, is this fine with you? I let you decide on this.

BTW, would it make sense at some point to remove all the getter/setter
per option and use the setter/getter flags approach as in libnftables?

Thanks.

> Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
> ---
>  py/nftables.py | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/py/nftables.py b/py/nftables.py
> index 81e57567c802..48eb54fe232d 100644
> --- a/py/nftables.py
> +++ b/py/nftables.py
> @@ -58,6 +58,8 @@ class Nftables:
>          "numeric_proto":  (1 << 7),
>          "numeric_prio":   (1 << 8),
>          "numeric_symbol": (1 << 9),
> +        "numeric_time":   (1 << 10),
> +        "terse":          (1 << 11),
>      }
>  
>      validator = None
> @@ -305,6 +307,39 @@ class Nftables:
>          """
>          return self.__set_output_flag("numeric_symbol", val)
>  
> +    def get_numeric_time_output(self):
> +        """Get current status of numeric times output flag.
> +
> +        Returns a boolean value indicating the status.
> +        """
> +        return self.__get_output_flag("numeric_time")
> +
> +    def set_numeric_time_output(self, val):
> +        """Set numeric times output flag.
> +
> +        Accepts a boolean turning numeric representation of time values
> +        in output either on or off.
> +
> +        Returns the previous value.
> +        """
> +        return self.__set_output_flag("numeric_time", val)
> +
> +    def get_terse_output(self):
> +        """Get the current state of terse output.
> +
> +        Returns a boolean indicating whether terse output is active or not.
> +        """
> +        return self.__get_output_flag("terse")
> +
> +    def set_terse_output(self, val):
> +        """Enable or disable terse output.
> +
> +        Accepts a boolean turning terse output either on or off.
> +
> +        Returns the previous value.
> +        """
> +        return self.__set_output_flag("terse", val)
> +
>      def get_debug(self):
>          """Get currently active debug flags.
>  
> -- 
> 2.23.0
> 



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux