Example #1
0
 def update_host(self, hyper_id, ipmi):
     new_ipmi = host_package.Host(**ipmi)
     yield host_package.update_host(hyper_id, new_ipmi.__dict__)
     host = yield host_package.query_host(id=int(hyper_id))
     optLog.write(self.request, Type.HOST, host[0]['name'], Operator.UPDATE,
                  '')
     self.response(Response())
Example #2
0
 def get_tenant_hosts(self, tenant_id):
     tenant_hosts = yield get_tenant_hosts(tenant_id)
     new_hosts = []
     if tenant_hosts:
         hypervisors = yield query_host()
         vm_counts = yield count_tenant_vm(tenant_id)
         vd_counts = yield count_tenant_vd(tenant_id)
         for hypervisor in hypervisors:
             hyper_id = hypervisor.get("id")
             if hyper_id in tenant_hosts:
                 new_hosts.append({
                     "id":
                     hyper_id,
                     "name":
                     hypervisor.get("name"),
                     "ip":
                     hypervisor.get("ip"),
                     "cpus":
                     hypervisor.get('cpus'),
                     "memory_mb":
                     hypervisor.get('memory_mb'),
                     "status":
                     hypervisor.get('status'),
                     "vm_counts":
                     vm_counts.get(hypervisor.get('name'), 0),
                     "vd_counts":
                     vd_counts.get(hypervisor.get('name'), 0)
                 })
     self.response(Response(result=new_hosts, total=len(new_hosts)))
Example #3
0
 def get_network_hosts(self, network_id):
     """
     Get network' s hosts
     :param network_id: network id
     :param tenant_id: project id, default is None
     """
     network = yield get_network(network_id)
     if not network:
         raise NetworkNotExist
     hosts = yield get_network_hosts(network_id)
     new_hosts = []
     if hosts:
         hypervisors = yield query_host()
         host_name = [
             hypervisor["name"] for hypervisor in hypervisors
             if str(hypervisor["id"]) in hosts
         ]
         vm_counts = yield count_network_vm(host_name, network_id)
         for hypervisor in hypervisors:
             hyper_id = str(hypervisor.get("id"))
             if hyper_id in hosts:
                 new_hosts.append({
                     "id": hyper_id,
                     "name": hypervisor.get("name"),
                     "ip": hypervisor.get("ip"),
                     "cpus": hypervisor.get('cpus'),
                     "memory_mb": hypervisor.get('memory_mb'),
                     "vlans": hypervisor.get("vlans"),
                     "status": hypervisor.get('status'),
                     "vm_counts": vm_counts[hypervisor["name"]]
                 })
     self.response(Response(result=new_hosts, total=len(new_hosts)))
Example #4
0
 def get_host(self, host_id):
     hosts = yield host_package.query_host(id=int(host_id))
     self.response(Response(result=hosts))
Example #5
0
 def list_host(self, volume_type=None, tenant_id=None):
     out_hosts = yield host_package.query_host(volume_type=volume_type,
                                               tenant_id=tenant_id)
     self.response(Response(result=out_hosts, total=len(out_hosts)))