def write_property(key, value): conf_file = find_properties_file() properties = Properties() try: properties.load(open(conf_file)) except Exception, e: print_error_msg('Could not read tbds config file "%s": %s' % (conf_file, e)) return -1
def write_property(key, value): conf_file = find_properties_file() properties = Properties() try: properties.load(open(conf_file)) except Exception, e: print_error_msg('Could not read ambari config file "%s": %s' % (conf_file, e)) return -1
def write_property(key, value): conf_file = find_properties_file() properties = Properties() try: with open(conf_file, "r") as hfR: properties.load(hfR) except Exception, e: print_error_msg('Could not read ambari config file "%s": %s' % (conf_file, e)) return -1
def get_ambari_properties(): conf_file = find_properties_file() properties = None try: properties = Properties() properties.load(open(conf_file)) except (Exception), e: print 'Could not read "%s": %s' % (conf_file, e) return -1
def get_ambari_properties(): conf_file = find_properties_file() properties = None try: properties = Properties() properties.load(open(conf_file)) except (Exception), e: print 'Could not read "%s": %s' % (conf_file, e) return -1
def update_ambari_properties(): prev_conf_file = search_file(configDefaults.AMBARI_PROPERTIES_BACKUP_FILE, get_conf_dir()) conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir()) # Previous config file does not exist if (not prev_conf_file) or (prev_conf_file is None): print_warning_msg("Can not find tbds.properties.backup file from previous version, skipping import of settings") return 0 try: old_properties = Properties() old_properties.load(open(prev_conf_file)) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1
def update_ambari_properties(): prev_conf_file = search_file(configDefaults.AMBARI_PROPERTIES_BACKUP_FILE, get_conf_dir()) conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir()) # Previous config file does not exist if (not prev_conf_file) or (prev_conf_file is None): print_warning_msg("Can not find ambari.properties.backup file from previous version, skipping import of settings") return 0 try: old_properties = Properties() old_properties.load(open(prev_conf_file)) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1
def update_ambari_properties(): prev_conf_file = search_file(configDefaults.AMBARI_PROPERTIES_BACKUP_FILE, get_conf_dir()) conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir()) # Previous config file does not exist if (not prev_conf_file) or (prev_conf_file is None): print_warning_msg("Can not find %s file from previous version, skipping import of settings" % configDefaults.AMBARI_PROPERTIES_BACKUP_FILE) return 0 # ambari.properties file does not exists if conf_file is None: print_error_msg("Can't find %s file" % AMBARI_PROPERTIES_FILE) return -1 with open(prev_conf_file) as hfOld: try: old_properties = Properties() old_properties.load(hfOld) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1
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)
if conf_file is None: print_error_msg("Can't find %s file" % AMBARI_PROPERTIES_FILE) return -1 with open(prev_conf_file) as hfOld: try: old_properties = Properties() old_properties.load(hfOld) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1 try: new_properties = Properties() 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")
# ambari.properties file does not exists if conf_file is None: print_error_msg("Can't find %s file" % AMBARI_PROPERTIES_FILE) return -1 try: old_properties = Properties() old_properties.load(open(prev_conf_file)) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1 try: 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 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():
if conf_file is None: print_error_msg("Can't find %s file" % AMBARI_PROPERTIES_FILE) return -1 with open(prev_conf_file) as hfOld: try: old_properties = Properties() old_properties.load(hfOld) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1 try: new_properties = Properties() 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")
# Previous config file does not exist if (not prev_conf_file) or (prev_conf_file is None): print_warning_msg("Can not find tbds.properties.backup file from previous version, skipping import of settings") return 0 try: old_properties = Properties() old_properties.load(open(prev_conf_file)) except Exception, e: print 'Could not read "%s": %s' % (prev_conf_file, e) return -1 try: 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")