mirror of
				https://github.com/retspen/webvirtcloud
				synced 2025-07-31 12:41:08 +00:00 
			
		
		
		
	Merge remote-tracking branch 'retspen/master' into upgrade_django
This commit is contained in:
		
						commit
						b909b9d0f1
					
				
					 28 changed files with 378 additions and 156 deletions
				
			
		|  | @ -32,27 +32,47 @@ | |||
|                                     <div class="col-lg-12"> | ||||
|                                         <div class="alert alert-warning alert-dismissable"> | ||||
|                                             <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> | ||||
|                                             <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instace" %} | ||||
|                                             <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instance" %} | ||||
|                                         </div> | ||||
|                                     </div> | ||||
|                                 {% else %} | ||||
|                                     <table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable> | ||||
|                                         <thead> | ||||
|                                         <thead > | ||||
|                                             <tr> | ||||
|                                                 <th>#</th> | ||||
|                                                 <th>Name<br>Description</th> | ||||
|                                                 <th>Host<br>User</th> | ||||
|                                                 <th>User</th> | ||||
|                                                 <th>Status</th> | ||||
|                                                 <th>VCPU</th> | ||||
|                                                 <th>Memory<br>({% trans "MB" %})</th> | ||||
|                                                 <th data-sortable="false" style="width:205px;">Actions</th> | ||||
|                                                 <th>Memory</th> | ||||
|                                                 <th data-sortable="false" style="width:205px;">Actions & Mem Usage</th> | ||||
|                                             </tr> | ||||
|                                         </thead> | ||||
|                                         <tbody class="searchable"> | ||||
|                                             {% for host, inst  in all_host_vms.items %} | ||||
|                                                 <tr class="success" style="font-size:16px"> | ||||
|                                                     <td>{{ forloop.counter }}</td> | ||||
|                                                     <td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a></td> | ||||
|                                                     <td></td> | ||||
|                                                     <td>{% ifequal host.2 1 %}<span class="label label-success">{% trans "Active" %} | ||||
|                                                         </span>{% endifequal %} | ||||
|                                                         {% ifequal host.2 2 %}<span class="label label-danger">{% trans "Not Active" %} | ||||
|                                                             </span>{% endifequal %} | ||||
|                                                         {% ifequal host.2 3 %}<span class="label label-danger">{% trans "Connection Failed" %} | ||||
|                                                             </span>{% endifequal %} | ||||
|                                                     </td> | ||||
|                                                     <td style="text-align:center;">{{ host.3 }}</td> | ||||
|                                                     <td style="text-align:right;">{{ host.4|filesizeformat }}</td> | ||||
|                                                     <td style="text-align:left;"> | ||||
|                                                             <div class="progress-bar-success" role="progressbar" style="width: {{ host.5 }}%" aria-valuenow="{{ host.5 }}" aria-valuemin="0" aria-valuemax="100">{{ host.5 }}%</div> | ||||
|                                                     </td> | ||||
|                                                 </tr> | ||||
| 
 | ||||
|                                                 {% for vm, info in inst.items %} | ||||
|                                                     <tr> | ||||
|                                                         <td><a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</em></small></td> | ||||
|                                                         <td><a href="{% url 'overview' host.0 %}">{{ host.1 }}</a><br><small><em>{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td> | ||||
|                                                         <td></td> | ||||
|                                                         <td>{{ forloop.counter }}   <a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</em></small></td> | ||||
|                                                         <td><small><em>{% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %}</em></small></td> | ||||
|                                                         <td>{% ifequal info.status 1 %} | ||||
|                                                                 <span class="text-success">{% trans "Active" %}</span> | ||||
|                                                             {% endifequal %} | ||||
|  | @ -63,8 +83,8 @@ | |||
|                                                                 <span class="text-warning">{% trans "Suspend" %}</span> | ||||
|                                                             {% endifequal %} | ||||
|                                                         </td> | ||||
|                                                         <td>{{ info.vcpu }}</td> | ||||
|                                                         <td>{{ info.memory }}</td> | ||||
|                                                         <td style="text-align:center;">{{ info.vcpu }}</td> | ||||
|                                                         <td style="text-align:right;">{{ info.memory |filesizeformat }}</td> | ||||
|                                                         <td><form action="" method="post" role="form">{% csrf_token %} | ||||
|                                                                 <input type="hidden" name="name" value="{{ vm }}"/> | ||||
|                                                                 <input type="hidden" name="compute_id" value="{{ host.0 }}"/> | ||||
|  | @ -138,7 +158,7 @@ | |||
|                                     <div class="col-lg-12"> | ||||
|                                         <div class="alert alert-warning alert-dismissable"> | ||||
|                                             <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> | ||||
|                                             <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instace" %} | ||||
|                                             <i class="fa fa-exclamation-triangle"></i> <strong>{% trans "Warning:" %}</strong> {% trans "You don't have any Instance" %} | ||||
|                                         </div> | ||||
|                                     </div> | ||||
|                                 {% else  %} | ||||
|  |  | |||
|  | @ -68,13 +68,24 @@ def instances(request): | |||
|                     i.delete() | ||||
|          | ||||
|         try: | ||||
|             check_uuid = Instance.objects.get(compute_id=comp.id, name=vm) | ||||
|             check_uuid = Instance.objects.get(compute_id=comp["id"], name=vm) | ||||
|             if check_uuid.uuid != info['uuid']: | ||||
|                 check_uuid.save() | ||||
|             all_host_vms[comp.id, comp.name][vm]['is_template'] = check_uuid.is_template | ||||
|             all_host_vms[comp.id, comp.name][vm]['userinstances'] = get_userinstances_info(check_uuid) | ||||
| 
 | ||||
|             all_host_vms[comp_info["id"], | ||||
|                          comp_info["name"], | ||||
|                          comp_info["status"], | ||||
|                          comp_info["cpu"], | ||||
|                          comp_info["mem_size"], | ||||
|                          comp_info["mem_perc"]][vm]['is_template'] = check_uuid.is_template | ||||
|             all_host_vms[comp_info["id"], | ||||
|                          comp_info["name"], | ||||
|                          comp_info["status"], | ||||
|                          comp_info["cpu"], | ||||
|                          comp_info["mem_size"], | ||||
|                          comp_info["mem_perc"]][vm]['userinstances'] = get_userinstances_info(check_uuid) | ||||
|         except Instance.DoesNotExist: | ||||
|             check_uuid = Instance(compute_id=comp.id, name=vm, uuid=info['uuid']) | ||||
|             check_uuid = Instance(compute_id=comp["id"], name=vm, uuid=info['uuid']) | ||||
|             check_uuid.save() | ||||
|      | ||||
|     if not request.user.is_superuser: | ||||
|  | @ -90,14 +101,27 @@ def instances(request): | |||
|                 all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id}) | ||||
|     else: | ||||
|         for comp in computes: | ||||
|             if connection_manager.host_is_up(comp.type, comp.hostname): | ||||
|             status = connection_manager.host_is_up(comp.type, comp.hostname) | ||||
|             if status: | ||||
|                 try: | ||||
|                     conn = wvmHostDetails(comp, comp.login, comp.password, comp.type) | ||||
|                     host_instances = conn.get_host_instances() | ||||
|                     if host_instances: | ||||
|                         all_host_vms[comp.id, comp.name] = host_instances | ||||
|                         for vm, info in host_instances.items(): | ||||
|                             refresh_instance_database(comp, vm, info) | ||||
|                     comp_node_info = conn.get_node_info() | ||||
|                     comp_mem = conn.get_memory_usage() | ||||
|                     comp_instances = conn.get_host_instances(True) | ||||
| 
 | ||||
|                     if comp_instances: | ||||
|                         comp_info= { | ||||
|                             "id": comp.id, | ||||
|                             "name": comp.name, | ||||
|                             "status": status, | ||||
|                             "cpu": comp_node_info[3], | ||||
|                             "mem_size": comp_node_info[2], | ||||
|                             "mem_perc": comp_mem['percent'] | ||||
|                         } | ||||
|                         all_host_vms[comp_info["id"], comp_info["name"], comp_info["status"], comp_info["cpu"], | ||||
|                                      comp_info["mem_size"], comp_info["mem_perc"]] = comp_instances | ||||
|                         for vm, info in comp_instances.items(): | ||||
|                             refresh_instance_database(comp_info, vm, info) | ||||
| 
 | ||||
|                     conn.close() | ||||
|                 except libvirtError as lib_err: | ||||
|  | @ -343,7 +367,6 @@ def instance(request, compute_id, vname): | |||
|         default_cache = settings.INSTANCE_VOLUME_DEFAULT_CACHE | ||||
|         default_format = settings.INSTANCE_VOLUME_DEFAULT_FORMAT | ||||
|         formats = conn.get_image_formats() | ||||
|         default_bus = settings.INSTANCE_VOLUME_DEFAULT_BUS | ||||
|         busses = conn.get_busses() | ||||
|         default_bus = settings.INSTANCE_VOLUME_DEFAULT_BUS | ||||
|         show_access_root_password = settings.SHOW_ACCESS_ROOT_PASSWORD | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue