Skip to content

Commit da1d8f9

Browse files
ramamurtiskaruturi
authored andcommitted
volume upload: fixed the UI after the change to move params to header.
Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>
1 parent dc870b5 commit da1d8f9

5 files changed

Lines changed: 136 additions & 111 deletions

File tree

‎systemvm/patches/debian/config/etc/init.d/cloud-early-config‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,9 +1159,11 @@ setup_secstorage() {
11591159
log_it "setting up apache2 for post upload of volume/template"
11601160
a2enmod proxy
11611161
a2enmod proxy_http
1162+
a2enmod headers
11621163

11631164
SSL_FILE="/etc/apache2/sites-available/default-ssl"
11641165
PATTERN="RewriteRule ^\/upload\/(.*)"
1166+
CORS_PATTERN="Header set Access-Control-Allow-Origin"
11651167
if [ -f $SSL_FILE ]; then
11661168
if grep -q "$PATTERN" $SSL_FILE ; then
11671169
log_it "rewrite rules already exist in file $SSL_FILE"
@@ -1172,6 +1174,14 @@ setup_secstorage() {
11721174
sed -i -e "s/<\/VirtualHost>/RewriteCond %{REQUEST_METHOD} =POST \n&/" $SSL_FILE
11731175
sed -i -e "s/<\/VirtualHost>/RewriteRule ^\/upload\/(.*) http:\/\/127.0.0.1:8210\/upload?uuid=\$1 [P,L] \n&/" $SSL_FILE
11741176
fi
1177+
if grep -q "$CORS_PATTERN" $SSL_FILE ; then
1178+
log_it "cors rules already exist in file $SSL_FILE"
1179+
else
1180+
log_it "adding cors rules to file: $SSL_FILE"
1181+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Origin \"*\" \n&/" $SSL_FILE
1182+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Methods \"POST, OPTIONS\" \n&/" $SSL_FILE
1183+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Headers \"x-requested-with, Content-Type, origin, authorization, accept, client-security-token, x-signature, x-metadata, x-expires\" \n&/" $SSL_FILE
1184+
fi
11751185
fi
11761186

11771187
service apache2 restart

‎systemvm/scripts/config_ssl.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ config_apache2_conf() {
6161

6262
SSL_FILE="/etc/apache2/sites-available/default-ssl"
6363
PATTERN="RewriteRule ^\/upload\/(.*)"
64+
CORS_PATTERN="Header set Access-Control-Allow-Origin"
6465
if [ -f $SSL_FILE ]; then
6566
if grep -q "$PATTERN" $SSL_FILE ; then
6667
echo "rewrite rules already exist in file $SSL_FILE"
@@ -71,6 +72,14 @@ config_apache2_conf() {
7172
sed -i -e "s/<\/VirtualHost>/RewriteCond %{REQUEST_METHOD} =POST \n&/" $SSL_FILE
7273
sed -i -e "s/<\/VirtualHost>/RewriteRule ^\/upload\/(.*) http:\/\/127.0.0.1:8210\/upload?uuid=\$1 [P,L] \n&/" $SSL_FILE
7374
fi
75+
if grep -q "$CORS_PATTERN" $SSL_FILE ; then
76+
echo "cors rules already exist in file $SSL_FILE"
77+
else
78+
echo "adding cors rules to file: $SSL_FILE"
79+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Origin \"*\" \n&/" $SSL_FILE
80+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Methods \"POST, OPTIONS\" \n&/" $SSL_FILE
81+
sed -i -e "s/<\/VirtualHost>/Header always set Access-Control-Allow-Headers \"x-requested-with, Content-Type, origin, authorization, accept, client-security-token, x-signature, x-metadata, x-expires\" \n&/" $SSL_FILE
82+
fi
7483
fi
7584

7685
}

‎ui/scripts/storage.js‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -454,28 +454,25 @@
454454

455455
args.response.success({
456456
url: uploadparams.postURL,
457+
ajaxPost: true,
457458
data: {
458-
signature: uploadparams.signature,
459-
expires: uploadparams.expires,
460-
metadata: uploadparams.metadata
459+
'X-signature': uploadparams.signature,
460+
'X-expires': uploadparams.expires,
461+
'X-metadata': uploadparams.metadata
461462
}
462463
});
463-
464-
cloudStack.dialog.notice({
465-
message: "This volume file has been uploaded. Please check its status at Stroage menu > Volumes > " + args.data.name + " > Status field."
466-
});
467464
}
468465
});
469466
},
470467
postUpload: function(args) {
471-
console.log("postUpload() is hit");
472-
// Called when upload is done to do
473-
// verification checks;
474-
// i.e., poll the server to verify successful upload
475-
//
476-
// success() will close the dialog and call standard action
477-
// error() will keep dialog open if user wants to re-submit
478-
args.response.success();
468+
if(args.error) {
469+
args.response.error(args.errorMsg);
470+
} else {
471+
cloudStack.dialog.notice({
472+
message: "This volume file has been uploaded. Please check its status at Stroage menu > Volumes > " + args.data.name + " > Status field."
473+
});
474+
args.response.success();
475+
}
479476
}
480477
},
481478
fields: {

‎ui/scripts/templates.js‎

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -636,48 +636,30 @@
636636
data: data,
637637
async: false,
638638
success: function(json) {
639-
/*
640-
{
641-
"postuploadtemplateresponse": {
642-
"getuploadparams": {
643-
"id": "d5bdaf23-dcb9-4eef-9b94-81870490f457",
644-
"postURL": "https://10.223.67.4/upload/d5bdaf23-dcb9-4eef-9b94-81870490f457",
645-
"metadata": "7jCvmzKuMBStM/qEjx9HjSAISd+f3VAUqC9CkYmq92O+SznYov415LUndZ4KuLAtGNY37VeePs8X+0oyaVSj+cjD+KKoBJuynjBJViAQQYKT/amcOdrkloBA4DgNEAn16p32Z2qI4+Ky1ecDAtg1vkYNoz9ReaKbehM3n5MIFPonhnYBEmbVSZkCIbVbJeh+vmYs9Y3SHtcG+0gWiU06YQ4KGl7Wc03wp3wusAlj7+L+fEBha54Rx+C7aS6UPZgm8/+atUUric6xiGMsx603NUElcLWE+gQ7PTimsIr6ySvcmc3D0n6JK6A7bc72sfPrHEbnNPD+5+qXJsBcXPLtEAG2WwduarwZ",
646-
"timeout": "2015-01-20T01:01:02.548Z",
647-
"signature": "NLXv5YsNuUn7NKC+ZP5JtSM26MY="
648-
}
649-
}
650-
}
651-
*/
652-
653-
var uploadparams = json.postuploadtemplateresponse.getuploadparams; //son.postuploadtemplateresponse.getuploadparams is an object, not an array of object.
639+
var uploadparams = json.postuploadtemplateresponse.getuploadparams;
654640
var templateId = uploadparams.id;
655641

656642
args.response.success({
657643
url: uploadparams.postURL,
644+
ajaxPost: true,
658645
data: {
659-
signature: uploadparams.signature,
660-
expires: uploadparams.timeout,
661-
metadata: uploadparams.metadata
646+
'X-signature': uploadparams.signature,
647+
'X-expires': uploadparams.expires,
648+
'X-metadata': uploadparams.metadata
662649
}
663650
});
664-
665-
cloudStack.dialog.notice({
666-
message: "This template file has been uploaded. Please check its status at Templates menu > " + args.data.name + " > Zones tab > click a zone > Status field and Ready field."
667-
});
668-
669651
}
670652
});
671653
},
672654
postUpload: function(args) {
673-
console.log("postUpload() is hit");
674-
// Called when upload is done to do
675-
// verification checks;
676-
// i.e., poll the server to verify successful upload
677-
//
678-
// success() will close the dialog and call standard action
679-
// error() will keep dialog open if user wants to re-submit
680-
args.response.success();
655+
if(args.error) {
656+
args.response.error(args.errorMsg);
657+
} else {
658+
cloudStack.dialog.notice({
659+
message: "This template file has been uploaded. Please check its status at Templates menu > " + args.data.name + " > Zones tab > click a zone > Status field and Ready field."
660+
});
661+
args.response.success();
662+
}
681663
}
682664
},
683665
fields: {

0 commit comments

Comments
 (0)