843 |
843 |
}
|
844 |
844 |
if (progress > 0 && progress < 99) {
|
845 |
845 |
this.state("BUILD_COPY");
|
846 |
|
var params = this.get_copy_details(true);
|
847 |
|
this.set({progress_message: BUILDING_MESSAGES['COPY'].format(params.copy,
|
848 |
|
params.size,
|
849 |
|
params.progress)});
|
|
846 |
this.get_copy_details(true, undefined, _.bind(function(details){
|
|
847 |
this.set({
|
|
848 |
progress_message: BUILDING_MESSAGES['COPY'].format(details.copy,
|
|
849 |
details.size,
|
|
850 |
details.progress)
|
|
851 |
});
|
|
852 |
}, this));
|
850 |
853 |
}
|
851 |
854 |
if (progress == 100) {
|
852 |
855 |
this.state("BUILD_FINAL");
|
... | ... | |
856 |
859 |
}
|
857 |
860 |
},
|
858 |
861 |
|
859 |
|
get_copy_details: function(human, image) {
|
|
862 |
get_copy_details: function(human, image, callback) {
|
860 |
863 |
var human = human || false;
|
861 |
|
var image = image || this.get_image();
|
|
864 |
var image = image || this.get_image(_.bind(function(image){
|
|
865 |
var progress = this.get('progress');
|
|
866 |
var size = image.get_size();
|
|
867 |
var size_copied = (size * progress / 100).toFixed(2);
|
|
868 |
|
|
869 |
if (human) {
|
|
870 |
size = util.readablizeBytes(size*1024*1024);
|
|
871 |
size_copied = util.readablizeBytes(size_copied*1024*1024);
|
|
872 |
}
|
862 |
873 |
|
863 |
|
var progress = this.get('progress');
|
864 |
|
var size = image.get_size();
|
865 |
|
var size_copied = (size * progress / 100).toFixed(2);
|
866 |
|
|
867 |
|
if (human) {
|
868 |
|
size = util.readablizeBytes(size*1024*1024);
|
869 |
|
size_copied = util.readablizeBytes(size_copied*1024*1024);
|
870 |
|
}
|
871 |
|
return {'progress': progress, 'size': size, 'copy': size_copied};
|
|
874 |
callback({'progress': progress, 'size': size, 'copy': size_copied})
|
|
875 |
}, this));
|
872 |
876 |
},
|
873 |
877 |
|
874 |
878 |
start_stats_update: function(force_if_empty) {
|
... | ... | |
1178 |
1182 |
},
|
1179 |
1183 |
|
1180 |
1184 |
// get image object
|
1181 |
|
get_image: function() {
|
|
1185 |
get_image: function(callback) {
|
1182 |
1186 |
var image = storage.images.get(this.get('imageRef'));
|
1183 |
1187 |
if (!image) {
|
1184 |
|
storage.images.update_unknown_id(this.get('imageRef'));
|
|
1188 |
storage.images.update_unknown_id(this.get('imageRef'), callback);
|
|
1189 |
return;
|
1185 |
1190 |
}
|
|
1191 |
callback(image);
|
1186 |
1192 |
return image;
|
1187 |
1193 |
},
|
1188 |
1194 |
|
... | ... | |
1207 |
1213 |
|
1208 |
1214 |
// get metadata OS value
|
1209 |
1215 |
get_os: function() {
|
1210 |
|
return this.get_meta().OS || (this.get_image() ? this.get_image().get_os() || "okeanos" : "okeanos");
|
|
1216 |
return this.get_meta().OS || (this.get_image(function(){}) ? this.get_image(function(){}).get_os() || "okeanos" : "okeanos");
|
1211 |
1217 |
},
|
1212 |
1218 |
|
1213 |
1219 |
// get public ip addresses
|
... | ... | |
1552 |
1558 |
// update collection model with id passed
|
1553 |
1559 |
// making a direct call to the image
|
1554 |
1560 |
// api url
|
1555 |
|
update_unknown_id: function(id) {
|
|
1561 |
update_unknown_id: function(id, callback) {
|
1556 |
1562 |
var url = getUrl.call(this) + "/" + id;
|
1557 |
|
this.api_call(this.path + "/" + id, this.read_method, {_options:{async:false, skip_api_error:true}}, undefined,
|
|
1563 |
this.api_call(this.path + "/" + id, this.read_method, {_options:{async:true, skip_api_error:true}}, undefined,
|
1558 |
1564 |
_.bind(function() {
|
1559 |
1565 |
this.add({id:id, name:"Unknown image", size:-1, progress:100, status:"DELETED"});
|
|
1566 |
callback(this.get(id));
|
1560 |
1567 |
}, this), _.bind(function(image, msg, xhr) {
|
1561 |
1568 |
var img_data = this._read_image_from_request(image, msg, xhr);
|
1562 |
1569 |
this.add(img_data);
|
|
1570 |
callback(this.get(id));
|
1563 |
1571 |
}, this));
|
1564 |
1572 |
},
|
1565 |
1573 |
|
... | ... | |
1642 |
1650 |
// update collection model with id passed
|
1643 |
1651 |
// making a direct call to the flavor
|
1644 |
1652 |
// api url
|
1645 |
|
update_unknown_id: function(id) {
|
|
1653 |
update_unknown_id: function(id, callback) {
|
1646 |
1654 |
var url = getUrl.call(this) + "/" + id;
|
1647 |
1655 |
this.api_call(this.path + "/" + id, "read", {_options:{async:false, skip_api_error:true}}, undefined,
|
1648 |
1656 |
_.bind(function() {
|