parameters: (request, host_id)
return_statement: return render_to_response('storages.html', locals(), context_instance=RequestContext(request))
docstring: Storage pool block
docstring_summary: Storage pool block
docstring_tokens: Storage pool block
function: def storages(request, host_id):
      """
      Storage pool block
      """
      if not request.user.is_authenticated():
          return HttpResponseRedirect(reverse('login'))
  
      errors = []
      compute = Compute.objects.get(id=host_id)
  
      try:
          conn = wvmStorages(compute.hostname,
                             compute.login,
                             compute.password,
                             compute.type)
          storages = conn.get_storages_info()
          secrets = conn.get_secrets()
  
          if request.method == 'POST':
              if 'create' in request.POST:
                  form = AddStgPool(request.POST)
                  if form.is_valid():
                      data = form.cleaned_data
                      if data['name'] in storages:
                          msg = _("Pool name already use")
                          errors.append(msg)
                      if data['stg_type'] == 'rbd':
                          if not data['secret']:
                              msg = _("You need create secret for pool")
                              errors.append(msg)
                          if not data['ceph_pool'] and not data['ceph_host'] and not data['ceph_user']:
                              msg = _("You need input all fields for creating ceph pool")
                              errors.append(msg)
                      if not errors:
                          if data['stg_type'] == 'rbd':
                              conn.create_storage_ceph(data['stg_type'], data['name'],
                                                       data['ceph_pool'], data['ceph_host'],
                                                       data['ceph_user'], data['secret'])
                          elif data['stg_type'] == 'netfs':
                              conn.create_storage_netfs(data['stg_type'], data['name'],
                                                        data['netfs_host'], data['source'],
                                                        data['source_format'], data['target'])
                          else:
                              conn.create_storage(data['stg_type'], data['name'], data['source'], data['target'])
                          return HttpResponseRedirect(reverse('storage', args=[host_id, data['name']]))
          conn.close()
      except libvirtError as err:
          errors.append(err)
  
      return render_to_response('storages.html', locals(), context_instance=RequestContext(request))
function_tokens: def storages ( request , host_id ) : if not request . user . is_authenticated ( ) : return HttpResponseRedirect ( reverse ( 'login' ) ) errors = [ ] compute = Compute . objects . get ( id = host_id ) try : conn = wvmStorages ( compute . hostname , compute . login , compute . password , compute . type ) storages = conn . get_storages_info ( ) secrets = conn . get_secrets ( ) if request . method == 'POST' : if 'create' in request . POST : form = AddStgPool ( request . POST ) if form . is_valid ( ) : data = form . cleaned_data if data [ 'name' ] in storages : msg = _ ( "Pool name already use" ) errors . append ( msg ) if data [ 'stg_type' ] == 'rbd' : if not data [ 'secret' ] : msg = _ ( "You need create secret for pool" ) errors . append ( msg ) if not data [ 'ceph_pool' ] and not data [ 'ceph_host' ] and not data [ 'ceph_user' ] : msg = _ ( "You need input all fields for creating ceph pool" ) errors . append ( msg ) if not errors : if data [ 'stg_type' ] == 'rbd' : conn . create_storage_ceph ( data [ 'stg_type' ] , data [ 'name' ] , data [ 'ceph_pool' ] , data [ 'ceph_host' ] , data [ 'ceph_user' ] , data [ 'secret' ] ) elif data [ 'stg_type' ] == 'netfs' : conn . create_storage_netfs ( data [ 'stg_type' ] , data [ 'name' ] , data [ 'netfs_host' ] , data [ 'source' ] , data [ 'source_format' ] , data [ 'target' ] ) else : conn . create_storage ( data [ 'stg_type' ] , data [ 'name' ] , data [ 'source' ] , data [ 'target' ] ) return HttpResponseRedirect ( reverse ( 'storage' , args = [ host_id , data [ 'name' ] ] ) ) conn . close ( ) except libvirtError as err : errors . append ( err ) return render_to_response ( 'storages.html' , locals ( ) , context_instance = RequestContext ( request ) )