lib/core/core_import_export.rb
# Function to export a Lorj Account in an encrypted Hash.
#
# The encrypted Hash will be encrypted by a new key returned.
# The content of the hash will built thanks to a Hash mapping
# or the list of data list in the config 'account' layer.
#
# * *Args* :
#   - +map+          : Hash map of fields to extract. if map is nil, the
#     export function will loop in the list of keys in the 'account' layer.
#     if map is provided, following data are expected:
#     - <key> : Data key to extract from config.
#       - :keys: Array. SubHash tree of keys to create. If :keys is missing,
#         the Data key will define the SubHash tree to use.
#
#         Ex:
#             map = {
#               # like :keys => [credentials, auth_uri]
#               'credentials#auth_uri' => {},
#               # extract from maestro but export under :server
#               'maestro#image_name' => {:keys => [:server, image_name]}
#               }
#   - +with_name+    : True to extract :name and :provider as well.
#     True by default.
#   - +account_only+ : True data extracted must come exclusively from the
#     config 'account' layer.
#   - +processes_options+ : Hash. Export options for processes
#     - :exclude: Array. name of process to exclude.
#
# * *returns* :
#   - key: String. Key used to encrypt.
#   - env_hash: String. Base64 encrypted Hash.
#   OR
#   - nil if issues.
Function to export a Lorj Account in an encrypted Hash.
The encrypted Hash will be encrypted by a new key returned.
The content of the hash will built thanks to a Hash mapping
or the list of data list in the config 'account' layer.

*Args* :
+map+          : Hash map of fields to extract. if map is nil, the
export function will loop in the list of keys in the 'account' layer.
if map is provided, following data are expected:
 : Data key to extract from config.
:keys: Array. SubHash tree of keys to create. If :keys is missing,
the Data key will define the SubHash tree to use.



*returns* :
key: String. Key used to encrypt.
Function to export a Lorj Account in an encrypted Hash . The encrypted Hash will be encrypted by a new key returned . The content of the hash will built thanks to a Hash mapping or the list of data list in the config ' account ' layer . * Args * : + map + : Hash map of fields to extract . if map is nil the export function will loop in the list of keys in the ' account ' layer . if map is provided following data are expected : : Data key to extract from config . : keys : Array . SubHash tree of keys to create . If : keys is missing the Data key will define the SubHash tree to use . * returns * : key : String . Key used to encrypt .
def account_export(map = nil, with_name = true, account_only = true,
                       processes_options = {})
      map = _account_map if map.nil?
      map.merge!('account#name' => {}, 'account#provider' => {}) if with_name
      entr = _get_encrypt_key
      rhash = {}
      map.each do |k, v|
        data_def = Lorj.data.auto_section_data(k)
        if account_only
          data = config.get(k, nil, :name => 'account')
        else
          data = config[k]
        end
        rhash_kpath = _export_keys_as_keypath(k, v)
        if !data_def.nil? && data_def[:encrypted].is_a?(TrueClass)
          data = Lorj::SSLCrypt.get_encrypted_value(data, entr, data_def[:desc])
        end
        rhash.rh_set(data, *(rhash_kpath.tree))
      end
      entr = Lorj::SSLCrypt.new_encrypt_key
      export_data = { :enc_data => Lorj::SSLCrypt.encrypt_value(rhash.to_yaml,
                                                                entr) }
      export_data[:processes] = _export_processes(processes_options)
      [entr, export_data.to_yaml]
    end
def account_export ( map = nil , with_name = true , account_only = true , processes_options = { } ) map = _account_map if map . nil? map . merge! ( 'account#name' => { } , 'account#provider' => { } ) if with_name entr = _get_encrypt_key rhash = { } map . each do | k , v | data_def = Lorj . data . auto_section_data ( k ) if account_only data = config . get ( k , nil , :name => 'account' ) else data = config [ k ] end rhash_kpath = _export_keys_as_keypath ( k , v ) if ! data_def . nil? && data_def [ :encrypted ] . is_a? ( TrueClass ) data = Lorj :: SSLCrypt . get_encrypted_value ( data , entr , data_def [ :desc ] ) end rhash . rh_set ( data , * ( rhash_kpath . tree ) ) end entr = Lorj :: SSLCrypt . new_encrypt_key export_data = { :enc_data => Lorj :: SSLCrypt . encrypt_value ( rhash . to_yaml , entr ) } export_data [ :processes ] = _export_processes ( processes_options ) [ entr , export_data . to_yaml ] end
Function to export a Lorj Account in an encrypted Hash.
Function to export a Lorj Account in an encrypted Hash .
map
<not_specific>
with_name
<not_specific>
account_only
<not_specific>
processes_options
<not_specific>