Exemple #1
0
 def forward_conf(configuration_path, unforward=False, reforward_ip=None):
     with open(configuration_path, 'r') as configuration_file:
         for line in configuration_file.readlines():
             line = line.strip()
             if not line or line.startswith('#'):
                 continue
             forward_args = ConsoleHelper.__transform_string_into_forward_args(line)
             if reforward_ip:
                 IptablesHelper.unforward_port(*forward_args)
                 forward_args[0] = reforward_ip
             if unforward:
                 IptablesHelper.unforward_port(*forward_args)
             else:
                 IptablesHelper.forward_port(*forward_args)
Exemple #2
0
 Config.start_log()
 logging.info('Received args: {0}'.format(args))
 if args.command == 'create':
     LxcHelper.create_call(args.name, args.backing_store, args.distro, args.release, args.architecture,
                           args.unprivileged)
 if args.command == 'copy':
     LxcHelper.copy_call(args.original_name, args.new_name, args.unprivileged)
 if args.command == 'list':
     LxcHelper.list_call(args.not_fancy, args.unprivileged)
 if args.command == 'remove':
     LxcHelper.remove_call(args.name, args.unprivileged)
 if args.command == 'net':
     if args.net_command == 'forward':
         if args.unforward:
             IptablesHelper.unforward_port(args.container_ip, args.container_port, args.host_port,
                                           args.host_interface,
                                           args.source_ip)
         else:
             IptablesHelper.forward_port(args.container_ip, args.container_port, args.host_port, args.host_interface,
                                         args.source_ip)
     if args.net_command == 'full-forward':
         if args.unforward:
             IptablesHelper.full_unforward(args.container_ip, args.host_interface, args.source_ip)
         else:
             IptablesHelper.full_forward(args.container_ip, args.host_interface, args.source_ip)
     if args.net_command == 'forward-conf':
         ConsoleHelper.forward_conf(args.configuration_path)
     if args.net_command == 'reforward-conf':
         ConsoleHelper.forward_conf(args.configuration_path, args.container_ip)
     if args.net_command == 'flush':
         IptablesHelper.flush()