create_profile_from_template = { label = "Create Profile From Template" shortcut = "cpft" parameters = { new_profile_name = { shortcut = "npn" required = true } template_profile_name = { shortcut = "tpn" required = true } changes = { shortcut = "c" required = true additional_legal_url_characters = " %{}\"'=" } } expression = ` #echo("create_profile_from_template"); include "lib.profile"; # Delete the profile we're about to create, if it exist string new_profile_pathname = LOGANALYSISINFO_DIRECTORY . internal.directory_divider . "profiles" . internal.directory_divider . new_profile_name . ".cfg"; if (file_exists(new_profile_pathname)) then ( # echo("Deleting " . new_profile_pathname); delete_file(new_profile_pathname); write_file(new_profile_pathname, new_profile_name . " = ''"); ); ## Duplicate the template profile node, creating the new profile #echo("Creating profile: " . new_profile_name); string newprofilepath = "profiles." . new_profile_name; node template_profile_node = "profiles." . template_profile_name; (newprofilepath . "") = ""; node newprofile = newprofilepath; save_node(newprofile); duplicate_node(template_profile_node, newprofile); # Apply the changes node changes_node = string_to_node(changes); #echo("changes_node: " . node_as_string(changes_node)); overlay_node(newprofile, changes_node); save_node(newprofile); # Generate the XML result, for use in network action node result = new_action_result(command_line.action); @result{"Result"} = "Success"; @result{"NewProfile"} = new_profile_name; @result{"TemplateProfile"} = template_profile_name; @result{"Changes"} = changes; string xml_result = action_result_to_xml(result); #echo("xml_result: " . xml_result); xml_result; ` # expression } # create_profile_from_template