summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2009-03-23 11:49:54 -0700
committerslioch <slioch@eng-140.vyatta.com>2009-03-23 11:49:54 -0700
commit6c68c83d206a408c3dd61c1bb9adda4e20206e01 (patch)
tree4964da93bc8dd8ce2b71d62a1fdc19d9b16dac03 /src
parente23a6efaeeaf1e1d35b64ac819aed7ea096e5288 (diff)
downloadvyatta-cfg-6c68c83d206a408c3dd61c1bb9adda4e20206e01.tar.gz
vyatta-cfg-6c68c83d206a408c3dd61c1bb9adda4e20206e01.zip
added command to view set of actions and nodes applied to system in order. The new command flag is "-a"
Diffstat (limited to 'src')
-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);
}