From 8ae3b07a1e796107f0238388586b8b41056f33a2 Mon Sep 17 00:00:00 2001 From: Chris Aumann Date: Sat, 23 Sep 2023 00:26:42 +0200 Subject: [PATCH] [squashme] howto pyhon enum plz? --- include/netplan.h | 3 --- python-cffi/netplan/_build_cffi.py | 3 ++- python-cffi/netplan/netdef.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/netplan.h b/include/netplan.h index b083d9896..8fbf3fba9 100644 --- a/include/netplan.h +++ b/include/netplan.h @@ -118,9 +118,6 @@ netplan_netdef_get_vlan_link(const NetplanNetDefinition* netdef); NETPLAN_PUBLIC NetplanNetDefinition* netplan_netdef_get_sriov_link(const NetplanNetDefinition* netdef); -NETPLAN_PUBLIC char * -netplan_netdef_get_keep_configuration(const NetplanNetDefinition* netdef); - NETPLAN_PUBLIC ssize_t netplan_netdef_get_set_name(const NetplanNetDefinition* netdef, char* out_buffer, size_t out_buffer_size); diff --git a/python-cffi/netplan/_build_cffi.py b/python-cffi/netplan/_build_cffi.py index 496e643fe..4a136c6f6 100644 --- a/python-cffi/netplan/_build_cffi.py +++ b/python-cffi/netplan/_build_cffi.py @@ -34,6 +34,7 @@ typedef struct netplan_net_definition NetplanNetDefinition; typedef enum { ... } NetplanBackend; typedef enum { ... } NetplanDefType; + typedef enum { ... } NetplanCriticalOption; // TODO: Introduce getters for .address/.lifetime/.label to avoid exposing the raw struct typedef struct { @@ -112,7 +113,7 @@ ssize_t _netplan_netdef_get_embedded_switch_mode(const NetplanNetDefinition* netdef, char* out_buffer, size_t out_buf_size); gboolean _netplan_netdef_get_sriov_vlan_filter(const NetplanNetDefinition* netdef); guint _netplan_netdef_get_vlan_id(const NetplanNetDefinition* netdef); - char* netplan_netdef_get_keep_configuration(const NetplanNetDefinition* netdef); + NetplanCriticalOption _netplan_netdef_get_critical(const NetplanNetDefinition* netdef); gboolean _netplan_netdef_is_trivial_compound_itf(const NetplanNetDefinition* netdef); int _netplan_state_get_vf_count_for_def( const NetplanState* np_state, const NetplanNetDefinition* netdef, NetplanError** error); diff --git a/python-cffi/netplan/netdef.py b/python-cffi/netplan/netdef.py index 495d687c4..cc2372567 100644 --- a/python-cffi/netplan/netdef.py +++ b/python-cffi/netplan/netdef.py @@ -75,8 +75,8 @@ def set_name(self) -> str: return _string_realloc_call_no_error(lambda b: lib.netplan_netdef_get_set_name(self._ptr, b, len(b))) @property - def keep_configuration(self) -> str: - return _string_realloc_call_no_error(lambda b: lib.netplan_netdef_get_keep_configuration(self._ptr, b, len(b))) + def critical(self) -> bool: + return bool(lib._netplan_netdef_get_critical(self._ptr)) @property def links(self) -> dict: