class AddMonitordKeystoneCredentialsHook(PreUpgradeHookBase): """Monitoring service Keystone credentials: [1]. This patch updates the astute.yaml file adding 'monitord' user credentials. This user is required to create Fuel notifications when disk space on master node is getting low. We don't want to use the standard 'admin' user because when user changes password via UI it's not reflected in the astute.yaml file. [1] https://bugs.launchpad.net/fuel/+bug/1371757 """ # : This hook required only for docker and host system engines enable_for_engines = [HostSystemUpgrader] # : New credentials keystone_config = { 'keystone': { "monitord_user": "******", "monitord_password": utils.generate_uuid_string(), } } def check_if_required(self): return len( set(self.keystone_config['keystone']).difference( self.config.astute.get('keystone', {}))) def run(self): """Adds default credentials to config file """ self.update_astute_config(defaults=self.keystone_config)
class AddCredentialsHook(PreUpgradeHookBase): """Feature `access control on master node` was introduced in 5.1 release [1]. In this feature fuelmenu generates credenitals and saves them in /etc/astute.yaml file. Before upgrade for this featuer we need to add default credentials to the file. [1] https://blueprints.launchpad.net/fuel/+spec/access-control-master-node """ #: This hook required only for docker and host system engines enable_for_engines = [DockerUpgrader, HostSystemUpgrader] #: Default credentials credentials = { "astute": { "user": "******", "password": "******"}, "cobbler": { "user": "******", "password": "******"}, "mcollective": { "user": "******", "password": "******"}, "postgres": { "keystone_dbname": "keystone", "keystone_user": "******", "keystone_password": "******", "nailgun_dbname": "nailgun", "nailgun_user": "******", "nailgun_password": "******", "ostf_dbname": "ostf", "ostf_user": "******", "ostf_password": "******"}, "keystone": { "admin_token": utils.generate_uuid_string()}, "FUEL_ACCESS": { "user": "******", "password": "******"}} def check_if_required(self): """Checks if it's required to run upgrade :returns: True - if it is required to run this hook False - if it is not required to run this hook """ is_required = not all(key in self.config.astute for key in self.credentials.keys()) return is_required def run(self): """Adds default credentials to config file """ self.update_astute_config(defaults=self.credentials)
class AddKeystoneCredentialsHook(PreUpgradeHookBase): """Feature `Fuel master access control improvements` was introduced in 6.0 release [1]. In this feature fuelmenu generates keystone credenitals and saves them in /etc/astute.yaml file. Before upgrade for this featuer we need to add new keystone credentials to the file. [1] https://blueprints.launchpad.net/fuel/+spec/ access-control-master-node-improvments """ #: This hook required only for docker and host system engines enable_for_engines = [DockerUpgrader, HostSystemUpgrader] #: New credentials keystone_config = { 'keystone': { "nailgun_user": "******", "nailgun_password": utils.generate_uuid_string(), "ostf_user": "******", "ostf_password": utils.generate_uuid_string(), } } def check_if_required(self): """Checks if it's required to run upgrade :returns: True - if it is required to run this hook False - if it is not required to run this hook """ is_required = not all( key in self.config.astute.get('keystone', {}) for key in self.keystone_config['keystone'].keys()) return is_required def run(self): """Adds default credentials to config file """ self.update_astute_config(defaults=self.keystone_config)
def test_generate_uuid_string(self): random_string = utils.generate_uuid_string() self.assertEqual(len(random_string), 36) self.assertTrue(isinstance(random_string, str))
def test_generate_uuid_string(self): random_string = utils.generate_uuid_string() self.assertEqual(len(random_string), 36) self.assertTrue(isinstance(random_string, str))
class AddCredentialsHook(PreUpgradeHookBase): """Feature `access control on master node` was introduced in 5.1 release [1]. In this feature fuelmenu generates credenitals and saves them in /etc/astute.yaml file. Before upgrade for this featuer we need to add default credentials to the file. [1] https://blueprints.launchpad.net/fuel/+spec/access-control-master-node """ #: This hook required only for docker and host system engines enable_for_engines = [DockerUpgrader, HostSystemUpgrader] #: Default credentials credentials = { "astute": { "user": "******", "password": "******" }, "cobbler": { "user": "******", "password": "******" }, "mcollective": { "user": "******", "password": "******" }, "postgres": { "keystone_dbname": "keystone", "keystone_user": "******", "keystone_password": "******", "nailgun_dbname": "nailgun", "nailgun_user": "******", "nailgun_password": "******", "ostf_dbname": "ostf", "ostf_user": "******", "ostf_password": "******" }, "keystone": { "admin_token": utils.generate_uuid_string() }, "FUEL_ACCESS": { "user": "******", "password": "******" } } def check_if_required(self): """Checks if it's required to run upgrade :returns: True - if it is required to run this hook False - if it is not required to run this hook """ is_required = not all(key in self.config.astute for key in self.credentials.keys()) return is_required def run(self): """Adds default credentials to config file """ # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect # us from loosing some useful injection of another hook astute_config = deepcopy(self.credentials) astute_config.update( read_yaml_config(self.config.current_fuel_astute_path)) # NOTE(eli): Just save file for backup in case # if user wants to restore it manually utils.copy_file(self.config.current_fuel_astute_path, '{0}_{1}'.format(self.config.current_fuel_astute_path, self.config.from_version), overwrite=False) utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)