2 # Copyright 2016 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
21 class ConfigPluginBase(object):
22 """Base class for config plugins. Need to implement public interfaces."""
23 __metaclass__ = abc.ABCMeta
25 class InitializationFailure(Exception):
28 def __init__(self, config):
30 raise ConfigPluginBase.InitializationFailure(
31 'Initialization parameters need to be assigned.')
37 """Returns updated default configuration file."""
40 def get_openstack_spec(self):
41 """Returns OpenStack specs for host."""
44 def get_run_spec(self, openstack_spec):
45 """Returns RunSpec for given platform."""
48 def validate_config(self, cfg):
49 """Validate config file."""
52 def prepare_results_config(self, cfg):
53 """This function is called before running configuration is copied.
54 Example usage is to remove sensitive information like switch credentials.
58 def get_version(self):
59 """Returns platform version."""
62 class ConfigPlugin(ConfigPluginBase):
63 """No-op config plugin class. Does not change anything."""
65 def __init__(self, config):
66 ConfigPluginBase.__init__(self, config)
69 """Public interface for updating config file. Just returns given config."""
72 def get_openstack_spec(self):
73 """Returns OpenStack specs for host."""
74 return specs.OpenStackSpec()
76 def get_run_spec(self, openstack_spec):
77 """Returns RunSpec for given platform."""
78 return specs.RunSpec(self.config.no_vswitch_access, openstack_spec)
80 def validate_config(self, config):
83 def prepare_results_config(self, cfg):
86 def get_version(self):