Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@jsonify
def submit( self ):
"""
Returns flatten list of components (services, agents) installed on hosts
returned by getHosts function
"""
checkUserCredentials()
DN = getUserDN()
group = getSelectedGroup()
callback = list()
request = self.request()
if not 'Hostname' in request:
return { "success" : "false" , "error" : "Name of the host is absent" }
host = request[ 'Hostname' ]
client = SystemAdministratorClient( host , None , delegatedDN=DN ,
delegatedGroup=group )
result = client.getOverallStatus()
gLogger.debug( "Result of getOverallStatus(): %s" % result )
if not result[ "OK" ]:
def __sendMessage( self ):
"""
This function is used to send a mail to specific group of DIRAC user
Expected parameters from request are group, title, body
"""
gLogger.info("Start message broadcasting")
checkUserCredentials()
dn = getUserDN()
if not dn:
error = "Certificate is not loaded in the browser or DN is absent"
gLogger.error( "Service response: %s" % error )
return { "success" : "false" , "error" : error }
username = getUsername()
if username == "anonymous":
error = "Sending an anonymous message is forbidden"
gLogger.error( "Service response: %s" % error )
return { "success" : "false" , "error" : error }
gLogger.info( "DN: %s" % dn )
email = gConfig.getValue( "/Registry/Users/%s/Email" % username , "" )
gLogger.debug( "/Registry/Users/%s/Email - '%s'" % ( username , email ) )
emil = email.strip()
def display(self):
checkUserCredentials()
dn = getUserDN()
user = getUsername()
group = getSelectedGroup()
gLogger.always( "User: %s, Group: %s, DN: %s" % ( user , group , dn ) )
templates = [ "reg_%s.mako" % i for i in [ "done" , "form" , "info" ] ]
html = [ "reg_%s.html" % i for i in [ "footer" , "header" , "conditions" , "form" , "done" ] ]
files = templates + html
basedir = os.path.join( rootPath , "Web" , "dirac" , "templates" )
for i in files:
f = os.path.join( basedir , i )
if not os.path.exists( f ):
gLogger.error( "File does not exists: %s" % f )
return render( "web/External.mako" )
if dn and user == "anonymous":
upc = UserProfileClient( "Registration" , getRPCClient )
result = upc.retrieveVar( dn )
@jsonify
def registerUser( self ):
"""
This function is used to notify DIRAC admins about user registration request
The logic is simple:
0) Check if request from this e-mail has already registered or not
1) Send mail to VO admin of requested VO
2) Send mail to users in group with UserAdministrator property
3) Send mail to users indicated in /Website/UserRegistrationAdmin option
"""
gLogger.info("Start processing a registration request")
checkUserCredentials()
# Check for having a DN but no username
dn = getUserDN()
if not dn:
error = "Certificate is not loaded in the browser or DN is absent"
gLogger.error( "Service response: %s" % error )
return { "success" : "false" , "error" : error }
username = getUsername()
if not username == "anonymous":
error = "You are already registered in DIRAC with username: %s" % username
gLogger.error( "Service response: %s" % error )
return { "success" : "false" , "error" : error }
gLogger.info( "DN: %s" % dn )
if not "email" in request.params:
error = "Can not get your email address from the request"
gLogger.debug( "Service response: %s" % error )