Merge "NSB installation fails at Yardstick GUI Ubuntu 18"
[yardstick.git] / yardstick / network_services / traffic_profile / landslide_profile.py
1 # Copyright (c) 2018 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 """ Spirent Landslide traffic profile definitions """
15
16 from yardstick.network_services.traffic_profile import base
17
18
19 class LandslideProfile(base.TrafficProfile):
20     """
21     This traffic profile handles attributes of Landslide data stream
22     """
23
24     def __init__(self, tp_config):
25         super(LandslideProfile, self).__init__(tp_config)
26
27         # for backward compatibility support dict and list of dicts
28         if isinstance(tp_config["dmf_config"], dict):
29             self.dmf_config = [tp_config["dmf_config"]]
30         else:
31             self.dmf_config = tp_config["dmf_config"]
32
33     def execute(self, traffic_generator):
34         pass
35
36     def update_dmf(self, options):
37         if 'dmf' in options:
38             if isinstance(options['dmf'], dict):
39                 _dmfs = [options['dmf']]
40             else:
41                 _dmfs = options['dmf']
42
43             for index, _dmf in enumerate(_dmfs):
44                 try:
45                     self.dmf_config[index].update(_dmf)
46                 except IndexError:
47                     pass