示例#1
0
def get_vcns_edge_vip_binding(session, id):
    with session.begin(subtransactions=True):
        try:
            qry = session.query(vcns_models.VcnsEdgeVipBinding)
            return qry.filter_by(vip_id=id).one()
        except exc.NoResultFound:
            msg = _("VIP Resource binding with id:%s not found!") % id
            LOG.exception(msg)
            raise vcns_exc.VcnsNotFound(resource='router_service_binding',
                                        msg=msg)
 def _get_vip_binding(self, session, id):
     vip_binding = vcns_db.get_vcns_edge_vip_binding(session, id)
     if not vip_binding:
         msg = (_("vip_binding not found with id: %(id)s "
                  "edge_id: %(edge_id)s") % {
                'id': id,
                'edge_id': vip_binding[vcns_const.EDGE_ID]})
         LOG.error(msg)
         raise vcns_exc.VcnsNotFound(
             resource='router_service_binding', msg=msg)
     return vip_binding
 def get_pool(self, context, id, edge_id):
     pool_binding = vcns_db.get_vcns_edge_pool_binding(
         context.session, id, edge_id)
     if not pool_binding:
         msg = (_("pool_binding not found with id: %(id)s "
                  "edge_id: %(edge_id)s") % {'id': id, 'edge_id': edge_id})
         LOG.error(msg)
         raise vcns_exc.VcnsNotFound(
             resource='router_service_binding', msg=msg)
     pool_vseid = pool_binding['pool_vseid']
     try:
         response = self.vcns.get_pool(edge_id, pool_vseid)[1]
     except vcns_exc.VcnsApiException:
         with excutils.save_and_reraise_exception():
             LOG.exception(_LE("Failed to get pool on edge"))
     return self._restore_lb_pool(context, edge_id, response)
 def get_health_monitor(self, context, id, edge_id):
     monitor_binding = vcns_db.get_vcns_edge_monitor_binding(
         context.session, id, edge_id)
     if not monitor_binding:
         msg = (_("monitor_binding not found with id: %(id)s "
                  "edge_id: %(edge_id)s") % {'id': id, 'edge_id': edge_id})
         LOG.error(msg)
         raise vcns_exc.VcnsNotFound(
             resource='router_service_binding', msg=msg)
     monitor_vseid = monitor_binding['monitor_vseid']
     try:
         response = self.vcns.get_health_monitor(edge_id, monitor_vseid)[1]
     except vcns_exc.VcnsApiException as e:
         with excutils.save_and_reraise_exception():
             LOG.exception(_LE("Failed to get monitor on edge: %s"),
                           e.response)
     return self._restore_lb_monitor(context, edge_id, response)
示例#5
0
 def get_firewall_rule(self, context, id, edge_id):
     rule_map = vcns_db.get_vcns_edge_firewallrule_binding(
         context.session, id, edge_id)
     if rule_map is None:
         msg = _("No rule id:%s found in the edge_firewall_binding") % id
         LOG.error(msg)
         raise vcns_exc.VcnsNotFound(resource='vcns_firewall_rule_bindings',
                                     msg=msg)
     vcns_rule_id = rule_map.rule_vseid
     try:
         response = self.vcns.get_firewall_rule(edge_id, vcns_rule_id)[1]
     except vcns_exc.VcnsApiException:
         with excutils.save_and_reraise_exception():
             LOG.exception(
                 _("Failed to get firewall rule: %(rule_id)s "
                   "with edge_id: %(edge_id)s"), {
                       'rule_id': id,
                       'edge_id': edge_id
                   })
     return self._restore_firewall_rule(context, edge_id, response)