Ejemplo n.º 1
0
    def populate_network_id_choices(self, request, context):
        try:
            networks = guts_api.networks_list(request)
        except Exception:
            networks = []
            exceptions.handle(request,
                _("Unable to retrieve networks list")
            )
        networks_list = [(network.id, "%s - %s" % (network.name, network.hypervisor_name))
                            for network in networks]

        if not networks_list:
            networks_list.insert(0
                ("", _("No Network present for migration"))
            )
        else:
            networks_list.insert(0,
                ("", _("Select a network to be migrated"))
            )
        return networks_list
Ejemplo n.º 2
0
 def get(self, request):
     """Get a list of networks
     """
     result = guts_api.networks_list(request)
     return {'items': [u.to_dict() for u in result]}