Merge "rhel73_install: Provide installer script for RHEL 7.3"
[vswitchperf.git] / tools / pkt_fwd / pkt_fwd.py
1 # Copyright 2016 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #   http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Abstract "packet forwarding" model.
15
16 This is an abstract class for packet forwarders.
17 """
18
19 class IPktFwd(object):
20     """Interface class that is implemented by specific classes
21     of packet forwarders
22     """
23
24     def __enter__(self):
25         """Start the packet forwarder.
26
27         Provide a context manager interface to the packet forwarders.
28         This simply calls the :func:`start` function.
29         """
30         return self.start()
31
32     def __exit__(self, type_, value, traceback):
33         """Stop the packet forwarder.
34
35         Provide a context manager interface to the packet forwarders.
36         This simply calls the :func:`stop` function.
37         """
38         self.stop()
39
40     def start(self):
41         """Start the packet forwarder.
42
43         :returns: None
44         """
45         raise NotImplementedError('Please call an implementation.')
46
47     def stop(self):
48         """Stop the packet forwarder.
49
50         :returns: None
51         """
52         raise NotImplementedError('Please call an implementation.')
53