def _configure_as_query_router(self): LOG.info(_("Configuring instance as a cluster query router.")) self.is_query_router = True # Write the 'mongos' upstart script. # FIXME(pmalik): The control script should really be written in the # elements. # The guestagent will choose the right daemon ('mongod' or 'mongos') # based on the 'cluster_config' values. upstart_contents = system.MONGOS_UPSTART_CONTENTS.format(config_file_placeholder=CONFIG_FILE) operating_system.write_file(system.MONGOS_UPSTART, upstart_contents, as_root=True) # FIXME(pmalik): We should really have a separate configuration # template for the 'mongos' process. # Remove all storage configurations from the template. # They apply only to 'mongod' processes. # Already applied overrides will be integrated into the base file and # their current groups removed. config = guestagent_utils.expand_dict(self.configuration_manager.parse_configuration()) if "storage" in config: LOG.debug("Removing 'storage' directives from the configuration " "template.") del config["storage"] self.configuration_manager.save_configuration(guestagent_utils.flatten_dict(config)) # Apply 'mongos' configuration. self._configure_network(MONGODB_PORT) self.configuration_manager.apply_system_override({"sharding.configDB": ""}, CNF_CLUSTER)
def _configure_as_query_router(self): LOG.info(_("Configuring instance as a cluster query router.")) self.is_query_router = True # Write the 'mongos' upstart script. # FIXME(pmalik): The control script should really be written in the # elements. # The guestagent will choose the right daemon ('mongod' or 'mongos') # based on the 'cluster_config' values. upstart_contents = (system.MONGOS_UPSTART_CONTENTS.format( config_file_placeholder=CONFIG_FILE)) operating_system.write_file(system.MONGOS_UPSTART, upstart_contents, as_root=True) # FIXME(pmalik): We should really have a separate configuration # template for the 'mongos' process. # Remove all storage configurations from the template. # They apply only to 'mongod' processes. # Already applied overrides will be integrated into the base file and # their current groups removed. config = guestagent_utils.expand_dict( self.configuration_manager.parse_configuration()) if 'storage' in config: LOG.debug("Removing 'storage' directives from the configuration " "template.") del config['storage'] self.configuration_manager.save_configuration( guestagent_utils.flatten_dict(config)) # Apply 'mongos' configuration. self._configure_network(MONGODB_PORT) self.configuration_manager.apply_system_override( {'sharding.configDB': ''}, CNF_CLUSTER)
def _configure_as_query_router(self): LOG.info(_("Configuring instance as a cluster query router.")) self.is_query_router = True # FIXME(pmalik): We should really have a separate configuration # template for the 'mongos' process. # Remove all storage configurations from the template. # They apply only to 'mongod' processes. # Already applied overrides will be integrated into the base file and # their current groups removed. config = guestagent_utils.expand_dict( self.configuration_manager.parse_configuration()) if 'storage' in config: LOG.debug("Removing 'storage' directives from the configuration " "template.") del config['storage'] self.configuration_manager.save_configuration( guestagent_utils.flatten_dict(config)) # Apply 'mongos' configuration. self._configure_network(MONGODB_PORT) self.configuration_manager.apply_system_override( {'sharding.configDB': ''}, CNF_CLUSTER)
def _assert_flatten_expand_dict(self, nested_dict, flattened_dict): self.assertEqual(flattened_dict, guestagent_utils.flatten_dict(nested_dict)) self.assertEqual(nested_dict, guestagent_utils.expand_dict(flattened_dict))
def _assert_flatten_expand_dict(self, nested_dict, flattened_dict): self.assertEqual( flattened_dict, guestagent_utils.flatten_dict(nested_dict)) self.assertEqual( nested_dict, guestagent_utils.expand_dict(flattened_dict))