helpers.py (manila-8.1.3) | : | helpers.py (manila-8.1.4) | ||
---|---|---|---|---|
skipping to change at line 278 | skipping to change at line 278 | |||
exception.InvalidShareAccessLevel): | exception.InvalidShareAccessLevel): | |||
LOG.warning( | LOG.warning( | |||
"Unsupported access level %(level)s or access type " | "Unsupported access level %(level)s or access type " | |||
"%(type)s, skipping removal of access rule to " | "%(type)s, skipping removal of access rule to " | |||
"%(to)s.", {'level': access['access_level'], | "%(to)s.", {'level': access['access_level'], | |||
'type': access['access_type'], | 'type': access['access_type'], | |||
'to': access['access_to']}) | 'to': access['access_to']}) | |||
continue | continue | |||
access_to = self._get_parsed_address_or_cidr( | access_to = self._get_parsed_address_or_cidr( | |||
access['access_to']) | access['access_to']) | |||
self._ssh_exec(server, ['sudo', 'exportfs', '-u', | try: | |||
':'.join((access_to, local_path))]) | self._ssh_exec(server, ['sudo', 'exportfs', '-u', | |||
':'.join((access_to, local_path))]) | ||||
except exception.ProcessExecutionError as e: | ||||
if "could not find" in e.stderr.lower(): | ||||
LOG.debug( | ||||
"Client/s with IP address/es %(host)s did not " | ||||
"have access to %(share)s. Nothing to deny.", | ||||
{'host': access_to, 'share': share_name}) | ||||
else: | ||||
raise | ||||
if delete_rules: | if delete_rules: | |||
self._sync_nfs_temp_and_perm_files(server) | self._sync_nfs_temp_and_perm_files(server) | |||
for access in add_rules: | for access in add_rules: | |||
access_to = self._get_parsed_address_or_cidr( | access_to = self._get_parsed_address_or_cidr( | |||
access['access_to']) | access['access_to']) | |||
found_item = re.search( | found_item = re.search( | |||
re.escape(local_path) + '[\s\n]*' + re.escape(access_to), | re.escape(local_path) + '[\s\n]*' + re.escape(access_to), | |||
out) | out) | |||
if found_item is not None: | if found_item is not None: | |||
LOG.warning("Access rule %(type)s:%(to)s already " | LOG.warning("Access rule %(type)s:%(to)s already " | |||
skipping to change at line 344 | skipping to change at line 354 | |||
This is required to ensure, that after share server reboot, exports | This is required to ensure, that after share server reboot, exports | |||
still exist. | still exist. | |||
""" | """ | |||
sync_cmd = [ | sync_cmd = [ | |||
'sudo', 'cp', const.NFS_EXPORTS_FILE_TEMP, const.NFS_EXPORTS_FILE | 'sudo', 'cp', const.NFS_EXPORTS_FILE_TEMP, const.NFS_EXPORTS_FILE | |||
] | ] | |||
self._ssh_exec(server, sync_cmd) | self._ssh_exec(server, sync_cmd) | |||
self._ssh_exec(server, ['sudo', 'exportfs', '-a']) | self._ssh_exec(server, ['sudo', 'exportfs', '-a']) | |||
out, _ = self._ssh_exec( | out, _ = self._ssh_exec( | |||
server, ['sudo', 'service', 'nfs-kernel-server', 'status'], | server, | |||
['sudo', 'systemctl', 'is-active', 'nfs-kernel-server'], | ||||
check_exit_code=False) | check_exit_code=False) | |||
if "not" in out: | if "inactive" in out: | |||
self._ssh_exec( | self._ssh_exec( | |||
server, ['sudo', 'service', 'nfs-kernel-server', 'restart']) | server, ['sudo', 'systemctl', 'restart', 'nfs-kernel-server']) | |||
def _get_export_location_template(self, export_location_or_path): | def _get_export_location_template(self, export_location_or_path): | |||
path = export_location_or_path.split(':')[-1] | path = export_location_or_path.split(':')[-1] | |||
return '%s:' + path | return '%s:' + path | |||
def get_share_path_by_export_location(self, server, export_location): | def get_share_path_by_export_location(self, server, export_location): | |||
return export_location.split(':')[-1] | return export_location.split(':')[-1] | |||
@nfs_synchronized | @nfs_synchronized | |||
def disable_access_for_maintenance(self, server, share_name): | def disable_access_for_maintenance(self, server, share_name): | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 16 lines changed or added |