|
| 1 | +#!/usr/bin/python |
| 2 | +# module_check: supported |
| 3 | + |
| 4 | +# Copyright 2021 VMware, Inc. All rights reserved. VMware Confidential |
| 5 | +# SPDX-License-Identifier: Apache License 2.0 |
| 6 | + |
| 7 | +from __future__ import (absolute_import, division, print_function) |
| 8 | +__metaclass__ = type |
| 9 | + |
| 10 | +ANSIBLE_METADATA = {'metadata_version': '1.1', |
| 11 | + 'status': ['preview'], |
| 12 | + 'supported_by': 'community'} |
| 13 | + |
| 14 | +DOCUMENTATION = ''' |
| 15 | +--- |
| 16 | +module: avi_upgradeprofile |
| 17 | +author: Gaurav Rastogi (@grastogi23) <[email protected]> |
| 18 | +short_description: Module for setup of UpgradeProfile Avi RESTful Object |
| 19 | +description: |
| 20 | + - This module is used to configure UpgradeProfile object |
| 21 | + - more examples at U(https://github.com/avinetworks/devops) |
| 22 | +options: |
| 23 | + state: |
| 24 | + description: |
| 25 | + - The state that should be applied on the entity. |
| 26 | + default: present |
| 27 | + choices: ["absent", "present"] |
| 28 | + type: str |
| 29 | + avi_api_update_method: |
| 30 | + description: |
| 31 | + - Default method for object update is HTTP PUT. |
| 32 | + - Setting to patch will override that behavior to use HTTP PATCH. |
| 33 | + default: put |
| 34 | + choices: ["put", "patch"] |
| 35 | + type: str |
| 36 | + avi_api_patch_op: |
| 37 | + description: |
| 38 | + - Patch operation to use when using avi_api_update_method as patch. |
| 39 | + choices: ["add", "replace", "delete", "remove"] |
| 40 | + type: str |
| 41 | + avi_patch_path: |
| 42 | + description: |
| 43 | + - Patch path to use when using avi_api_update_method as patch. |
| 44 | + type: str |
| 45 | + avi_patch_value: |
| 46 | + description: |
| 47 | + - Patch value to use when using avi_api_update_method as patch. |
| 48 | + type: str |
| 49 | + controller: |
| 50 | + description: |
| 51 | + - List of controller upgrade related configurable parameters. |
| 52 | + - Field introduced in 31.1.1. |
| 53 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 54 | + type: dict |
| 55 | + dry_run: |
| 56 | + description: |
| 57 | + - List of dryrun related configurable parameters. |
| 58 | + - Field introduced in 31.1.1. |
| 59 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 60 | + type: dict |
| 61 | + image: |
| 62 | + description: |
| 63 | + - List of image related configurable parameters. |
| 64 | + - Field introduced in 31.1.1. |
| 65 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 66 | + type: dict |
| 67 | + pre_checks: |
| 68 | + description: |
| 69 | + - List of upgrade pre-checks related configurable parameters. |
| 70 | + - Field introduced in 31.1.1. |
| 71 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 72 | + type: dict |
| 73 | + service_engine: |
| 74 | + description: |
| 75 | + - List of service engine upgrade related configurable parameters. |
| 76 | + - Field introduced in 31.1.1. |
| 77 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 78 | + type: dict |
| 79 | + url: |
| 80 | + description: |
| 81 | + - Avi controller URL of the object. |
| 82 | + type: str |
| 83 | + uuid: |
| 84 | + description: |
| 85 | + - Uuid identifier for the upgradeprofile object. |
| 86 | + - Field introduced in 31.1.1. |
| 87 | + - Allowed with any value in enterprise, enterprise with cloud services edition. |
| 88 | + type: str |
| 89 | +extends_documentation_fragment: |
| 90 | + - vmware.alb.avi |
| 91 | +''' |
| 92 | + |
| 93 | +EXAMPLES = """ |
| 94 | +- hosts: all |
| 95 | + vars: |
| 96 | + avi_credentials: |
| 97 | + username: "admin" |
| 98 | + password: "something" |
| 99 | + controller: "192.168.15.18" |
| 100 | + api_version: "21.1.1" |
| 101 | +
|
| 102 | +- name: Example to create UpgradeProfile object |
| 103 | + vmware.alb.avi_upgradeprofile: |
| 104 | + avi_credentials: "{{ avi_credentials }}" |
| 105 | + state: present |
| 106 | + name: sample_upgradeprofile |
| 107 | +""" |
| 108 | + |
| 109 | +RETURN = ''' |
| 110 | +obj: |
| 111 | + description: UpgradeProfile (api/upgradeprofile) object |
| 112 | + returned: success, changed |
| 113 | + type: dict |
| 114 | +''' |
| 115 | + |
| 116 | +from ansible.module_utils.basic import AnsibleModule |
| 117 | +try: |
| 118 | + from ansible_collections.vmware.alb.plugins.module_utils.utils.ansible_utils import ( |
| 119 | + avi_common_argument_spec, avi_ansible_api) |
| 120 | + HAS_REQUESTS = True |
| 121 | +except ImportError: |
| 122 | + HAS_REQUESTS = False |
| 123 | + |
| 124 | + |
| 125 | +def main(): |
| 126 | + argument_specs = dict( |
| 127 | + state=dict(default='present', |
| 128 | + choices=['absent', 'present']), |
| 129 | + avi_api_update_method=dict(default='put', |
| 130 | + choices=['put', 'patch']), |
| 131 | + avi_api_patch_op=dict(choices=['add', 'replace', 'delete', 'remove']), |
| 132 | + avi_patch_path=dict(type='str',), |
| 133 | + avi_patch_value=dict(type='str',), |
| 134 | + controller=dict(type='dict',), |
| 135 | + dry_run=dict(type='dict',), |
| 136 | + image=dict(type='dict',), |
| 137 | + pre_checks=dict(type='dict',), |
| 138 | + service_engine=dict(type='dict',), |
| 139 | + url=dict(type='str',), |
| 140 | + uuid=dict(type='str',), |
| 141 | + ) |
| 142 | + argument_specs.update(avi_common_argument_spec()) |
| 143 | + module = AnsibleModule( |
| 144 | + argument_spec=argument_specs, supports_check_mode=True) |
| 145 | + if not HAS_REQUESTS: |
| 146 | + return module.fail_json(msg=( |
| 147 | + 'Python requests package is not installed. ' |
| 148 | + 'For installation instructions, visit https://pypi.org/project/requests.')) |
| 149 | + return avi_ansible_api(module, 'upgradeprofile', |
| 150 | + set()) |
| 151 | + |
| 152 | + |
| 153 | +if __name__ == '__main__': |
| 154 | + main() |
0 commit comments