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