Filesystems

Creating a Filesystem

Creating filesystems is done with the create method:

>>> from capacity import GiB, GB
>>> my_fs = system.filesystems.create(pool=pool, name='my_fs', size=GiB)

Note

When a size is not explicitly stated, a default of 1 GiB is used. You can also provide the size explicitly:

>>> fs = system.filesystems.create(pool=pool, size=1*GiB)

It is also possible to create multiple filesystems with a single line, by calling create_many():

>>> filesystems = system.filesystems.create_many(pool=pool, name='fs', count=5)
>>> len(filesystems)
5
>>> for fs in filesystems:
...     print(fs.get_name())
fs_1
fs_2
fs_3
fs_4
fs_5

We can now access various attributes of the filesystem:

>>> print(my_fs.get_name())
my_fs
>>> my_fs.get_size()
1*GiB

Moving Between Pools

Use Filesystem.move_pool() to move a filesystem between pools:

>>> new_pool = system.pools.create()
>>> fs.move_pool(new_pool)

Resizing Filesystems

Use Filesystem.resize() to resize the filesystem by the given delta: .. code-block:: python

>>> fs.resize(delta=2*GB)

Deleting Filesystems

Deleting a filesystem is done with Filesystem.delete():

>>> fs.delete()

Example: Deleting All Filesystems with Specific Name Prefix

>>> for fs in system.filesystems:
...     if fs.get_name(from_cache=True).startswith('prefix'):
...         fs.delete()

Exports

Creating a Filesystem Export

A filesystem export is created with default settings and advanced setting. For a detailed documentation of these settings, Read more Here.

>>> export = fs.add_export()

We can now access and modify various attributes of the export:

>>> from capacity import MiB
>>> export.get_max_read()
1*MiB
>>> export.update_max_read(2*MiB)
>>> export.get_max_read()
2*MiB

Disabling an Export

Following this operation, the filesystem is not accessible by the user. The export path is not deleted, and can be enabled.

>>> export.disable()
>>> export.is_enabled()
False

Enabling an Export

>>> export.enable()
>>> export.is_enabled()
True

Querying for Filesystem Exports

Like other InfiniBox collections, InfiniSDK provides iteration and filtering abilty for exports.

>>> system.exports.count()
1

Export Permissions

Export permissions can be modified with Export.update_permissions().
This method overrides current permissions.

To preserve current permission settings, first use Export.get_permissions(), then update accordingly.
>>> from munch import Munch
>>> permissions = export.get_permissions()
>>> permissions[0] ==  Munch({'access': 'RW', 'no_root_squash': True, 'client': '*'})
True
>>> export.update_permissions(permissions +
...   [{'access': 'RO', 'client': '1.1.1.1', 'no_root_squash': True}])
>>> permissions = export.get_permissions()
>>> permissions[0] == Munch({'access': 'RW', 'no_root_squash': True, 'client': '*'})
True
>>> permissions[1] == Munch({'access': 'RO', 'no_root_squash': True, 'client': '1.1.1.1'})
True
>>> export.update_permissions([{'access': 'RW', 'client': '2.2.2.2', 'no_root_squash': True}])
>>> permissions = export.get_permissions()
>>> permissions[0] == Munch({'access': 'RW', 'no_root_squash': True, 'client': '2.2.2.2'})
True

Deleting an Export

Deleting an export is done with Export.delete():

>>> export.delete()