Commit 99c65963 authored by Efthymia Bika's avatar Efthymia Bika

Pass certificate file to duplicity calls

parent 2d4d8a49
......@@ -159,6 +159,8 @@ function run_duplicity(restore, force) {
var exclude_device_files_arg = (restore) ? " " :
" --exclude-device-files ";
cacert_arg = " --ssl-cacert-file " + clouds[cloud].cert + " ";
function dup_output(error, stdout, stderr) {
toggle_error(error, stderr);
if(error) {
......@@ -252,9 +254,9 @@ function run_duplicity(restore, force) {
escape_quote_str(directory);
}
var cmd = build_win_commands();
var dup_cmd = DUPLICITY_PATH + " " + type_arg + force_arg +
exclude_device_files_arg + include_arg + exclude_arg +
file_arg + time_arg + dirs + ";";
var dup_cmd = DUPLICITY_PATH + " " + type_arg + cacert_arg +
force_arg + exclude_device_files_arg + include_arg +
exclude_arg + file_arg + time_arg + dirs + ";";
var args = ["-c", cmd + dup_cmd];
execFile(CYGWIN_BASH, args, dup_output);
......@@ -268,8 +270,8 @@ function run_duplicity(restore, force) {
dirs = " swift://" + container_name + " " +
escape_quote_str(directory);
}
var dup_cmd = DUPLICITY_PATH + " " + type_arg + force_arg +
exclude_device_files_arg + dup_verbosity + log_arg +
var dup_cmd = DUPLICITY_PATH + " " + type_arg + cacert_arg +
force_arg + exclude_device_files_arg + dup_verbosity + log_arg +
include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
exec(dup_cmd , dup_output);
}
......@@ -289,7 +291,10 @@ function load_status() {
}
$("#loader").hide();
}
var dup_cmd = DUPLICITY_PATH + " collection-status swift://" + container;
var cacert_arg = " --ssl-cacert-file " +
clouds[$("#cloud").val()].cert;
var dup_cmd = DUPLICITY_PATH + cacert_arg +
" collection-status swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
var args = ["-c", cmd + dup_cmd];
......@@ -334,8 +339,10 @@ function remove_all(time, force) {
force_arg = " --force ";
}
var cacert_arg = " --ssl-cacert-file " +
clouds[$("#cloud").val()].cert;
var dup_cmd = DUPLICITY_PATH + " remove-older-than " +
time + force_arg + " swift://" + container;
time + force_arg + cacert_arg + " swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
var args = ["-c", cmd + dup_cmd];
......
......@@ -51,9 +51,11 @@ function show_contents_by_date(error, stdout, stderr) {
}
var locale_date = new Date(el.timestamp).toLocaleString();
var filename = (el.name.length > 30) ?
el.name.substring(0,7) + "..." + el.name.substring(el.name.length-7, el.name.length):
el.name;
var li = $("<li>&nbsp;<span>" + filename + "&nbsp;</span><span class='right'>"
el.name.substring(0,7) + "..." +
el.name.substring(el.name.length-7, el.name.length) :
el.name;
var li = $("<li>&nbsp;<span>" + filename +
"&nbsp;</span><span class='right'>"
+ locale_date + "</span></li>")
.attr("id", el.name);
var icon_class = (el.type == 'dir')
......@@ -65,7 +67,8 @@ function show_contents_by_date(error, stdout, stderr) {
.attr("id", "rest_icon_" + i)
.attr("title", "Restore")
.attr("class", "hide")
.attr("onclick", "go_to_restore_single('" + escape_illegal_chars(el.name) + "')");
.attr("onclick", "go_to_restore_single('" +
escape_illegal_chars(el.name) + "')");
li.append(icon);
li.append(rest_icon);
......@@ -119,7 +122,8 @@ function fill_breadcrumbs(path) {
}
var a_crumb = $("<a>" + value + "</a>")
.attr("href", "#")
.attr("onclick", "go_to_path('" + escape_illegal_chars(cur_path) + "')");
.attr("onclick", "go_to_path('" +
escape_illegal_chars(cur_path) + "')");
li_crumb.append(a_crumb);
$(".breadcrumbs").append(li_crumb);
});
......@@ -151,9 +155,12 @@ function get_contents_by_date(value) {
init_path = time_path;
}
var datapath = path.join(BAAS_CACHE_DIR, 'timeviews');
var cacert_file = " " + clouds[$("#cloud").val()].cert + " ";
var time_cmd = "python " + TIMEVIEW_PATH + " " + datapath + " swift://" +
container + " get " + value + " " + escape_quote_str(time_path);
container + cacert_file + " get " + value + " " +
escape_quote_str(time_path);
if(process.platform == 'win32') {
var cmd = build_win_commands();
var args = ["-c", cmd + time_cmd];
......@@ -180,7 +187,8 @@ function load_timeview() {
value = value.substring(0, 19);
var iso_time = value.replace('.', 'T');
dates_list += "<a href='#' onclick='get_contents_by_date(\""
+ iso_time + "\")' id='" + iso_time + "'>" + value.replace('.', ' ') + "</a><br>";
+ iso_time + "\")' id='" + iso_time + "'>" +
value.replace('.', ' ') + "</a><br>";
});
}
$("#time-dates").html(dates_list);
......@@ -188,7 +196,10 @@ function load_timeview() {
parse_cloud_error(false, stderr, false);
}
}
var dup_cmd = DUPLICITY_PATH + " collection-status swift://" + container;
var cacert_arg = " --ssl-cacert-file " +
clouds[$("#cloud").val()].cert;
var dup_cmd = DUPLICITY_PATH + cacert_arg +
" collection-status swift://" + container;
if(process.platform == 'win32') {
var cmd = build_win_commands();
var args = ["-c", cmd + dup_cmd];
......
......@@ -79,11 +79,12 @@ def put_timepoint(config, timepoint, data):
f.write(json.dumps(root, indent=2))
def fetch_timepoint(config, timepoint):
def fetch_timepoint(config, timepoint, cacert_file):
curpath = os.path.dirname(os.path.realpath(__file__))
duplicity = os.path.join(curpath, 'duplicity')
args = [duplicity, 'list-current-files', '-t', timepoint,
config['target_url']]
'--ssl-cacert-file', cacert_file, config['target_url']]
proc = Popen(args, stdout=PIPE, stderr=PIPE)
procout, procerr = proc.communicate()
proc.wait()
......@@ -93,7 +94,7 @@ def fetch_timepoint(config, timepoint):
put_timepoint(config, timepoint, procout)
def get_timepoint(config, timepoint, path):
def get_timepoint(config, timepoint, path, cacert_file):
datafile = path_join(config['datapath'], timepoint)
retries = 1
while True:
......@@ -105,7 +106,7 @@ def get_timepoint(config, timepoint, path):
if e.errno != errno.ENOENT or retries == 0:
raise
fetch_timepoint(config, timepoint)
fetch_timepoint(config, timepoint, cacert_file)
if retries <= 0:
raise e
retries -= 1
......@@ -150,30 +151,33 @@ def get_config():
def main():
from sys import argv, stdin, stdout
def help():
print "Usage: %s <datapath> <target_url> [get <absolute_timepoint> <path> | list]" % argv[0]
print "Usage: %s <datapath> <target_url> <cacert_file> [get <absolute_timepoint> <path> | list]" % argv[0]
raise SystemExit(1)
if len(argv) < 4:
if len(argv) < 5:
help()
datapath = argv[1]
ensure_datapath(datapath)
target_url = argv[2]
cmd = argv[3]
cmd = argv[4]
if cmd not in ['get', 'list']:
help()
cacert_file = argv[3]
#config = get_config()
config = {'datapath': datapath, 'target_url': target_url}
config = {'datapath': datapath,
'target_url': target_url,
'cacert_file': cacert_file}
if cmd == 'get':
if len(argv) < 6:
if len(argv) < 7:
help()
timepoint = argv[4]
path = unicode(argv[5], encoding='UTF-8')
r = get_timepoint(config, timepoint, path)
timepoint = argv[5]
path = unicode(argv[6], encoding='UTF-8')
r = get_timepoint(config, timepoint, path, cacert_file)
print json.dumps(r, indent=2)
elif cmd == 'list':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment