def rsync_module_interpolation(template, device):
 replacements = {'ip': rsync_ip(device.get('ip', '')), 'port': device.get('port', ''), 'replication_ip': rsync_ip(device.get('replication_ip', '')), 'replication_port': device.get('replication_port', ''), 'region': device.get('region', ''), 'zone': device.get('zone', ''), 'device': device.get('device', ''), 'meta': device.get('meta', '')}
 try:
  module = template.format(**replacements)
 except KeyError as e:
  raise ValueError(('Cannot interpolate rsync_module, invalid variable: %s' % e))
 return module

def rsync_module_interpolation ( template , device ) : replacements = { 'ip' : rsync_ip ( device . get ( 'ip' , '' ) ) , 'port' : device . get ( 'port' , '' ) , 'replication_ip' : rsync_ip ( device . get ( 'replication_ip' , '' ) ) , 'replication_port' : device . get ( 'replication_port' , '' ) , 'region' : device . get ( 'region' , '' ) , 'zone' : device . get ( 'zone' , '' ) , 'device' : device . get ( 'device' , '' ) , 'meta' : device . get ( 'meta' , '' ) } try : module = template . format ( ** replacements ) except KeyError as e : raise ValueError ( ( 'Cannot interpolate rsync_module, invalid variable: %s' % e ) ) return module
interpolate devices variables inside a rsync module template .