original_docstring: Update access rules for given share.
  
          Please refer to base class for a more in-depth description.
          
docstring: Update access rules for given share.
  Please refer to base class for a more in-depth description.
docstring_tokens: Update access rules for given share . Please refer to base class for a more in - depth description .
code: def update_access(self, server, share_name, access_rules, add_rules,
                        delete_rules):
          """Update access rules for given share.
  
          Please refer to base class for a more in-depth description.
          """
          local_path = os.path.join(self.configuration.share_mount_path,
                                    share_name)
          out, err = self._ssh_exec(server, ['sudo', 'exportfs'])
          # Recovery mode
          if not (add_rules or delete_rules):
  
              self.validate_access_rules(
                  access_rules, ('ip',),
                  (const.ACCESS_LEVEL_RO, const.ACCESS_LEVEL_RW))
  
              hosts = self._get_host_list(out, local_path)
              for host in hosts:
                  self._ssh_exec(server, ['sudo', 'exportfs', '-u',
                                          ':'.join((host, local_path))])
              self._sync_nfs_temp_and_perm_files(server)
              for access in access_rules:
                  rules_options = '%s,no_subtree_check'
                  if access['access_level'] == const.ACCESS_LEVEL_RW:
                      rules_options = ','.join((rules_options, 'no_root_squash'))
                  self._ssh_exec(
                      server,
                      ['sudo', 'exportfs', '-o',
                       rules_options % access['access_level'],
                       ':'.join((self._get_parsed_access_to(access['access_to']),
                                 local_path))])
              self._sync_nfs_temp_and_perm_files(server)
          # Adding/Deleting specific rules
          else:
  
              self.validate_access_rules(
                  add_rules, ('ip',),
                  (const.ACCESS_LEVEL_RO, const.ACCESS_LEVEL_RW))
  
              for access in delete_rules:
                  access['access_to'] = self._get_parsed_access_to(
                      access['access_to'])
                  try:
                      self.validate_access_rules(
                          [access], ('ip',),
                          (const.ACCESS_LEVEL_RO, const.ACCESS_LEVEL_RW))
                  except (exception.InvalidShareAccess,
                          exception.InvalidShareAccessLevel):
                      LOG.warning(_LW(
                          "Unsupported access level %(level)s or access type "
                          "%(type)s, skipping removal of access rule to "
                          "%(to)s.") % {'level': access['access_level'],
                                        'type': access['access_type'],
                                        'to': access['access_to']})
                      continue
                  self._ssh_exec(server, ['sudo', 'exportfs', '-u',
                                 ':'.join((access['access_to'], local_path))])
              if delete_rules:
                  self._sync_nfs_temp_and_perm_files(server)
              for access in add_rules:
                  access['access_to'] = self._get_parsed_access_to(
                      access['access_to'])
                  found_item = re.search(
                      re.escape(local_path) + '[\s\n]*' + re.escape(
                          access['access_to']), out)
                  if found_item is not None:
                      LOG.warning(_LW("Access rule %(type)s:%(to)s already "
                                      "exists for share %(name)s") % {
                          'to': access['access_to'],
                          'type': access['access_type'],
                          'name': share_name
                      })
                  else:
                      rules_options = '%s,no_subtree_check'
                      if access['access_level'] == const.ACCESS_LEVEL_RW:
                          rules_options = ','.join((rules_options,
                                                   'no_root_squash'))
                      self._ssh_exec(
                          server,
                          ['sudo', 'exportfs', '-o',
                           rules_options % access['access_level'],
                           ':'.join((access['access_to'], local_path))])
              if add_rules:
                  self._sync_nfs_temp_and_perm_files(server)
code_tokens: def update_access ( self , server , share_name , access_rules , add_rules , delete_rules ) : local_path = os . path . join ( self . configuration . share_mount_path , share_name ) out , err = self . _ssh_exec ( server , [ 'sudo' , 'exportfs' ] ) if not ( add_rules or delete_rules ) : self . validate_access_rules ( access_rules , ( 'ip' , ) , ( const . ACCESS_LEVEL_RO , const . ACCESS_LEVEL_RW ) ) hosts = self . _get_host_list ( out , local_path ) for host in hosts : self . _ssh_exec ( server , [ 'sudo' , 'exportfs' , '-u' , ':' . join ( ( host , local_path ) ) ] ) self . _sync_nfs_temp_and_perm_files ( server ) for access in access_rules : rules_options = '%s,no_subtree_check' if access [ 'access_level' ] == const . ACCESS_LEVEL_RW : rules_options = ',' . join ( ( rules_options , 'no_root_squash' ) ) self . _ssh_exec ( server , [ 'sudo' , 'exportfs' , '-o' , rules_options % access [ 'access_level' ] , ':' . join ( ( self . _get_parsed_access_to ( access [ 'access_to' ] ) , local_path ) ) ] ) self . _sync_nfs_temp_and_perm_files ( server ) else : self . validate_access_rules ( add_rules , ( 'ip' , ) , ( const . ACCESS_LEVEL_RO , const . ACCESS_LEVEL_RW ) ) for access in delete_rules : access [ 'access_to' ] = self . _get_parsed_access_to ( access [ 'access_to' ] ) try : self . validate_access_rules ( [ access ] , ( 'ip' , ) , ( const . ACCESS_LEVEL_RO , const . ACCESS_LEVEL_RW ) ) except ( exception . InvalidShareAccess , exception . InvalidShareAccessLevel ) : LOG . warning ( _LW ( "Unsupported access level %(level)s or access type " "%(type)s, skipping removal of access rule to " "%(to)s." ) % { 'level' : access [ 'access_level' ] , 'type' : access [ 'access_type' ] , 'to' : access [ 'access_to' ] } ) continue self . _ssh_exec ( server , [ 'sudo' , 'exportfs' , '-u' , ':' . join ( ( access [ 'access_to' ] , local_path ) ) ] ) if delete_rules : self . _sync_nfs_temp_and_perm_files ( server ) for access in add_rules : access [ 'access_to' ] = self . _get_parsed_access_to ( access [ 'access_to' ] ) found_item = re . search ( re . escape ( local_path ) + '[\s\n]*' + re . escape ( access [ 'access_to' ] ) , out ) if found_item is not None : LOG . warning ( _LW ( "Access rule %(type)s:%(to)s already " "exists for share %(name)s" ) % { 'to' : access [ 'access_to' ] , 'type' : access [ 'access_type' ] , 'name' : share_name } ) else : rules_options = '%s,no_subtree_check' if access [ 'access_level' ] == const . ACCESS_LEVEL_RW : rules_options = ',' . join ( ( rules_options , 'no_root_squash' ) ) self . _ssh_exec ( server , [ 'sudo' , 'exportfs' , '-o' , rules_options % access [ 'access_level' ] , ':' . join ( ( access [ 'access_to' ] , local_path ) ) ] ) if add_rules : self . _sync_nfs_temp_and_perm_files ( server )
short_docstring: Update access rules for given share.
short_docstring_tokens: Update access rules for given share .
comment: """Update access rules for given share.
  
          Please refer to base class for a more in-depth description.
          """$SEP$# Recovery mode$SEP$# Adding/Deleting specific rules