Commit fed6ed40 by Bach Dániel

Merge branch 'issue-289' into 'master'

show current node of vm

fixes #289
parents dc674ca8 bc48c0ba
......@@ -974,6 +974,10 @@ textarea[name="new_members"] {
color: orange;
}
#vm-info-pane {
margin-bottom: 20px;
}
.node-list-table tbody>tr>td, .node-list-table thead>tr>th {
vertical-align: middle;
}
......
......@@ -90,6 +90,20 @@
</div>
</form>
</div><!-- id:vm-details-tags -->
{% if request.user.is_superuser %}
<dl>
<dt>{% trans "Node" %}:</dt>
<dd>
{% if instance.node %}
<a href="{{ instance.node.get_absolute_url }}">
{{ instance.node.name }}
</a>
{% else %}
-
{% endif %}
</dd>
{% endif %}
</dl>
<dl>
<dt>{% trans "Template" %}:</dt>
<dd>
......
......@@ -919,10 +919,16 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
delete_dump.apply_async(args=[self.mem_dump['path']],
queue=queue_name).get(timeout=timeout)
def allocate_node(self):
if self.node is None:
self.node = self.select_node()
def allocate_node(self, activity):
if self.node is not None:
return None
with activity.sub_activity(
'scheduling',
readable_name=ugettext_noop("schedule")) as sa:
sa.result = self.node = self.select_node()
self.save()
return self.node
def yield_node(self):
if self.node is not None:
......
......@@ -293,7 +293,7 @@ class DeployOperation(InstanceOperation):
def _operation(self, activity, timeout=15):
# Allocate VNC port and host node
self.instance.allocate_vnc_port()
self.instance.allocate_node()
self.instance.allocate_node(activity)
# Deploy virtual images
with activity.sub_activity(
......@@ -398,12 +398,7 @@ class MigrateOperation(InstanceOperation):
def _operation(self, activity, to_node=None, timeout=120):
if not to_node:
with activity.sub_activity('scheduling',
readable_name=ugettext_noop(
"schedule")) as sa:
to_node = self.instance.select_node()
sa.result = to_node
self.instance.allocate_node(activity)
try:
with activity.sub_activity(
'migrate_vm', readable_name=create_readable(
......@@ -742,7 +737,7 @@ class WakeUpOperation(InstanceOperation):
def _operation(self, activity, timeout=60):
# Schedule vm
self.instance.allocate_vnc_port()
self.instance.allocate_node()
self.instance.allocate_node(activity)
# Resume vm
with activity.sub_activity(
......
......@@ -112,8 +112,7 @@ class InstanceTestCase(TestCase):
migrate_op(system=True)
migr.apply_async.assert_called()
self.assertIn(call.sub_activity(
u'scheduling', readable_name=u'schedule'), act.mock_calls)
inst.allocate_node.assert_called()
inst.select_node.assert_called()
def test_migrate_wo_scheduling(self):
......@@ -130,7 +129,7 @@ class InstanceTestCase(TestCase):
migrate_op(to_node=inst.node, system=True)
migr.apply_async.assert_called()
self.assertNotIn(call.sub_activity(u'scheduling'), act.mock_calls)
inst.allocate_node.assert_called()
def test_migrate_with_error(self):
inst = Mock(destroyed_at=None, spec=Instance)
......@@ -149,11 +148,9 @@ class InstanceTestCase(TestCase):
migr.apply_async.assert_called()
self.assertIn(call.sub_activity(
u'scheduling', readable_name=u'schedule'), act.mock_calls)
self.assertIn(call.sub_activity(
u'rollback_net', readable_name=u'redeploy network (rollback)'),
act.mock_calls)
inst.select_node.assert_called()
inst.allocate_node.assert_called()
def test_status_icon(self):
inst = MagicMock(spec=Instance)
......
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