Commit 0a3d40e0 by Szabolcs Gelencser

Show connected vms of network

parent 2c453601
...@@ -48,7 +48,14 @@ ...@@ -48,7 +48,14 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<h3 class="pull-right"><small>{% trans "connected virtual machines" %}</small></h3> <h3 class="pull-right"><small>{% trans "connected virtual machines" %}</small></h3>
<div class="clearfix"></div>
<table class="table">
{% for vm in vms %}
<tr style="text-align: right">
<td>{{ vm.name }}</td>
</tr>
{% endfor %}
</table>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
...@@ -106,11 +106,6 @@ class VxlanDelete(LoginRequiredMixin, OperationView): #TODO: check user ...@@ -106,11 +106,6 @@ class VxlanDelete(LoginRequiredMixin, OperationView): #TODO: check user
def get_object(self, queryset=None): def get_object(self, queryset=None):
return openstack_api.neutron.network_get(self.request, self.kwargs['pk'], expand_subnet=True) return openstack_api.neutron.network_get(self.request, self.kwargs['pk'], expand_subnet=True)
def delete(self, request, *args, **kwargs):
response = super(VxlanDelete, self).delete(request, *args, **kwargs)
messages.success(request, _(u"Vxlan successfully deleted."))
return response
network_ops = OrderedDict([ network_ops = OrderedDict([
('network_delete', VxlanDelete), ('network_delete', VxlanDelete),
]) ])
...@@ -1030,11 +1025,20 @@ class VxlanDetail(LoginRequiredMixin, SuccessMessageMixin, DetailView): #TODO: c ...@@ -1030,11 +1025,20 @@ class VxlanDetail(LoginRequiredMixin, SuccessMessageMixin, DetailView): #TODO: c
'isDhcpEnabled': subnet.enable_dhcp if subnet else False, 'isDhcpEnabled': subnet.enable_dhcp if subnet else False,
}) })
all_ports = openstack_api.neutron.port_list(self.request)
ports = [p for p in all_ports if p.network_id == self.object.id]
vm_ids = [p.device_id for p in ports if p.device_owner == "compute:nova"]
vms = []
for vm_id in vm_ids:
vms.append(openstack_api.nova.server_get(self.request, vm_id))
context['isMultipleSubnetsAvailable'] = len(self.object.subnets) > 1 context['isMultipleSubnetsAvailable'] = len(self.object.subnets) > 1
context['isSubnetMissing'] = len(self.object.subnets) < 1 context['isSubnetMissing'] = len(self.object.subnets) < 1
context['vm_list'] = () #SmallVmTable(self.object.vm_interface.all()) context['vm_list'] = ()
context['form'] = form context['form'] = form
context['op'] = {i.op: i for i in ops} context['op'] = {i.op: i for i in ops}
context['vms'] = vms
return context return context
class VxlanCreate(LoginRequiredMixin, FormView): class VxlanCreate(LoginRequiredMixin, FormView):
......
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