Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend KeepConfiguration= functionality #409

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/netplan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion python-cffi/netplan/_build_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions python-cffi/netplan/netdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could keep the Python binding untouched and return False if critical is false (or unset) and True if it's set to any of the other values...

Although we probably should change it to return the enum values. You can see an example of enums in the Python code here https://github.com/chr4/netplan/blob/feat/keep-configuration/python-cffi/netplan/_utils.py#L27

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting thought. I feel like we should not diverge the bindings from the native API behavior, though. But we need to think about how we can handle that in a backwards compatible way.

return bool(lib._netplan_netdef_get_critical(self._ptr))

@property
def links(self) -> dict:
Expand Down
Loading