def update_properties(propertyMap): conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir()) backup_file_in_temp(conf_file) if propertyMap is not None and conf_file is not None: properties = Properties() try: with open(conf_file, 'r') as file: properties.load(file) except (Exception), e: print_error_msg('Could not read "%s": %s' % (conf_file, e)) return -1 for key in propertyMap.keys(): properties.removeOldProp(key) properties.process_pair(key, str(propertyMap[key])) for key in properties.keys(): if not propertyMap.has_key(key): properties.removeOldProp(key) with open(conf_file, 'w') as file: properties.store_ordered(file)
def update_properties(propertyMap): conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir()) backup_file_in_temp(conf_file) if propertyMap is not None and conf_file is not None: properties = Properties() try: with open(conf_file, 'r') as file: properties.load(file) except (Exception), e: print_error_msg('Could not read "%s": %s' % (conf_file, e)) return -1 for key in propertyMap.keys(): properties.removeOldProp(key) properties.process_pair(key, str(propertyMap[key])) for key in properties.keys(): if not propertyMap.has_key(key): properties.removeOldProp(key) with open(conf_file, 'w') as file: properties.store_ordered(file)
with open(conf_file) as hfNew: new_properties.load(hfNew) for prop_key, prop_value in old_properties.getPropertyDict().items(): if "agent.fqdn.service.url" == prop_key: # BUG-7179 what is agent.fqdn property in ambari.props? new_properties.process_pair(GET_FQDN_SERVICE_URL, prop_value) elif "server.os_type" == prop_key: new_properties.process_pair(OS_TYPE_PROPERTY, OS_FAMILY + OS_VERSION) else: new_properties.process_pair(prop_key, prop_value) # Adding custom user name property if it is absent # In previous versions without custom user support server was started as # "root" anyway so it's a reasonable default if NR_USER_PROPERTY not in new_properties.keys(): new_properties.process_pair(NR_USER_PROPERTY, "root") if OS_FAMILY_PROPERTY not in new_properties.keys(): new_properties.process_pair(OS_FAMILY_PROPERTY, OS_FAMILY + OS_VERSION) with open(conf_file, 'w') as hfW: new_properties.store(hfW) except Exception, e: print 'Could not write "%s": %s' % (conf_file, e) return -1 timestamp = datetime.datetime.now() fmt = '%Y%m%d%H%M%S' new_conf_file = prev_conf_file + '.' + timestamp.strftime(fmt)
new_properties.load(open(conf_file)) for prop_key, prop_value in old_properties.getPropertyDict().items(): if ("agent.fqdn.service.url" == prop_key): #BUG-7179 what is agent.fqdn property in ambari.props? new_properties.process_pair(GET_FQDN_SERVICE_URL, prop_value) elif ("server.os_type" == prop_key): new_properties.process_pair(OS_TYPE_PROPERTY, OS_FAMILY + OS_VERSION) else: new_properties.process_pair(prop_key, prop_value) # Adding custom user name property if it is absent # In previous versions without custom user support server was started as # "root" anyway so it's a reasonable default if not NR_USER_PROPERTY in new_properties.keys(): new_properties.process_pair(NR_USER_PROPERTY, "root") isJDK16Installed = new_properties.get_property( JAVA_HOME_PROPERTY) == DEFAULT_JDK16_LOCATION if not JDK_NAME_PROPERTY in new_properties.keys() and isJDK16Installed: new_properties.process_pair(JDK_NAME_PROPERTY, JDK_NAMES[1]) if not JCE_NAME_PROPERTY in new_properties.keys() and isJDK16Installed: new_properties.process_pair(JCE_NAME_PROPERTY, JCE_POLICY_FILENAMES[1]) if not OS_FAMILY_PROPERTY in new_properties.keys(): new_properties.process_pair(OS_FAMILY_PROPERTY, OS_FAMILY + OS_VERSION)
with open(conf_file) as hfNew: new_properties.load(hfNew) for prop_key, prop_value in old_properties.getPropertyDict().items(): if "agent.fqdn.service.url" == prop_key: # BUG-7179 what is agent.fqdn property in ambari.props? new_properties.process_pair(GET_FQDN_SERVICE_URL, prop_value) elif "server.os_type" == prop_key: new_properties.process_pair(OS_TYPE_PROPERTY, OS_FAMILY + OS_VERSION) else: new_properties.process_pair(prop_key, prop_value) # Adding custom user name property if it is absent # In previous versions without custom user support server was started as # "root" anyway so it's a reasonable default if NR_USER_PROPERTY not in new_properties.keys(): new_properties.process_pair(NR_USER_PROPERTY, "root") if OS_FAMILY_PROPERTY not in new_properties.keys(): new_properties.process_pair(OS_FAMILY_PROPERTY, OS_FAMILY + OS_VERSION) with open(conf_file, 'w') as hfW: new_properties.store(hfW) except Exception, e: print 'Could not write "%s": %s' % (conf_file, e) return -1 timestamp = datetime.datetime.now() fmt = '%Y%m%d%H%M%S' new_conf_file = prev_conf_file + '.' + timestamp.strftime(fmt)
new_properties = Properties() new_properties.load(open(conf_file)) for prop_key, prop_value in old_properties.getPropertyDict().items(): if ("agent.fqdn.service.url" == prop_key): #BUG-7179 what is agent.fqdn property in tbds.props? new_properties.process_pair(GET_FQDN_SERVICE_URL, prop_value) elif ("server.os_type" == prop_key): new_properties.process_pair(OS_TYPE_PROPERTY, OS_FAMILY + OS_VERSION) else: new_properties.process_pair(prop_key, prop_value) # Adding custom user name property if it is absent # In previous versions without custom user support server was started as # "root" anyway so it's a reasonable default if not NR_USER_PROPERTY in new_properties.keys(): new_properties.process_pair(NR_USER_PROPERTY, "root") isJDK16Installed = new_properties.get_property(JAVA_HOME_PROPERTY) == DEFAULT_JDK16_LOCATION if not JDK_NAME_PROPERTY in new_properties.keys() and isJDK16Installed: new_properties.process_pair(JDK_NAME_PROPERTY, JDK_NAMES[1]) if not JCE_NAME_PROPERTY in new_properties.keys() and isJDK16Installed: new_properties.process_pair(JCE_NAME_PROPERTY, JCE_POLICY_FILENAMES[1]) if not OS_FAMILY_PROPERTY in new_properties.keys(): new_properties.process_pair(OS_FAMILY_PROPERTY, OS_FAMILY + OS_VERSION) new_properties.store(open(conf_file, 'w')) except Exception, e: