Fix: generate a full output configuration node
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 4 Jul 2016 19:29:56 +0000 (15:29 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 4 Jul 2016 19:42:28 +0000 (15:42 -0400)
The lttng save --omit-output does not remove the destination node but the full
output node. Make sure to create a full one.

src/bin/lttng/commands/create.c

index c8027133d2a0666cf9b2f79dc3c556a046293fc1..7581624aded45e4c2de710413c67f6876f3e65ff 100644 (file)
@@ -765,6 +765,59 @@ static int create_session_from_template(struct config_document *template,
        config_element_free(temp_element_child);
        temp_element_child = NULL;
 
+       /* Construct the output/consumer_output/ node*/
+       temp_element_child = temp_element;
+       temp_element = config_element_create("consumer_output", NULL);
+       if (!temp_element) {
+               ERR("Could not create consumer_output node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       ret = config_element_add_child(temp_element, temp_element_child);
+       if (ret) {
+               ERR("Could not append output data to the consumer_output node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       config_element_free(temp_element_child);
+       temp_element_child = config_element_create("enabled", "true");
+       if (!temp_element_child) {
+               ERR("Could not create enbaled node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       ret = config_element_add_child(temp_element, temp_element_child);
+       if (ret) {
+               ERR("Could not append node to the consumer_output node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       config_element_free(temp_element_child);
+       temp_element_child = NULL;
+
+
+       temp_element_child = temp_element;
+       temp_element = config_element_create("output", NULL);
+       if (!temp_element) {
+               ERR("Could not create output node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       ret = config_element_add_child(temp_element, temp_element_child);
+       if (ret) {
+               ERR("Could not append output data to the output node configuration");
+               ret = CMD_ERROR;
+               goto error;
+       }
+
+       config_element_free(temp_element_child);
+       temp_element_child = NULL;
+
 
        /*
         * validate and replace the destination node for each session type
@@ -774,22 +827,44 @@ static int create_session_from_template(struct config_document *template,
        switch (session_type) {
        case SESSION_NORMAL:
        case SESSION_LIVE:
-               if (!config_document_element_exist(template, "/sessions/session/output/consumer_output/destination")) {
-                       ERR("Invalid template no destination node configuration present");
+               break;
+       case SESSION_SNAPSHOT:
+               /* construct the output/snapshots_outputs/ */
+               temp_element_child = temp_element;
+               temp_element = config_element_create("snapshot_outputs", NULL);
+               if (!temp_element) {
+                       ERR("Could not create snapshot_outputs node configuration");
                        ret = CMD_ERROR;
                        goto error;
                }
 
-               ret = config_document_replace_element(template, "/sessions/session/output/consumer_output/destination", temp_element);
-               break;
-       case SESSION_SNAPSHOT:
-               if (!config_document_element_exist(template, "/sessions/session/output/snapshot_outputs/output/consumer_output/destination")) {
-                       ERR("Invalid template no destination node configuration present");
+               ret = config_element_add_child(temp_element, temp_element_child);
+               if (ret) {
+                       ERR("Could not append output data to the snapshot_outputs node configuration");
                        ret = CMD_ERROR;
                        goto error;
                }
 
-               ret = config_document_replace_element(template, "/sessions/session/output/snapshot_outputs/output/consumer_output/destination", temp_element);
+               config_element_free(temp_element_child);
+               temp_element_child = NULL;
+
+               temp_element_child = temp_element;
+               temp_element = config_element_create("output", NULL);
+               if (!temp_element) {
+                       ERR("Could not create output node configuration");
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
+               ret = config_element_add_child(temp_element, temp_element_child);
+               if (ret) {
+                       ERR("Could not append output data to the output node configuration");
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
+               config_element_free(temp_element_child);
+               temp_element_child = NULL;
                break;
        default:
                ERR("Invalid session type");
@@ -797,6 +872,12 @@ static int create_session_from_template(struct config_document *template,
                goto error;
        }
 
+       if (!config_document_element_exist(template, "/sessions/session/output")) {
+               ret = config_document_insert_element(template, "/sessions/session", temp_element);
+       } else {
+               ret = config_document_replace_element(template, "/sessions/session/output", temp_element);
+       }
+
        config_element_free(temp_element);
        temp_element = NULL;
 
This page took 0.028608 seconds and 5 git commands to generate.