示例#1
0
    def addGroupforDelayBasedRouting(self, upstreamPortsList=None):
        group4 = sh.ActionProfileGroup(
            self,
            "IngressPipeImpl.delay_based_upstream_path_selector")(group_id=3)
        group3 = sh.ActionProfileGroup(
            self,
            "IngressPipeImpl.delay_based_upstream_path_selector")(group_id=4)
        group2 = sh.ActionProfileGroup(
            self,
            "IngressPipeImpl.delay_based_upstream_path_selector")(group_id=5)
        group1 = sh.ActionProfileGroup(
            self,
            "IngressPipeImpl.delay_based_upstream_path_selector")(group_id=6)

        group4.insert()
        group3.insert()
        group2.insert()
        group1.insert()

        upstreamPortsList = [3]
        for i in range(0, len(upstreamPortsList)):
            member = sh.ActionProfileMember(
                self, "IngressPipeImpl.delay_based_upstream_path_selector"
            )(member_id=upstreamPortsList[i],
              action="delay_based_upstream_path_selector_action_with_param")
            member.action["port_num"] = str(upstreamPortsList[i])
            member.insert()
            # group4.add(member.member_id)
            # group3.add(member.member_id)
            group2.add(member.member_id)
            # group1.add(member.member_id)
        upstreamPortsList = [4]
        for i in range(0, len(upstreamPortsList)):
            member = sh.ActionProfileMember(
                self, "IngressPipeImpl.delay_based_upstream_path_selector"
            )(member_id=upstreamPortsList[i],
              action="delay_based_upstream_path_selector_action_with_param")
            member.action["port_num"] = str(upstreamPortsList[i])
            member.insert()
            # group4.add(member.member_id)
            # group3.add(member.member_id)
            group4.add(member.member_id)
            # group1.add(member.member_id)
        for i in range(128, 140):
            member = sh.ActionProfileMember(
                self, "IngressPipeImpl.delay_based_upstream_path_selector"
            )(member_id=i,
              action="delay_based_upstream_path_selector_action_with_param")
            member.action["port_num"] = str(i)
            member.insert()
            group3.add(member.member_id)

        group4.modify()
        group3.modify()
        group2.modify()
        group1.modify()
示例#2
0
def delFrmGrp(dev, port):
    group = sh.ActionProfileGroup(dev, "upstream_path_selector")(
        group_id=InternalConfig.LEAF_SWITCH_UPSTREAM_PORTS_GROUP)
    #group = dev.grp
    #print("Group is "+group)
    member = sh.ActionProfileMember(dev, "upstream_path_selector")(member_id=port, action="set_upstream_egress_port")
    member.action["port_num"] = str(port)
    group.del_member_from_group(member)
    group.modify()
示例#3
0
def addUpStreamRoutingGroupForLeafSwitch(dev, upstreamPortsList):
    group = sh.ActionProfileGroup(dev, "upstream_path_selector")(
        group_id=InternalConfig.LEAF_SWITCH_UPSTREAM_PORTS_GROUP)
    group.insert()
    for i in range(0, len(upstreamPortsList)):
        member = sh.ActionProfileMember(dev, "upstream_path_selector")(member_id=i, action="set_upstream_egress_port")
        member.action["port_num"] = str(upstreamPortsList[i])
        member.insert()
        group.add(member.member_id)
    group.modify()
示例#4
0
def addUpStreamRoutingGroupForSpineSwitchWithExistingGroup(
        dev, upstreamPortsList, groupID):
    group = sh.ActionProfileGroup(dev,
                                  "upstream_path_selector")(group_id=groupID)

    for i in range(0, len(upstreamPortsList)):
        if (group.isMemberExists(dev, member=upstreamPortsList[i]) == False):
            member = sh.ActionProfileMember(dev, "upstream_path_selector")(
                member_id=i, action="set_upstream_egress_port")
            member.action["port_num"] = str(upstreamPortsList[i])
            member.insert()
            group.add(member.member_id)
    group.modify()
示例#5
0
    def test_table_indirect(self):
        member = sh.ActionProfileMember("ActProfWS")(member_id=1,
                                                     action="actionA")
        member.action["param"] = "aa:bb:cc:dd:ee:ff"
        group = sh.ActionProfileGroup("ActProfWS")(group_id=1)
        group.add(member.member_id)

        expected_member = """
action_profile_id: 285237193
member_id: 1
action {
  action_id: 16783703
  params {
    param_id: 1
    value: "\\xaa\\xbb\\xcc\\xdd\\xee\\xff"
  }
}
"""

        expected_group = """
action_profile_id: 285237193
group_id: 1
members {
  member_id: 1
  weight: 1
}
"""

        expected_entry_1 = """
table_id: 33586946
match {
  field_id: 1
  exact {
    value: "\\x0a\\x00\\x00\\x00"
  }
}
action {
  action_profile_member_id: 1
}
"""

        expected_entry_2 = """
table_id: 33586946
match {
  field_id: 1
  exact {
    value: "\\x0a\\x00\\x00\\x00"
  }
}
action {
  action_profile_group_id: 1
}
"""

        expected_req = self.make_write_request(
            p4runtime_pb2.Update.INSERT, P4RuntimeEntity.action_profile_member,
            expected_member)
        member.insert()
        self.servicer.Write.assert_called_with(ProtoCmp(expected_req), ANY)

        expected_req = self.make_write_request(
            p4runtime_pb2.Update.INSERT, P4RuntimeEntity.action_profile_group,
            expected_group)
        group.insert()
        self.servicer.Write.assert_called_with(ProtoCmp(expected_req), ANY)

        te = sh.TableEntry("IndirectWS")
        te.match["header_test.field32"] = "10.0.0.0"
        te.member_id = member.member_id
        te.insert()

        expected_req = self.make_write_request(p4runtime_pb2.Update.INSERT,
                                               P4RuntimeEntity.table_entry,
                                               expected_entry_1)
        self.servicer.Write.assert_called_with(ProtoCmp(expected_req), ANY)

        te.group_id = group.group_id
        te.modify()

        expected_req = self.make_write_request(p4runtime_pb2.Update.MODIFY,
                                               P4RuntimeEntity.table_entry,
                                               expected_entry_2)
        self.servicer.Write.assert_called_with(ProtoCmp(expected_req), ANY)