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."""
39 def set_config(self, config):
40 """This method is called when the config has changed after this instance was initialized.
42 This is needed in teh frequent case where the main config is changed in a copy and to
43 prevent this instance to keep pointing to the old copy of the config
48 def get_openstack_spec(self):
49 """Returns OpenStack specs for host."""
52 def get_run_spec(self, openstack_spec):
53 """Returns RunSpec for given platform."""
56 def validate_config(self, cfg, openstack_spec):
57 """Validate config file."""
60 def prepare_results_config(self, cfg):
61 """This function is called before running configuration is copied.
62 Example usage is to remove sensitive information like switch credentials.
66 def get_version(self):
67 """Returns platform version."""
70 class ConfigPlugin(ConfigPluginBase):
71 """No-op config plugin class. Does not change anything."""
73 def __init__(self, config):
74 ConfigPluginBase.__init__(self, config)
77 """Public interface for updating config file. Just returns given config."""
80 def get_openstack_spec(self):
81 """Returns OpenStack specs for host."""
82 return specs.OpenStackSpec()
84 def get_run_spec(self, openstack_spec):
85 """Returns RunSpec for given platform."""
86 return specs.RunSpec(self.config.no_vswitch_access, openstack_spec)
88 def validate_config(self, config, openstack_spec):
91 def prepare_results_config(self, cfg):
94 def get_version(self):