+ # Download sfi_config
+ elif 'dl_sfi_config' in request.POST:
+ platform_detail = get_myslice_platform(request)
+ platform_config = json.loads(platform_detail['config'])
+ account_detail = get_myslice_account(request)
+ account_config = json.loads(account_detail['config'])
+
+ user_hrn = account_config.get('user_hrn','N/A')
+ t_user_hrn = user_hrn.split('.')
+ authority_hrn = t_user_hrn[0] + '.' + t_user_hrn[1]
+ import socket
+ hostname = socket.gethostbyaddr(socket.gethostname())[0]
+ registry = platform_config.get('registry','N/A')
+ admin_user = platform_config.get('user','N/A')
+ if 'localhost' in registry:
+ port = registry.split(':')[-1:][0]
+ registry = "http://" + hostname +':'+ port
+ manifold_host = ConfigEngine().manifold_url()
+ if 'localhost' in manifold_host:
+ manifold_host = manifold_host.replace('localhost',hostname)
+ sfi_config = '[sfi]\n'
+ sfi_config += 'auth = '+ authority_hrn +'\n'
+ sfi_config += 'user = '+ user_hrn +'\n'
+ sfi_config += 'registry = '+ registry +'\n'
+ sfi_config += 'sm = http://sfa3.planet-lab.eu:12346/\n\n'
+ sfi_config += '[myslice]\n'
+ sfi_config += 'backend = '+ manifold_host +'\n'
+ sfi_config += 'delegate = '+ admin_user +'\n'
+ sfi_config += 'platform = myslice\n'
+ sfi_config += 'username = '+ user_email +'\n'
+ response = HttpResponse(sfi_config, content_type='text/plain')
+ response['Content-Disposition'] = 'attachment; filename="sfi_config"'
+ return response
+
+ #clear all creds
+ elif 'clear_cred' in request.POST:
+ try:
+ result = clear_user_creds(request, user_email)
+ if result is not None:
+ messages.success(request, 'All Credentials cleared')
+ else:
+ messages.error(request, 'Delete error: Credentials are not stored in the server')
+ except Exception,e:
+ print "Exception in accountview.py in clear_user_creds %s" % e
+ messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
+ return HttpResponseRedirect("/portal/account/")