check_remote_yp

PURPOSE ^

LUKE - Check if remote links are available and functionning

SYNOPSIS ^

function flag = check_remote_yp(dkepath,remlist,debugmode,link_mode,log_mode)

DESCRIPTION ^

 LUKE - Check if remote links are available and functionning

    Check if remote links are available and functionning

    Input:

       - dkepath: path structure with remote profiles
           (default: if no input structure or empty, dkepath is automatically loaded from LUKE_PATH.mat
       - remlist : list of profiles indices to be tested
           o NaN : (default) test all profiles
           o []  : user-prompt profile list
           o [1,3...] : tests specified profiles
       - debugmode: display details   
       - link_mode : connection mode prescription
           o -1  : local profiles only
           o NaN : (default) use value from remote.link_mode
           o []  : give priority to (0) ssh key pair, (1) ssh bridge, (2) url/ftp bridge
           o 0   : ssh key pair enforced
           o 1   : ssh bridge enforced
           o 2   : url/ftp bridge enforced
       - log_mode : output results in a log file
           o 0 : no 
           o 1 : yes (default)

    Output:

       - flag    : 1 -> remote link working, 0 -> remote link not working [1,nrem]

   Warning: If the process is blocked (no automatic ssh login for example or remote computer behind a firewall or 
   remote cluster (or computer) not running, type CTRL-C to escape.

 by Yves Peysson (CEA/DSM/IRFM, yves.peysson@cea.fr) and Joan Decker (CEA/DSM/IRFM, joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function flag = check_remote_yp(dkepath,remlist,debugmode,link_mode,log_mode)
0002 % LUKE - Check if remote links are available and functionning
0003 %
0004 %    Check if remote links are available and functionning
0005 %
0006 %    Input:
0007 %
0008 %       - dkepath: path structure with remote profiles
0009 %           (default: if no input structure or empty, dkepath is automatically loaded from LUKE_PATH.mat
0010 %       - remlist : list of profiles indices to be tested
0011 %           o NaN : (default) test all profiles
0012 %           o []  : user-prompt profile list
0013 %           o [1,3...] : tests specified profiles
0014 %       - debugmode: display details
0015 %       - link_mode : connection mode prescription
0016 %           o -1  : local profiles only
0017 %           o NaN : (default) use value from remote.link_mode
0018 %           o []  : give priority to (0) ssh key pair, (1) ssh bridge, (2) url/ftp bridge
0019 %           o 0   : ssh key pair enforced
0020 %           o 1   : ssh bridge enforced
0021 %           o 2   : url/ftp bridge enforced
0022 %       - log_mode : output results in a log file
0023 %           o 0 : no
0024 %           o 1 : yes (default)
0025 %
0026 %    Output:
0027 %
0028 %       - flag    : 1 -> remote link working, 0 -> remote link not working [1,nrem]
0029 %
0030 %   Warning: If the process is blocked (no automatic ssh login for example or remote computer behind a firewall or
0031 %   remote cluster (or computer) not running, type CTRL-C to escape.
0032 %
0033 % by Yves Peysson (CEA/DSM/IRFM, yves.peysson@cea.fr) and Joan Decker (CEA/DSM/IRFM, joan.decker@cea.fr)
0034 %
0035 if nargin < 5,
0036     log_mode = 1;
0037 end
0038 if nargin < 4,
0039     link_mode = NaN;
0040 end
0041 if nargin < 3,
0042     debugmode = 0;
0043 end
0044 if nargin < 2,
0045     remlist = NaN;
0046 end
0047 if nargin < 1,
0048     dkepath = '';
0049 end
0050 %
0051 if ~isempty(link_mode) && ~isnan(link_mode),
0052     link_modestr = ['_link_mode_',num2str(link_mode)];
0053 else
0054     link_modestr = '';
0055 end
0056 %
0057 filename = '';
0058 %
0059 if log_mode,
0060     %
0061     filename = ['res_check_remote_yp_',datestr(now,29),link_modestr,'.log'];
0062     %
0063     if input_dke_yp(['Do you want to save the results in the log file ',filename,' ? (y/n)'],'n',{'y','n'}) == 'y',
0064         %
0065         if exist(filename,'file'),
0066             delete(filename);
0067         end
0068         %
0069         diary(filename);
0070         %
0071     end
0072     %
0073 end
0074 %
0075 if ~isempty(remlist) && ~isnan(sum(remlist)) && ~isempty(dkepath),%for the remlist only
0076     %
0077     dkepath.remote = dkepath.remote(remlist);
0078     dkepath.profilestr = dkepath.profilestr(remlist);
0079     dkepath.remprofiles = dkepath.remprofiles([1,remlist+1]);
0080     dkepath.distprofiles = dkepath.distprofiles([1:3,remlist+3]);
0081     %
0082     remlist = 1:length(remlist);
0083     %
0084     dkepath = setpath_luke_jd(dkepath,link_mode);
0085     %
0086 else
0087     dkepath = setpath_luke_jd(dkepath,link_mode,0);
0088 end
0089 %
0090 % test connection and identify local profiles
0091 %
0092 disp(' ')
0093 info_dke_yp(2,'Testing remote connection for dkepath.remote profiles using LUKE code.');
0094 %
0095 nrem = length(dkepath.remote);
0096 %
0097 flag = zeros(1,nrem);
0098 %
0099 if nargin < 4 || isempty(remlist),
0100     remlist = input_dke_yp('Please identify profiles to be tested.',1:nrem,[1;nrem]);
0101 elseif isnan(remlist),
0102     remlist = 1:nrem;
0103 end
0104 %
0105 for irem = remlist,
0106     %
0107     disp(' ')
0108     disp('-----------------------------------------------------')
0109     disp(' ')
0110     info_dke_yp(2,['Testing profile : ',dkepath.profilestr{irem}]);
0111     %
0112     job = matstandardjob_jd('runmat');% standard matlab job
0113     job.debugmode = debugmode; % to display info and debug
0114     job.remtimout = 5;% in minutes
0115     %
0116     job.funcopy = 0; % (0) to use function LUKEversion_jd on the remote host within matlab path - TEST REMOTE PATH
0117     %
0118     flag_remote_path = 0;
0119     disp(' - LUKEversion_jd.m on the remote machine is used');
0120     [err,~,remotelukever,~,remotematrel] = matremote_jd('LUKEversion_jd',{},dkepath.remote(irem),job);
0121     %
0122     if ~isempty(err),
0123         disp('----------------------------')
0124         disperr_jd(err);
0125         disp('----------------------------')
0126         %
0127         disp(' - LUKEversion_jd.m send from the local machine to the remote one is used.');
0128         job.funcopy = 1; % (0) to use function LUKEversion_jd on the remote host within matlab path - TEST REMOTE PATH
0129         [err,~,remotelukever,~,remotematrel] = matremote_jd('LUKEversion_jd',{},dkepath.remote(irem),job);
0130         flag_remote_path = 1;
0131     end
0132     %
0133     disp(' ')
0134     if isempty(err),        
0135         info_dke_yp(4,['Version ',remotelukever,' with Matlab ',remotematrel,' working.'])
0136         flag(irem) = 1;
0137         if flag_remote_path, flag(irem) = -1; end 
0138     else
0139         disperr_jd(err);
0140     end
0141     %
0142 end
0143 %
0144 disp(' ')
0145 %
0146 if ~isempty(filename),
0147     diary('off');
0148 end
0149 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.