コード例 #1
0
 def add_table_entry(self, table_entry):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     update = request.updates.add()
     update.type = p4runtime_pb2.Update.INSERT
     update.entity.table_entry.CopyFrom(table_entry)
     request.election_id.CopyFrom(self.election_id)
     # pdb.set_trace()
     self.client_stub.Write(request)
コード例 #2
0
 def WriteTableEntry(self, table_entry, dry_run=False):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     update = request.updates.add()
     update.type = p4runtime_pb2.Update.INSERT
     update.entity.table_entry.CopyFrom(table_entry)
     if dry_run:
         print "P4 Runtime Write:", request
     else:
         self.client_stub.Write(request)
コード例 #3
0
 def ModifyTableEntry(self, table_entry, dry_run=False):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     request.election_id.low = 1
     update = request.updates.add()
     update.type = p4runtime_pb2.Update.MODIFY
     update.entity.table_entry.CopyFrom(table_entry)
     if dry_run:
         print "P4Runtime Write:", request
     else:
         self.client_stub.Write(request)
コード例 #4
0
ファイル: switch.py プロジェクト: rachitnigam/Hula-hoop
 def WriteMCastEntry(self, mcast_entry, dry_run=False):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     request.election_id.low = 1
     update = request.updates.add()
     update.type = p4runtime_pb2.Update.INSERT
     update.entity.packet_replication_engine_entry.CopyFrom(mcast_entry)
     if dry_run:
         print "P4Runtime Write:", request
     else:
         self.client_stub.Write(request)
コード例 #5
0
 def WriteListTableEntry(self, list_table_entry, dry_run=False):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     request.election_id.low = 1
     for table_entry in list_table_entry:
         update = request.updates.add()
         update.type = p4runtime_pb2.Update.INSERT
         update.entity.table_entry.CopyFrom(table_entry)
     if dry_run:
         print "P4Runtime Write:", request
     else:
         self.client_stub.Write(request)
コード例 #6
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def undo_write_requests(self, reqs):
     updates = []
     for req in reversed(reqs):
         for update in reversed(req.updates):
             if update.type == p4runtime_pb2.Update.INSERT:
                 updates.append(update)
     new_req = p4runtime_pb2.WriteRequest()
     new_req.device_id = self.device_id
     for update in updates:
         update.type = p4runtime_pb2.Update.DELETE
         new_req.updates.add().CopyFrom(update)
     rep = self.stub.Write(new_req)
コード例 #7
0
 def WriteTableEntry(self, table_entry, dry_run=False):
     request = p4runtime_pb2.WriteRequest()
     request.device_id = self.device_id
     request.election_id.low = 1
     update = request.updates.add()
     update.type = p4runtime_pb2.Update.INSERT
     update.entity.table_entry.CopyFrom(table_entry)
     if self.proto_dump_file is not None:
         with open(self.proto_dump_file, 'a') as f:
             f.write("%s" % update.entity)
     if dry_run:
         print "P4 Runtime Write:", request
     else:
         self.client_stub.Write(request)
コード例 #8
0
 def DeleteAllTableEntries(self, table_id, dry_run=False):
     print "DeleteTableEntry() is called, device_id=", self.device_id
     updates = []
     for req in reversed(self._reqs):
         for update in reversed(req.updates):
             if update.type == p4runtime_pb2.Update.INSERT:
                 if update.entity.table_entry.table_id == table_id:
                     updates.append(update)
     new_req = p4runtime_pb2.WriteRequest()
     new_req.device_id = self.device_id
     for update in updates:
         update.type = p4runtime_pb2.Update.DELETE
         new_req.updates.add().CopyFrom(update)
     if dry_run:
         print "P4 Runtime Write:", new_req
     else:
         self.client_stub.Write(new_req)
コード例 #9
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def send_request_add_entry_to_group(self, t_name, mk, grp_id):
     req = p4runtime_pb2.WriteRequest()
     req.device_id = self.device_id
     self.push_update_add_entry_to_group(req, t_name, mk, grp_id)
     return req, self.write_request(req, store=(mk is not None))
コード例 #10
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def send_request_add_entry_to_action(self, t_name, mk, a_name, params):
     req = p4runtime_pb2.WriteRequest()
     req.device_id = self.device_id
     self.push_update_add_entry_to_action(req, t_name, mk, a_name, params)
     return req, self.write_request(req, store=(mk is not None))
コード例 #11
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def send_request_set_group_membership(self, ap_name, grp_id, mbr_ids=[]):
     req = p4runtime_pb2.WriteRequest()
     req.device_id = self.device_id
     self.push_update_set_group_membership(req, ap_name, grp_id, mbr_ids)
     return req, self.write_request(req, store=False)
コード例 #12
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def send_request_add_group(self, ap_name, grp_id, grp_size=32, mbr_ids=[]):
     req = p4runtime_pb2.WriteRequest()
     req.device_id = self.device_id
     self.push_update_add_group(req, ap_name, grp_id, grp_size, mbr_ids)
     return req, self.write_request(req)
コード例 #13
0
ファイル: base_test.py プロジェクト: zubinshah/PI
 def send_request_modify_member(self, ap_name, mbr_id, a_name, params):
     req = p4runtime_pb2.WriteRequest()
     req.device_id = self.device_id
     self.push_update_modify_member(req, ap_name, mbr_id, a_name, params)
     return req, self.write_request(req, store=False)