def list_profiles(self, request, context): print("Handling list_profiles call") baseconfig = Kbaseconfig() profiles = [] for profile in baseconfig.list_profiles(): newprofile = {} newprofile['name'] = profile[0] newprofile['flavor'] = profile[1] newprofile['pool'] = profile[2] newprofile['disks'] = profile[3] newprofile['image'] = profile[4] newprofile['nets'] = profile[5] newprofile['cloudinit'] = profile[6] newprofile['nested'] = profile[7] newprofile['reservedns'] = profile[8] newprofile['reservehost'] = profile[9] profiles.append(kcli_pb2.profile(**newprofile)) response = kcli_pb2.profileslist(profiles=profiles) return response
def list_hosts(self, request, context): print("Handling list_hosts call") baseconfig = Kbaseconfig() clients = [] for client in sorted(baseconfig.clients): newclient = {} newclient['client'] = client newclient['type'] = baseconfig.ini[client].get('type', 'kvm') newclient['enabled'] = baseconfig.ini[client].get('enabled', True) newclient['enabled'] = baseconfig.ini[client].get('enabled', True) newclient['current'] = True if client == baseconfig.client else False clients.append(kcli_pb2.client(**newclient)) response = kcli_pb2.clientslist(clients=clients) return response
def switch_host(self, request, context): print("Handling switch_host call for:\n%s" % request) baseconfig = Kbaseconfig() result = baseconfig.switch_host(request.client) response = kcli_pb2.result(**result) return response