Examples¶
Create a snapshot¶
>>> def create_snapshot(filer_name, volume_name, snapshot_name):
... from schtob.pyontapi import Filers, errors
... try:
... result = Filers(filer_name).snapshot.create(snapshot=snapshot_name,
... volume=volume_name
... )
... return True
... except errors.APIFailure, exc:
... print exc
... return False
...
>>> print create_snapshot('my-filer', 'vol0', 'snap1')
True
Listing snapshots¶
>>> def list_snapshot(filer_name, volume_name):
... from schtob.pyontapi import Filers, errors
... try:
... result = Filers(filer_name).snapshot.list_info(volume=volume_name)
... return result['snapshots']
... except errors.APIFailure, exc:
... print exc
... return False
...
>>> result = list_snapshot('my-filer', 'vol0')
>>> print result
[{'name': 'hourly.0',
'access-time': 1293015631,
'cumulative-percentage-of-used-blocks': 1,
'percentage-of-used-blocks': 1,
'total': 5420,
'cumulative-total': 5420}]}
Delete a snapshot¶
>>> def delete_snapshot(filer_name, volume_name, snapshot_name):
... from schtob.pyontapi import Filers, errors
... try:
... result = Filers(filer_name).snapshot.delete(snapshot=snapshot_name,
... volume=volume_name
... )
... return True
... except errors.APIFailure, exc:
... print exc
... return False
...
>>> print delete_snapshot('my-filer', 'vol0', 'snap1')
True
Modify a NFS export¶
>>> def modify_rule(filer_name, volume_name, machine_name):
... from schtob.pyontapi import Filers, errors
... try:
... result = Filers(filer_name).nfs.exportfs_modify_rule(
... persistent=False,
... rule={
... 'pathname': volume_name,
... 'read-write': [{'all-hosts':True}],
... 'root': [{'name':machine_name}]
... })
... return True
... except errors.APIFailure, exc:
... print exc
... return False