1 ###############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # szilard.cserey@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ###############################################################################
22 class ConfigureSettings(object):
24 def __init__(self, yaml_config_dir, env_id, dea):
25 self.yaml_config_dir = yaml_config_dir
29 def download_settings(self):
30 log('Download settings for environment %s' % self.env_id)
31 exec_cmd('fuel settings --env %s --download --dir %s'
32 % (self.env_id, self.yaml_config_dir))
34 def upload_settings(self):
35 log('Upload settings for environment %s' % self.env_id)
36 exec_cmd('fuel settings --env %s --upload --dir %s'
37 % (self.env_id, self.yaml_config_dir))
39 def config_settings(self):
40 log('Configure settings')
41 self.download_settings()
42 self.modify_settings()
43 self.upload_settings()
45 def modify_settings(self):
46 log('Modify settings for environment %s' % self.env_id)
47 settings_yaml = ('%s/settings_%s.yaml'
48 % (self.yaml_config_dir, self.env_id))
49 check_file_exists(settings_yaml)
52 settings = self.dea.get_property('settings')
54 with io.open(settings_yaml, 'w') as stream:
55 yaml.dump(settings, stream, default_flow_style=False)