parameters: (request, host_id, pool)
return_statement: return render_to_response('network.html', locals(), context_instance=RequestContext(request))
docstring: Networks block
docstring_summary: Networks block
docstring_tokens: Networks block
function: def network(request, host_id, pool):
      """
      Networks block
      """
      if not request.user.is_authenticated():
          return HttpResponseRedirect(reverse('login'))
  
      errors = []
      compute = Compute.objects.get(id=host_id)
  
      try:
          conn = wvmNetwork(compute.hostname,
                            compute.login,
                            compute.password,
                            compute.type,
                            pool)
          networks = conn.get_networks()
          state = conn.is_active()
          device = conn.get_bridge_device()
          autostart = conn.get_autostart()
          ipv4_forward = conn.get_ipv4_forward()
          ipv4_dhcp_range_start = conn.get_ipv4_dhcp_range_start()
          ipv4_dhcp_range_end = conn.get_ipv4_dhcp_range_end()
          ipv4_network = conn.get_ipv4_network()
          fixed_address = conn.get_mac_ipaddr()
      except libvirtError as err:
          errors.append(err)
  
      if request.method == 'POST':
          if 'start' in request.POST:
              try:
                  conn.start()
                  return HttpResponseRedirect(request.get_full_path())
              except libvirtError as error_msg:
                  errors.append(error_msg.message)
          if 'stop' in request.POST:
              try:
                  conn.stop()
                  return HttpResponseRedirect(request.get_full_path())
              except libvirtError as error_msg:
                  errors.append(error_msg.message)
          if 'delete' in request.POST:
              try:
                  conn.delete()
                  return HttpResponseRedirect(reverse('networks', args=[host_id]))
              except libvirtError as error_msg:
                  errors.append(error_msg.message)
          if 'set_autostart' in request.POST:
              try:
                  conn.set_autostart(1)
                  return HttpResponseRedirect(request.get_full_path())
              except libvirtError as error_msg:
                  errors.append(error_msg.message)
          if 'unset_autostart' in request.POST:
              try:
                  conn.set_autostart(0)
                  return HttpResponseRedirect(request.get_full_path())
              except libvirtError as error_msg:
                  errors.append(error_msg.message)
  
      conn.close()
  
      return render_to_response('network.html', locals(), context_instance=RequestContext(request))
function_tokens: def network ( request , host_id , pool ) : if not request . user . is_authenticated ( ) : return HttpResponseRedirect ( reverse ( 'login' ) ) errors = [ ] compute = Compute . objects . get ( id = host_id ) try : conn = wvmNetwork ( compute . hostname , compute . login , compute . password , compute . type , pool ) networks = conn . get_networks ( ) state = conn . is_active ( ) device = conn . get_bridge_device ( ) autostart = conn . get_autostart ( ) ipv4_forward = conn . get_ipv4_forward ( ) ipv4_dhcp_range_start = conn . get_ipv4_dhcp_range_start ( ) ipv4_dhcp_range_end = conn . get_ipv4_dhcp_range_end ( ) ipv4_network = conn . get_ipv4_network ( ) fixed_address = conn . get_mac_ipaddr ( ) except libvirtError as err : errors . append ( err ) if request . method == 'POST' : if 'start' in request . POST : try : conn . start ( ) return HttpResponseRedirect ( request . get_full_path ( ) ) except libvirtError as error_msg : errors . append ( error_msg . message ) if 'stop' in request . POST : try : conn . stop ( ) return HttpResponseRedirect ( request . get_full_path ( ) ) except libvirtError as error_msg : errors . append ( error_msg . message ) if 'delete' in request . POST : try : conn . delete ( ) return HttpResponseRedirect ( reverse ( 'networks' , args = [ host_id ] ) ) except libvirtError as error_msg : errors . append ( error_msg . message ) if 'set_autostart' in request . POST : try : conn . set_autostart ( 1 ) return HttpResponseRedirect ( request . get_full_path ( ) ) except libvirtError as error_msg : errors . append ( error_msg . message ) if 'unset_autostart' in request . POST : try : conn . set_autostart ( 0 ) return HttpResponseRedirect ( request . get_full_path ( ) ) except libvirtError as error_msg : errors . append ( error_msg . message ) conn . close ( ) return render_to_response ( 'network.html' , locals ( ) , context_instance = RequestContext ( request ) )