API Reference¶
schtob.pyontapi.NaFiler - Single Filer Connection¶
After creating a schtob.pyontapi.NaFiler object, it automatically invokes the API command system-get-ontapi-version on the filer to determine the API version.
Afterwards, some API commands are invoked to get all available API commands in order to dynamically create a python method for each API command on your storage system.
Using the API commands¶
Changed in version 0.2.1.
The API commands are wrapped into command packages which are added to the schtob.pyontapi.NaFiler instance as instance attributes.
If you want to know which API commands are available on your filer, read the original NetApp documentation or instantiate a new filer object in an interactive python shell (we recommend to use Ipython) like this and hit TAB:
>>> from schtob.pyontapi import NaFiler, errors
>>> filer = NaFiler('filer-name', {'user': 'root', 'password': 'foobar'})
>>> filer.<HIT TAB>
This will give you all available command packages (like snapshot or nfs).
You can get even more information about your desired command using the help() function:
>>> help(filer.snapshot.list_info)
This example shows you how to use a filer instance:
>>> from schtob.pyontapi import NaFiler, errors
>>> filer = NaFiler('filer-name', {'user': 'root', 'password': 'foobar'})
>>> try:
... result = filer.volume.list_info()
... except errors.APIFailure, exc:
... print exc.get_error()
...
>>> print result['volumes']
Another example showing how to get all snapshots for volume vol0:
>>> from schtob.pyontapi import NaFiler, errors
>>> filer = NaFiler('filer-name', {'user': 'root', 'password': 'foobar'})
>>> try:
... result = filer.snapshot.list_info(volume='vol0')
... except errors.APIFailure, exc:
... print exc.get_error()
...
>>> print result['snapshots']
[{'access-time': 1292425201,
'cumulative-percentage-of-used-blocks': 1,
'cumulative-total': 6996,
'name': 'hourly.0',
'percentage-of-used-blocks': 1,
'total': 6996}]
A more advanced command for modifying NFS exports:
>>> from schtob.pyontapi import NaFiler, errors
>>> filer = NaFiler('filer-name', {'user': 'root', 'password': 'foobar'})
>>> try:
... result = filer.nfs.exportfs_modify_rule(persistent=False, rule={
... 'pathname': '/vol/vol0',
... 'read-write': [{'all-hosts':True}],
... 'root': [{'name':'my-machine-name'}]
... })
... print "rule successfully modified"
... except errors.APIFailure, exc:
... print exc.get_error()
... return False
API reference¶
- class schtob.pyontapi.NaFiler(filer, settings=None)¶
Create a new connection to filer filer using settings dict.
settings may consist of the following entries:
Key Default Possible values user “root” str password “” str style LOGIN LOGIN, HOSTS, CERTIFICATE vfiler “” str server_type “Filer” “Filer”, “NetCache”, “DFM”, “Agent” transport_type HTTP HTTP, HTTPS port None int url None str cert_file “” Path to Cert file key_file “” Path to Key file ca_file “” Path to Key file cert_required False bool verify_cn False bool cmd_list ‘None’ ‘list of api_commands’ - call(api_command_name, **kwargs)¶
Invoke api_command_name using kwargs as arguments.
New in version 0.2.5.
- get_api_module(package_name)¶
Get API class for package_name.
- get_api_modules()¶
Get all API classes as a dictionary of package_name: api_class.
schtob.pyontapi.Filers - Multi-Filer Support¶
This class is intended to be used for handling a bunch of schtob.pyontapi.NaFiler objects in an environment where you have a single user, which is allowed to run API commands on all your filers. Instead of manually creating multiple schtob.pyontapi.NaFiler objects, you can use the schtob.pyontapi.Filers class which encapsulates all the required connection and authentication settings for each filer. The only thing you have to do is defining the NA_CONFIG dict in schtob.pyontapi.settings. See Multi-Filer configuration for more details.
Usage¶
Once you have defined the NA_CONFIG dict, you can access a schtob.pyontapi.NaFiler object using the schtob.pyontapi.Filers class like this:
>>> from schtob.pyontapi import Filers, errors
>>> try:
... result = Filers('filer-name').system.get_ontapi_version()
... except errors.APIFailure, exc:
... print exc.get_error()
...
>>> print result
{'major-version': 1, 'minor-version': 9}
API reference¶
- class schtob.pyontapi.Filers¶
Connections to multiple filers.
Use it in a static way like this:
>>> Filers('my-filer').volume.list_info()
- classmethod create_connection(name, settings, role='default')¶
Create a connection to filer name with settings.
Use this to instantiate a “special” connection where settings differ from NA_CONFIG instead of just using Filers(name).
New in version 0.2.2: The role parameter was added.
- classmethod drop_connection(name, role='default')¶
Drops connection to filer name.
- classmethod get_connection(name, role='default')¶
Get connection to filer name.
New in version 0.2.2: The role parameter was added.
- classmethod setup_config(config)¶
Setup the configuration for all your Filers.
New in version 0.2.2.