original_docstring: Create a user on OneFS and in the local script.
docstring: Create a user on OneFS and in the local script.
docstring_tokens: Create a user on OneFS and in the local script .
code: def create_user(self, user_name, primary_group_name):
          """Create a user on OneFS and in the local script."""
          while True:
              try:
                  uid = self.next_uid
                  LOGGER.info(
                      'Creating the %s user with UID %s on %s...',
                      user_name,
                      uid,
                      self.onefs.address,
                  )
                  self.onefs.create_user(
                      name=user_name,
                      uid=uid,
                      primary_group_name=primary_group_name,
                      zone=self.onefs_zone,
                      enabled=True,
                  )
                  break
              except isilon_hadoop_tools.onefs.APIError as exc:
                  if exc.uid_already_exists_error(uid):
                      LOGGER.warning(exc.uid_already_exists_error_format.format(uid))
                      continue
                  if exc.user_already_exists_error(user_name):
                      LOGGER.warning(exc.user_already_exists_error_format.format(user_name))
                      uid = self.onefs.uid_of_user(user_name=user_name, zone=self.onefs_zone)
                      break
                  raise
          if self.script_path:
              self._create_script()
              LOGGER.info(
                  'Creating the %s user with UID %s in %s...',
                  user_name,
                  uid,
                  self.script_path,
              )
              with open(self.script_path, 'a') as script_file:
                  script_file.write(
                      'useradd --uid {uid} --gid {gid} {name}\n'.format(
                          uid=uid,
                          gid=self.onefs.gid_of_group(
                              group_name=self.onefs.primary_group_of_user(
                                  user_name=user_name,
                                  zone=self.onefs_zone,
                              ),
                              zone=self.onefs_zone,
                          ),
                          name=user_name,
                      ),
                  )
          return uid
code_tokens: def create_user ( self , user_name , primary_group_name ) : while True : try : uid = self . next_uid LOGGER . info ( 'Creating the %s user with UID %s on %s...' , user_name , uid , self . onefs . address , ) self . onefs . create_user ( name = user_name , uid = uid , primary_group_name = primary_group_name , zone = self . onefs_zone , enabled = True , ) break except isilon_hadoop_tools . onefs . APIError as exc : if exc . uid_already_exists_error ( uid ) : LOGGER . warning ( exc . uid_already_exists_error_format . format ( uid ) ) continue if exc . user_already_exists_error ( user_name ) : LOGGER . warning ( exc . user_already_exists_error_format . format ( user_name ) ) uid = self . onefs . uid_of_user ( user_name = user_name , zone = self . onefs_zone ) break raise if self . script_path : self . _create_script ( ) LOGGER . info ( 'Creating the %s user with UID %s in %s...' , user_name , uid , self . script_path , ) with open ( self . script_path , 'a' ) as script_file : script_file . write ( 'useradd --uid {uid} --gid {gid} {name}\n' . format ( uid = uid , gid = self . onefs . gid_of_group ( group_name = self . onefs . primary_group_of_user ( user_name = user_name , zone = self . onefs_zone , ) , zone = self . onefs_zone , ) , name = user_name , ) , ) return uid
short_docstring: Create a user on OneFS and in the local script.
short_docstring_tokens: Create a user on OneFS and in the local script .
comment: """Create a user on OneFS and in the local script."""