ifupdown: make testcase parsing quiet
Removes messages about invalid ENI formatting when running the testcases.
This commit is contained in:
@@ -90,7 +90,7 @@ static char *join_values_with_spaces(char *dst, char **src)
|
|||||||
return(dst);
|
return(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ifparser_init (const char *eni_file)
|
void ifparser_init (const char *eni_file, int quiet)
|
||||||
{
|
{
|
||||||
FILE *inp = fopen (eni_file, "r");
|
FILE *inp = fopen (eni_file, "r");
|
||||||
char line[255];
|
char line[255];
|
||||||
@@ -99,7 +99,8 @@ void ifparser_init (const char *eni_file)
|
|||||||
int offs = 0;
|
int offs = 0;
|
||||||
|
|
||||||
if (inp == NULL) {
|
if (inp == NULL) {
|
||||||
nm_warning ("Error: Can't open %s\n", eni_file);
|
if (!quiet)
|
||||||
|
g_warning ("Error: Can't open %s\n", eni_file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +120,10 @@ void ifparser_init (const char *eni_file)
|
|||||||
len = strlen(line);
|
len = strlen(line);
|
||||||
// skip over-long lines
|
// skip over-long lines
|
||||||
if (!feof(inp) && len > 0 && line[len-1] != '\n') {
|
if (!feof(inp) && len > 0 && line[len-1] != '\n') {
|
||||||
if (!skip_long_line)
|
if (!skip_long_line) {
|
||||||
g_message ("Error: Skipping over-long-line '%s...'\n", line);
|
if (!quiet)
|
||||||
|
g_message ("Error: Skipping over-long-line '%s...'\n", line);
|
||||||
|
}
|
||||||
skip_long_line = 1;
|
skip_long_line = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -158,8 +161,10 @@ void ifparser_init (const char *eni_file)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (toknum < 2) {
|
if (toknum < 2) {
|
||||||
g_message ("Error: Can't parse interface line '%s'\n",
|
if (!quiet) {
|
||||||
join_values_with_spaces(value, token));
|
g_message ("Error: Can't parse interface line '%s'\n",
|
||||||
|
join_values_with_spaces(value, token));
|
||||||
|
}
|
||||||
skip_to_block = 1;
|
skip_to_block = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -170,8 +175,10 @@ void ifparser_init (const char *eni_file)
|
|||||||
// iface stanza takes at least 3 parameters
|
// iface stanza takes at least 3 parameters
|
||||||
if (strcmp(token[0], "iface") == 0) {
|
if (strcmp(token[0], "iface") == 0) {
|
||||||
if (toknum < 4) {
|
if (toknum < 4) {
|
||||||
g_message ("Error: Can't parse iface line '%s'\n",
|
if (!quiet) {
|
||||||
join_values_with_spaces(value, token));
|
g_message ("Error: Can't parse iface line '%s'\n",
|
||||||
|
join_values_with_spaces(value, token));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
add_block(token[0], token[1]);
|
add_block(token[0], token[1]);
|
||||||
@@ -199,10 +206,12 @@ void ifparser_init (const char *eni_file)
|
|||||||
skip_to_block = 0;
|
skip_to_block = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (skip_to_block)
|
if (skip_to_block) {
|
||||||
g_message ("Error: ignoring out-of-block data '%s'\n",
|
if (!quiet) {
|
||||||
join_values_with_spaces(value, token));
|
g_message ("Error: ignoring out-of-block data '%s'\n",
|
||||||
else
|
join_values_with_spaces(value, token));
|
||||||
|
}
|
||||||
|
} else
|
||||||
add_data(token[0], join_values_with_spaces(value, token + 1));
|
add_data(token[0], join_values_with_spaces(value, token + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ typedef struct _if_block
|
|||||||
struct _if_block *next;
|
struct _if_block *next;
|
||||||
} if_block;
|
} if_block;
|
||||||
|
|
||||||
void ifparser_init(const char *eni_file);
|
void ifparser_init(const char *eni_file, int quiet);
|
||||||
void ifparser_destroy(void);
|
void ifparser_destroy(void);
|
||||||
|
|
||||||
if_block *ifparser_getif(const char* iface);
|
if_block *ifparser_getif(const char* iface);
|
||||||
|
@@ -357,7 +357,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||||||
update_system_hostname (inotify_helper, NULL, NULL, config);
|
update_system_hostname (inotify_helper, NULL, NULL, config);
|
||||||
|
|
||||||
/* Read in all the interfaces */
|
/* Read in all the interfaces */
|
||||||
ifparser_init (ENI_INTERFACES_FILE);
|
ifparser_init (ENI_INTERFACES_FILE, 0);
|
||||||
block = ifparser_getfirst ();
|
block = ifparser_getfirst ();
|
||||||
while (block) {
|
while (block) {
|
||||||
if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type))
|
if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type))
|
||||||
|
@@ -189,7 +189,7 @@ init_ifparser_with_file (const char *path, const char *file)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = g_strdup_printf ("%s/%s", path, file);
|
tmp = g_strdup_printf ("%s/%s", path, file);
|
||||||
ifparser_init (tmp);
|
ifparser_init (tmp, 1);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user