def addvalidation(self, username, loginname, password, accounts): """ add validation function :param username: username to be added :type username: str. :param loginname: loginname to be added :type loginname: str. :param password: password to be added :type password: str. :param accounts: list of federation accounts :type accounts: list. """ for acct in accounts: if acct['UserName'] == username or acct['Oem']\ [self.typepath.defs.oemhp]['LoginName']\ == loginname: raise AccountExists( 'Username or login name is already in use.') if len(username) >= 60: raise ValidationError('Username exceeds maximum length.') if len(loginname) >= 60: raise ValidationError('Login name exceeds maximum length.') if len(password) >= 40 or len(password) < 8: raise ValidationError('Password length is invalid.')
def addmaintenancewindow(self, options, windows, startafter): """ Add a maintenance window :param options: command line options :type options: list. :param windows: list of maintenance windows on the system :type windows: list. :param startafter: redfish date-time string to start the maintenance window :type startafter: str. """ adddata = {'StartAfter': startafter} if options.name: adddata['Name'] = options.name else: adddata['Name'] = 'MW-%s' % str(randint(0, 1000000)) if options.description: if options.description.startswith('"') and options.description.endswith('"'): options.description = options.description[1:-1] adddata['Description'] = options.description if options.expire: adddata['Expire'] = options.expire errors = self.validatewindow(adddata, windows) if not errors: path = '/redfish/v1/UpdateService/MaintenanceWindows/' self.rdmc.app.post_handler(path, adddata) else: self.rdmc.ui.error("Invalid Maintenance Window:\n") for error in errors: self.rdmc.ui.error('\t'+error+'\n') raise ValidationError('')