@@ -2475,9 +2475,12 @@ def format_host_time(t):
24752475 elif guest_os == 'omnios' :
24762476 # OmniOS: chrony is the preferred and often only functional tool.
24772477 sync_cmd = "chronyc -a makestep || (svcadm enable chrony && sleep 2 && chronyc -a makestep)"
2478- elif guest_os in [ 'solaris' , 'openindiana' ] :
2479- # General Solaris-like systems
2478+ elif guest_os == 'solaris' :
2479+ # Oracle Solaris: Typically has ntpdate in /usr/sbin
24802480 sync_cmd = "ntpdate -u {0} || sntp -sS {0}" .format (ntp_servers )
2481+ elif guest_os == 'openindiana' :
2482+ # OpenIndiana: Use ntpdate for time sync.
2483+ sync_cmd = "/usr/sbin/ntpdate -u {0} || /usr/bin/ntpdate -u {0} || ntpdate -u {0}" .format (ntp_servers )
24812484 elif guest_os == 'haiku' :
24822485 # Haiku uses Time --update to sync with configured NTP servers
24832486 sync_cmd = "Time --update || ntpdate -u {0}" .format (ntp_servers )
@@ -2901,21 +2904,45 @@ def sync_scp(ssh_cmd, vhost, vguest, sshport, hostid_file, ssh_user):
29012904 sources = [vhost ]
29022905
29032906 # SCP command to push files
2904- # Added -O option for legacy protocol support
2905- cmd = [
2906- "scp" , "-r" , "-q" , "-O" ,
2907- "-P" , str (sshport ),
2908- ]
2909- if hostid_file :
2910- cmd .extend (["-i" , hostid_file ])
2907+ # We use a retry loop because initial connections might be flaky on some OSs.
2908+ synced = False
2909+ for i in range (5 ):
2910+ # Added -O option for legacy protocol support as a fallback if needed
2911+ # but try modern SFTP-based protocol first on some attempts.
2912+ mode_desc = "Standard (SFTP)"
2913+ cmd = [
2914+ "scp" , "-r" , "-q" ,
2915+ "-P" , str (sshport ),
2916+ ]
2917+ if i % 2 == 1 :
2918+ cmd .append ("-O" )
2919+ mode_desc = "Legacy (SCP)"
2920+
2921+ if hostid_file :
2922+ cmd .extend (["-i" , hostid_file ])
2923+
2924+ cmd .extend ([
2925+ "-o" , "StrictHostKeyChecking=no" ,
2926+ "-o" , "UserKnownHostsFile={}" .format (SSH_KNOWN_HOSTS_NULL ),
2927+ "-o" , "LogLevel=ERROR" ,
2928+ "-o" , "ConnectTimeout=10" ,
2929+ ] + sources + ["{}@127.0.0.1:" .format (ssh_user ) + vguest + "/" ])
29112930
2912- cmd .extend ([
2913- "-o" , "StrictHostKeyChecking=no" ,
2914- "-o" , "UserKnownHostsFile={}" .format (SSH_KNOWN_HOSTS_NULL ),
2915- "-o" , "LogLevel=ERROR" ,
2916- ] + sources + ["{}@127.0.0.1:" .format (ssh_user ) + vguest + "/" ])
2917-
2918- if subprocess .call (cmd ) != 0 :
2931+ debuglog (True , "SCP Attempt {} ({}): Executing sync..." .format (i + 1 , mode_desc ))
2932+ try :
2933+ ret = subprocess .call (cmd )
2934+ if ret == 0 :
2935+ debuglog (True , "SCP Attempt {} successful." .format (i + 1 ))
2936+ synced = True
2937+ break
2938+ else :
2939+ debuglog (True , "SCP Attempt {} failed with return code {}." .format (i + 1 , ret ))
2940+ except Exception as e :
2941+ debuglog (True , "SCP Attempt {} encounterd exception: {}" .format (i + 1 , e ))
2942+
2943+ time .sleep (2 )
2944+
2945+ if not synced :
29192946 log ("Warning: SCP sync failed." )
29202947
29212948def version_tokens (text ):
0 commit comments