Пример #1
0
def save_configuration():
	global _data_dir

	# Don't write if there's no destination
	if _data_dir is None:
		return False

	rm_old_files()

	snapshot = {}
	# Get a raw copy of all data
	snapshot[ 'copy'] = data.get_copy()
	# Get current system state
	snapshot[ 'cluster'] = sync.cluster_state.get_state()

	# Write this configuration
	file_name = _data_dir + '/' +helpers.now().strftime( DATA_DIR_STRFTIME)
	with open(file_name, 'w') as f:
		f.write( helpers.dump_json( snapshot))
	return True
Пример #2
0
def save_configuration():
    global _data_dir

    # Don't write if there's no destination
    if _data_dir is None:
        return False

    rm_old_files()

    snapshot = {}
    # Get a raw copy of all data
    snapshot['copy'] = data.get_copy()
    # Get current system state
    snapshot['cluster'] = sync.cluster_state.get_state()

    # Write this configuration
    file_name = _data_dir + '/' + helpers.now().strftime(DATA_DIR_STRFTIME)
    with open(file_name, 'w') as f:
        f.write(helpers.dump_json(snapshot))
    return True
Пример #3
0
	def get_state(self):
		""" Returns version information and cluster state. """
		response = data.get_copy( get_data=False)
		response[ 'cluster'] = sync.cluster_state.get_state()
		response[ 'Me'] = sync.cluster_state.me
		return self._response_json( response)
Пример #4
0
	def get_copy(self):
		""" Returns raw data copy. """
		return self._response_json( data.get_copy())
Пример #5
0
 def get_state(self):
     """ Returns version information and cluster state. """
     response = data.get_copy(get_data=False)
     response['cluster'] = sync.cluster_state.get_state()
     response['Me'] = sync.cluster_state.me
     return self._response_json(response)
Пример #6
0
 def get_copy(self):
     """ Returns raw data copy. """
     return self._response_json(data.get_copy())