From aec9ee38b819e7e9612c6347ed5a08d3f9ea4320 Mon Sep 17 00:00:00 2001 From: slioch Date: Tue, 17 Feb 2009 11:46:02 -0800 Subject: added generic commit failed message on any portion of the configuration failing. To get additional details (i.e. location of failure and actions associated with nodes) run with the -e flag. --- src/commit2.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/commit2.c b/src/commit2.c index b56fceb..6555bd8 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -202,6 +202,10 @@ main(int argc, char** argv) printf("commit2: successful commit, now cleaning up temp directories\n"); } } + else { + fprintf(out_stream,"Commit failed\n"); + } + set_in_commit(FALSE); cleanup(config_data); -- cgit v1.2.3 From a3400424074a9d3b76c95561af4a948a430d4be4 Mon Sep 17 00:00:00 2001 From: slioch Date: Tue, 17 Feb 2009 11:50:42 -0800 Subject: added dump transaction support to write to stdout rather than redirected /tmp/cfg-stdout.log file. Enable with -s flag on commit to view local session data and associated actions. --- src/commit2.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/commit2.c b/src/commit2.c index 6555bd8..cb129dd 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -8,6 +8,7 @@ boolean g_debug = FALSE; boolean g_display_error_node = FALSE; boolean g_coverage = FALSE; +boolean g_dump_trans = FALSE; char* ActionNames[top_act] = { "delete", @@ -98,7 +99,6 @@ int main(int argc, char** argv) { int ch; - boolean dump_trans = TRUE; boolean priority_mode = TRUE; boolean test_mode = FALSE; @@ -119,7 +119,7 @@ main(int argc, char** argv) test_mode = TRUE; break; case 's': - dump_trans = TRUE; + g_dump_trans = TRUE; break; case 'e': g_display_error_node = TRUE; @@ -154,7 +154,7 @@ main(int argc, char** argv) exit(0); } - if (dump_trans == TRUE) { + if (g_dump_trans == TRUE) { printf("Dumping transactions\n"); //iterate over config_data and dump... g_node_traverse(trans_coll, @@ -163,7 +163,7 @@ main(int argc, char** argv) -1, (GNodeTraverseFunc)dump_func, (gpointer)NULL); - // exit(0); + exit(0); } GNode *trans_child_node = (GNode*)g_node_first_child(trans_coll); @@ -567,7 +567,7 @@ dump_func(GNode *node, gpointer data) guint depth = g_node_depth(node); if (depth == 2) { - printf("NEW TRANS\n"); + fprintf(out_stream,"NEW TRANS\n"); } gpointer gp = ((GNode*)node)->data; @@ -575,57 +575,57 @@ dump_func(GNode *node, gpointer data) int i; if (IS_DELETE(((struct VyattaNode*)gp)->_data._operation)) { - printf("-"); + fprintf(out_stream,"-"); } else if (IS_CREATE(((struct VyattaNode*)gp)->_data._operation)) { - printf("+"); + fprintf(out_stream,"+"); } else if (IS_SET(((struct VyattaNode*)gp)->_data._operation)) { - printf(">"); + fprintf(out_stream,">"); } else { - printf(" "); + fprintf(out_stream," "); } for (i = 0; i < depth; ++i) { - printf(" "); + fprintf(out_stream," "); } - printf("%s (t: %d, p: %d)", ((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_config._def.def_type,((struct VyattaNode*)gp)->_priority); + fprintf(out_stream,"%s (t: %d, p: %d)", ((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_config._def.def_type,((struct VyattaNode*)gp)->_priority); if (((struct VyattaNode*)gp)->_data._value == TRUE) { - printf(" [VALUE]"); + fprintf(out_stream," [VALUE]"); } if (((struct VyattaNode*)gp)->_config._multi == TRUE) { - printf(" [MULTI]"); + fprintf(out_stream," [MULTI]"); } if (((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head && ((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head->vtw_node_aux == 0) { - printf(" [SYNTAX]"); + fprintf(out_stream," [SYNTAX]"); } if (((struct VyattaNode*)gp)->_config._def.actions[create_act].vtw_list_head) { - printf(" [CREATE]"); + fprintf(out_stream," [CREATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[activate_act].vtw_list_head) { - printf(" [ACTIVATE]"); + fprintf(out_stream," [ACTIVATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[update_act].vtw_list_head) { - printf(" [UPDATE]"); + fprintf(out_stream," [UPDATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[delete_act].vtw_list_head) { - printf(" [DELETE]"); + fprintf(out_stream," [DELETE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head && ((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head->vtw_node_aux == 1) { - printf(" [COMMIT]"); + fprintf(out_stream," [COMMIT]"); } if (((struct VyattaNode*)gp)->_config._def.actions[begin_act].vtw_list_head) { - printf(" [BEGIN]"); + fprintf(out_stream," [BEGIN]"); } if (((struct VyattaNode*)gp)->_config._def.actions[end_act].vtw_list_head) { - printf(" [END]"); + fprintf(out_stream," [END]"); } if (((struct VyattaNode*)gp)->_config._help != NULL) { - // printf("[help: %s]",((struct VyattaNode*)gp)->_config._help); + // fprintf(out_stream,"[help: %s]",((struct VyattaNode*)gp)->_config._help); } - printf("\n"); + fprintf(out_stream,"\n"); } } -- cgit v1.2.3 From 79c1a2d2dcbb74447ad5b142295161e0340a36f4 Mon Sep 17 00:00:00 2001 From: slioch Date: Tue, 17 Feb 2009 16:43:45 -0800 Subject: added additional debug output and fixed dumping of trans nodes to screen. added default priorities in priorities file. also fixed bug where interface changes could sweep in portions of failed configuration on error. now fixed. --- src/commit2.c | 104 ++++++++++++++++++++++++++++++++++----------------- src/common/unionfs.c | 12 ++++-- templates/priority | 3 ++ 3 files changed, 82 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/commit2.c b/src/commit2.c index cb129dd..82045fc 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -10,15 +10,28 @@ boolean g_display_error_node = FALSE; boolean g_coverage = FALSE; boolean g_dump_trans = FALSE; +int ActionOrder[top_act] = { + 4, + 5, + 6, + 0, + 1, + 2, + 3, + 7 +}; + + + char* ActionNames[top_act] = { - "delete", - "create", - "activate", - "update", - "syntax", - "commit", - "begin", - "end" + "delete", //0 + "create", //1 + "activate", //2 + "update", //3 + "syntax", //4 + "commit", //5 + "begin", //6 + "end" //7 }; extern boolean @@ -154,8 +167,10 @@ main(int argc, char** argv) exit(0); } - if (g_dump_trans == TRUE) { - printf("Dumping transactions\n"); + if (g_debug == TRUE || g_dump_trans == TRUE) { + if (g_dump_trans == TRUE) { + fprintf(out_stream,"Dumping transactions\n"); + } //iterate over config_data and dump... g_node_traverse(trans_coll, G_PRE_ORDER, @@ -163,7 +178,9 @@ main(int argc, char** argv) -1, (GNodeTraverseFunc)dump_func, (gpointer)NULL); - exit(0); + if (g_dump_trans == TRUE) { + exit(0); + } } GNode *trans_child_node = (GNode*)g_node_first_child(trans_coll); @@ -178,13 +195,24 @@ main(int argc, char** argv) do { boolean success = TRUE; if (g_debug == TRUE) { - printf("commit2: Starting new transaction processing pass on root\n"); + if (trans_child_node != NULL && trans_child_node->data != NULL && ((struct VyattaNode*)(trans_child_node->data))->_data._name != NULL) { + printf("commit2: Starting new transaction processing pass on root: %s\n", ((struct VyattaNode*)(trans_child_node->data))->_data._name); + } + else { + printf("commit2: Starting new transaction processing pass on root:\n"); + } } //on each priority node now execute actions if ((success = process_priority_node(trans_child_node)) == TRUE) { //this below copies the node directory from the local to active location - complete(trans_child_node, test_mode); + //if this is true root skip + if (trans_child_node != NULL && trans_child_node->data != NULL && strcmp(((struct VyattaNode*)(trans_child_node->data))->_data._path,"/") == 0) { + //no op, need better way to define true root + } + else { + complete(trans_child_node, test_mode); + } } if (success == FALSE) { @@ -563,11 +591,19 @@ cleanup(GNode *root_node) gboolean dump_func(GNode *node, gpointer data) { + FILE *out; + if (g_dump_trans) { + out = out_stream; + } + else { + out = stdout; + } + if (node != NULL) { guint depth = g_node_depth(node); if (depth == 2) { - fprintf(out_stream,"NEW TRANS\n"); + fprintf(out,"NEW TRANS\n"); } gpointer gp = ((GNode*)node)->data; @@ -575,57 +611,57 @@ dump_func(GNode *node, gpointer data) int i; if (IS_DELETE(((struct VyattaNode*)gp)->_data._operation)) { - fprintf(out_stream,"-"); + fprintf(out,"-"); } else if (IS_CREATE(((struct VyattaNode*)gp)->_data._operation)) { - fprintf(out_stream,"+"); + fprintf(out,"+"); } else if (IS_SET(((struct VyattaNode*)gp)->_data._operation)) { - fprintf(out_stream,">"); + fprintf(out,">"); } else { - fprintf(out_stream," "); + fprintf(out," "); } for (i = 0; i < depth; ++i) { - fprintf(out_stream," "); + fprintf(out," "); } - fprintf(out_stream,"%s (t: %d, p: %d)", ((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_config._def.def_type,((struct VyattaNode*)gp)->_priority); + fprintf(out,"%s (t: %d, p: %d)", ((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_config._def.def_type,((struct VyattaNode*)gp)->_priority); if (((struct VyattaNode*)gp)->_data._value == TRUE) { - fprintf(out_stream," [VALUE]"); + fprintf(out," [VALUE]"); } if (((struct VyattaNode*)gp)->_config._multi == TRUE) { - fprintf(out_stream," [MULTI]"); + fprintf(out," [MULTI]"); } if (((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head && ((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head->vtw_node_aux == 0) { - fprintf(out_stream," [SYNTAX]"); + fprintf(out," [SYNTAX]"); } if (((struct VyattaNode*)gp)->_config._def.actions[create_act].vtw_list_head) { - fprintf(out_stream," [CREATE]"); + fprintf(out," [CREATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[activate_act].vtw_list_head) { - fprintf(out_stream," [ACTIVATE]"); + fprintf(out," [ACTIVATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[update_act].vtw_list_head) { - fprintf(out_stream," [UPDATE]"); + fprintf(out," [UPDATE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[delete_act].vtw_list_head) { - fprintf(out_stream," [DELETE]"); + fprintf(out," [DELETE]"); } if (((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head && ((struct VyattaNode*)gp)->_config._def.actions[syntax_act].vtw_list_head->vtw_node_aux == 1) { - fprintf(out_stream," [COMMIT]"); + fprintf(out," [COMMIT]"); } if (((struct VyattaNode*)gp)->_config._def.actions[begin_act].vtw_list_head) { - fprintf(out_stream," [BEGIN]"); + fprintf(out," [BEGIN]"); } if (((struct VyattaNode*)gp)->_config._def.actions[end_act].vtw_list_head) { - fprintf(out_stream," [END]"); + fprintf(out," [END]"); } if (((struct VyattaNode*)gp)->_config._help != NULL) { - // fprintf(out_stream,"[help: %s]",((struct VyattaNode*)gp)->_config._help); + // fprintf(out,"[help: %s]",((struct VyattaNode*)gp)->_config._help); } - fprintf(out_stream,"\n"); + fprintf(out,"\n"); } } @@ -681,7 +717,7 @@ process_priority_node(GNode *priority_node) order = G_POST_ORDER; } - result._action = i; + result._action = ActionOrder[i]; g_node_traverse((GNode*)priority_node, order, G_TRAVERSE_ALL, @@ -737,7 +773,7 @@ enclosing_process_func(GNode *node, gpointer data) order = G_POST_ORDER; } - result->_action = i; + result->_action = ActionOrder[i]; g_node_traverse((GNode*)node, order, G_TRAVERSE_ALL, diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 1d9cbe8..7084893 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -381,7 +381,9 @@ value_exists(char *path) void common_set_parent_context(char *cpath, char *dpath) { - printf("common_set_parent_context(incoming): %s, %s\n",cpath,dpath); + if (g_debug) { + printf("common_set_parent_context(incoming): %s, %s\n",cpath,dpath); + } //strip off last path and set int index = strlen(cpath)-1; if (cpath[index] == '/') { @@ -412,7 +414,9 @@ common_set_parent_context(char *cpath, char *dpath) *ptr = '\0'; } set_path(dpath,FALSE); - printf("common_set_parent_context: %s, %s\n",cpath,dpath); + if (g_debug) { + printf("common_set_parent_context: %s, %s\n",cpath,dpath); + } } /** @@ -421,7 +425,9 @@ common_set_parent_context(char *cpath, char *dpath) void common_set_context(char *cpath, char *dpath) { - printf("common_set_context: %s, %s\n",cpath,dpath); + if (g_debug) { + printf("common_set_context: %s, %s\n",cpath,dpath); + } set_path(cpath,TRUE); set_path(dpath,FALSE); } diff --git a/templates/priority b/templates/priority index f8e3063..ff7a7e6 100644 --- a/templates/priority +++ b/templates/priority @@ -26,4 +26,7 @@ 630 protocols 700 vpn 900 cluster +900 qos-policy +900 test-definition +900 content-inspection 900 load-balancing -- cgit v1.2.3