Ejemplo n.º 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
                nsx_router_id = nsx_utils.get_nsx_router_id(
                    context.session, self._cluster, neutron_router_data['id'])
                lrouter = nvplib.get_lrouter(
                    self._cluster, nsx_router_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)
Ejemplo n.º 2
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
                nsx_router_id = nsx_utils.get_nsx_router_id(
                    context.session, self._cluster, neutron_router_data['id'])
                lrouter = routerlib.get_lrouter(self._cluster, nsx_router_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)
Ejemplo n.º 3
0
 def _verify_get_nsx_router_id(self, exp_lr_uuid):
     # The nvplib and db calls are  mocked, therefore the cluster
     # and the neutron_router_id parameters can be set to None
     lr_uuid = nsx_utils.get_nsx_router_id(db_api.get_session(), None, None)
     self.assertEqual(exp_lr_uuid, lr_uuid)
Ejemplo n.º 4
0
 def _verify_get_nsx_router_id(self, exp_lr_uuid):
     # The nvplib and db calls are  mocked, therefore the cluster
     # and the neutron_router_id parameters can be set to None
     lr_uuid = nsx_utils.get_nsx_router_id(db_api.get_session(), None, None)
     self.assertEqual(exp_lr_uuid, lr_uuid)