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 ###############################################################################
18 exec_cmd = common.exec_cmd
21 check_file_exists = common.check_file_exists
23 backup = common.backup
26 class ConfigureSettings(object):
28 def __init__(self, yaml_config_dir, env_id, dea):
29 self.yaml_config_dir = yaml_config_dir
33 def download_settings(self):
34 log('Download settings for environment %s' % self.env_id)
35 exec_cmd('fuel settings --env %s --download --dir %s'
36 % (self.env_id, self.yaml_config_dir))
38 def upload_settings(self):
39 log('Upload settings for environment %s' % self.env_id)
40 exec_cmd('fuel settings --env %s --upload --dir %s'
41 % (self.env_id, self.yaml_config_dir))
43 def config_settings(self):
44 log('Configure settings')
45 self.download_settings()
46 self.modify_settings()
47 self.upload_settings()
49 def modify_settings(self):
50 log('Modify settings for environment %s' % self.env_id)
51 settings_yaml = ('%s/settings_%s.yaml'
52 % (self.yaml_config_dir, self.env_id))
53 check_file_exists(settings_yaml)
56 settings = self.dea.get_property('settings')
58 with io.open(settings_yaml, 'w') as stream:
59 yaml.dump(settings, stream, default_flow_style=False)