|
| 1 | +|sf-python-logo| SolidFire Python SDK |
| 2 | +===================================== |
| 3 | + |
| 4 | +Python SDK library for interacting with SolidFire Element API |
| 5 | + |
| 6 | +|pypy| |python| |format| |downloads| |license| |build| |
| 7 | + |
| 8 | +Current Release |
| 9 | +--------------- |
| 10 | + |
| 11 | +Version 1.4.0.271 |
| 12 | + |
| 13 | +Description |
| 14 | +----------- |
| 15 | + |
| 16 | +The SolidFire Python SDK is a collection of libraries that facilitate |
| 17 | +integration and orchestration between proprietary systems and |
| 18 | +third-party applications. The Python SDK allows developers to deeply |
| 19 | +integrate SolidFire system API with the Python programming language. The |
| 20 | +SolidFire Python SDK reduces the amount of additional coding time |
| 21 | +required for integration. |
| 22 | + |
| 23 | +Compatibility |
| 24 | +------------- |
| 25 | + |
| 26 | ++------------------------+---------------+ |
| 27 | +| Component | Version | |
| 28 | ++========================+===============+ |
| 29 | +| SolidFire Element OS | 7.0 - 9.1 | |
| 30 | ++------------------------+---------------+ |
| 31 | + |
| 32 | +Getting Help |
| 33 | +------------ |
| 34 | + |
| 35 | +If you have any questions or comments about this product, contact |
| 36 | +ng-sf-host-integrations-sdk@netapp.com or reach out to the online |
| 37 | +developer community at `ThePub <http://netapp.io>`__. Your feedback |
| 38 | +helps us focus our efforts on new features and capabilities. |
| 39 | + |
| 40 | +Documentation |
| 41 | +------------- |
| 42 | + |
| 43 | +`Latest Docs <https://pythonhosted.org/solidfire-sdk-python/>`__ |
| 44 | + |
| 45 | +`Release |
| 46 | +Notes <https://github.com/solidfire/solidfire-sdk-python/blob/master/NetApp_SolidFire_Python_SDK_Release_Notes.pdf>`__ |
| 47 | + |
| 48 | +Installation |
| 49 | +------------ |
| 50 | + |
| 51 | +**From PyPI** |
| 52 | + |
| 53 | +:: |
| 54 | + |
| 55 | + pip install solidfire-sdk-python |
| 56 | + |
| 57 | +**From Source** |
| 58 | + |
| 59 | +*Note*: It is recommended using |
| 60 | +`virtualenv <https://github.com/pypa/virtualenv>`__ for isolating the |
| 61 | +python environment to only the required libraries. |
| 62 | + |
| 63 | +Alternatively, for development purposes or to inspect the source, the |
| 64 | +following will work: |
| 65 | + |
| 66 | +:: |
| 67 | + |
| 68 | + git clone git@github.com:solidfire/solidfire-sdk-python.git |
| 69 | + cd solidfire-sdk-python |
| 70 | + git checkout develop |
| 71 | + pip install -e ".[dev, test, docs, release]" |
| 72 | + python setup.py install |
| 73 | + |
| 74 | +Then append the location of this directory to the ``PYTHONPATH`` |
| 75 | +environment variable to use the SDK in other python scripts: |
| 76 | + |
| 77 | +:: |
| 78 | + |
| 79 | + export PYTHONPATH=$PYTHONPATH:/path/to/sf-python-sdk/ |
| 80 | + |
| 81 | +That's it -- you are ready to start interacting with your SolidFire |
| 82 | +cluster using Python! |
| 83 | + |
| 84 | +Examples |
| 85 | +-------- |
| 86 | + |
| 87 | +Step 1 - Build an `Element <https://pythonhosted.org/solidfire-sdk-python/solidfire.html#solidfire.Element>`__ object using the factory |
| 88 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 89 | + |
| 90 | +This is the preferred way to construct the |
| 91 | +`Element <https://pythonhosted.org/solidfire-sdk-python/solidfire.html#solidfire.Element>`__ |
| 92 | +object. The factory will make a call to the SolidFire cluster using the |
| 93 | +credentials supplied to test the connection. It will also set the |
| 94 | +version to communicate with based on the highest number supported by the |
| 95 | +SDK and Element OS. Optionally, you can choose to set the version |
| 96 | +manually and whether or not to verify SSL. Read more about it in the |
| 97 | +`ElementFactory <https://pythonhosted.org/solidfire-sdk-python/solidfire.html#solidfire.factory.ElementFactory>`__ documentation. |
| 98 | + |
| 99 | +.. code-block:: python |
| 100 | +
|
| 101 | + from solidfire.factory import ElementFactory |
| 102 | +
|
| 103 | + # Use ElementFactory to get a SolidFireElement object. |
| 104 | + sfe = ElementFactory.create("ip-address-of-cluster", "username", "password") |
| 105 | +
|
| 106 | +Step 2 - Call the API method and retrieve the result |
| 107 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 108 | + |
| 109 | +All service methods in SolidFireElement call API endpoints and they all |
| 110 | +return result objects. The naming convention is :code:`[method_name]_result`. |
| 111 | +For example, :code:`list_accounts` returns a :code:`list_accounts_result` object |
| 112 | +which has a property called :code:`accounts` that can be iterated. |
| 113 | + |
| 114 | +This example sends a request to list accounts then pulls the first account |
| 115 | +from the :code:`add_account_result` object. |
| 116 | + |
| 117 | +.. code-block:: python |
| 118 | +
|
| 119 | + # Send the request and wait for the result then pull the AccountID |
| 120 | + list_accounts_result = sfe.list_accounts() |
| 121 | + account = list_accounts_result.accounts[0]; |
| 122 | +
|
| 123 | +More examples using the Python SDK |
| 124 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 125 | + |
| 126 | +.. code-block:: python |
| 127 | +
|
| 128 | + from solidfire.factory import ElementFactory |
| 129 | +
|
| 130 | + # Create connection to SF Cluster |
| 131 | + sfe = ElementFactory.create("ip-address-of-cluster", "username", "password") |
| 132 | +
|
| 133 | + # --------- EXAMPLE 1 - CREATE AN ACCOUNT ----------- |
| 134 | + # Send the request with required parameters and gather the result |
| 135 | + add_account_result = sfe.add_account(username="example-account") |
| 136 | + # Pull the account ID from the result object |
| 137 | + account_id = add_account_result.account_id |
| 138 | +
|
| 139 | + # --------- EXAMPLE 2 - CREATE A VOLUME ------------- |
| 140 | + # Send the request with required parameters and gather the result |
| 141 | + create_volume_result = sfe.create_volume(name="example-volume", |
| 142 | + account_id=account_id, |
| 143 | + total_size=1000000000, |
| 144 | + enable512e=False) |
| 145 | + # Pull the VolumeID off the result object |
| 146 | + volume_id = create_volume_result.volume_id |
| 147 | +
|
| 148 | + # --------- EXAMPLE 3 - LIST ONE VOLUME FOR AN ACCOUNT ------------- |
| 149 | + # Send the request with desired parameters and pull the first volume in the |
| 150 | + # result |
| 151 | + volume = sfe.list_volumes(accounts=[account_id], limit=1).volumes[0] |
| 152 | + # pull the iqn from the volume |
| 153 | + iqn = volume.iqn |
| 154 | +
|
| 155 | + # --------- EXAMPLE 3 - MODIFY A VOLUME ------------- |
| 156 | + # Send the request with the desired parameters |
| 157 | + sfe.modify_volume(volume_id=volume_id, total_size=2000000000) |
| 158 | +
|
| 159 | +More Examples |
| 160 | +------------- |
| 161 | + |
| 162 | +More specific examples are available `here <https://github.com/solidfire/solidfire-sdk-python/blob/master/examples/examples.rst>`__ |
| 163 | + |
| 164 | +Logging |
| 165 | +------- |
| 166 | + |
| 167 | +To configure logging responses, execute the following: |
| 168 | + |
| 169 | +.. code-block:: python |
| 170 | +
|
| 171 | + import logging |
| 172 | + from solidfire import common |
| 173 | + common.setLogLevel(logging.DEBUG) |
| 174 | +
|
| 175 | +To access the logger for the Element instance: |
| 176 | + |
| 177 | +.. code-block:: python |
| 178 | +
|
| 179 | + from solidfire.common import LOG |
| 180 | +
|
| 181 | +Timeouts |
| 182 | +-------- |
| 183 | + |
| 184 | +Connection timeout (useful for failing fast when a host becomes |
| 185 | +unreachable): |
| 186 | + |
| 187 | +.. code-block:: python |
| 188 | +
|
| 189 | + from solidfire.factory import ElementFactory |
| 190 | + sfe = ElementFactory.create("ip-address-of-cluster", "username", "password") |
| 191 | + sfe.timeout(600) |
| 192 | +
|
| 193 | +Read timeout (useful for extending time for a service call to return): |
| 194 | + |
| 195 | +.. code-block:: python |
| 196 | +
|
| 197 | + from solidfire.factory import ElementFactory |
| 198 | + sfe = ElementFactory.create("ip-address-of-cluster", "username", "password") |
| 199 | + sf.read_timeout(600) |
| 200 | +
|
| 201 | +**License** |
| 202 | +----------- |
| 203 | + |
| 204 | +Copyright © 2016, 2017 NetApp, Inc. All rights reserved. |
| 205 | + |
| 206 | +Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 207 | +not use this file except in compliance with the License. You may obtain |
| 208 | +a copy of the License at |
| 209 | + |
| 210 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 211 | + |
| 212 | +Unless required by applicable law or agreed to in writing, software |
| 213 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 214 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 215 | +See the License for the specific language governing permissions and |
| 216 | +limitations under the License. |
| 217 | + |
| 218 | +.. |sf-python-logo| image:: https://raw.githubusercontent.com/solidfire/solidfire-sdk-python/release1.1/img/python-50.png |
| 219 | +.. |pypy| image:: https://img.shields.io/pypi/v/solidfire-sdk-python.svg |
| 220 | + :target: https://badge.fury.io/py/solidfire-sdk-python |
| 221 | +.. |python| image:: https://img.shields.io/pypi/pyversions/solidfire-sdk-python.svg |
| 222 | + :target: https://pypi.python.org/pypi/solidfire-sdk-python/ |
| 223 | +.. |format| image:: https://img.shields.io/pypi/format/solidfire-sdk-python.svg |
| 224 | + :target: https://pypi.python.org/pypi/solidfire-sdk-python/ |
| 225 | +.. |downloads| image:: https://img.shields.io/pypi/dm/solidfire-sdk-python.svg |
| 226 | + :target: https://pypi.python.org/pypi/solidfire-sdk-python/ |
| 227 | +.. |license| image:: https://img.shields.io/pypi/l/solidfire-sdk-python.svg |
| 228 | + :target: https://pypi.python.org/pypi/solidfire-sdk-python/ |
| 229 | +.. |build| image:: https://img.shields.io/travis/solidfire/solidfire-sdk-python/release/1.0.0.svg |
| 230 | + :target: https://pypi.python.org/pypi/solidfire-sdk-python/ |
| 231 | + |
0 commit comments