示例#1
0
    def synchronize_router(self, context, neutron_router_data, lrouter=None):
        """Synchronize a neutron router with its NVP counterpart."""
        if not lrouter:
            # Try to get router from nvp
            try:
                # This query will return the logical router status too
                lrouter = nvplib.get_lrouter(self._cluster,
                                             neutron_router_data['id'])
            except exceptions.NotFound:
                # NOTE(salv-orlando): We should be catching
                # NvpApiClient.ResourceNotFound here
                # The logical router was not found
                LOG.warning(
                    _("Logical router for neutron router %s not "
                      "found on NVP."), neutron_router_data['id'])
                lrouter = None
            else:
                # Update the cache
                self._nvp_cache.update_lrouter(lrouter)

        # Note(salv-orlando): It might worth adding a check to verify neutron
        # resource tag in nvp entity matches a Neutron id.
        # By default assume things go wrong
        status = constants.NET_STATUS_ERROR
        if lrouter:
            lr_status = (
                lrouter['_relations']['LogicalRouterStatus']['fabric_status'])
            status = (lr_status and constants.NET_STATUS_ACTIVE
                      or constants.NET_STATUS_DOWN)
        # Update db object
        self._update_neutron_object(context, neutron_router_data, status)
示例#2
0
文件: sync.py 项目: ntt-sic/neutron
    def synchronize_router(self, context, neutron_router_data, lrouter=None):
        """Synchronize a neutron router with its NVP counterpart."""
        if not lrouter:
            # Try to get router from nvp
            try:
                # This query will return the logical router status too
                lrouter = nvplib.get_lrouter(self._cluster, neutron_router_data["id"])
            except exceptions.NotFound:
                # NOTE(salv-orlando): We should be catching
                # NvpApiClient.ResourceNotFound here
                # The logical router was not found
                LOG.warning(_("Logical router for neutron router %s not " "found on NVP."), neutron_router_data["id"])
                lrouter = None
            else:
                # Update the cache
                self._nvp_cache.update_lrouter(lrouter)

        # Note(salv-orlando): It might worth adding a check to verify neutron
        # resource tag in nvp entity matches a Neutron id.
        # By default assume things go wrong
        status = constants.NET_STATUS_ERROR
        if lrouter:
            lr_status = lrouter["_relations"]["LogicalRouterStatus"]["fabric_status"]
            status = lr_status and constants.NET_STATUS_ACTIVE or constants.NET_STATUS_DOWN
        # Update db object
        self._update_neutron_object(context, neutron_router_data, status)
    def _get_nvp_lrouter_status(self, id):
        try:
            lrouter = nvplib.get_lrouter(self.cluster, id)
            lr_status = lrouter["_relations"]["LogicalRouterStatus"]
            if lr_status["fabric_status"]:
                nvp_status = RouterStatus.ROUTER_STATUS_ACTIVE
            else:
                nvp_status = RouterStatus.ROUTER_STATUS_DOWN
        except q_exc.NotFound:
            nvp_status = RouterStatus.ROUTER_STATUS_ERROR

        return nvp_status
示例#4
0
文件: sync.py 项目: rhel-osp/neutron
    def synchronize_router(self, context, neutron_router_data, lrouter=None):
        """Synchronize a neutron router with its NVP counterpart."""
        if not lrouter:
            # Try to get router from nvp
            try:
                # This query will return the logical router status too
                lrouter = nvplib.get_lrouter(self._cluster,
                                             neutron_router_data['id'])
            except exceptions.NotFound:
                # NOTE(salv-orlando): We should be catching
                # NvpApiClient.ResourceNotFound here
                # The logical router was not found
                LOG.warning(
                    _("Logical router for neutron router %s not "
                      "found on NVP."), neutron_router_data['id'])
                lrouter = None
            else:
                # Update the cache
                self._nvp_cache.update_lrouter(lrouter)

        # Note(salv-orlando): It might worth adding a check to verify neutron
        # resource tag in nvp entity matches a Neutron id.
        # By default assume things go wrong
        status = constants.NET_STATUS_ERROR
        if lrouter:
            lr_status = (
                lrouter['_relations']['LogicalRouterStatus']['fabric_status'])
            status = (lr_status and constants.NET_STATUS_ACTIVE
                      or constants.NET_STATUS_DOWN)
        # Update db object
        if status == neutron_router_data['status']:
            # do nothing
            return

        with context.session.begin(subtransactions=True):
            try:
                router = self._plugin._get_router(context,
                                                  neutron_router_data['id'])
            except exc.NoResultFound:
                pass
            else:
                router.status = status
                LOG.debug(
                    _("Updating status for neutron resource %(q_id)s to:"
                      " %(status)s"), {
                          'q_id': neutron_router_data['id'],
                          'status': status
                      })