diff options
author | Alexey Shchepin <alexey@process-one.net> | 2003-02-22 19:11:00 +0000 |
---|---|---|
committer | Alexey Shchepin <alexey@process-one.net> | 2003-02-22 19:11:00 +0000 |
commit | 764a4288ce2a769cf18efb7fd02832d68a04f8f5 (patch) | |
tree | 39ef7eb0ee596016a8219c282d34c8abdc719f59 /src/mod_configure.erl | |
parent | * src/mod_offline.erl: Now possible to unload this module (diff) |
* src/mod_configure.erl: Backup management support
* src/mod_disco.erl: Likewise
SVN Revision: 81
Diffstat (limited to 'src/mod_configure.erl')
-rw-r--r-- | src/mod_configure.erl | 127 |
1 files changed, 126 insertions, 1 deletions
diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 3f6c09a08..05381cbcc 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -211,6 +211,60 @@ get_form(["running nodes", ENode, "modules", "start"], Lang) -> } ]}; +get_form(["running nodes", ENode, "backup", "backup"], Lang) -> + {result, [{xmlelement, "title", [], + [{xmlcdata, + translate:translate( + Lang, "Backup to File")}]}, + {xmlelement, "instructions", [], + [{xmlcdata, + translate:translate( + Lang, "Enter path to backup file")}]}, + {xmlelement, "field", [{"type", "text-single"}, + {"label", + translate:translate( + Lang, "Path to File")}, + {"var", "path"}], + [{xmlelement, "value", [], [{xmlcdata, ""}]}] + } + ]}; + +get_form(["running nodes", ENode, "backup", "restore"], Lang) -> + {result, [{xmlelement, "title", [], + [{xmlcdata, + translate:translate( + Lang, "Restore Backup from File")}]}, + {xmlelement, "instructions", [], + [{xmlcdata, + translate:translate( + Lang, "Enter path to backup file")}]}, + {xmlelement, "field", [{"type", "text-single"}, + {"label", + translate:translate( + Lang, "Path to File")}, + {"var", "path"}], + [{xmlelement, "value", [], [{xmlcdata, ""}]}] + } + ]}; + +get_form(["running nodes", ENode, "backup", "textfile"], Lang) -> + {result, [{xmlelement, "title", [], + [{xmlcdata, + translate:translate( + Lang, "Dump Backup to Text File")}]}, + {xmlelement, "instructions", [], + [{xmlcdata, + translate:translate( + Lang, "Enter path to text file")}]}, + {xmlelement, "field", [{"type", "text-single"}, + {"label", + translate:translate( + Lang, "Path to File")}, + {"var", "path"}], + [{xmlelement, "value", [], [{xmlcdata, ""}]}] + } + ]}; + get_form(["running nodes", ENode, "import", "file"], Lang) -> {result, [{xmlelement, "title", [], [{xmlcdata, @@ -428,6 +482,76 @@ set_form(["running nodes", ENode, "modules", "start"], Lang, XData) -> end; +set_form(["running nodes", ENode, "backup", "backup"], Lang, XData) -> + case search_running_node(ENode) of + false -> + {error, "404", "Not Found"}; + Node -> + case lists:keysearch("path", 1, XData) of + false -> + {error, "406", "Not Acceptable"}; + {value, {_, [String]}} -> + case rpc:call(Node, mnesia, backup, [String]) of + {badrpc, Reason} -> + {error, "500", "Internal Server Error"}; + {error, Reason} -> + {error, "500", "Internal Server Error"}; + _ -> + {result, []} + end; + _ -> + {error, "406", "Not Acceptable"} + end + end; + + +set_form(["running nodes", ENode, "backup", "restore"], Lang, XData) -> + case search_running_node(ENode) of + false -> + {error, "404", "Not Found"}; + Node -> + case lists:keysearch("path", 1, XData) of + false -> + {error, "406", "Not Acceptable"}; + {value, {_, [String]}} -> + case rpc:call(Node, mnesia, restore, + [String, [{default_op, keep_tables}]]) of + {badrpc, Reason} -> + {error, "500", "Internal Server Error"}; + {error, Reason} -> + {error, "500", "Internal Server Error"}; + _ -> + {result, []} + end; + _ -> + {error, "406", "Not Acceptable"} + end + end; + + +set_form(["running nodes", ENode, "backup", "textfile"], Lang, XData) -> + case search_running_node(ENode) of + false -> + {error, "404", "Not Found"}; + Node -> + case lists:keysearch("path", 1, XData) of + false -> + {error, "406", "Not Acceptable"}; + {value, {_, [String]}} -> + case rpc:call(Node, mnesia, dump_to_textfile, [String]) of + {badrpc, Reason} -> + {error, "500", "Internal Server Error"}; + {error, Reason} -> + {error, "500", "Internal Server Error"}; + _ -> + {result, []} + end; + _ -> + {error, "406", "Not Acceptable"} + end + end; + + set_form(["running nodes", ENode, "import", "file"], Lang, XData) -> case search_running_node(ENode) of false -> @@ -437,7 +561,8 @@ set_form(["running nodes", ENode, "import", "file"], Lang, XData) -> false -> {error, "406", "Not Acceptable"}; {value, {_, [String]}} -> - rpc:call(Node, jd2ejd, import_file, [String]); + rpc:call(Node, jd2ejd, import_file, [String]), + {result, []}; _ -> {error, "406", "Not Acceptable"} end |