diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 6e545fcc3e8..b729c4bcc1f 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -853,12 +853,40 @@ url: createURL('addResourceDetail'), data: { resourceType: 'uservm', - resourceId: 3, + resourceId: args.context.instances[0].id, 'details[0].key': 'hypervisortoolsversion', 'details[0].value': (args.data.xenserverToolsVersion61plus == "on") ? 'xenserver61' : 'xenserver56' }, - success: function(json) { - //do nothing + success: function(json) { + var jobId = json.addResourceDetailresponse.jobid; + var addResourceDetailIntervalID = setInterval(function() { + $.ajax({ + url: createURL("queryAsyncJobResult&jobid=" + jobId), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + + if (result.jobstatus == 0) { + return; //Job has not completed + } else { + clearInterval(addResourceDetailIntervalID); + + if (result.jobstatus == 1) { + //do nothing + } else if (result.jobstatus == 2) { + cloudStack.dialog.notice({ + message: "Failed to update XenServer Tools Version 6.1+ field. Error: " + _s(result.jobresult.errortext) + }); + } + } + }, + error: function(XMLHttpResponse) { + cloudStack.dialog.notice({ + message: "Failed to update XenServer Tools Version 6.1+ field. Error: " + parseXMLHttpResponse(XMLHttpResponse) + }); + } + }); + }, g_queryAsyncJobResultInterval); } }); } diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 922c87e32eb..d4655e72e0a 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -670,12 +670,40 @@ url: createURL('addResourceDetail'), data: { resourceType: 'template', - resourceId: 1, + resourceId: args.context.templates[0].id, 'details[0].key': 'hypervisortoolsversion', 'details[0].value': (args.data.xenserverToolsVersion61plus == "on") ? 'xenserver61' : 'xenserver56' }, success: function(json) { - //do nothing + var jobId = json.addResourceDetailresponse.jobid; + var addResourceDetailIntervalID = setInterval(function() { + $.ajax({ + url: createURL("queryAsyncJobResult&jobid=" + jobId), + dataType: "json", + success: function(json) { + var result = json.queryasyncjobresultresponse; + + if (result.jobstatus == 0) { + return; //Job has not completed + } else { + clearInterval(addResourceDetailIntervalID); + + if (result.jobstatus == 1) { + //do nothing + } else if (result.jobstatus == 2) { + cloudStack.dialog.notice({ + message: "Failed to update XenServer Tools Version 6.1+ field. Error: " + _s(result.jobresult.errortext) + }); + } + } + }, + error: function(XMLHttpResponse) { + cloudStack.dialog.notice({ + message: "Failed to update XenServer Tools Version 6.1+ field. Error: " + parseXMLHttpResponse(XMLHttpResponse) + }); + } + }); + }, g_queryAsyncJobResultInterval); } }); }