mirror of https://github.com/apache/cloudstack.git
bug 11481: cloudStack 2.2 - system VM page - add "Migration System VM" action.
This commit is contained in:
parent
d59cfab7f3
commit
cd02613173
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
|
||||
#Labels
|
||||
label.action.migrate.systemvm=Migrate System VM
|
||||
label.action.migrate.systemvm.processing=Migrating System VM....
|
||||
message.migrate.systemvm.confirm=Please confirm the host you wish to migrate the System VM to:
|
||||
label.migrate.systemvm.to=Migrate System VM to
|
||||
|
||||
mode=Mode
|
||||
side.by.side=Side by Side
|
||||
inline=Inline
|
||||
|
|
|
|||
|
|
@ -18,7 +18,12 @@ dictionary = {
|
|||
'message.action.reboot.systemvm' : '<fmt:message key="message.action.reboot.systemvm"/>',
|
||||
'label.action.destroy.systemvm': '<fmt:message key="label.action.destroy.systemvm"/>',
|
||||
'label.action.destroy.systemvm.processing': '<fmt:message key="label.action.destroy.systemvm.processing"/>',
|
||||
'message.action.destroy.systemvm': '<fmt:message key="message.action.destroy.systemvm"/>'
|
||||
'message.migrate.systemvm.confirm' : '<fmt:message key="message.migrate.systemvm.confirm"/>',
|
||||
'label.action.migrate.systemvm': '<fmt:message key="label.action.migrate.systemvm"/>',
|
||||
'label.action.migrate.systemvm.processing': '<fmt:message key="label.action.migrate.systemvm.processing"/>',
|
||||
'message.action.destroy.systemvm': '<fmt:message key="message.action.destroy.systemvm"/>',
|
||||
'label.full': '<fmt:message key="label.full"/>',
|
||||
'label.available': '<fmt:message key="label.available"/>'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
@ -204,6 +209,27 @@ dictionary = {
|
|||
<!-- Details tab (end)-->
|
||||
</div>
|
||||
|
||||
<!-- Migrate System VM Dialog -->
|
||||
<div id="dialog_migrate_systemvm" title='<fmt:message key="label.action.migrate.systemvm" />' style="display: none">
|
||||
<p>
|
||||
<fmt:message key="message.migrate.systemvm.confirm" />
|
||||
</p>
|
||||
<div class="dialog_formcontent">
|
||||
<form action="#" method="post" id="form_acquire">
|
||||
<ol>
|
||||
<li>
|
||||
<label>
|
||||
<fmt:message key="label.migrate.systemvm.to" />:</label>
|
||||
<select class="select" id="migrate_instance_hosts">
|
||||
</select>
|
||||
<div id="migrate_vm_hosts_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- view console template (begin) -->
|
||||
<div id="view_console_template" style="display: none">
|
||||
<div class="vm_consolebox" id="box0">
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
}
|
||||
|
||||
function afterLoadSystemVmJSP($midmenuItem1) {
|
||||
|
||||
initDialog("dialog_migrate_systemvm", 600);
|
||||
}
|
||||
|
||||
function systemvmToMidmenu(jsonObj, $midmenuItem1) {
|
||||
|
|
@ -183,7 +183,11 @@ function systemvmBuildActionMenu(jsonObj, $thisTab, $midmenuItem1) {
|
|||
if (jsonObj.state == 'Running') {
|
||||
buildActionLinkForTab("label.action.stop.systemvm", systemVmActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
buildActionLinkForTab("label.action.reboot.systemvm", systemVmActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
buildActionLinkForTab("label.action.destroy.systemvm", systemVmActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
buildActionLinkForTab("label.action.destroy.systemvm", systemVmActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
if (isAdmin())
|
||||
{
|
||||
buildActionLinkForTab("label.action.migrate.systemvm", systemVmActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
}
|
||||
noAvailableActions = false;
|
||||
}
|
||||
else if (jsonObj.state == 'Stopped') {
|
||||
|
|
@ -276,7 +280,28 @@ var systemVmActionMap = {
|
|||
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
"label.action.migrate.systemvm": {
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "migratesystemvmresponse",
|
||||
inProcessText: "label.action.migrate.systemvm.processing",
|
||||
dialogBeforeActionFn : doMigrateSystemVM,
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
//var jsonObj = json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
|
||||
$.ajax({
|
||||
data: createURL("command=listSystemVms&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.listsystemvmsresponse.systemvm;
|
||||
if(items != null && items.length > 0) {
|
||||
jsonObj = items[0];
|
||||
systemvmToMidmenu(jsonObj, $midmenuItem1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doStartSystemVM($actionLink, $detailsTab, $midmenuItem1) {
|
||||
|
|
@ -352,4 +377,58 @@ function doDestroySystemVM($actionLink, $detailsTab, $midmenuItem1) {
|
|||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
}
|
||||
|
||||
function doMigrateSystemVM($actionLink, $detailsTab, $midmenuItem1) {
|
||||
var jsonObj = $midmenuItem1.data("jsonObj");
|
||||
var id = jsonObj.id;
|
||||
$.ajax({
|
||||
data: createURL("command=listHosts&VirtualMachineId="+id),
|
||||
//data: createURL("command=listHosts"), //for testing, comment it out before checking in.
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var hosts = json.listhostsresponse.host;
|
||||
var hostSelect = $("#dialog_migrate_systemvm #migrate_instance_hosts").empty();
|
||||
|
||||
if (hosts != null && hosts.length > 0) {
|
||||
for (var i = 0; i < hosts.length; i++) {
|
||||
var option = $("<option value='" + hosts[i].id + "'>" + fromdb(hosts[i].name) + ": " +((hosts[i].hasEnoughCapacity) ? dictionary["label.available"] : dictionary["label.full"]) + "</option>").data("name", fromdb(hosts[i].name));
|
||||
hostSelect.append(option);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
$("#dialog_migrate_systemvm #migrate_instance_hosts").empty();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#dialog_migrate_systemvm")
|
||||
.dialog('option', 'buttons', {
|
||||
"OK": function() {
|
||||
var $thisDialog = $(this);
|
||||
|
||||
var isValid = true;
|
||||
isValid &= validateDropDownBox("Host", $thisDialog.find("#migrate_instance_hosts"), $thisDialog.find("#migrate_instance_errormsg"));
|
||||
if (!isValid)
|
||||
return;
|
||||
|
||||
$thisDialog.dialog("close");
|
||||
var hostId = $thisDialog.find("#migrate_instance_hosts").val();
|
||||
/*
|
||||
if(jsonObj.state != "Stopped") {
|
||||
$midmenuItem1.find("#info_icon").addClass("error").show();
|
||||
$midmenuItem1.data("afterActionInfo", ($actionLink.data("label") + " action failed. Reason: virtual instance needs to be stopped before you can change its service."));
|
||||
}
|
||||
*/
|
||||
var apiCommand = "command=migrateSystemVm&hostid="+hostId+"&virtualmachineid="+id;
|
||||
doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $detailsTab);
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue