def if_firewall_available(distribution, commands):
 if is_centos_or_rhel(distribution):
  firewall_command = 'firewall-cmd'
 elif is_ubuntu(distribution):
  firewall_command = 'ufw'
 else:
  raise DistributionNotSupported(distribution=distribution)
 return run_from_args(['which', firewall_command]).on(success=(lambda result: commands), error=catch_exit_code(1))

def if_firewall_available ( distribution , commands ) : if is_centos_or_rhel ( distribution ) : firewall_command = 'firewall-cmd' elif is_ubuntu ( distribution ) : firewall_command = 'ufw' else : raise DistributionNotSupported ( distribution = distribution ) return run_from_args ( [ 'which' , firewall_command ] ) . on ( success = ( lambda result : commands ) , error = catch_exit_code ( 1 ) )
open the firewall for remote access to control service if firewall command is available .