summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2009-02-17 16:43:45 -0800
committerslioch <slioch@eng-140.vyatta.com>2009-02-17 16:43:45 -0800
commit79c1a2d2dcbb74447ad5b142295161e0340a36f4 (patch)
treef25a6fb4c088555b0707d15fe57cff9997dec913 /src
parenta3400424074a9d3b76c95561af4a948a430d4be4 (diff)
downloadvyatta-cfg-79c1a2d2dcbb74447ad5b142295161e0340a36f4.tar.gz
vyatta-cfg-79c1a2d2dcbb74447ad5b142295161e0340a36f4.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/commit2.c104
-rw-r--r--src/common/unionfs.c12
2 files changed, 79 insertions, 37 deletions
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);
}