mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge pull request #253 from abelCoronado93/template-ajax
F #4913: Created new images and networks before import vCenter template
This commit is contained in:
commit
5370bde6bf
@ -45,7 +45,6 @@ define(function(require) {
|
||||
|
||||
/*
|
||||
Retrieve the list of templates from vCenter and fill the container with them
|
||||
|
||||
opts = {
|
||||
datacenter: "Datacenter Name",
|
||||
cluster: "Cluster Name",
|
||||
@ -56,6 +55,7 @@ define(function(require) {
|
||||
}
|
||||
*/
|
||||
function _fillVCenterTemplates(opts) {
|
||||
this.opts = opts;
|
||||
var path = '/vcenter/templates';
|
||||
|
||||
var context = $(".vcenter_import", opts.container);
|
||||
@ -157,6 +157,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _import(context) {
|
||||
that = this;
|
||||
$.each($(".vcenter_import_table", context), function() {
|
||||
$.each($(this).DataTable().$(".check_item:checked"), function() {
|
||||
var row_context = $(this).closest("tr");
|
||||
@ -198,29 +199,72 @@ define(function(require) {
|
||||
template += "\nUSER_INPUTS=[\n" + userInputs.join(",\n") + "]";
|
||||
}
|
||||
|
||||
var template_json = {
|
||||
"vmtemplate": {
|
||||
"template_raw": template
|
||||
}
|
||||
};
|
||||
if($(this).data("import_data").import_disks_and_nics){
|
||||
var path = '/vcenter/template/' + $(this).data("import_data").vcenter_ref;
|
||||
$.ajax({
|
||||
url: path,
|
||||
type: "GET",
|
||||
data: {timeout: false},
|
||||
headers: {
|
||||
"X-VCENTER-USER": that.opts.vcenter_user,
|
||||
"X-VCENTER-PASSWORD": that.opts.vcenter_password,
|
||||
"X-VCENTER-HOST": that.opts.vcenter_host
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(response){
|
||||
template += "\n" + response.one;
|
||||
var template_json = {
|
||||
"vmtemplate": {
|
||||
"template_raw": template
|
||||
}
|
||||
};
|
||||
OpenNebulaTemplate.create({
|
||||
timeout: true,
|
||||
data: template_json,
|
||||
success: function(request, response) {
|
||||
VCenterCommon.importSuccess({
|
||||
context : row_context,
|
||||
message : Locale.tr("Template created successfully. ID: %1$s", response.VMTEMPLATE.ID)
|
||||
});
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
VCenterCommon.importFailure({
|
||||
context : row_context,
|
||||
message : (error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?"))
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(response){
|
||||
Notifier.onError({}, OpenNebulaError(response));
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
var template_json = {
|
||||
"vmtemplate": {
|
||||
"template_raw": template
|
||||
}
|
||||
};
|
||||
|
||||
OpenNebulaTemplate.create({
|
||||
timeout: true,
|
||||
data: template_json,
|
||||
success: function(request, response) {
|
||||
VCenterCommon.importSuccess({
|
||||
context : row_context,
|
||||
message : Locale.tr("Template created successfully. ID: %1$s", response.VMTEMPLATE.ID)
|
||||
});
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
VCenterCommon.importFailure({
|
||||
context : row_context,
|
||||
message : (error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?"))
|
||||
});
|
||||
}
|
||||
});
|
||||
OpenNebulaTemplate.create({
|
||||
timeout: true,
|
||||
data: template_json,
|
||||
success: function(request, response) {
|
||||
VCenterCommon.importSuccess({
|
||||
context : row_context,
|
||||
message : Locale.tr("Template created successfully. ID: %1$s", response.VMTEMPLATE.ID)
|
||||
});
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
VCenterCommon.importFailure({
|
||||
context : row_context,
|
||||
message : (error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?"))
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user