mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #3748: Add migrate dialog
This commit is contained in:
parent
e4f1cf5a1c
commit
df3f2427b4
@ -9,7 +9,7 @@ define(function(require) {
|
||||
|
||||
var _dialogs = [
|
||||
require('./vms-tab/dialogs/deploy'),
|
||||
// require('./vms-tab/dialogs/instantiate')
|
||||
require('./vms-tab/dialogs/migrate')
|
||||
];
|
||||
|
||||
var _panels = [
|
||||
|
@ -8,7 +8,8 @@ define(function(require) {
|
||||
var TAB_ID = require('./tabId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
var DEPLOY_DIALOG_ID = require('./dialogs/deploy/dialogId');
|
||||
//var INSTANTIATE_DIALOG_ID = require('./dialogs/instantiate/dialogId');
|
||||
var MIGRATE_DIALOG_ID = require('./dialogs/migrate/dialogId');
|
||||
|
||||
var XML_ROOT = "VM";
|
||||
var RESOURCE = "VM";
|
||||
|
||||
@ -68,6 +69,22 @@ define(function(require) {
|
||||
Sunstone.getDialog(DEPLOY_DIALOG_ID).show();
|
||||
}
|
||||
},
|
||||
"VM.migrate" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID);
|
||||
dialog.setLive(false);
|
||||
dialog.show();
|
||||
}
|
||||
},
|
||||
"VM.migrate_live" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID);
|
||||
dialog.setLive(true);
|
||||
dialog.show();
|
||||
}
|
||||
},
|
||||
/*"VM.create" : {
|
||||
type: "custom",
|
||||
call: function(id, name) {
|
||||
@ -95,20 +112,6 @@ define(function(require) {
|
||||
error: onError
|
||||
},
|
||||
|
||||
"VM.migrate" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpMigrateVMDialog(false);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"VM.migrate_live" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpMigrateVMDialog(true);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"VM.saveas" : {
|
||||
|
136
src/sunstone/public/app/tabs/vms-tab/dialogs/migrate.js
Normal file
136
src/sunstone/public/app/tabs/vms-tab/dialogs/migrate.js
Normal file
@ -0,0 +1,136 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./migrate/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var DatastoresTable = require('tabs/datastores-tab/datatable');
|
||||
var HostsTable = require('tabs/hosts-tab/datatable');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Tips = require('utils/tips');
|
||||
var Locale = require('utils/locale');
|
||||
var OpenNebulaVM = require('opennebula/vm');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./migrate/dialogId');
|
||||
var TAB_ID = require('../tabId')
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
this.hostsTable = new HostsTable('migrate_vm', {'select': true});
|
||||
this.datastoresTable = new DatastoresTable('migrate_vm_ds', {
|
||||
'select': true,
|
||||
'selectOptions': {
|
||||
'filter_fn': function(ds) { return ds.TYPE == 1; } // Show system DS only
|
||||
}
|
||||
});
|
||||
|
||||
BaseDialog.call(this);
|
||||
};
|
||||
|
||||
Dialog.DIALOG_ID = DIALOG_ID;
|
||||
Dialog.prototype = Object.create(BaseDialog.prototype);
|
||||
Dialog.prototype.constructor = Dialog;
|
||||
Dialog.prototype.html = _html;
|
||||
Dialog.prototype.onShow = _onShow;
|
||||
Dialog.prototype.setup = _setup;
|
||||
Dialog.prototype.setLive = _setLive;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId,
|
||||
'hostsTableHTML': this.hostsTable.dataTableHTML,
|
||||
'datastoresTableHTML': this.datastoresTable.dataTableHTML
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
that.hostsTable.initialize();
|
||||
that.datastoresTable.initialize();
|
||||
|
||||
Tips.setup(context);
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
var extra_info = {};
|
||||
|
||||
if ($("#selected_resource_id_migrate_vm", context).val()) {
|
||||
extra_info['host_id'] = $("#selected_resource_id_migrate_vm", context).val();
|
||||
} else {
|
||||
notifyError(tr("You have not selected a host"));
|
||||
return false;
|
||||
}
|
||||
|
||||
extra_info['ds_id'] = $("#selected_resource_id_migrate_vm_ds", context).val() || -1
|
||||
extra_info['enforce'] = $("#enforce", context).is(":checked");
|
||||
|
||||
$.each(Sunstone.getDataTable(TAB_ID).elements(), function(index, elem) {
|
||||
if (that.live) {
|
||||
Sunstone.runAction("VM.migrate_live_action", elem, extra_info);
|
||||
} else {
|
||||
Sunstone.runAction("VM.migrate_action", elem, extra_info);
|
||||
}
|
||||
});
|
||||
|
||||
Sunstone.getDialog(DIALOG_ID).hide();
|
||||
Sunstone.getDialog(DIALOG_ID).reset();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
this.datastoresTable.resetResourceTableSelect();
|
||||
this.hostsTable.resetResourceTableSelect();
|
||||
|
||||
if (this.live) {
|
||||
$(".migrate_vm_ds_selection", context).hide();
|
||||
}
|
||||
|
||||
$.each(Sunstone.getDataTable(TAB_ID).elements(), function() {
|
||||
var vm_id = "" + this;
|
||||
|
||||
OpenNebulaVM.show({
|
||||
data : {
|
||||
id: vm_id
|
||||
},
|
||||
timeout: true,
|
||||
success: function (request, vm_json) {
|
||||
var element = vm_json.VM;
|
||||
var hostname = OpenNebulaVM.hostnameStr(element);
|
||||
|
||||
$("#current_hosts_of_vms").append(
|
||||
'<span class="radius secondary label">' +
|
||||
Locale.tr("VM") + ' [' + element.ID + '] ' +
|
||||
Locale.tr("is currently running on Host") +
|
||||
' [' + hostname + ']</span><br>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
// @param [Boolean] live Set migrate live or migrate
|
||||
function _setLive(live) {
|
||||
this.live = live;
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'migrateVMDialog';
|
||||
})
|
@ -0,0 +1,43 @@
|
||||
<div id="{{dialogId}}" class="reveal-modal large" role="dialog" data-reveal >
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h3 id="migrate_vm_header" class="subheader">{{tr "Migrate Virtual Machine"}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body">
|
||||
<form id="{{dialogId}}Form" action="">
|
||||
<div id="current_hosts_of_vms" class="row"></div>
|
||||
<br>
|
||||
<br>
|
||||
<div class="row">
|
||||
<fieldset>
|
||||
<legend>{{tr "Select a Host"}}</legend>
|
||||
{{{hostsTableHTML}}}
|
||||
</fieldset>
|
||||
{{#advancedSection (tr "Advanced Options") }}
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<input type="checkbox" name="enforce" id="enforce"/>
|
||||
<label for="vm_id">
|
||||
{{tr "Enforce"}}
|
||||
<span class="tip">
|
||||
{{tr "If it is set to true, the host capacity will be checked. This will only affect oneadmin requests, regular users resize requests will always be enforced"}}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<fieldset class="migrate_vm_ds_selection">
|
||||
<legend>{{tr "Select a datastore"}}</legend>
|
||||
{{{datastoresTableHTML}}}
|
||||
</fieldset>
|
||||
{{/advancedSection}}
|
||||
<div class="form_buttons reveal-footer">
|
||||
<div class="form_buttons">
|
||||
<button class="button radius right success" id="migrate_vm_proceed" value="VM.migrate">{{tr "Migrate"}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user