summaryrefslogtreecommitdiff
path: root/src/commit2.c
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-23 14:08:25 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-23 14:08:25 -0700
commit085991ef81d5641c7df953508a82d9a890f9ef37 (patch)
tree0e166efdb4cb774f11c1862f9edfe3b031f364fe /src/commit2.c
parent5acbf279c7fd5d47c28db0b29ea76b3e81e3e920 (diff)
parenta7fbe5bbaa0e7d6d65b11a81ebc3b4080f0973ef (diff)
downloadvyatta-cfg-085991ef81d5641c7df953508a82d9a890f9ef37.tar.gz
vyatta-cfg-085991ef81d5641c7df953508a82d9a890f9ef37.zip
Merge branch 'jenner' of suva.vyatta.com:/git/vyatta-cfg into jenner
Diffstat (limited to 'src/commit2.c')
-rw-r--r--src/commit2.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/commit2.c b/src/commit2.c
index bf5957d..5eb8e55 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -12,6 +12,7 @@ boolean g_debug = FALSE;
boolean g_display_error_node = FALSE;
boolean g_coverage = FALSE;
boolean g_dump_trans = FALSE;
+boolean g_dump_actions = FALSE;
const int ActionOrder[top_act] = {
4,
@@ -88,6 +89,7 @@ usage(void)
printf("commit2\n");
printf("\t-d\t\tdebug mode\n");
printf("\t-s\t\tdump sorted transactions and exit\n");
+ printf("\t-a\t\tdump ordered node actions and exit\n");
printf("\t-p\t\tdisable priority mode\n");
printf("\t-t\t\ttest mode (don't apply directory modifications)\n");
printf("\t-e\t\tprint node where error occurred\n");
@@ -109,7 +111,7 @@ main(int argc, char** argv)
boolean disable_partial_commit = FALSE;
//grab inputs
- while ((ch = getopt(argc, argv, "dpthseco")) != -1) {
+ while ((ch = getopt(argc, argv, "dpthsecoa")) != -1) {
switch (ch) {
case 'd':
g_debug = TRUE;
@@ -136,6 +138,9 @@ main(int argc, char** argv)
case 'o':
disable_partial_commit = TRUE;
break;
+ case 'a':
+ g_dump_actions = TRUE;
+ break;
default:
usage();
exit(0);
@@ -207,6 +212,10 @@ main(int argc, char** argv)
//complete() now requires a undisturbed copy of the trans_child_node tree
GNode *comp_cp_node = g_node_copy(trans_child_node);
+ if (g_dump_actions == TRUE) {
+ fprintf(out_stream,"\n"); //add an extra line here
+ }
+
//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
@@ -215,12 +224,16 @@ main(int argc, char** argv)
//no op, need better way to define true root
}
else {
- if (disable_partial_commit == FALSE) {
+ if (disable_partial_commit == FALSE && g_dump_actions == FALSE) {
complete(comp_cp_node, test_mode);
}
}
}
+ if (g_dump_actions == FALSE) {
+ success = TRUE; //FORCE SUCCESS ON DISPLAY MODE OF ACTIONS
+ }
+
if (success == FALSE) {
no_errors = FALSE;
if (g_debug == TRUE) {
@@ -231,13 +244,15 @@ main(int argc, char** argv)
} while ((trans_child_node = (GNode*)g_node_nth_child((GNode*)trans_coll,(guint)i)) != NULL);
if (no_errors == TRUE) {
- if (disable_partial_commit == TRUE) {
+ if (disable_partial_commit == TRUE && g_dump_actions == FALSE) {
complete(orig_node_tree, test_mode);
}
/*
* Need to add to the following func below to clean up dangling .wh. files
*/
- common_commit_clean_temp_config(test_mode);
+ if (g_dump_actions == FALSE) {
+ common_commit_clean_temp_config(test_mode);
+ }
if (g_debug == TRUE) {
printf("commit2: successful commit, now cleaning up temp directories\n");
}
@@ -356,7 +371,19 @@ process_func(GNode *node, gpointer data)
setenv(ENV_ACTION_NAME,ENV_ACTION_SET,1);
}
- status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def);
+ if (g_dump_actions == FALSE) {
+ status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def);
+ }
+ else {
+ if (c->_def.actions[syntax_act].vtw_list_head &&
+ c->_def.actions[syntax_act].vtw_list_head->vtw_node_aux == 1) {
+ fprintf(out_stream,"commit\t:\t%s\n",d->_path);
+ }
+ else {
+ fprintf(out_stream,"%s\t:\t%s\n",ActionNames[result->_action],d->_path);
+ }
+ status = 1;
+ }
if (result->_action == delete_act) {
set_in_delete_action(FALSE);
}