4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain 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,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 from cmframework.apis import cmvalidator
19 from cmdatahandlers.api import validation
22 class SectionValidation(cmvalidator.CMValidator):
24 Required = ['cloud.name', 'cloud.version', 'cloud.time', 'cloud.users', 'cloud.networking',
25 'cloud.storage', 'cloud.hosts', 'cloud.network_profiles',
26 'cloud.storage_profiles', 'cloud.host_os']
28 filterstr = r'^cloud\.'
30 def get_subscription_info(self):
31 logging.debug('get_subscription info called')
34 def validate_set(self, dict_key_value):
35 logging.debug('validate_set called with %s', str(dict_key_value))
37 key_list = dict_key_value.keys()
38 self.validate_sections(key_list)
40 def validate_delete(self, prop):
41 # Domain specific validators should take care of validating deletion
44 def validate_sections(self, sections):
47 client = self.get_plugin_client()
49 for name in self.Required:
50 if name not in sections:
52 properties = client.get_properties(self.filterstr)
53 keys = properties.keys()
56 missing += ', ' + name if missing else name
58 raise validation.ValidationError('Mandatory sections missing from configuration: %s'