• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ofctl_utils.send_msg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ryu.lib.ofctl_utils.send_msg函数的典型用法代码示例。如果您正苦于以下问题:Python send_msg函数的具体用法?Python send_msg怎么用?Python send_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了send_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: mod_group_entry

def mod_group_entry(dp, group, cmd):
    group_type = str(group.get("type", "ALL"))
    t = UTIL.ofp_group_type_from_user(group_type)
    group_type = t if t != group_type else None
    if group_type is None:
        LOG.error("Unknown group type: %s", group.get("type"))

    group_id = UTIL.ofp_group_from_user(group.get("group_id", 0))

    buckets = []
    for bucket in group.get("buckets", []):
        weight = int(bucket.get("weight", 0))
        watch_port = int(bucket.get("watch_port", dp.ofproto.OFPP_ANY))
        watch_group = int(bucket.get("watch_group", dp.ofproto.OFPG_ANY))
        actions = []
        for dic in bucket.get("actions", []):
            action = to_action(dp, dic)
            if action is not None:
                actions.append(action)
        b = dp.ofproto_parser.OFPBucket(weight, watch_port, watch_group, actions)
        buckets.append(b)

    group_mod = dp.ofproto_parser.OFPGroupMod(dp, cmd, group_type, group_id, buckets)

    ofctl_utils.send_msg(dp, group_mod, LOG)
开发者ID:jhhan,项目名称:ryu,代码行数:25,代码来源:ofctl_v1_4.py


示例2: mod_port_behavior

def mod_port_behavior(dp, port_config):
    ofp = dp.ofproto
    parser = dp.ofproto_parser
    port_no = UTIL.ofp_port_from_user(port_config.get("port_no", 0))
    hw_addr = str(port_config.get("hw_addr"))
    config = int(port_config.get("config", 0))
    mask = int(port_config.get("mask", 0))
    properties = port_config.get("properties")

    prop = []
    for p in properties:
        type_ = UTIL.ofp_port_mod_prop_type_from_user(p["type"])
        length = None
        if type_ == ofp.OFPPDPT_ETHERNET:
            advertise = UTIL.ofp_port_features_from_user(p["advertise"])
            m = parser.OFPPortModPropEthernet(type_, length, advertise)
        elif type_ == ofp.OFPPDPT_OPTICAL:
            m = parser.OFPPortModPropOptical(
                type_, length, p["configure"], p["freq_lmda"], p["fl_offset"], p["grid_span"], p["tx_pwr"]
            )
        elif type_ == ofp.OFPPDPT_EXPERIMENTER:
            m = parser.OFPPortModPropExperimenter(type_, length, p["experimenter"], p["exp_type"], p["data"])
        else:
            LOG.error("Unknown port desc prop type: %s", type_)
            continue
        prop.append(m)

    port_mod = dp.ofproto_parser.OFPPortMod(dp, port_no, hw_addr, config, mask, prop)

    ofctl_utils.send_msg(dp, port_mod, LOG)
开发者ID:jhhan,项目名称:ryu,代码行数:30,代码来源:ofctl_v1_4.py


示例3: mod_flow_entry

def mod_flow_entry(dp, flow, cmd):
    cookie = int(flow.get("cookie", 0))
    cookie_mask = int(flow.get("cookie_mask", 0))
    table_id = UTIL.ofp_table_from_user(flow.get("table_id", 0))
    idle_timeout = int(flow.get("idle_timeout", 0))
    hard_timeout = int(flow.get("hard_timeout", 0))
    priority = int(flow.get("priority", 0))
    buffer_id = UTIL.ofp_buffer_from_user(flow.get("buffer_id", dp.ofproto.OFP_NO_BUFFER))
    out_port = UTIL.ofp_port_from_user(flow.get("out_port", dp.ofproto.OFPP_ANY))
    out_group = UTIL.ofp_group_from_user(flow.get("out_group", dp.ofproto.OFPG_ANY))
    importance = int(flow.get("importance", 0))
    flags = int(flow.get("flags", 0))
    match = to_match(dp, flow.get("match", {}))
    inst = to_instructions(dp, flow.get("instructions", []))

    flow_mod = dp.ofproto_parser.OFPFlowMod(
        dp,
        cookie,
        cookie_mask,
        table_id,
        cmd,
        idle_timeout,
        hard_timeout,
        priority,
        buffer_id,
        out_port,
        out_group,
        importance,
        flags,
        match,
        inst,
    )

    ofctl_utils.send_msg(dp, flow_mod, LOG)
开发者ID:jhhan,项目名称:ryu,代码行数:34,代码来源:ofctl_v1_4.py


示例4: mod_group_entry

def mod_group_entry(dp, group, cmd):

    type_convert = {'ALL': dp.ofproto.OFPGT_ALL,
                    'SELECT': dp.ofproto.OFPGT_SELECT,
                    'INDIRECT': dp.ofproto.OFPGT_INDIRECT,
                    'FF': dp.ofproto.OFPGT_FF}

    type_ = type_convert.get(group.get('type', 'ALL'))
    if type_ is None:
        LOG.error('Unknown group type: %s', group.get('type'))

    group_id = UTIL.ofp_group_from_user(group.get('group_id', 0))

    buckets = []
    for bucket in group.get('buckets', []):
        weight = int(bucket.get('weight', 0))
        watch_port = int(bucket.get('watch_port', dp.ofproto.OFPP_ANY))
        watch_group = int(bucket.get('watch_group', dp.ofproto.OFPG_ANY))
        actions = []
        for dic in bucket.get('actions', []):
            action = to_action(dp, dic)
            if action is not None:
                actions.append(action)
        buckets.append(dp.ofproto_parser.OFPBucket(
            weight, watch_port, watch_group, actions))

    group_mod = dp.ofproto_parser.OFPGroupMod(
        dp, cmd, type_, group_id, buckets)

    ofctl_utils.send_msg(dp, group_mod, LOG)
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:30,代码来源:ofctl_v1_3.py


示例5: mod_port_behavior

def mod_port_behavior(dp, port_config):
    ofp = dp.ofproto
    parser = dp.ofproto_parser
    port_no = UTIL.ofp_port_from_user(port_config.get('port_no', 0))
    hw_addr = str(port_config.get('hw_addr'))
    config = int(port_config.get('config', 0))
    mask = int(port_config.get('mask', 0))
    properties = port_config.get('properties')

    prop = []
    for p in properties:
        type_ = UTIL.ofp_port_mod_prop_type_from_user(p['type'])
        length = None
        if type_ == ofp.OFPPDPT_ETHERNET:
            advertise = UTIL.ofp_port_features_from_user(p['advertise'])
            prop.append(
                parser.OFPPortModPropEthernet(type_, length, advertise))
        elif type_ == ofp.OFPPDPT_OPTICAL:
            prop.append(
                parser.OFPPortModPropOptical(
                    type_, length, p['configure'], p['freq_lmda'],
                    p['fl_offset'], p['grid_span'], p['tx_pwr']))
        elif type_ == ofp.OFPPDPT_EXPERIMENTER:
            prop.append(
                parser.OFPPortModPropExperimenter(
                    type_, length, p['experimenter'], p['exp_type'],
                    p['data']))
        else:
            LOG.error('Unknown port desc prop type: %s', type_)

    port_mod = dp.ofproto_parser.OFPPortMod(
        dp, port_no, hw_addr, config, mask, prop)

    ofctl_utils.send_msg(dp, port_mod, LOG)
开发者ID:Huangmachi,项目名称:ryu,代码行数:34,代码来源:ofctl_v1_5.py


示例6: mod_group_entry

def mod_group_entry(dp, group, cmd):
    group_type = str(group.get('type', 'ALL'))
    t = UTIL.ofp_group_type_from_user(group_type)
    group_type = t if t != group_type else None
    if group_type is None:
        LOG.error('Unknown group type: %s', group.get('type'))

    group_id = UTIL.ofp_group_from_user(group.get('group_id', 0))

    buckets = []
    for bucket in group.get('buckets', []):
        weight = int(bucket.get('weight', 0))
        watch_port = int(bucket.get('watch_port', dp.ofproto.OFPP_ANY))
        watch_group = int(bucket.get('watch_group', dp.ofproto.OFPG_ANY))
        actions = []
        for dic in bucket.get('actions', []):
            action = to_action(dp, dic)
            if action is not None:
                actions.append(action)
        buckets.append(dp.ofproto_parser.OFPBucket(
            weight, watch_port, watch_group, actions))

    group_mod = dp.ofproto_parser.OFPGroupMod(
        dp, cmd, group_type, group_id, buckets)

    ofctl_utils.send_msg(dp, group_mod, LOG)
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:26,代码来源:ofctl_v1_4.py


示例7: delete_flow_entry

def delete_flow_entry(dp):
    match = dp.ofproto_parser.OFPMatch(
        dp.ofproto.OFPFW_ALL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    flow_mod = dp.ofproto_parser.OFPFlowMod(
        datapath=dp, match=match, cookie=0,
        command=dp.ofproto.OFPFC_DELETE)

    ofctl_utils.send_msg(dp, flow_mod, LOG)
开发者ID:Huangmachi,项目名称:ryu,代码行数:9,代码来源:ofctl_v1_0.py


示例8: mod_port_behavior

def mod_port_behavior(dp, port_config):
    port_no = UTIL.ofp_port_from_user(port_config.get('port_no', 0))
    hw_addr = str(port_config.get('hw_addr'))
    config = int(port_config.get('config', 0))
    mask = int(port_config.get('mask', 0))
    advertise = int(port_config.get('advertise'))

    port_mod = dp.ofproto_parser.OFPPortMod(
        dp, port_no, hw_addr, config, mask, advertise)

    ofctl_utils.send_msg(dp, port_mod, LOG)
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:11,代码来源:ofctl_v1_3.py


示例9: mod_meter_entry

def mod_meter_entry(dp, meter, cmd):

    flags_convert = {'KBPS': dp.ofproto.OFPMF_KBPS,
                     'PKTPS': dp.ofproto.OFPMF_PKTPS,
                     'BURST': dp.ofproto.OFPMF_BURST,
                     'STATS': dp.ofproto.OFPMF_STATS}

    flags = 0
    if 'flags' in meter:
        meter_flags = meter['flags']
        if not isinstance(meter_flags, list):
            meter_flags = [meter_flags]
        for flag in meter_flags:
            if flag not in flags_convert:
                LOG.error('Unknown meter flag: %s', flag)
                continue
            flags |= flags_convert.get(flag)

    meter_id = UTIL.ofp_meter_from_user(meter.get('meter_id', 0))

    bands = []
    for band in meter.get('bands', []):
        band_type = band.get('type')
        rate = int(band.get('rate', 0))
        burst_size = int(band.get('burst_size', 0))
        if band_type == 'DROP':
            bands.append(
                dp.ofproto_parser.OFPMeterBandDrop(rate, burst_size))
        elif band_type == 'DSCP_REMARK':
            prec_level = int(band.get('prec_level', 0))
            bands.append(
                dp.ofproto_parser.OFPMeterBandDscpRemark(
                    rate, burst_size, prec_level))
        elif band_type == 'EXPERIMENTER':
            experimenter = int(band.get('experimenter', 0))
            bands.append(
                dp.ofproto_parser.OFPMeterBandExperimenter(
                    rate, burst_size, experimenter))
        else:
            LOG.error('Unknown band type: %s', band_type)

    meter_mod = dp.ofproto_parser.OFPMeterMod(
        dp, cmd, flags, meter_id, bands)

    ofctl_utils.send_msg(dp, meter_mod, LOG)
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:45,代码来源:ofctl_v1_3.py


示例10: mod_meter_entry

def mod_meter_entry(dp, meter, cmd):
    flags = 0
    if 'flags' in meter:
        meter_flags = meter['flags']
        if not isinstance(meter_flags, list):
            meter_flags = [meter_flags]
        for flag in meter_flags:
            t = UTIL.ofp_meter_flags_from_user(flag)
            f = t if t != flag else None
            if f is None:
                LOG.error('Unknown meter flag: %s', flag)
                continue
            flags |= f

    meter_id = UTIL.ofp_meter_from_user(meter.get('meter_id', 0))

    bands = []
    for band in meter.get('bands', []):
        band_type = band.get('type')
        rate = str_to_int(band.get('rate', 0))
        burst_size = str_to_int(band.get('burst_size', 0))
        if band_type == 'DROP':
            bands.append(
                dp.ofproto_parser.OFPMeterBandDrop(rate, burst_size))
        elif band_type == 'DSCP_REMARK':
            prec_level = str_to_int(band.get('prec_level', 0))
            bands.append(
                dp.ofproto_parser.OFPMeterBandDscpRemark(
                    rate, burst_size, prec_level))
        elif band_type == 'EXPERIMENTER':
            experimenter = str_to_int(band.get('experimenter', 0))
            bands.append(
                dp.ofproto_parser.OFPMeterBandExperimenter(
                    rate, burst_size, experimenter))
        else:
            LOG.error('Unknown band type: %s', band_type)

    meter_mod = dp.ofproto_parser.OFPMeterMod(
        dp, cmd, flags, meter_id, bands)

    ofctl_utils.send_msg(dp, meter_mod, LOG)
开发者ID:vinaykothiyal,项目名称:ryu,代码行数:41,代码来源:ofctl_v1_5.py


示例11: mod_flow_entry

def mod_flow_entry(dp, flow, cmd):
    cookie = int(flow.get('cookie', 0))
    cookie_mask = int(flow.get('cookie_mask', 0))
    table_id = UTIL.ofp_table_from_user(flow.get('table_id', 0))
    idle_timeout = int(flow.get('idle_timeout', 0))
    hard_timeout = int(flow.get('hard_timeout', 0))
    priority = int(flow.get('priority', 0))
    buffer_id = UTIL.ofp_buffer_from_user(
        flow.get('buffer_id', dp.ofproto.OFP_NO_BUFFER))
    out_port = UTIL.ofp_port_from_user(
        flow.get('out_port', dp.ofproto.OFPP_ANY))
    out_group = UTIL.ofp_group_from_user(
        flow.get('out_group', dp.ofproto.OFPG_ANY))
    flags = int(flow.get('flags', 0))
    match = to_match(dp, flow.get('match', {}))
    inst = to_actions(dp, flow.get('actions', []))

    flow_mod = dp.ofproto_parser.OFPFlowMod(
        dp, cookie, cookie_mask, table_id, cmd, idle_timeout,
        hard_timeout, priority, buffer_id, out_port, out_group,
        flags, match, inst)

    ofctl_utils.send_msg(dp, flow_mod, LOG)
开发者ID:Aries-Sushi,项目名称:ryu,代码行数:23,代码来源:ofctl_v1_3.py


示例12: mod_flow_entry

def mod_flow_entry(dp, flow, cmd):
    cookie = int(flow.get('cookie', 0))
    priority = int(flow.get('priority',
                            dp.ofproto.OFP_DEFAULT_PRIORITY))
    buffer_id = UTIL.ofp_buffer_from_user(
        flow.get('buffer_id', dp.ofproto.OFP_NO_BUFFER))
    out_port = UTIL.ofp_port_from_user(
        flow.get('out_port', dp.ofproto.OFPP_NONE))
    flags = int(flow.get('flags', 0))
    idle_timeout = int(flow.get('idle_timeout', 0))
    hard_timeout = int(flow.get('hard_timeout', 0))
    actions = to_actions(dp, flow.get('actions', []))
    match = to_match(dp, flow.get('match', {}))

    flow_mod = dp.ofproto_parser.OFPFlowMod(
        datapath=dp, match=match, cookie=cookie,
        command=cmd, idle_timeout=idle_timeout,
        hard_timeout=hard_timeout, priority=priority,
        buffer_id=buffer_id, out_port=out_port,
        flags=flags,
        actions=actions)

    ofctl_utils.send_msg(dp, flow_mod, LOG)
开发者ID:Huangmachi,项目名称:ryu,代码行数:23,代码来源:ofctl_v1_0.py


示例13: mod_meter_entry

def mod_meter_entry(dp, meter, cmd):
    flags = 0
    if "flags" in meter:
        meter_flags = meter["flags"]
        if not isinstance(meter_flags, list):
            meter_flags = [meter_flags]
        for flag in meter_flags:
            t = UTIL.ofp_meter_flags_from_user(flag)
            f = t if t != flag else None
            if f is None:
                LOG.error("Unknown meter flag: %s", flag)
                continue
            flags |= f

    meter_id = UTIL.ofp_meter_from_user(meter.get("meter_id", 0))

    bands = []
    for band in meter.get("bands", []):
        band_type = band.get("type")
        rate = int(band.get("rate", 0))
        burst_size = int(band.get("burst_size", 0))
        if band_type == "DROP":
            b = dp.ofproto_parser.OFPMeterBandDrop(rate, burst_size)
        elif band_type == "DSCP_REMARK":
            prec_level = int(band.get("prec_level", 0))
            b = dp.ofproto_parser.OFPMeterBandDscpRemark(rate, burst_size, prec_level)
        elif band_type == "EXPERIMENTER":
            experimenter = int(band.get("experimenter", 0))
            b = dp.ofproto_parser.OFPMeterBandExperimenter(rate, burst_size, experimenter)
        else:
            LOG.error("Unknown band type: %s", band_type)
            continue
        bands.append(b)

    meter_mod = dp.ofproto_parser.OFPMeterMod(dp, cmd, flags, meter_id, bands)

    ofctl_utils.send_msg(dp, meter_mod, LOG)
开发者ID:jhhan,项目名称:ryu,代码行数:37,代码来源:ofctl_v1_4.py


示例14: mod_group_entry

def mod_group_entry(dp, group, cmd):
    ofp = dp.ofproto
    parser = dp.ofproto_parser

    group_type = str(group.get('type', 'ALL'))
    t = UTIL.ofp_group_type_from_user(group_type)
    group_type = t if t != group_type else None
    if group_type is None:
        LOG.error('Unknown group type: %s', group.get('type'))

    group_id = UTIL.ofp_group_from_user(group.get('group_id', 0))
    command_bucket_id = int(group.get('command_bucket_id', 0))

    # Note:
    # The list of group property types that are currently defined
    # are only OFPGPT_EXPERIMENTER(Experimenter defined).
    properties = []

    buckets = []
    for bucket in group.get('buckets', []):

        # get bucket_id in buckets
        bucket_id = int(bucket.get('bucket_id', 0))

        # get actions in buckets
        bucket_actions = []
        for dic in bucket.get('actions', []):
            action = to_action(dp, dic)
            if action is not None:
                bucket_actions.append(action)

        # get properties in buckets
        bucket_properties = []
        for p in bucket.get('properties', []):
            group_bp_type = str(p.get('type', 'WEIGHT'))
            t = UTIL.ofp_group_bucket_prop_type_from_user(group_bp_type)
            group_bp_type = t if t != group_bp_type else ofp.OFPGBPT_WEIGHT

            if group_bp_type == ofp.OFPGBPT_WEIGHT:
                weight = int(p.get('weight', 0))
                bucket_properties.append(
                    parser.OFPGroupBucketPropWeight(
                        type_=group_bp_type, weight=weight))
            elif group_bp_type == ofp.OFPGBPT_WATCH_PORT:
                watch_port = int(p.get('watch', dp.ofproto.OFPP_ANY))
                bucket_properties.append(
                    parser.OFPGroupBucketPropWatch(
                        type_=group_bp_type, watch=watch_port))
            elif group_bp_type == ofp.OFPGBPT_WATCH_GROUP:
                watch_group = int(p.get('watch', dp.ofproto.OFPG_ANY))
                bucket_properties.append(
                    parser.OFPGroupBucketPropWatch(
                        type_=group_bp_type, watch=watch_group))
            elif group_bp_type == ofp.OFPGBPT_EXPERIMENTER:
                experimenter = p.get('experimenter', 0)
                exp_type = p.get('exp_type', 0)
                data_type = p.get('data_type', 'ascii')
                if data_type not in ['ascii', 'base64']:
                    LOG.error('Unknown data type: %s', data_type)
                data = p.get('data', '')
                if data_type == 'base64':
                    data = base64.b64decode(data)
                bucket_properties.append(
                    parser.OFPGroupBucketPropExperimenter(
                        type_=group_bp_type, experimenter=experimenter,
                        exp_type=exp_type, data=data))
            else:
                LOG.error('Unknown group bucket prop type: %s', p['type'])

        # create bucket
        bucket = parser.OFPBucket(bucket_id=bucket_id,
                                  actions=bucket_actions,
                                  properties=bucket_properties)
        buckets.append(bucket)

    group_mod = parser.OFPGroupMod(dp, cmd, group_type, group_id,
                                   command_bucket_id, buckets,
                                   properties)

    ofctl_utils.send_msg(dp, group_mod, LOG)
开发者ID:Huangmachi,项目名称:ryu,代码行数:80,代码来源:ofctl_v1_5.py


示例15: set_role

def set_role(dp, role):
    r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
    role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
    ofctl_utils.send_msg(dp, role_request, LOG)
开发者ID:Huangmachi,项目名称:ryu,代码行数:4,代码来源:ofctl_v1_5.py



注:本文中的ryu.lib.ofctl_utils.send_msg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ofctl_utils.send_stats_request函数代码示例发布时间:2022-05-27
下一篇:
Python mac.haddr_to_str函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap