diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-05-16 14:42:41 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-05-26 09:16:46 +0200 |
commit | 3c649e6429908e0b83bc176f8349c72ebd61ad60 (patch) | |
tree | 5953cadf8a8262ed54ee62f38fe706570bcf47bb /libnm | |
parent | 3df3e46d64f428a44548bb70fff3bb87d4e75ab2 (diff) | |
download | NetworkManager-3c649e6429908e0b83bc176f8349c72ebd61ad60.tar.gz |
team: expose current device configuration through D-Bus and nmcli
Add a new "Config" property to the D-Bus interface for team devices
and show its value through "nmcli device show". The property contains
the full JSON configuration from teamd for the device.
https://bugzilla.redhat.com/show_bug.cgi?id=1310435
Diffstat (limited to 'libnm')
-rw-r--r-- | libnm/libnm.ver | 1 | ||||
-rw-r--r-- | libnm/nm-device-team.c | 40 | ||||
-rw-r--r-- | libnm/nm-device-team.h | 3 |
3 files changed, 44 insertions, 0 deletions
diff --git a/libnm/libnm.ver b/libnm/libnm.ver index f8e2c4eb2d..abd4c57e44 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1061,6 +1061,7 @@ global: libnm_1_4_0 { global: + nm_device_team_get_config; nm_setting_ip_config_get_dns_priority; nm_vpn_editor_plugin_load; nm_vpn_plugin_info_get_auth_dialog; diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index b855d5ec38..3955e10561 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -39,6 +39,7 @@ typedef struct { char *hw_address; gboolean carrier; GPtrArray *slaves; + char *config; } NMDeviceTeamPrivate; enum { @@ -46,6 +47,7 @@ enum { PROP_HW_ADDRESS, PROP_CARRIER, PROP_SLAVES, + PROP_CONFIG, LAST_PROP }; @@ -101,6 +103,25 @@ nm_device_team_get_slaves (NMDeviceTeam *device) return NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves; } +/** + * nm_device_team_get_config: + * @device: a #NMDeviceTeam + * + * Gets the current JSON configuration of the #NMDeviceTeam + * + * Returns: the current configuration. This is the internal string used by the + * device, and must not be modified. + * + * Since: 1.4 + **/ +const char * +nm_device_team_get_config (NMDeviceTeam *device) +{ + g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), NULL); + + return NM_DEVICE_TEAM_GET_PRIVATE (device)->config; +} + static const char * get_hw_address (NMDevice *device) { @@ -150,6 +171,7 @@ init_dbus (NMObject *object) { NM_DEVICE_TEAM_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_TEAM_CARRIER, &priv->carrier }, { NM_DEVICE_TEAM_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE }, + { NM_DEVICE_TEAM_CONFIG, &priv->config }, { NULL }, }; @@ -176,6 +198,7 @@ finalize (GObject *object) NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); g_free (priv->hw_address); + g_free (priv->config); G_OBJECT_CLASS (nm_device_team_parent_class)->finalize (object); } @@ -198,6 +221,9 @@ get_property (GObject *object, case PROP_SLAVES: g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_team_get_slaves (device))); break; + case PROP_CONFIG: + g_value_set_string (value, nm_device_team_get_config (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -265,4 +291,18 @@ nm_device_team_class_init (NMDeviceTeamClass *team_class) G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** + * NMDeviceTeam:config: + * + * The current JSON configuration of the device. + * + * Since: 1.4 + **/ + g_object_class_install_property + (object_class, PROP_CONFIG, + g_param_spec_string (NM_DEVICE_TEAM_CONFIG, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-device-team.h b/libnm/nm-device-team.h index a9b71c6ab0..522e3d29c0 100644 --- a/libnm/nm-device-team.h +++ b/libnm/nm-device-team.h @@ -39,6 +39,7 @@ G_BEGIN_DECLS #define NM_DEVICE_TEAM_HW_ADDRESS "hw-address" #define NM_DEVICE_TEAM_CARRIER "carrier" #define NM_DEVICE_TEAM_SLAVES "slaves" +#define NM_DEVICE_TEAM_CONFIG "config" /** * NMDeviceTeam: @@ -59,6 +60,8 @@ GType nm_device_team_get_type (void); const char *nm_device_team_get_hw_address (NMDeviceTeam *device); gboolean nm_device_team_get_carrier (NMDeviceTeam *device); const GPtrArray *nm_device_team_get_slaves (NMDeviceTeam *device); +NM_AVAILABLE_IN_1_4 +const char *nm_device_team_get_config (NMDeviceTeam *device); G_END_DECLS |