Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre
authorRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Fri, 24 Oct 2014 18:03:17 +0000 (16:03 -0200)
committerRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Fri, 24 Oct 2014 18:03:17 +0000 (16:03 -0200)
1  2 
portal/actions.py
portal/homeview.py

diff --combined portal/actions.py
@@@ -593,31 -593,21 +593,31 @@@ def create_slice(wsgi_request, request)
          Exception
      """
      hrn = "%s.%s" % (request['authority_hrn'], request['slice_name'])
 +     
      # XXX tmp sfa dependency
      from sfa.util.xrn import Xrn 
      urn = Xrn(hrn, request['type']).get_urn()
      
      # Add User to Slice if we have the user_hrn in pendingslice table
      user_hrn = request.get('user_hrn', None)
 +    user_obj = User.objects.get(username = user_hrn.split(".")[1])
 +    list_users = []
      user_hrns = list([user_hrn]) if user_hrn else list()
 +    for user in user_hrns:
 +        list_users +=[User.objects.get(username = user.split(".")[1])] 
 +    
 +    #user_query  = Query.get('local:user').select('email').filter_by('email','==',user.username)
 +    #user_details_sfa = execute_admin_query(wsgi_request, user_query)
 +    
 +    pendinguser = PendingUser.objects.filter(login__iexact = user_obj.username)    
 +    if pendinguser :
 +        raise Exception, "User %s doesn't exist, validate user before validating slice" % user_obj.username
 +    #if not user_details_sfa:
 +    #    raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn
 +    #for user in list_users:
 +     
 +    user_email = user_obj.email
      
 -    user_query  = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn)
 -    user_details_sfa = execute_admin_query(wsgi_request, user_query)
 -    if not user_details_sfa:
 -        raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn
 -    for user in user_details_sfa:
 -        user_email = user['user_email']
 -
      # XXX LOIC Quick fix because this is totally inconsistent
      if not 'number_of_nodes' in request:
          request['number_of_nodes']=""
          'slice_enabled'    : True
      }
      # ignored in request: id, timestamp,  number_of_nodes, type_of_nodes, purpose
 -
 +    
      query = Query.create('slice').set(slice_params).select('slice_hrn')
      results = execute_query(wsgi_request, query)
      if not results:
          raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
      else:
 -        clear_user_creds(wsgi_request,user_email)
 +        clear_user_creds(wsgi_request,user_obj.username)
          # log user activity
 -        activity.slice.validate(self.request, "Slice validation", { "slice" : hrn })
 +        activity.slice.validate(request, "Slice validation")#, { "slice" : hrn })
 +      
          try:
              theme.template_name = 'slice_request_validated.txt'
              text_content = render_to_string(theme.template, request)
@@@ -893,7 -882,7 +893,7 @@@ def iotlab_create_user (wsgi_request, r
          "structure"     : request['authority_hrn'],
          "city"          : "N/A",
          "country"       : "N/A",
-         "sshPublicKey"  : [request['public_key']],
+         "sshPublicKey"  : request['public_key'],
          "motivations"   : "SFA federation",
      }    
     
diff --combined portal/homeview.py
@@@ -65,7 -65,7 +65,7 @@@ class HomeView (FreeAccessView, ThemeVi
        ## first you must open a connection to the server
        try:
                # Connect to NOC
 -              l = ldap.initialize("ldap://10.128.0.50:389")
 +                l = ldap.initialize("ldap://200.130.15.186:389")
                # Bind/authenticate with a root user to search all objects
                l.simple_bind_s("cn=Manager,dc=br,dc=fibre","fibre2013")
                
              # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
              platform_details = execute_query(self.request, platform_query)
              account_details = execute_query(self.request, account_query)
-             for platform_detail in platform_details:
-                 for account_detail in account_details:
-                     if 'platform_id' in platform_detail:
-                         if platform_detail['platform_id'] == account_detail['platform_id']:
-                             if 'config' in account_detail and account_detail['config'] is not '':
-                                 account_config = json.loads(account_detail['config'])
-                                 if 'myslice' in platform_detail['platform']:
-                                     acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
-                                     acc_user_cred = account_config.get('delegated_user_credential','N/A')
+             if platform_details is not None and platform_details != {}:
+                 for platform_detail in platform_details:
+                     for account_detail in account_details:
+                         if 'platform_id' in platform_detail:
+                             if platform_detail['platform_id'] == account_detail['platform_id']:
+                                 if 'config' in account_detail and account_detail['config'] is not '':
+                                     account_config = json.loads(account_detail['config'])
+                                     if 'myslice' in platform_detail['platform']:
+                                         acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                                         acc_user_cred = account_config.get('delegated_user_credential','N/A')
              # assigning values
              if acc_auth_cred=={} or acc_auth_cred=='N/A':
                  pi = "is_not_pi"