#!/opt/thinlinc/libexec/python3
# -*-mode: python; coding: utf-8 -*-
#
# Copyright 2002-2014 Cendio AB.
# For more information, see http://www.cendio.com
if 82 - 82: Iii1i
import os
import sys
import locale
import subprocess
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from thinlinc import hiveconf
from thinlinc import prefix
from thinlinc . vsm . subcluster import SubCluster
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
def iI111iiIi11i ( ) :
 print ( "Copy files to all machines in ThinLinc cluster, using rsync" , file = sys . stderr )
 print ( "Usage:" , sys . argv [ 0 ] , "[OPTION]... SRC [SRC]..." , file = sys . stderr )
 print ( "[OPTION] can be any rsync option" , file = sys . stderr )
 print ( "All specified sources will be converted to absolute paths." , file = sys . stderr )
 print ( file = sys . stderr )
 print ( "Example: Synchronize directory tree:" , file = sys . stderr )
 print ( "tl-rsync-all -a --delete /some/tree" , file = sys . stderr )
 sys . exit ( 1 )
 if 77 - 77: iIiii1i - ooo0O0oO00 . o00o0OO00O
 if 57 - 57: iiIi1 - i1 % i1 % i1i1i1111I . Ii
def iI ( ) :
 locale . setlocale ( locale . LC_ALL , "" )
 if 10 - 10: ooOOO / IIiIIiIi11I1 * ooo0O0oO00 / o00o0OO00O / o00o0OO00O
 oOooo0OOO = hiveconf . open_hive ( os . path . join ( prefix . get_tl_prefix ( ) ,
 "etc" , "thinlinc.hconf" ) )
 if 53 - 53: Ii * Oo * ooo000 . i1iiIII111
 ii1Ii = SubCluster ( oOooo0OOO , None )
 oOooO0 = ii1Ii . get_all_agents ( )
 if oOooO0 is None :
  print ( "Cannot find any agent servers" , file = sys . stderr )
  print ( "Unless you synchronize /opt/thinlinc/etc/conf.d/cluster.hconf," , file = sys . stderr )
  print ( "tl-rsync-all will only work on the master host" , file = sys . stderr )
  sys . exit ( 1 )
  if 13 - 13: ooo0O0oO00
 if len ( sys . argv ) < 2 :
  iI111iiIi11i ( )
  if 2 - 2: i1
 IIiIiiIiI = [ "rsync" , "-rR" , "--rsh=ssh" ]
 if 34 - 34: Ooo0Ooo + ooo0O0oO00 * IIiIIiIi11I1 * OooOoo
 if 25 - 25: Ii / ooo0O0oO00 % Ii
 if 96 - 96: Ii . IIiIIiIi11I1 % iIiii1i
 if 68 - 68: iIiii1i . i1i1i1111I
 if 24 - 24: iiIi1
 ii1i11i1 = 0
 for I111IIi11IiI in sys . argv [ 1 : ] :
  if not I111IIi11IiI . startswith ( "-" ) :
   ii1i11i1 = 1
   I111IIi11IiI = os . path . abspath ( I111IIi11IiI )
  IIiIiiIiI . append ( I111IIi11IiI )
  if 51 - 51: oOo0O00 * iI1iII1I1I1i
 if not ii1i11i1 :
  iI111iiIi11i ( )
  if 41 - 41: Iii1i
 for o0o in oOooO0 :
  oooOOoO = IIiIiiIiI [ : ]
  oooOOoO . append ( "root@%s:/" % o0o )
  print ( "syncing with host" , o0o , file = sys . stderr )
  try :
   o0O0ooOoo00o = subprocess . call ( oooOOoO )
  except FileNotFoundError :
   print ( "Could not find rsync. Make sure that it is "
 "installed and try again." , file = sys . stderr )
   sys . exit ( 1 )
  except OSError as Oo0Oo00O0OO :
   print ( "Error starting rsync: %s" % Oo0Oo00O0OO , file = sys . stderr )
   sys . exit ( 1 )
  if o0O0ooOoo00o != 0 :
   print ( " **** rsync for host %s failed ****" % o0o , file = sys . stderr )
   if 7 - 7: Ooo0Ooo
   if 36 - 36: Iii1i
if __name__ == "__main__" :
 iI ( )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
