2 # Copyright 2017 Cisco Systems, Inc. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
17 from chain_clients import EXTStageClient
18 from chain_clients import PVPStageClient
19 from chain_clients import PVVPStageClient
20 from chain_managers import EXTStatsManager
21 from chain_managers import PVPStatsManager
22 from chain_managers import PVVPStatsManager
23 import chain_workers as workers
24 from config_plugin import ConfigPlugin
25 from specs import ChainType
29 class BasicFactory(object):
31 chain_classes = [ChainType.EXT, ChainType.PVP, ChainType.PVVP]
33 chain_stats_classes = {
34 ChainType.EXT: EXTStatsManager,
35 ChainType.PVP: PVPStatsManager,
36 ChainType.PVVP: PVVPStatsManager,
39 stage_clients_classes = {
40 ChainType.EXT: EXTStageClient,
41 ChainType.PVP: PVPStageClient,
42 ChainType.PVVP: PVVPStageClient,
45 def get_stats_class(self, service_chain):
46 CLASS = self.chain_stats_classes.get(service_chain, None)
48 raise Exception("Service chain '{}' not supported.".format(service_chain))
52 def get_stage_class(self, service_chain):
53 CLASS = self.stage_clients_classes.get(service_chain, None)
55 raise Exception("VM Client for chain '{}' not supported.".format(service_chain))
59 def get_chain_worker(self, encaps, service_chain):
60 return workers.BasicWorker
62 def get_tor_class(self, tor_type, no_tor_access):
63 if no_tor_access or not tor_type:
64 # if no TOR access is required, use basic no-op client
65 tor_type = 'BasicTORClient'
67 return getattr(tor_client, tor_type)
69 def get_config_plugin_class(self):