def list_backends(request): """Gets the available backends. .. note:: Currently, this is only used by the backend controller in js. """ user = user_from_request(request) return methods.list_backends(user)
def list_backends_from_socket(namespace): user = namespace.user backends = methods.list_backends(user) namespace.emit('list_backends', backends) for key, task in (('list_machines', tasks.ListMachines()), ('list_images', tasks.ListImages()), ('list_sizes', tasks.ListSizes()), ('list_locations', tasks.ListLocations())): for backend_id in user.backends: if user.backends[backend_id].enabled: cached = task.smart_delay(user.email, backend_id) if cached is not None: namespace.emit(key, cached)
def list_backends(self): backends = methods.list_backends(self.user) self.send('list_backends', backends) for key, task in (('list_machines', tasks.ListMachines()), ('list_images', tasks.ListImages()), ('list_sizes', tasks.ListSizes()), ('list_networks', tasks.ListNetworks()), ('list_locations', tasks.ListLocations()),): for backend_id in self.user.backends: if self.user.backends[backend_id].enabled: cached = task.smart_delay(self.user.email, backend_id) if cached is not None: log.info("Emitting %s from cache", key) self.send(key, cached)