+ platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
+ platform_details = execute_query(request, platform_query)
+ user_hrn = None
+ #getting user_hrn from local:account
+ for account_detail in account_details:
+ for platform_detail in platform_details:
+ if platform_detail['platform_id'] == account_detail['platform_id']:
+ # taking user_hrn only from myslice account
+ # NOTE: we should later handle accounts filter_by auth_type= managed OR user
+ if 'myslice' in platform_detail['platform']:
+ account_config = json.loads(account_detail['config'])
+ user_hrn = account_config.get('user_hrn','N/A')
+ # acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+
+ pi = request.session['user']['pi']
+
+ # Page rendering
+ page = Page(request)
+ page.add_js_files ( [ "js/jquery.validate.js", "js/jquery-ui.js" ] )
+ page.add_css_files ( [ "css/jquery-ui.css" ] )
+ page.expose_js_metadata()
+
+ if method == 'POST':
+ # The form has been submitted
+
+ if request.is_secure():
+ current_site = 'https://'
+ else:
+ current_site = 'http://'
+ current_site += request.META['HTTP_HOST']
+
+ #if theme.theme != 'fed4fire' or self.theme != 'onelab':
+ # getting the authority_hrn from the selected organization
+ # for authority in authorities:
+ # if authority['name'] == request.POST.get('org_name', ''):
+ # authority_hrn = authority['authority_hrn']
+
+ # Handle the case when we use only hrn and not name
+ if authority_hrn is None:
+ authority_hrn = request.POST.get('org_name', '')
+
+ # Handle project if used
+ project = request.POST.get('org_name', None)
+ if project is not None and project != '':
+ authority_hrn = project
+ slice_name = request.POST.get('slice_name', '')
+ if not slice_name or len(slice_name) == 0 :
+ errors.append('Slice name can\'t be empty')
+
+ # accept only lowercase names
+ slice_name = slice_name.lower()
+
+ slice_request = {
+ 'type' : 'slice',
+ 'id' : None,
+ 'user_hrn' : user_hrn,
+ 'email' : user_email,
+ 'timestamp' : time.time(),
+ 'authority_hrn' : authority_hrn,
+ 'organization' : request.POST.get('org_name', ''),
+ 'slice_name' : slice_name,
+ #'url' : request.POST.get('url', ''),
+ #'purpose' : request.POST.get('purpose', ''),
+ 'current_site' : current_site
+ }
+
+ # slice name is unique among all authorities
+ slice_query = Query().get('myslice:slice').select('slice_hrn')
+ slice_details_sfa = execute_admin_query(request, slice_query)
+ for _slice in slice_details_sfa:
+ split_list = _slice['slice_hrn'].split('.')
+ sfa_slice_name = split_list[-1]
+ if sfa_slice_name == slice_name:
+ errors.append('Slice already exists. Please use a different slice name.')