Client for Purity//FB REST API 1.0, developed by Pure Storage, Inc. Documentations can be found at purity-fb.readthedocs.io.
This Python package is automatically generated by the Swagger Codegen project:
- API version: 1.0
- Package version: 1.0
- Build package: io.swagger.codegen.languages.PythonClientCodegen For more information, please visit http://www.purestorage.com
Python 2.7 and 3.4+
There are two ways to use pip to install.
The first is the easiest, i.e., using pypi:
pip install purity_fb
The second is to install from Github:
pip install git+https://github.com/purestorage/purity_fb_python_client.git
(you may need to run pip
with root permission: sudo pip install git+https://github.com/purestorage/purity_fb_python_client.git
)
Then import the package:
import purity_fb
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import purity_fb
Please follow the installation procedure and then run the following:
from purity_fb import PurityFb, FileSystem, SnapshotSuffix, rest
# create PurityFb object for a certain array
fb = PurityFb("10.255.8.20")
fb.disable_verify_ssl() # this is required because Purity//FB 2.1 only supports self-signed certificate
try:
fb.login("T-e7e551be-fe5d-4669-baf5-670cd8ea0560")
fs_obj = FileSystem(name="myfs", provisioned=50000)
fb.file_systems.create_file_systems(fs_obj)
fb.file_systems.list_file_systems()
fb.file_system_snapshots.create_file_system_snapshots(sources=["myfs"], suffix=SnapshotSuffix("mysnap"))
fb.file_system_snapshots.list_file_system_snapshots()
fb.logout()
except rest.ApiException as e:
print("Exception: %s\n" % e)
A PurityFb object represents a FlashBlade device.
class purity_fb.PurityFb(host)
The argument host is required, which is the IP address or host name of the device,
Two methods are provided for logging into and out from a device.
Method | Parameters | Description |
---|---|---|
disable_verify_ssl | n/a | Disable certificate verification for SSL. This method must be executed before calling login. |
login | api_token | Login to the REST server with a specified api-token. This method must be executed successfully before making any function calls to any APIs. |
logout | n/a | Logout from the REST server |
Note: Purity//FB 2.1 doesn't support configuring certificates. It uses a self signed certificate. Using a self-signed certificate will result in the following error:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
Therefore, it is required to call disable_verify_ssl before making any other function calls. Once SSL verification is disabled, there will be warnings like the following:
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.20-py3.6.egg/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
These warnings could be disabled using urllib3.disable_warnings.
Once login succeeds, different endpoints could be accessed through the following read-only properties of PurityFb objects.
Property | Type | Descripstion |
---|---|---|
file_systems | FileSystemsApi | API for the file system endpoint (create, list, and update) |
file_systems_beta | FileSystemsBetaApi | API for the beta file system endpoint (delete only) |
file_system_snapshots | FileSystemSnapshotsApi | API for the file system snapshots endpoint (create and list) |
file_system_snapshots_beta | FileSystemSnapshotsBetaApi | API for the beta file system snapshots endpoint (delete only) |
Every method of each endpoint returns an object representing the body of the response from the server.
If other information such as response status code or response header is needed, the corresponding method
XXX_with_http_info()
can be used.
For example,
fb = purity_fb.PurityFb("10.255.3.20")
fb.disable_verify_ssl()
fb.login("T-1eeb15b4-1288-49b2-b0cc-5a7c9e5d524f")
data = fb.file_systems.create_file_systems(FileSystem(name="myfs"))
Here response_data has type FileSystemResponse. And if call with HTTP information, both the response status and header will be returned as well.
(data, status, header) = fb.file_systems.create_file_systems_with_http_info(FileSystem(name="myfs"))
The property PurityFb.request_timeout allows one to get or update the global request timeout used by default for all API calls. The default request_timeout is 10 seconds for connection, and 30 seconds for read.
Property | Type | Descripstion |
---|---|---|
request_timeout | urllib3.Timeout | Set or get the global request timeout for accessing the device. |
For example, fb.request_timeout = urllib3.Timeout(connect=8.0, read=20.0)
. This updates all API call to have 8 seconds connection
timeout and 20 seconds read timeout by default.
All APIs support the keyword parameter _request_timeout (of type urllib3.Timeout ) to specify request timeout for a specific API call.
For example,
fb.file_systems.create_file_systems(FileSystem(name="myfs"), _request_timeout=urllib3.Timeout(connect=5.0, read=15.0))}}
The property PurityFb.request_retry allows one to get or update the global retry setting used by default for all API calls. The default request_retry is 5 retries per call.
Property | Type | Descripstion |
---|---|---|
request_retry | urllib3.Retry | Set or get the global request timeout for accessing the device. |
For example, fb.request_retry = urllib3.Retry(total=20, connect=15, read=15)
. This updates all API call to have
at most 20 retries in total, among which at most 15 connection retries and at most 15 read retries.
- ErrorResponse
- FileSystem
- FileSystemResponse
- FileSystemSnapshot
- FileSystemSnapshotResponse
- LoginResponse
- NfsRule
- ObjectResponse
- PaginationInfo
- ProtocolRule
- PureError
- PureObject
- SnapshotSuffix
- Space
- Type: API key
- API key parameter name: api-token
- Location: URL query string
- Type: API key
- API key parameter name: x-auth-token
- Location: HTTP header