cli: add support for new InfiniBand properties
This commit is contained in:
@@ -237,10 +237,11 @@ usage_connection_add (void)
|
||||
" [password <password>]\n\n"
|
||||
" infiniband: [mac <MAC address>]\n"
|
||||
" [mtu <MTU>]\n"
|
||||
" [transport-mode <mode>]\n\n"
|
||||
" [transport-mode datagram | connected]\n\n"
|
||||
" [parent <ifname>]\n\n"
|
||||
" [p-key <IPoIB P_Key>]\n\n"
|
||||
" bluetooth: [addr <bluetooth address>]\n"
|
||||
" [bt-type panu|dun-gsm|dun-cdma]\n"
|
||||
" [transport-mode datagram | connected]\n\n"
|
||||
" vlan: dev <parent device (connection UUID, ifname, or MAC)\n"
|
||||
" [id <VLAN id>]\n"
|
||||
" [flags <VLAN flags>]\n"
|
||||
@@ -2010,9 +2011,14 @@ cleanup_wired:
|
||||
const char *mac = NULL;
|
||||
GByteArray *array = NULL;
|
||||
const char *mode = "datagram"; /* 'datagram' mode is default */
|
||||
const char *parent = NULL;
|
||||
const char *p_key = NULL;
|
||||
long p_key_int;
|
||||
nmc_arg_t exp_args[] = { {"mtu", TRUE, &mtu, FALSE},
|
||||
{"mac", TRUE, &mac, FALSE},
|
||||
{"transport-mode", TRUE, &mode, FALSE},
|
||||
{"parent", TRUE, &mode, FALSE},
|
||||
{"p-key", TRUE, &mode, FALSE},
|
||||
{NULL} };
|
||||
|
||||
if (!nmc_parse_args (exp_args, FALSE, &argc, &argv, error))
|
||||
@@ -2027,6 +2033,27 @@ cleanup_wired:
|
||||
}
|
||||
if (!check_and_convert_mac (mac, &array, ARPHRD_INFINIBAND, "mac", error))
|
||||
return FALSE;
|
||||
if (p_key) {
|
||||
gboolean p_key_valid = FALSE;
|
||||
if (!strncmp (p_key, "0x", 2))
|
||||
p_key_valid = nmc_string_to_int_base (p_key + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int);
|
||||
else
|
||||
p_key_valid = nmc_string_to_int (p_key, TRUE, 0, G_MAXUINT16, &p_key_int);
|
||||
if (!p_key_valid) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: 'p-key': '%s' is not valid."), p_key);
|
||||
return FALSE;
|
||||
}
|
||||
if (parent && !nm_utils_iface_valid_name (parent)) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: 'parent': '%s' is not a valid interface name."), parent);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (parent) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: 'parent': not valid without p-key."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Add 'infiniband' setting */
|
||||
s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new ();
|
||||
@@ -2039,6 +2066,10 @@ cleanup_wired:
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
if (p_key)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_P_KEY, p_key_int, NULL);
|
||||
if (parent)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_PARENT, parent, NULL);
|
||||
|
||||
} else if (!strcmp (con_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
||||
/* Build up the settings required for 'wifi' */
|
||||
|
@@ -512,13 +512,17 @@ static NmcOutputField nmc_fields_setting_infiniband[] = {
|
||||
SETTING_FIELD (NM_SETTING_INFINIBAND_MAC_ADDRESS, 61), /* 1 */
|
||||
SETTING_FIELD (NM_SETTING_INFINIBAND_MTU, 6), /* 2 */
|
||||
SETTING_FIELD (NM_SETTING_INFINIBAND_TRANSPORT_MODE, 12), /* 3 */
|
||||
SETTING_FIELD (NM_SETTING_INFINIBAND_P_KEY, 6), /* 4 */
|
||||
SETTING_FIELD (NM_SETTING_INFINIBAND_PARENT, 16), /* 5 */
|
||||
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
|
||||
};
|
||||
#define NMC_FIELDS_SETTING_INFINIBAND_ALL "name"","\
|
||||
NM_SETTING_INFINIBAND_MAC_ADDRESS","\
|
||||
NM_SETTING_INFINIBAND_MTU"," \
|
||||
NM_SETTING_INFINIBAND_TRANSPORT_MODE
|
||||
#define NMC_FIELDS_SETTING_INFINIBAND_COMMON NMC_FIELDS_SETTING_INFINIBAND_ALL
|
||||
NM_SETTING_INFINIBAND_TRANSPORT_MODE"," \
|
||||
NM_SETTING_INFINIBAND_P_KEY"," \
|
||||
NM_SETTING_INFINIBAND_PARENT
|
||||
#define NMC_FIELDS_SETTING_INFINIBAND_COMMON NMC_FIELDS_SETTING_INFINIBAND_ALL \
|
||||
|
||||
/* Available fields for NM_SETTING_BOND_SETTING_NAME */
|
||||
static NmcOutputField nmc_fields_setting_bond[] = {
|
||||
@@ -1071,6 +1075,21 @@ nmc_property_ib_get_mtu (NMSetting *setting)
|
||||
return g_strdup_printf ("%d", nm_setting_infiniband_get_mtu (s_infiniband));
|
||||
}
|
||||
|
||||
static char *
|
||||
nmc_property_ib_get_p_key (NMSetting *setting)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting);
|
||||
int p_key;
|
||||
|
||||
p_key = nm_setting_infiniband_get_p_key (s_infiniband);
|
||||
if (p_key == -1)
|
||||
return g_strdup (_("default"));
|
||||
else
|
||||
return g_strdup_printf ("0x%04x", p_key);
|
||||
}
|
||||
|
||||
DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
|
||||
|
||||
/* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP4_CONFIG_METHOD)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP4_CONFIG_DNS)
|
||||
@@ -1920,6 +1939,8 @@ setting_infiniband_details (NMSetting *setting, NmCli *nmc)
|
||||
set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting));
|
||||
set_val_str (arr, 2, nmc_property_ib_get_mtu (setting));
|
||||
set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting));
|
||||
set_val_str (arr, 4, nmc_property_ib_get_p_key (setting));
|
||||
set_val_str (arr, 5, nmc_property_ib_get_parent (setting));
|
||||
g_ptr_array_add (nmc->output_data, arr);
|
||||
|
||||
print_data (nmc); /* Print all data */
|
||||
|
Reference in New Issue
Block a user