|
13 | 13 | from distutils.version import LooseVersion
|
14 | 14 |
|
15 | 15 | # The current version of this library.
|
16 |
| -VERSION = "1.18.0" |
| 16 | +VERSION = "1.19.0" |
17 | 17 |
|
18 | 18 |
|
19 | 19 | class FlashArray(object):
|
@@ -89,6 +89,7 @@ class FlashArray(object):
|
89 | 89 | """
|
90 | 90 |
|
91 | 91 | supported_rest_versions = [
|
| 92 | + "1.19", |
92 | 93 | "1.18",
|
93 | 94 | "1.17",
|
94 | 95 | "1.16",
|
@@ -166,7 +167,10 @@ def _request(self, method, path, data=None, reestablish_session=True):
|
166 | 167 | except requests.exceptions.RequestException as err:
|
167 | 168 | # error outside scope of HTTP status codes
|
168 | 169 | # e.g. unable to resolve domain name
|
169 |
| - raise PureError(err.message) |
| 170 | + try: |
| 171 | + raise PureError(err.message) |
| 172 | + except: |
| 173 | + raise PureError(err) |
170 | 174 |
|
171 | 175 | if response.status_code == 200:
|
172 | 176 | if "application/json" in response.headers.get("Content-Type", ""):
|
@@ -491,6 +495,62 @@ def create_conglomerate_volume(self, volume):
|
491 | 495 | """
|
492 | 496 | return self._request("POST", "volume/{0}".format(volume), {"protocol_endpoint": True})
|
493 | 497 |
|
| 498 | + def add_tag_to_volume(self, volume, key, value, **kwargs): |
| 499 | + """Add tag to volume and return a dictionary describing it. |
| 500 | +
|
| 501 | + :param volume: Name of the volume to add tags to. |
| 502 | + :type volume: str |
| 503 | + :param key: The Key to a key-value pair of the tag to add to a volume |
| 504 | + :type volume: str |
| 505 | + :param key: The Value to a key-value pair of the tag to add to a volume |
| 506 | + :type volume: str |
| 507 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 508 | + documentation on the request: |
| 509 | + **POST volume/:volume/tags** |
| 510 | +
|
| 511 | + :returns: A dictionary describing the tags added to the volume. |
| 512 | + :rtype: ResponseDict |
| 513 | +
|
| 514 | + .. note:: |
| 515 | +
|
| 516 | + Add key/value pairs to a volume. |
| 517 | +
|
| 518 | + .. note:: |
| 519 | +
|
| 520 | + Requires use of REST API 1.19 or later. |
| 521 | +
|
| 522 | + """ |
| 523 | + data = {"key": key, "value": value} |
| 524 | + data.update(kwargs) |
| 525 | + return self._request("POST", "volume/{0}/tags".format(volume), data) |
| 526 | + |
| 527 | + def remove_tag_from_volume(self, volume, key, **kwargs): |
| 528 | + """Remove a tag from a volume and return a dictionary describing it. |
| 529 | +
|
| 530 | + :param volume: Name of the volume. |
| 531 | + :type volume: str |
| 532 | + :param key: Name of the key to be deleted |
| 533 | + :type volume: str |
| 534 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 535 | + documentation on the request: |
| 536 | + **DELETE volume/:volume/tags** |
| 537 | +
|
| 538 | + :returns: A dictionary describing the tags added to the volume. |
| 539 | + :rtype: ResponseDict |
| 540 | +
|
| 541 | + .. note:: |
| 542 | +
|
| 543 | + Remove a key from the volume. |
| 544 | +
|
| 545 | + .. note:: |
| 546 | +
|
| 547 | + Requires use of REST API 1.19 or later. |
| 548 | +
|
| 549 | + """ |
| 550 | + data = {} |
| 551 | + data.update(kwargs) |
| 552 | + return self._request("DELETE", "volume/{0}/tags/{1}".format(volume, key), data) |
| 553 | + |
494 | 554 | def copy_volume(self, source, dest, **kwargs):
|
495 | 555 | """Clone a volume and return a dictionary describing the new volume.
|
496 | 556 |
|
@@ -3329,6 +3389,168 @@ def recover_pod(self, pod):
|
3329 | 3389 | """
|
3330 | 3390 | return self.set_pod(pod, action="recover")
|
3331 | 3391 |
|
| 3392 | + # |
| 3393 | + # nearsync methods |
| 3394 | + # |
| 3395 | + |
| 3396 | + def create_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs): |
| 3397 | + """Create replica-link. |
| 3398 | +
|
| 3399 | + :param local_pod_name: local pod name. |
| 3400 | + :type local_pod_name: str |
| 3401 | + :param remote_pod_name: remote pod name. |
| 3402 | + :type remote_pod_name: str |
| 3403 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3404 | + documentation on the request: |
| 3405 | + **POST pod/replica-link** |
| 3406 | +
|
| 3407 | + :returns: a dictionary describing the new replica-link |
| 3408 | + :rtype: ResponseDict |
| 3409 | +
|
| 3410 | + .. note:: |
| 3411 | +
|
| 3412 | + Requires use of REST API 1.19 or later. |
| 3413 | +
|
| 3414 | + """ |
| 3415 | + data = {"local_pod_name": local_pod_name, |
| 3416 | + "remote_pod_name": remote_pod_name} |
| 3417 | + data.update(kwargs) |
| 3418 | + return self._request("POST", "pod/replica-link", data) |
| 3419 | + |
| 3420 | + def delete_pod_replica_link(self, local_pod_name, remote_pod_name): |
| 3421 | + """Delete replica-link. |
| 3422 | +
|
| 3423 | + :param local_pod_name: local pod name. |
| 3424 | + :type local_pod_name: str |
| 3425 | + :param remote_pod_name: remote pod name. |
| 3426 | + :type remote_pod_name: str |
| 3427 | +
|
| 3428 | + :returns: a dictionary describing the deleted replica-link, contains two pod names of the replica-link |
| 3429 | + :rtype: ResponseDict |
| 3430 | +
|
| 3431 | + .. note:: |
| 3432 | +
|
| 3433 | + Requires use of REST API 1.19 or later. |
| 3434 | +
|
| 3435 | + """ |
| 3436 | + data = {"local_pod_name": local_pod_name, |
| 3437 | + "remote_pod_name": remote_pod_name} |
| 3438 | + |
| 3439 | + return self._request("DELETE", "pod/replica-link", data) |
| 3440 | + |
| 3441 | + def list_pod_replica_links(self, **kwargs): |
| 3442 | + """List replica-link. |
| 3443 | +
|
| 3444 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3445 | + documentation on the request: |
| 3446 | + **GET pod/replica-link** |
| 3447 | + :returns: a dictionary describing the replica-link |
| 3448 | + :rtype: ResponseDict |
| 3449 | +
|
| 3450 | + .. note:: |
| 3451 | +
|
| 3452 | + Requires use of REST API 1.19 or later. |
| 3453 | +
|
| 3454 | + """ |
| 3455 | + data = {} |
| 3456 | + if "local_pod_names" in kwargs and kwargs["local_pod_names"]: |
| 3457 | + local_pod_names = kwargs.get("local_pod_names") |
| 3458 | + builder = "" |
| 3459 | + for local_pod_name in local_pod_names: |
| 3460 | + builder = builder + local_pod_name + "," |
| 3461 | + builder = builder[:-1] |
| 3462 | + data = {"local_pod_names": builder} |
| 3463 | + data.update(kwargs) |
| 3464 | + return self._request("GET", "pod/replica-link", data) |
| 3465 | + |
| 3466 | + def _pause_resume_pod_replica_link(self, **kwargs): |
| 3467 | + data = {k: kwargs.get(k) for k in ("local_pod_name", "remote_pod_name", "remote_name", "paused") if kwargs.get(k)} |
| 3468 | + data.update(kwargs) |
| 3469 | + return self._request("PUT", "pod/replica-link", data) |
| 3470 | + |
| 3471 | + def pause_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs): |
| 3472 | + """Create replica-link. |
| 3473 | +
|
| 3474 | + :param local_pod_name: local pod name. |
| 3475 | + :type local_pod_name: str |
| 3476 | + :param remote_pod_name: remote pod name. |
| 3477 | + :type remote_pod_name: str |
| 3478 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3479 | + documentation on the request: |
| 3480 | + **PUT pod/replica-link** |
| 3481 | + :returns: a dictionary describing the replica-link |
| 3482 | + :rtype: ResponseDict |
| 3483 | +
|
| 3484 | + .. note:: |
| 3485 | +
|
| 3486 | + Requires use of REST API 1.19 or later. |
| 3487 | +
|
| 3488 | + """ |
| 3489 | + return self._pause_resume_pod_replica_link( |
| 3490 | + local_pod_name=local_pod_name, remote_pod_name=remote_pod_name, paused=True, **kwargs) |
| 3491 | + |
| 3492 | + def resume_pod_replica_link(self, local_pod_name, remote_pod_name, **kwargs): |
| 3493 | + """Resume replica-link. |
| 3494 | +
|
| 3495 | + :param local_pod_name: local pod name. |
| 3496 | + :type local_pod_name: str |
| 3497 | + :param remote_pod_name: remote pod name. |
| 3498 | + :type remote_pod_name: str |
| 3499 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3500 | + documentation on the request: |
| 3501 | + **PUT pod/replica-link** |
| 3502 | + :returns: a dictionary describing the replica-link |
| 3503 | + :rtype: ResponseDict |
| 3504 | +
|
| 3505 | + .. note:: |
| 3506 | +
|
| 3507 | + Requires use of REST API 1.19 or later. |
| 3508 | +
|
| 3509 | + """ |
| 3510 | + return self._pause_resume_pod_replica_link( |
| 3511 | + local_pod_name=local_pod_name, remote_pod_name=remote_pod_name, paused=False, **kwargs) |
| 3512 | + |
| 3513 | + def _promote_demote_pod(self, pod, **kwargs): |
| 3514 | + return self._request("PUT", "pod/{0}".format(pod), kwargs) |
| 3515 | + |
| 3516 | + def promote_pod(self, pod, **kwargs): |
| 3517 | + """Promote pod |
| 3518 | +
|
| 3519 | + :param pod: Name of pod to be promoted. |
| 3520 | + :type pod: str |
| 3521 | +
|
| 3522 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3523 | + documentation on the request: |
| 3524 | + **PUT pod** |
| 3525 | + :returns: a dictionary describing a pod |
| 3526 | + :rtype: ResponseDict |
| 3527 | +
|
| 3528 | + .. note:: |
| 3529 | +
|
| 3530 | + Requires use of REST API 1.19 or later. |
| 3531 | +
|
| 3532 | + """ |
| 3533 | + return self._promote_demote_pod(pod, requested_promotion_state="promoted", **kwargs) |
| 3534 | + |
| 3535 | + def demote_pod(self, pod, **kwargs): |
| 3536 | + """Demote pod |
| 3537 | + |
| 3538 | + :param pod: Name of pod to be demoted. |
| 3539 | + :type pod: str |
| 3540 | +
|
| 3541 | + :param \*\*kwargs: See the REST API Guide on your array for the |
| 3542 | + documentation on the request: |
| 3543 | + **PUT pod** |
| 3544 | + :returns: a dictionary describing a pod |
| 3545 | + :rtype: ResponseDict |
| 3546 | +
|
| 3547 | + .. note:: |
| 3548 | +
|
| 3549 | + Requires use of REST API 1.19 or later. |
| 3550 | +
|
| 3551 | + """ |
| 3552 | + return self._promote_demote_pod(pod, requested_promotion_state="demoted", **kwargs) |
| 3553 | + |
3332 | 3554 | #
|
3333 | 3555 | # SSL Certificate related methods.
|
3334 | 3556 | # Note: These methods are not supported before REST API 1.3.
|
|
0 commit comments