def validate_conf(self): valid = True messages = [] if not self.server_conf.get_chef_conf().validate(): valid = False messages.append({'type': 'error', 'message': _('Chef and Chef Cert URLs must be valid URLs.')}) hostname = self.server_conf.get_chef_conf().get_hostname() if not validation.is_qname(hostname): valid = False messages.append({'type': 'error', 'message': _('Host name is empty or contains invalid characters.')}) try: used_hostnames = serverconf.get_chef_hostnames(self.server_conf.get_chef_conf()) except Exception as e: used_hostnames = [] # IMPORTANT: Append the error but don't touch the variable "valid" here, # just because if we can't get the hostnames here, # Chef will inform us about that later, while we are registering # the client. messages.append({'type': 'error', 'message': str(e)}) if hostname in used_hostnames: valid = False messages.append({'type': 'error', 'message': _('Node name already exists in the Chef server. Choose a different one.')}) return valid, messages
def validate_user(self, user): valid = True messages = [] if not validation.is_qname(user['login']): messages.append(_('The user login is empty or contains invalid characters.')) valid = False if validation.is_empty(user['password']): messages.append(_('The user password couldn\'t be empty.')) valid = False elif user['password'] != __DUMMY_PASSWORD__ and user['password'] != user['confirm']: messages.append(_('The passwords doesn\'t match.')) valid = False if not valid: msgs = '\n'.join(messages) Dialogs.user_error_dialog(msgs) return valid
def validate_user(self, user): valid = True messages = [] if not validation.is_qname(user['login']): messages.append( _('User login is empty or contains invalid characters.')) valid = False if validation.is_empty(user['password']): messages.append(_('User password can not be empty.')) valid = False elif user['password'] != __DUMMY_PASSWORD__ and user[ 'password'] != user['confirm']: messages.append(_('Passwords do not match.')) valid = False if not valid: msgs = '\n'.join(messages) Dialogs.user_error_dialog(msgs) return valid
def validate(self): valid = validation.is_qname(self._data['host']) return valid
def validate(self): valid = validation.is_url(self._data['chef_server_url']) \ and validation.is_url(self._data['chef_validation_url']) \ and validation.is_qname(self._data['chef_default_role']) return valid