コード例 #1
0
ファイル: path.py プロジェクト: tubbytani/python-rdma
def _resolve_path_async(mad,path,reversible=False,properties=None):
    if path.end_port is None:
        path.end_port = mad.end_port;

    q = IBA.ComponentMask(IBA.SAPathRecord());
    if reversible:
        q.reversible = True;
    # FIXME: want to remove this line ...
    q.reversible = True;
    if path.SGID is not None:
        q.SGID = path.SGID;
    else:
        q.SGID = mad.end_port.default_gid;

    if path.DGID is not None:
        q.DGID = path.DGID;
    else:
        q.DLID = path.DLID;

    if properties:
        for k,v in properties.iteritems():
            setattr(q,k,v);

    try:
        rep = yield mad.SubnAdmGet(q);
    except rdma.MADClassError as err:
        if err.code == IBA.MAD_STATUS_SA_NO_RECORDS:
            raise SAPathNotFoundError("Failed getting path record for path %r."%(path),
                                      err);
        err.message("Failed getting path record for path %r."%(path));
        raise
    except rdma.MADError as err:
        err.message("Failed getting path record for path %r."%(path));
        raise

    path.DGID = rep.DGID;
    path.SGID = rep.SGID;
    path.DLID = rep.DLID;
    path.SLID = rep.SLID;
    path.flow_label = rep.flowLabel;
    path.hop_limit = rep.hopLimit;
    path.traffic_class = rep.TClass;
    path.pkey = rep.PKey;
    path.SL = rep.SL;
    path.MTU = rep.MTU;
    path.rate = rep.rate;
    path.has_grh = rep.hopLimit != 0;
    path.packet_life_time = rep.packetLifeTime;
    mad.result = path;