Beispiel #1
0
    def _netbox_query(query):
        """Runs a Django get()-query on the Netbox model, based on query.

        :param query: A Q object usable in a Netbox query.
        :returns: A shadows.Netbox object if a db object was found, otherwise
                  None.

        """
        assert query
        try:
            netbox = manage.Netbox.objects.values('id', 'sysname').get(query)
        except manage.Netbox.DoesNotExist:
            return None
        return shadows.Netbox(**netbox)
Beispiel #2
0
    def _netbox_query(self, query):
        """Runs a Django get()-query on the Netbox model, based on query.

        :param query: A Q object usable in a Netbox query.
        :returns: A shadows.Netbox object if a db object was found, otherwise
                  None.

        """
        assert query
        try:
            netbox = manage.Netbox.objects.values('id', 'sysname').get(query)
        except manage.Netbox.DoesNotExist:
            return None
        except manage.Netbox.MultipleObjectsReturned:
            self._logger.info(
                "found multiple matching neighbors on remote, "
                "cannot decide: %s", query)
            return None
        return shadows.Netbox(**netbox)