Commit 36cb71a0 by Bach Dániel

Merge branch 'enhance-migration-dialog' into 'master'

Enhance Migration Dialog

* add border around nodes
* add label tag
* disable checkbox for current node
* check checkbox for recommended node
* show recommended and current node
parents dbdf9d47 bf4950bf
...@@ -18,6 +18,15 @@ $(function() { ...@@ -18,6 +18,15 @@ $(function() {
$('#create-modal').on('hidden.bs.modal', function() { $('#create-modal').on('hidden.bs.modal', function() {
$('#create-modal').remove(); $('#create-modal').remove();
}); });
$('#vm-migrate-node-list li').click(function(e) {
var li = $(this).closest('li');
if (li.find('input').attr('disabled'))
return true;
$('#vm-migrate-node-list li').removeClass('panel-primary');
li.addClass('panel-primary').find('input').attr('checked', true);
return false;
});
$('#vm-migrate-node-list li input:checked').closest('li').addClass('panel-primary');
} }
}); });
return false; return false;
......
{% load i18n %} {% load i18n %}
{% load sizefieldtags %} {% load sizefieldtags %}
<form method="POST" action="{% url "dashboard.views.vm-migrate" pk=vm %}"> <form method="POST" action="{% url "dashboard.views.vm-migrate" pk=vm.pk %}">
{% csrf_token %} {% csrf_token %}
<ul id="vm-migrate-node-list"> <ul id="vm-migrate-node-list">
{% for n in nodes %} {% with current=vm.node.pk selected=vm.select_node.pk %}
<li> {% for n in nodes %}
<strong>{{ n }}</strong> <li class="panel panel-default"><div class="panel-body">
<input type="radio" name="node" value="{{ n.pk }}" style="float: right;"/> <label for="migrate-to-{{n.pk}}">
<span class="vm-migrate-node-property">{% trans "CPU load" %}: {{ n.cpu_usage }}</span> <strong>{{ n }}</strong>
<span class="vm-migrate-node-property">{% trans "RAM usage" %}: {{ n.byte_ram_usage|filesize }}/{{ n.ram_size|filesize }}</span> {% if current == n.pk %}<div class="label label-info">{% trans "current" %}</div>{% endif %}
<div style="clear: both;"></div> {% if selected == n.pk %}<div class="label label-success">{% trans "recommended" %}</div>{% endif %}
</li> </label>
{% endfor %} <input id="migrate-to-{{n.pk}}" type="radio" name="node" value="{{ n.pk }}" style="float: right;"
{% if current == n.pk %}disabled="disabled"{% endif %}
{% if selected == n.pk %}checked="checked"{% endif %} />
<span class="vm-migrate-node-property">{% trans "CPU load" %}: {{ n.cpu_usage }}</span>
<span class="vm-migrate-node-property">{% trans "RAM usage" %}: {{ n.byte_ram_usage|filesize }}/{{ n.ram_size|filesize }}</span>
<div style="clear: both;"></div>
</div></li>
{% endfor %}
{% endwith %}
</ul> </ul>
<button type="submit" class="btn btn-primary btn-sm"><i class="icon-truck"></i> Migrate</button> <button type="submit" class="btn btn-primary btn-sm"><i class="icon-truck"></i> Migrate</button>
</form> </form>
...@@ -1731,7 +1731,7 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView): ...@@ -1731,7 +1731,7 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
'template': 'dashboard/_vm-migrate.html', 'template': 'dashboard/_vm-migrate.html',
'box_title': _('Migrate %(name)s' % {'name': vm.name}), 'box_title': _('Migrate %(name)s' % {'name': vm.name}),
'ajax_title': True, 'ajax_title': True,
'vm': kwargs['pk'], 'vm': vm,
'nodes': [n for n in Node.objects.filter(enabled=True) 'nodes': [n for n in Node.objects.filter(enabled=True)
if n.state == "ONLINE"] if n.state == "ONLINE"]
}) })
......
...@@ -583,10 +583,13 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -583,10 +583,13 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
self.pw)) self.pw))
self.save() self.save()
def __schedule_vm(self, act): def select_node(self):
"""Schedule the virtual machine. """Returns the node the VM should be deployed or migrated to.
"""
return scheduler.select_node(self, Node.objects.all())
:param self: The virtual machine. def __schedule_vm(self, act):
"""Schedule the virtual machine as part of a higher level activity.
:param act: Parent activity. :param act: Parent activity.
""" """
...@@ -596,7 +599,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -596,7 +599,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
# Schedule # Schedule
if self.node is None: if self.node is None:
self.node = scheduler.select_node(self, Node.objects.all()) self.node = self.select_node()
self.save() self.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment