4
This guide is intended to give users a basic idea of REST Client usage
11
You should already have the Pure Storage FlashArray REST Client installed.
13
This includes installing REST Client package dependencies.
15
See :doc:`installation` for more information.
21
To verify the REST Client package is installed and importable, try executing
22
the following in a Python interpreter:
24
.. code-block:: python
26
>>> import purestorage
29
If that succeeds without an ImportError, you are ready to start a REST session
32
REST sessions are automatically established when a FlashArray object is
33
instantiated. To instantiate a FlashArray object, provide the IP address
34
or domain name of the target array as well as a username and password, or
37
.. code-block:: python
39
>>> array = purestorage.FlashArray("localhost", "pureuser", "pureuser")
42
.. code-block:: python
44
>>> array = purestorage.FlashArray("localhost",
45
api_token="6e1b80a1-cd63-de90-b74a-7fc16d034016")
48
.. code-block:: python
50
from purestorage import FlashArray
52
array = FlashArray("localhost", "pureuser", "pureuser")
53
array_info = array.get()
54
print "FlashArray {} (version {}) REST session established!".format(
55
array_info['array_name'], array_info['version'])
58
To end a session, invalidate your REST cookie:
60
.. code-block:: python
62
array.invalidate_cookie()
65
Calling any other methods again creates a new cookie automatically.
71
When creating a volume, specify the volume name and a size.
73
Size can either be an integer or a string with an optional suffix.
75
.. code-block:: python
77
>>> array.create_volume("vol1", 1024 ** 3)
80
u'serial': u'DABA29111570F7A4000114C0',
83
u'created': u'2014-08-11T17:19:35Z'
85
>>> array.create_volume("vol2", "5M")
88
u'serial': u'DABA29111570F7A4000114C1',
91
u'created': u'2014-08-11T17:19:51Z'
95
Creating Hosts and Hgroups
96
--------------------------
98
Host creation requires a name only.
100
Optionally IQNs or WWNs can be specified during creation, or they can
101
be set for a particular host after creating.
103
Similarly, hgroup creation requires a name only and hosts can be
104
added to the hgroup as part of creation or in a subsequent set call.
106
.. code-block:: python
108
>>> array.create_host("host1", iqnlist=["iqn.2001-04.com.example:diskarrays-sn-a8675308",
109
"iqn.2001-04.com.example:diskarrays-sn-a8675309"])
111
u'iqn': [u'iqn.2001-04.com.example:diskarrays-sn-a8675308', u'iqn.2001-04.com.example:diskarrays-sn-a8675309'],
115
>>> array.create_host("host2")
122
>>> array.set_host("host2", wwnlist=["1234567812345678"])
125
u'wwn': [u'1234567812345678'],
129
>>> array.create_hgroup("hgroup1", hostlist=["host1", "host2"])
131
u'hosts': [u'host1', u'host2'],
139
When connecting volumes to hosts and hgroups, just specify the volume name
140
and the name of the host or hgroup. LUNs may also be specified as optional
143
.. code-block:: python
145
>>> array.connect_host("host1", "vol1")
151
>>> array.connect_hgroup("hgroup1", "vol2")
157
>>> array.list_host_connections("host1")
169
u'hgroup': u'hgroup1'
172
>>> array.list_hgroup_connections("hgroup1")
183
Snapshots can be taken of individual volumes or collections of volumes. Snapshots
184
of more than one volume are guaranteed to be point in time consistent.
186
Snapshots (or volumes) can be copied out to new volumes.
188
.. code-block:: python
190
>>> array.create_snapshot("vol2")
193
u'serial': u'DABA29111570F7A4000115A3',
195
u'name': u'vol2.5539',
196
u'created': u'2014-08-15T17:21:22Z'
198
>>> array.create_snapshots(["vol1", "vol2"], suffix="together")
202
u'serial': u'DABA29111570F7A4000115A4',
204
u'name': u'vol1.together',
205
u'created': u'2014-08-15T17:21:58Z'
209
u'serial': u'DABA29111570F7A4000115A5',
211
u'name': u'vol2.together',
212
u'created': u'2014-08-15T17:21:58Z'
215
>>> array.copy_volume("vol1.together", "vol3")
218
u'serial': u'DABA29111570F7A4000115A6',
221
u'created': u'2014-08-15T17:21:58Z'
223
>>> array.list_volumes(snap=True)
227
u'serial': u'DABA29111570F7A4000115A4',
229
u'name': u'vol1.together',
230
u'created': u'2014-08-15T17:21:58Z'
234
u'serial': u'DABA29111570F7A4000115A5',
236
u'name': u'vol2.together',
237
u'created': u'2014-08-15T17:21:58Z'
241
u'serial': u'DABA29111570F7A4000115A3',
243
u'name': u'vol2.5539',
244
u'created': u'2014-08-15T17:21:22Z'
249
Disconnecting and Destroying Volumes
250
------------------------------------
252
Volumes must be disconnected before they can be destroyed, just as hosts must
253
be disconnected before they can be deleted.
255
A destroyed volume may be recovered (for up to 24 hours following destruction)
256
or explicitly eradicated.
258
.. code-block:: python
260
>>> array.disconnect_host("host1", "vol1")
265
>>> array.destroy_volume("vol1")
269
>>> array.list_volumes(pending_only=True)
273
u'created': u'2014-08-15T17:13:08Z',
275
u'time_remaining': 86400,
276
u'serial': u'DABA29111570F7A4000115A1',
280
>>> array.recover_volume("vol1")
284
>>> array.rename_volume("vol1", "renamed")
288
>>> array.destroy_volume("renamed")
292
>>> array.eradicate_volume("renamed")
296
>>> array.list_volumes(pending_only=True)
300
Enable Secure HTTPS Requests
301
----------------------------
303
By default the requests being made will not verify the SSL certificate of the
304
target array. Requests made this way will log a InsecureRequestWarning.
306
To enable verification use the verify_https flag:
308
.. code-block:: python
310
>>> array = purestorage.FlashArray("localhost", "pureuser", "pureuser", verify_https=True)
313
This does require that the target array has a trusted certificate and will
314
be validated correctly by the system making the request.
316
If using an 'untrusted' certificate (e.g. self-signed certificate) you can
317
optionally pass in a path to the certificate file:
319
.. code-block:: python
321
>>> array = purestorage.FlashArray("localhost", "pureuser", "pureuser", verify_https=True,
322
ssl_cert="/etc/ssl/certs/pure-self-signed.crt")