def rename_fs(module, array): """Recover a file system""" changed = True if not module.check_mode: try: target = list( array.get_file_systems(names=[module.params["rename"]]).items )[0] except Exception: target = None if not target: try: file_system = flasharray.FileSystemPatch(name=module.params["rename"]) array.patch_file_systems( names=[module.params["name"]], file_system=file_system ) except Exception: module.fail_json( msg="Failed to delete file system {0}".format(module.params["name"]) ) else: module.fail_json( msg="Target file system {0} already exists".format( module.params["rename"] ) ) module.exit_json(changed=changed)
def recover_fs(module, array): """Recover a file system""" changed = True if not module.check_mode: try: file_system = flasharray.FileSystemPatch(destroyed=False) array.patch_file_systems(names=[module.params['name']], file_system=file_system) except Exception: module.fail_json(msg="Failed to delete file system {0}".format(module.params['name'])) module.exit_json(changed=changed)
def delete_fs(module, array): """Delete a file system""" changed = True if not module.check_mode: try: file_system = flasharray.FileSystemPatch(destroyed=True) array.patch_file_systems(names=[module.params['name']], file_system=file_system) except Exception: module.fail_json(msg="Failed to delete file system {0}".format(module.params['name'])) if module.params['eradicate']: try: array.delete_file_systems(names=[module.params['name']]) except Exception: module.fail_json(msg="Eradication of file system {0} failed".format(module.params['name'])) module.exit_json(changed=changed)