mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-19 21:20:26 +01:00
merge: branch 'lr/ask-mode'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1215
This commit is contained in:
commit
33688caabc
3 changed files with 172 additions and 104 deletions
|
|
@ -4456,7 +4456,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "primary",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding primary interface [none]"),
|
||||
.prompt = N_("Bonding primary interface"),
|
||||
.def_hint = "[none]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4472,7 +4473,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "miimon",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding miimon [100]"),
|
||||
.prompt = N_("Bonding miimon"),
|
||||
.def_hint = "[100]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4480,7 +4482,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "downdelay",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding downdelay [0]"),
|
||||
.prompt = N_("Bonding downdelay"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4488,7 +4491,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "updelay",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding updelay [0]"),
|
||||
.prompt = N_("Bonding updelay"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4496,7 +4500,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "arp-interval",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding arp-interval [0]"),
|
||||
.prompt = N_("Bonding arp-interval"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4504,7 +4509,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "arp-ip-target",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding arp-ip-target [none]"),
|
||||
.prompt = N_("Bonding arp-ip-target"),
|
||||
.def_hint = "[none]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4512,7 +4518,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "lacp-rate",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("LACP rate ('slow' or 'fast') [slow]"),
|
||||
.prompt = N_("LACP rate (slow/fast)"),
|
||||
.def_hint = "[slow]",
|
||||
)
|
||||
},
|
||||
};
|
||||
|
|
@ -5121,7 +5128,7 @@ static const NMMetaPropertyInfo *const property_infos_BOND_PORT[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BOND_PORT_QUEUE_ID,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "queue-id",
|
||||
.prompt = N_("Queue ID [0]"),
|
||||
.prompt = N_("Queue ID"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -5139,37 +5146,37 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_STP,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "stp",
|
||||
.prompt = N_("Enable STP [no]"),
|
||||
.prompt = N_("Enable STP"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PRIORITY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "priority",
|
||||
.prompt = N_("STP priority [32768]"),
|
||||
.prompt = N_("STP priority"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_FORWARD_DELAY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "forward-delay",
|
||||
.prompt = N_("Forward delay [15]"),
|
||||
.prompt = N_("Forward delay"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_HELLO_TIME,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "hello-time",
|
||||
.prompt = N_("Hello time [2]"),
|
||||
.prompt = N_("Hello time"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MAX_AGE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "max-age",
|
||||
.prompt = N_("Max age [20]"),
|
||||
.prompt = N_("Max age"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_AGEING_TIME,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "ageing-time",
|
||||
.prompt = N_("MAC address ageing time [300]"),
|
||||
.prompt = N_("MAC address ageing time"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_GROUP_ADDRESS,
|
||||
|
|
@ -5179,7 +5186,7 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "group-forward-mask",
|
||||
.prompt = N_("Group forward mask [0]"),
|
||||
.prompt = N_("Group forward mask"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_HASH_MAX,
|
||||
|
|
@ -5221,7 +5228,7 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_SNOOPING,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "multicast-snooping",
|
||||
.prompt = N_("Enable IGMP snooping [no]"),
|
||||
.prompt = N_("Enable IGMP snooping"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT,
|
||||
|
|
@ -5279,19 +5286,19 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE_PORT[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_PRIORITY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "priority",
|
||||
.prompt = N_("Bridge port priority [32]"),
|
||||
.prompt = N_("Bridge port priority"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_PATH_COST,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "path-cost",
|
||||
.prompt = N_("Bridge port STP path cost [100]"),
|
||||
.prompt = N_("Bridge port STP path cost"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "hairpin",
|
||||
.prompt = N_("Hairpin [no]"),
|
||||
.prompt = N_("Hairpin"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_VLANS,
|
||||
|
|
@ -5878,7 +5885,7 @@ static const NMMetaPropertyInfo *const property_infos_INFINIBAND[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_INFINIBAND_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingInfiniband, nm_setting_infiniband_get_mtu),
|
||||
|
|
@ -6510,7 +6517,7 @@ static const NMMetaPropertyInfo *const property_infos_MACSEC[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_ENCRYPT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "encrypt",
|
||||
.prompt = N_("Enable encryption [yes]"),
|
||||
.prompt = N_("Enable encryption"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_MKA_CAK,
|
||||
|
|
@ -6532,7 +6539,7 @@ static const NMMetaPropertyInfo *const property_infos_MACSEC[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_PORT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "port",
|
||||
.prompt = N_("SCI port [1]"),
|
||||
.prompt = N_("SCI port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_VALIDATION,
|
||||
|
|
@ -6579,7 +6586,7 @@ static const NMMetaPropertyInfo *const property_infos_MACVLAN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACVLAN_TAP,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "tap",
|
||||
.prompt = N_("Tap [no]"),
|
||||
.prompt = N_("Tap"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -6655,7 +6662,7 @@ static const NMMetaPropertyInfo *const property_infos_OLPC_MESH[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_OLPC_MESH_CHANNEL,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "channel",
|
||||
.prompt = N_("OLPC Mesh channel [1]"),
|
||||
.prompt = N_("OLPC Mesh channel"),
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
.get_fcn = _get_fcn_gobject,
|
||||
.set_fcn = _set_fcn_olpc_mesh_channel,
|
||||
|
|
@ -6881,7 +6888,7 @@ static const NMMetaPropertyInfo *const property_infos_PROXY[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_PROXY_BROWSER_ONLY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "browser-only",
|
||||
.prompt = N_("Browser only [no]"),
|
||||
.prompt = N_("Browser only"),
|
||||
.property_type = &_pt_gobject_bool
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_PROXY_PAC_URL,
|
||||
|
|
@ -7320,19 +7327,19 @@ static const NMMetaPropertyInfo *const property_infos_TUN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_PI,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "pi",
|
||||
.prompt = N_("Enable PI [no]"),
|
||||
.prompt = N_("Enable PI"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_VNET_HDR,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "vnet-hdr",
|
||||
.prompt = N_("Enable VNET header [no]"),
|
||||
.prompt = N_("Enable VNET header"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_MULTI_QUEUE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "multi-queue",
|
||||
.prompt = N_("Enable multi queue [no]"),
|
||||
.prompt = N_("Enable multi queue"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -7458,7 +7465,7 @@ static const NMMetaPropertyInfo *const property_infos_VRF[] = {
|
|||
.is_cli_option = TRUE,
|
||||
.property_alias = "table",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_REQD,
|
||||
.prompt = N_("Table [0]"),
|
||||
.prompt = N_("Table"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -7496,19 +7503,19 @@ static const NMMetaPropertyInfo *const property_infos_VXLAN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_SOURCE_PORT_MIN,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "source-port-min",
|
||||
.prompt = N_("Minimum source port [0]"),
|
||||
.prompt = N_("Minimum source port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_SOURCE_PORT_MAX,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "source-port-max",
|
||||
.prompt = N_("Maximum source port [0]"),
|
||||
.prompt = N_("Maximum source port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_DESTINATION_PORT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "destination-port",
|
||||
.prompt = N_("Destination port [8472]"),
|
||||
.prompt = N_("Destination port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_TOS,
|
||||
|
|
@ -7640,7 +7647,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRED[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRED_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingWired, nm_setting_wired_get_mtu),
|
||||
|
|
@ -7834,7 +7841,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingWireless, nm_setting_wireless_get_mtu),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct _NMDevice;
|
|||
"(" NM_SETTING_ADSL_ENCAPSULATION_VCMUX "/" NM_SETTING_ADSL_ENCAPSULATION_LLC ") [none]"
|
||||
|
||||
#define NM_META_TEXT_PROMPT_CON_TYPE N_("Connection type")
|
||||
#define NM_META_TEXT_PROMPT_IFNAME N_("Interface name [*]")
|
||||
#define NM_META_TEXT_PROMPT_IFNAME N_("Interface name")
|
||||
#define NM_META_TEXT_PROMPT_VPN_TYPE N_("VPN type")
|
||||
#define NM_META_TEXT_PROMPT_MASTER N_("Master")
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ typedef struct _OptionInfo {
|
|||
NMConnection *connection,
|
||||
const struct _OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error);
|
||||
CompEntryFunc generator_func;
|
||||
} OptionInfo;
|
||||
|
|
@ -4173,11 +4174,14 @@ enable_options(const char *setting_name, const char *property, const char *const
|
|||
for (i = 0; i < nm_meta_property_typ_data_bond.nested_len; i++) {
|
||||
const NMMetaNestedPropertyInfo *bi = &nm_meta_property_typ_data_bond.nested[i];
|
||||
|
||||
if (bi->base.inf_flags & NM_META_PROPERTY_INF_FLAG_DONT_ASK && bi->base.property_alias
|
||||
&& g_strv_contains(opts, bi->base.property_alias))
|
||||
_dynamic_options_set((const NMMetaAbstractInfo *) bi,
|
||||
PROPERTY_INF_FLAG_ENABLED,
|
||||
PROPERTY_INF_FLAG_ENABLED);
|
||||
if (opts) {
|
||||
if (!bi->base.property_alias || !g_strv_contains(opts, bi->base.property_alias))
|
||||
continue;
|
||||
}
|
||||
|
||||
_dynamic_options_set((const NMMetaAbstractInfo *) bi,
|
||||
PROPERTY_INF_FLAG_ENABLED | PROPERTY_INF_FLAG_DISABLED,
|
||||
PROPERTY_INF_FLAG_ENABLED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -4185,11 +4189,14 @@ enable_options(const char *setting_name, const char *property, const char *const
|
|||
if (!property_info->is_cli_option)
|
||||
g_return_if_reached();
|
||||
|
||||
if (property_info->inf_flags & NM_META_PROPERTY_INF_FLAG_DONT_ASK
|
||||
&& property_info->property_alias && g_strv_contains(opts, property_info->property_alias))
|
||||
_dynamic_options_set((const NMMetaAbstractInfo *) property_info,
|
||||
PROPERTY_INF_FLAG_ENABLED,
|
||||
PROPERTY_INF_FLAG_ENABLED);
|
||||
if (opts) {
|
||||
if (!property_info->property_alias || !g_strv_contains(opts, property_info->property_alias))
|
||||
return;
|
||||
}
|
||||
|
||||
_dynamic_options_set((const NMMetaAbstractInfo *) property_info,
|
||||
PROPERTY_INF_FLAG_ENABLED | PROPERTY_INF_FLAG_DISABLED,
|
||||
PROPERTY_INF_FLAG_ENABLED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -4375,7 +4382,7 @@ set_option(NmCli *nmc,
|
|||
NULL,
|
||||
NULL);
|
||||
if (option && option->check_and_set) {
|
||||
return option->check_and_set(nmc, connection, option, value, error);
|
||||
return option->check_and_set(nmc, connection, option, value, allow_reset, error);
|
||||
} else if (value || allow_reset) {
|
||||
return set_property(nmc->client,
|
||||
connection,
|
||||
|
|
@ -4501,21 +4508,63 @@ gen_func_bond_lacp_rate(const char *text, int state)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
enable_type_settings_and_options(NmCli *nmc, NMConnection *con, GError **error)
|
||||
{
|
||||
const NMMetaSettingValidPartItem *const *type_settings;
|
||||
const NMMetaSettingValidPartItem *const *slv_settings;
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
s_con = nm_connection_get_setting_connection(con);
|
||||
g_return_val_if_fail(s_con, FALSE);
|
||||
|
||||
if (nm_setting_connection_get_slave_type(s_con))
|
||||
enable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, NULL);
|
||||
|
||||
if (NM_IN_STRSET(nm_setting_connection_get_connection_type(s_con),
|
||||
NM_SETTING_BLUETOOTH_SETTING_NAME,
|
||||
NM_SETTING_BOND_SETTING_NAME,
|
||||
NM_SETTING_BRIDGE_SETTING_NAME,
|
||||
NM_SETTING_DUMMY_SETTING_NAME,
|
||||
NM_SETTING_OVS_BRIDGE_SETTING_NAME,
|
||||
NM_SETTING_OVS_PATCH_SETTING_NAME,
|
||||
NM_SETTING_OVS_PORT_SETTING_NAME,
|
||||
NM_SETTING_TEAM_SETTING_NAME,
|
||||
NM_SETTING_VETH_SETTING_NAME,
|
||||
NM_SETTING_VRF_SETTING_NAME,
|
||||
NM_SETTING_WIREGUARD_SETTING_NAME)) {
|
||||
enable_options(NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!con_settings(con, &type_settings, &slv_settings, error))
|
||||
return FALSE;
|
||||
|
||||
ensure_settings(con, slv_settings);
|
||||
ensure_settings(con, type_settings);
|
||||
|
||||
/* For some software connection types we generate the interface name for the user. */
|
||||
set_default_interface_name(nmc, s_con);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_connection_type(NmCli *nmc,
|
||||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
const NMMetaSettingValidPartItem *const *type_settings;
|
||||
const NMMetaSettingValidPartItem *const *slv_settings;
|
||||
GError *local = NULL;
|
||||
const char *master[] = {"master", NULL};
|
||||
const char *slave_type = NULL;
|
||||
GError *local = NULL;
|
||||
const char *slave_type = NULL;
|
||||
|
||||
value = check_valid_name_toplevel(value, &slave_type, &local);
|
||||
if (!value) {
|
||||
if (!allow_reset)
|
||||
return TRUE;
|
||||
g_set_error(error,
|
||||
NMCLI_ERROR,
|
||||
NMC_RESULT_ERROR_USER_INPUT,
|
||||
|
|
@ -4535,16 +4584,6 @@ set_connection_type(NmCli *nmc,
|
|||
error)) {
|
||||
return FALSE;
|
||||
}
|
||||
enable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, master);
|
||||
}
|
||||
|
||||
/* ifname is mandatory for all connection types except virtual ones (bond, team, bridge, vlan) */
|
||||
if (NM_IN_STRSET(value,
|
||||
NM_SETTING_BOND_SETTING_NAME,
|
||||
NM_SETTING_TEAM_SETTING_NAME,
|
||||
NM_SETTING_BRIDGE_SETTING_NAME,
|
||||
NM_SETTING_VLAN_SETTING_NAME)) {
|
||||
disable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
|
||||
}
|
||||
|
||||
if (!set_property(nmc->client,
|
||||
|
|
@ -4556,13 +4595,7 @@ set_connection_type(NmCli *nmc,
|
|||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!con_settings(con, &type_settings, &slv_settings, error))
|
||||
return FALSE;
|
||||
|
||||
ensure_settings(con, slv_settings);
|
||||
ensure_settings(con, type_settings);
|
||||
|
||||
return TRUE;
|
||||
return enable_type_settings_and_options(nmc, con, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -4570,12 +4603,15 @@ set_connection_iface(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
if (value) {
|
||||
/* Special value of '*' means no specific interface name */
|
||||
if (nm_streq(value, "*"))
|
||||
value = NULL;
|
||||
} else if (!allow_reset) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return set_property(nmc->client,
|
||||
|
|
@ -4592,6 +4628,7 @@ set_connection_master(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
const GPtrArray *connections;
|
||||
|
|
@ -4602,6 +4639,8 @@ set_connection_master(NmCli *nmc,
|
|||
g_return_val_if_fail(s_con, FALSE);
|
||||
|
||||
if (!value) {
|
||||
if (!allow_reset)
|
||||
return TRUE;
|
||||
g_set_error_literal(error,
|
||||
NMCLI_ERROR,
|
||||
NMC_RESULT_ERROR_USER_INPUT,
|
||||
|
|
@ -4637,10 +4676,10 @@ set_bond_option(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingBond *s_bond;
|
||||
gboolean success;
|
||||
gs_free char *name = NULL;
|
||||
char *p;
|
||||
|
||||
|
|
@ -4654,26 +4693,25 @@ set_bond_option(NmCli *nmc,
|
|||
}
|
||||
|
||||
if (nm_str_is_empty(value)) {
|
||||
nm_setting_bond_remove_option(s_bond, name);
|
||||
success = TRUE;
|
||||
} else
|
||||
success = _nm_meta_setting_bond_add_option(NM_SETTING(s_bond), name, value, error);
|
||||
if (allow_reset) {
|
||||
nm_setting_bond_remove_option(s_bond, name);
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
if (!_nm_meta_setting_bond_add_option(NM_SETTING(s_bond), name, value, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
if (success) {
|
||||
if (nm_streq(name, NM_SETTING_BOND_OPTION_MODE)) {
|
||||
value = nmc_bond_validate_mode(value, error);
|
||||
if (nm_streq(value, "active-backup")) {
|
||||
enable_options(NM_SETTING_BOND_SETTING_NAME,
|
||||
NM_SETTING_BOND_OPTIONS,
|
||||
NM_MAKE_STRV("primary"));
|
||||
}
|
||||
if (nm_streq(name, NM_SETTING_BOND_OPTION_MODE)) {
|
||||
value = nm_setting_bond_get_option_by_name(s_bond, name);
|
||||
if (nm_streq(value, "active-backup")) {
|
||||
enable_options(NM_SETTING_BOND_SETTING_NAME,
|
||||
NM_SETTING_BOND_OPTIONS,
|
||||
NM_MAKE_STRV("primary"));
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -4681,6 +4719,7 @@ set_bond_monitoring_mode(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingBond *s_bond;
|
||||
|
|
@ -4721,6 +4760,7 @@ set_bluetooth_type(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSetting *setting;
|
||||
|
|
@ -4769,6 +4809,7 @@ set_ip4_address(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -4796,6 +4837,7 @@ set_ip6_address(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
|
@ -5557,17 +5599,30 @@ ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstr
|
|||
GError *error = NULL;
|
||||
gs_free char *prompt = NULL;
|
||||
gboolean multi;
|
||||
const char *setting_name, *property_name;
|
||||
const char *opt_prompt, *opt_def_hint;
|
||||
gs_free char *def_hint = NULL;
|
||||
gs_free char *property_val = NULL;
|
||||
NMMetaPropertyInfFlags inf_flags;
|
||||
NMSetting *setting;
|
||||
|
||||
_meta_abstract_get(abstract_info,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&setting_name,
|
||||
&property_name,
|
||||
NULL,
|
||||
&inf_flags,
|
||||
&opt_prompt,
|
||||
&opt_def_hint);
|
||||
|
||||
if (!opt_def_hint) {
|
||||
setting = nm_connection_get_setting_by_name(connection, setting_name);
|
||||
if (setting)
|
||||
property_val = nmc_setting_get_property_parsable(setting, property_name, NULL);
|
||||
if (property_val)
|
||||
opt_def_hint = def_hint = g_strdup_printf("[%s]", property_val);
|
||||
}
|
||||
|
||||
prompt =
|
||||
g_strjoin("", gettext(opt_prompt), opt_def_hint ? " " : "", opt_def_hint ?: "", ": ", NULL);
|
||||
|
||||
|
|
@ -5578,8 +5633,6 @@ ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstr
|
|||
|
||||
again:
|
||||
value = nmc_readline(&nmc->nmc_config, "%s", prompt);
|
||||
if (multi && !value)
|
||||
return;
|
||||
|
||||
if (!set_option(nmc, connection, abstract_info, value, FALSE, &error)) {
|
||||
g_printerr("%s\n", error->message);
|
||||
|
|
@ -5599,7 +5652,9 @@ connection_get_base_meta_setting_type(NMConnection *connection)
|
|||
const NMMetaSettingInfoEditor *editor;
|
||||
|
||||
connection_type = nm_connection_get_connection_type(connection);
|
||||
nm_assert(connection_type);
|
||||
if (!connection_type)
|
||||
return NM_META_SETTING_TYPE_UNKNOWN;
|
||||
|
||||
base_setting = nm_connection_get_setting_by_name(connection, connection_type);
|
||||
nm_assert(base_setting);
|
||||
editor = nm_meta_setting_info_editor_find_by_setting(base_setting);
|
||||
|
|
@ -5655,10 +5710,15 @@ questionnaire_mandatory(NmCli *nmc, NMConnection *connection)
|
|||
NMMetaSettingType s, base;
|
||||
|
||||
/* First ask connection properties */
|
||||
questionnaire_mandatory_ask_setting(nmc, connection, NM_META_SETTING_TYPE_CONNECTION);
|
||||
while (1) {
|
||||
base = connection_get_base_meta_setting_type(connection);
|
||||
if (base != NM_META_SETTING_TYPE_UNKNOWN)
|
||||
break;
|
||||
enable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE, NULL);
|
||||
questionnaire_mandatory_ask_setting(nmc, connection, NM_META_SETTING_TYPE_CONNECTION);
|
||||
}
|
||||
|
||||
/* Ask properties of the base setting */
|
||||
base = connection_get_base_meta_setting_type(connection);
|
||||
questionnaire_mandatory_ask_setting(nmc, connection, base);
|
||||
|
||||
/* Remaining settings */
|
||||
|
|
@ -5673,16 +5733,14 @@ want_provide_opt_args(const NmcConfig *nmc_config, const char *type, guint num)
|
|||
{
|
||||
gs_free char *answer = NULL;
|
||||
|
||||
/* Don't ask to ask. */
|
||||
if (num == 1)
|
||||
return TRUE;
|
||||
|
||||
/* Ask for optional arguments. */
|
||||
g_print(ngettext("There is %d optional setting for %s.\n",
|
||||
"There are %d optional settings for %s.\n",
|
||||
num),
|
||||
(int) num,
|
||||
type);
|
||||
answer = nmc_readline(
|
||||
nmc_config,
|
||||
ngettext("Do you want to provide it? %s", "Do you want to provide them? %s", num),
|
||||
prompt_yes_no(TRUE, NULL));
|
||||
g_print(_("There are %d optional settings for %s.\n"), (int) num, type);
|
||||
answer =
|
||||
nmc_readline(nmc_config, _("Do you want to provide them? %s"), prompt_yes_no(TRUE, NULL));
|
||||
nm_strstrip(answer);
|
||||
return !answer || matches(answer, WORD_YES);
|
||||
}
|
||||
|
|
@ -5845,6 +5903,12 @@ read_properties:
|
|||
if (nmc->complete)
|
||||
goto finish;
|
||||
|
||||
if (!enable_type_settings_and_options(nmc, connection, &error)) {
|
||||
g_string_assign(nmc->return_text, error->message);
|
||||
nmc->return_value = error->code;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
/* Now ask user for the rest of the mandatory options. */
|
||||
if (nmc->ask)
|
||||
questionnaire_mandatory(nmc, connection);
|
||||
|
|
@ -5880,9 +5944,6 @@ read_properties:
|
|||
}
|
||||
}
|
||||
|
||||
/* For some software connection types we generate the interface name for the user. */
|
||||
set_default_interface_name(nmc, s_con);
|
||||
|
||||
/* Now see if there's something optional that needs to be asked for.
|
||||
* Keep asking until there's no more things to ask for. */
|
||||
do {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue