mirror of
				https://github.com/retspen/webvirtcloud
				synced 2025-07-31 12:41:08 +00:00 
			
		
		
		
	instance template change to instances as group of hosts. bootstrap.min.css and js updated. some info added.
This commit is contained in:
		
							parent
							
								
									a933ffb00f
								
							
						
					
					
						commit
						20e8b876e4
					
				
					 8 changed files with 88 additions and 29 deletions
				
			
		| 
						 | 
					@ -37,21 +37,41 @@
 | 
				
			||||||
                                    </div>
 | 
					                                    </div>
 | 
				
			||||||
                                {% else %}
 | 
					                                {% else %}
 | 
				
			||||||
                                    <table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
 | 
					                                    <table class="table table-hover table-striped sortable-theme-bootstrap" data-sortable>
 | 
				
			||||||
                                        <thead>
 | 
					                                        <thead >
 | 
				
			||||||
                                            <tr>
 | 
					                                            <tr>
 | 
				
			||||||
 | 
					                                                <th>#</th>
 | 
				
			||||||
                                                <th>Name<br>Description</th>
 | 
					                                                <th>Name<br>Description</th>
 | 
				
			||||||
                                                <th>Host<br>User</th>
 | 
					                                                <th>Host<br>User</th>
 | 
				
			||||||
                                                <th>Status</th>
 | 
					                                                <th>Status</th>
 | 
				
			||||||
                                                <th>VCPU</th>
 | 
					                                                <th>VCPU</th>
 | 
				
			||||||
                                                <th>Memory<br>({% trans "MB" %})</th>
 | 
					                                                <th>Memory<br>({% trans "MB" %})</th>
 | 
				
			||||||
                                                <th data-sortable="false" style="width:205px;">Actions</th>
 | 
					                                                <th data-sortable="false" style="width:205px;">Actions & Usage</th>
 | 
				
			||||||
                                            </tr>
 | 
					                                            </tr>
 | 
				
			||||||
                                        </thead>
 | 
					                                        </thead>
 | 
				
			||||||
                                        <tbody class="searchable">
 | 
					                                        <tbody class="searchable">
 | 
				
			||||||
                                            {% for host, inst  in all_host_vms.items %}
 | 
					                                            {% for host, inst  in all_host_vms.items %}
 | 
				
			||||||
 | 
					                                                <!-- copied /-->
 | 
				
			||||||
 | 
					                                                 <!-- <tr style="font-size:16px;background-color: #5CB75C; color: white" > /-->
 | 
				
			||||||
 | 
					                                                <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;">Mem Usage: {{ host.5 }}%</td>
 | 
				
			||||||
 | 
					                                                </tr>
 | 
				
			||||||
 | 
					                                                <!-- copied /-->
 | 
				
			||||||
                                                {% for vm, info in inst.items %}
 | 
					                                                {% for vm, info in inst.items %}
 | 
				
			||||||
                                                    <tr>
 | 
					                                                    <tr>
 | 
				
			||||||
                                                        <td><a href="{% url 'instance' host.0 vm %}">{{ vm }}</a><br><small><em>{{ info.title }}</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><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><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>{% ifequal info.status 1 %}
 | 
					                                                        <td>{% ifequal info.status 1 %}
 | 
				
			||||||
                                                                <span class="text-success">{% trans "Active" %}</span>
 | 
					                                                                <span class="text-success">{% trans "Active" %}</span>
 | 
				
			||||||
| 
						 | 
					@ -63,8 +83,8 @@
 | 
				
			||||||
                                                                <span class="text-warning">{% trans "Suspend" %}</span>
 | 
					                                                                <span class="text-warning">{% trans "Suspend" %}</span>
 | 
				
			||||||
                                                            {% endifequal %}
 | 
					                                                            {% endifequal %}
 | 
				
			||||||
                                                        </td>
 | 
					                                                        </td>
 | 
				
			||||||
                                                        <td>{{ info.vcpu }}</td>
 | 
					                                                        <td style="text-align:center;">{{ info.vcpu }}</td>
 | 
				
			||||||
                                                        <td>{{ info.memory }}</td>
 | 
					                                                        <td style="text-align:right;">{{ info.memory |filesizeformat }}</td>
 | 
				
			||||||
                                                        <td><form action="" method="post" role="form">{% csrf_token %}
 | 
					                                                        <td><form action="" method="post" role="form">{% csrf_token %}
 | 
				
			||||||
                                                                <input type="hidden" name="name" value="{{ vm }}"/>
 | 
					                                                                <input type="hidden" name="name" value="{{ vm }}"/>
 | 
				
			||||||
                                                                <input type="hidden" name="compute_id" value="{{ host.0 }}"/>
 | 
					                                                                <input type="hidden" name="compute_id" value="{{ host.0 }}"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,11 +68,22 @@ def instances(request):
 | 
				
			||||||
                    i.delete()
 | 
					                    i.delete()
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        try:
 | 
					        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']:
 | 
					            if check_uuid.uuid != info['uuid']:
 | 
				
			||||||
                check_uuid.save()
 | 
					                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:
 | 
					        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()
 | 
					            check_uuid.save()
 | 
				
			||||||
| 
						 | 
					@ -90,14 +101,27 @@ def instances(request):
 | 
				
			||||||
                all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id})
 | 
					                all_user_vms[usr_inst].update({'compute_id': usr_inst.instance.compute.id})
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        for comp in computes:
 | 
					        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:
 | 
					                try:
 | 
				
			||||||
                    conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
 | 
					                    conn = wvmHostDetails(comp, comp.login, comp.password, comp.type)
 | 
				
			||||||
                    host_instances = conn.get_host_instances()
 | 
					                    comp_node_info = conn.get_node_info()
 | 
				
			||||||
                    if host_instances:
 | 
					                    comp_mem = conn.get_memory_usage()
 | 
				
			||||||
                        all_host_vms[comp.id, comp.name] = host_instances
 | 
					                    comp_instances = conn.get_host_instances(True)
 | 
				
			||||||
                        for vm, info in host_instances.items():
 | 
					
 | 
				
			||||||
                            refresh_instance_database(comp, vm, info)
 | 
					                    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()
 | 
					                    conn.close()
 | 
				
			||||||
                except libvirtError as lib_err:
 | 
					                except libvirtError as lib_err:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								static/css/bootstrap.min.css
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								static/css/bootstrap.min.css
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										5
									
								
								static/css/bootstrap.min.css_332
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								static/css/bootstrap.min.css_332
									
										
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										10
									
								
								static/js/bootstrap.min.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								static/js/bootstrap.min.js
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										7
									
								
								static/js/bootstrap.min.js_332
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								static/js/bootstrap.min.js_332
									
										
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -454,11 +454,13 @@ class wvmConnect(object):
 | 
				
			||||||
                netdevice.append(interface)
 | 
					                netdevice.append(interface)
 | 
				
			||||||
        return netdevice
 | 
					        return netdevice
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_host_instances(self):
 | 
					    def get_host_instances(self, raw_mem_size=False):
 | 
				
			||||||
        vname = {}
 | 
					        vname = {}
 | 
				
			||||||
        def get_info(doc):
 | 
					        def get_info(doc):
 | 
				
			||||||
            mem = util.get_xpath(doc, "/domain/currentMemory")
 | 
					            mem = util.get_xpath(doc, "/domain/currentMemory")
 | 
				
			||||||
            mem = int(mem) / 1024
 | 
					            mem = int(mem) / 1024
 | 
				
			||||||
 | 
					            if raw_mem_size:
 | 
				
			||||||
 | 
					                mem = int(mem) * (1024*1024)
 | 
				
			||||||
            cur_vcpu = util.get_xpath(doc, "/domain/vcpu/@current")
 | 
					            cur_vcpu = util.get_xpath(doc, "/domain/vcpu/@current")
 | 
				
			||||||
            if cur_vcpu:
 | 
					            if cur_vcpu:
 | 
				
			||||||
                vcpu = cur_vcpu
 | 
					                vcpu = cur_vcpu
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,12 +59,12 @@ class wvmHostDetails(wvmConnect):
 | 
				
			||||||
        Function return host server information: hostname, cpu, memory, ...
 | 
					        Function return host server information: hostname, cpu, memory, ...
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        info = []
 | 
					        info = []
 | 
				
			||||||
        info.append(self.wvm.getHostname())
 | 
					        info.append(self.wvm.getHostname()) # hostname
 | 
				
			||||||
        info.append(self.wvm.getInfo()[0])
 | 
					        info.append(self.wvm.getInfo()[0]) # architecture
 | 
				
			||||||
        info.append(self.wvm.getInfo()[1] * 1048576)
 | 
					        info.append(self.wvm.getInfo()[1] * 1048576) # memory
 | 
				
			||||||
        info.append(self.wvm.getInfo()[2])
 | 
					        info.append(self.wvm.getInfo()[2]) # cpu core count
 | 
				
			||||||
        info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version))
 | 
					        info.append(get_xml_path(self.wvm.getSysinfo(0), func=cpu_version)) # cpu version
 | 
				
			||||||
        info.append(self.wvm.getURI())
 | 
					        info.append(self.wvm.getURI()) #uri
 | 
				
			||||||
        return info
 | 
					        return info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def hypervisor_type(self):
 | 
					    def hypervisor_type(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue