From b8fd3154396762563cf89585a78bfbd35671a544 Mon Sep 17 00:00:00 2001 From: wypior Date: Thu, 23 Nov 2023 07:16:37 +0000 Subject: [PATCH] Version 1.5.0 release --- .ansible-lint-ignore | 2 + .../f5networks/f5os/CHANGELOG.rst | 10 ++ .../f5os/changelogs/.plugin-cache.yaml | 2 +- .../f5networks/f5os/changelogs/changelog.yaml | 10 ++ .../f5networks/f5os/changelogs/config.yaml | 32 +++--- .../f5networks/f5os/galaxy.yml | 4 +- .../f5networks/f5os/plugins/httpapi/f5os.py | 29 +++++ .../f5os/plugins/module_utils/client.py | 4 + .../f5os/plugins/module_utils/teem.py | 4 +- .../f5os/plugins/module_utils/version.py | 2 +- .../plugins/modules/f5os_config_backup.py | 55 ++++------ .../f5os/plugins/modules/f5os_device_info.py | 45 +++----- .../f5os/plugins/modules/f5os_interface.py | 103 ++++++++---------- .../f5os/plugins/modules/f5os_lag.py | 97 +++++++---------- .../f5os/plugins/modules/f5os_tenant.py | 61 ++++------- .../f5os/plugins/modules/f5os_tenant_image.py | 53 ++++----- .../f5os/plugins/modules/f5os_tenant_wait.py | 43 +++----- .../f5os/plugins/modules/f5os_vlan.py | 41 +++---- .../f5os/plugins/modules/velos_partition.py | 39 +++---- .../velos_partition_change_password.py | 23 +--- .../plugins/modules/velos_partition_image.py | 57 ++++------ .../plugins/modules/velos_partition_wait.py | 40 +++---- .../f5/fixtures/rseries_software_version.json | 7 ++ .../f5/fixtures/velos_partition_version.json | 26 +++++ .../module_utils/network/f5/test_client.py | 4 +- .../module_utils/network/f5/test_teem.py | 54 ++++++++- .../f5os/tests/plugins/httpapi/test_f5os.py | 4 + 27 files changed, 422 insertions(+), 429 deletions(-) create mode 100644 .ansible-lint-ignore create mode 100644 ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/rseries_software_version.json create mode 100644 ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/velos_partition_version.json diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore new file mode 100644 index 0000000..fbf68be --- /dev/null +++ b/.ansible-lint-ignore @@ -0,0 +1,2 @@ +# This file contains ignores rule violations for ansible-lint +ansible_collections/f5networks/f5os/changelogs/changelog.yaml yaml[indentation] diff --git a/ansible_collections/f5networks/f5os/CHANGELOG.rst b/ansible_collections/f5networks/f5os/CHANGELOG.rst index 52febf1..7881823 100644 --- a/ansible_collections/f5networks/f5os/CHANGELOG.rst +++ b/ansible_collections/f5networks/f5os/CHANGELOG.rst @@ -5,6 +5,16 @@ F5Networks.F5OS Release Notes .. contents:: Topics +v1.5.0 +====== + +Minor Changes +------------- + +- client.py - added client property to return software version of the F5OS platform +- f5os.py - added code to fetch the software version of the F5OS platform +- teem.py - added a new field, f5SoftwareVersion to the teem data, and changed the field, F5OSPlatform to f5Platform + v1.4.0 ====== diff --git a/ansible_collections/f5networks/f5os/changelogs/.plugin-cache.yaml b/ansible_collections/f5networks/f5os/changelogs/.plugin-cache.yaml index e535ac7..86a0f80 100644 --- a/ansible_collections/f5networks/f5os/changelogs/.plugin-cache.yaml +++ b/ansible_collections/f5networks/f5os/changelogs/.plugin-cache.yaml @@ -78,4 +78,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.4.0 +version: 1.5.0 diff --git a/ansible_collections/f5networks/f5os/changelogs/changelog.yaml b/ansible_collections/f5networks/f5os/changelogs/changelog.yaml index e091fe2..9a86b4b 100644 --- a/ansible_collections/f5networks/f5os/changelogs/changelog.yaml +++ b/ansible_collections/f5networks/f5os/changelogs/changelog.yaml @@ -110,3 +110,13 @@ releases: fragments: - add-lag-info-f5os-device-info.yaml release_date: '2023-10-12' + 1.5.0: + changes: + minor_changes: + - client.py - added client property to return software version of the F5OS platform + - f5os.py - added code to fetch the software version of the F5OS platform + - teem.py - added a new field, f5SoftwareVersion to the teem data, and changed + the field, F5OSPlatform to f5Platform + fragments: + - teem-add-software-version-field.yaml + release_date: '2023-11-23' diff --git a/ansible_collections/f5networks/f5os/changelogs/config.yaml b/ansible_collections/f5networks/f5os/changelogs/config.yaml index 0f89c93..5c1c9a9 100644 --- a/ansible_collections/f5networks/f5os/changelogs/config.yaml +++ b/ansible_collections/f5networks/f5os/changelogs/config.yaml @@ -12,22 +12,22 @@ prelude_section_name: release_summary prelude_section_title: Release Summary sanitize_changelog: true sections: -- - major_changes - - Major Changes -- - minor_changes - - Minor Changes -- - breaking_changes - - Breaking Changes / Porting Guide -- - deprecated_features - - Deprecated Features -- - removed_features - - Removed Features (previously deprecated) -- - security_fixes - - Security Fixes -- - bugfixes - - Bugfixes -- - known_issues - - Known Issues + - - major_changes + - Major Changes + - - minor_changes + - Minor Changes + - - breaking_changes + - Breaking Changes / Porting Guide + - - deprecated_features + - Deprecated Features + - - removed_features + - Removed Features (previously deprecated) + - - security_fixes + - Security Fixes + - - bugfixes + - Bugfixes + - - known_issues + - Known Issues title: F5Networks.F5OS trivial_section_name: trivial use_fqcn: true diff --git a/ansible_collections/f5networks/f5os/galaxy.yml b/ansible_collections/f5networks/f5os/galaxy.yml index 0abe19f..86eb77a 100644 --- a/ansible_collections/f5networks/f5os/galaxy.yml +++ b/ansible_collections/f5networks/f5os/galaxy.yml @@ -11,10 +11,12 @@ license: name: f5os namespace: f5networks readme: README.md +build_ignore: + - tests repository: https://github.com/F5Networks/f5-ansible-f5os tags: - f5 - networking - rseries - velos -version: 1.4.0 +version: 1.5.0 diff --git a/ansible_collections/f5networks/f5os/plugins/httpapi/f5os.py b/ansible_collections/f5networks/f5os/plugins/httpapi/f5os.py index 5659715..ad858ea 100644 --- a/ansible_collections/f5networks/f5os/plugins/httpapi/f5os.py +++ b/ansible_collections/f5networks/f5os/plugins/httpapi/f5os.py @@ -49,6 +49,7 @@ def __init__(self, connection): self.connection = connection self.access_token = None self.platform_type = None + self.software_version = None def login(self, username, password): using_default_creds = (username == "admin") and (password == "admin") @@ -63,6 +64,7 @@ def login(self, username, password): self.connection._auth = {'X-Auth-Token': self.access_token} if not using_default_creds: self._set_platform_type() + self._set_software_version() else: raise AnsibleConnectionFailure('Server returned invalid response during connection authentication.') else: @@ -155,6 +157,33 @@ def _set_platform_type(self): def get_platform_type(self): return self.platform_type + def _rseries_software_version(self): + uri = ROOT + '/openconfig-system:system/f5-system-version:version' + response = self.send_request(path=uri, method='GET', headers=BASE_HEADERS) + if response['code'] != 200: + raise F5ModuleError(response['contents']) + version = response['contents']['f5-system-version:version']['os-version'] + return version + + def _velos_software_version(self): + uri = ROOT + '/openconfig-platform:components/component' + response = self.send_request(path=uri, method='GET', headers=BASE_HEADERS) + if response['code'] != 200: + raise F5ModuleError(response['contents']) + + res = response['contents'] + version = res['openconfig-platform:component'][0]['f5-platform:software']['state']['software-components']['software-component'][0]['state']['version'] + return version + + def _set_software_version(self): + if self.platform_type == 'Velos Partition': + self.software_version = self._velos_software_version() + elif self.platform_type == 'rSeries Platform': + self.software_version = self._rseries_software_version() + + def get_software_version(self): + return self.software_version + def _check_seek_raising(error): # small helper function to catch seek unsupported operation diff --git a/ansible_collections/f5networks/f5os/plugins/module_utils/client.py b/ansible_collections/f5networks/f5os/plugins/module_utils/client.py index b09c146..d601a56 100644 --- a/ansible_collections/f5networks/f5os/plugins/module_utils/client.py +++ b/ansible_collections/f5networks/f5os/plugins/module_utils/client.py @@ -68,6 +68,10 @@ def ansible_version(self): def module_name(self): return self.module._name + @property + def software_version(self): + return self.plugin.get_software_version() + def send_teem(client, start_time): """ Sends Teem Data if allowed.""" diff --git a/ansible_collections/f5networks/f5os/plugins/module_utils/teem.py b/ansible_collections/f5networks/f5os/plugins/module_utils/teem.py index 813925f..e65a18e 100644 --- a/ansible_collections/f5networks/f5os/plugins/module_utils/teem.py +++ b/ansible_collections/f5networks/f5os/plugins/module_utils/teem.py @@ -93,6 +93,7 @@ def build_telemetry(self): if 'f5networks' in module_name: module_name = module_name.split('.')[2] platform = self.f5client.platform + software_version = self.f5client.software_version ansible_version = self.f5client.ansible_version python_version = sys.version.split(' ', maxsplit=1)[0] self.in_ci, ci_name = in_cicd() @@ -101,7 +102,8 @@ def build_telemetry(self): 'CollectionName': f'{self.coll_name}', 'CollectionVersion': CURRENT_COLL_VERSION, 'CollectionModuleName': module_name, - 'F5OSPlatform': platform, + 'f5Platform': platform, + 'f5SoftwareVersion': software_version, 'ControllerAnsibleVersion': ansible_version, 'ControllerPythonVersion': python_version, 'ControllerAsDocker': self.docker, diff --git a/ansible_collections/f5networks/f5os/plugins/module_utils/version.py b/ansible_collections/f5networks/f5os/plugins/module_utils/version.py index 6aed906..f10b435 100644 --- a/ansible_collections/f5networks/f5os/plugins/module_utils/version.py +++ b/ansible_collections/f5networks/f5os/plugins/module_utils/version.py @@ -4,4 +4,4 @@ # GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # This collection version needs to be updated at each release -CURRENT_COLL_VERSION = "1.4.0" +CURRENT_COLL_VERSION = "1.5.0" diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_config_backup.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_config_backup.py index 4c70788..f2895bf 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_config_backup.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_config_backup.py @@ -80,40 +80,27 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Create backup config and import it to remote server - f5os_config_backup: - name: foo - remote_host: builds.mydomain.com - remote_path: /uploads/upload.php - timeout: 300 - state: present - - - name: Recreate existing backup file and upload it to remote server - f5os_config_backup: - name: foo - remote_host: builds.mydomain.com - remote_path: /uploads/upload.php - timeout: 300 - force: true - state: present - - - name: Remove backup file - f5os_config_backup: - name: foo - state: absent +- name: Create backup config and import it to remote server + f5os_config_backup: + name: foo + remote_host: builds.mydomain.com + remote_path: /uploads/upload.php + timeout: 300 + state: present + +- name: Recreate existing backup file and upload it to remote server + f5os_config_backup: + name: foo + remote_host: builds.mydomain.com + remote_path: /uploads/upload.php + timeout: 300 + force: true + state: present + +- name: Remove backup file + f5os_config_backup: + name: foo + state: absent ''' RETURN = r''' remote_host: diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py index e010697..2f444fc 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py @@ -47,35 +47,22 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Collect interface and vlan information on F5OS device - f5os_device_info: - gather_subset: - - interfaces - - vlans - - - name: Collect all F5OS device information - f5os_device_info: - gather_subset: - - all - - - name: Collect all F5OS device information except system-info - f5os_device_info: - gather_subset: - - all - - "!system-info" +- name: Collect interface and vlan information on F5OS device + f5os_device_info: + gather_subset: + - interfaces + - vlans + +- name: Collect all F5OS device information + f5os_device_info: + gather_subset: + - all + +- name: Collect all F5OS device information except system-info + f5os_device_info: + gather_subset: + - all + - "!system-info" ''' RETURN = r''' lag_interfaces: diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_interface.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_interface.py index bffb88b..4da02da 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_interface.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_interface.py @@ -53,64 +53,51 @@ - Wojciech Wypior (@wojtek0806) ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Creating VLAN444 - f5os_vlan: - name: vlan-444 - vlan_id: 444 - - - name: Creating VLAN555 - f5os_vlan: - name: vlan-555 - vlan_id: 555 - - - name: Attach Vlans to interface on Velos Partition - f5os_interface: - name: "2/1.0" - trunk_vlans: [444] - state: present - - - name: Modify Vlans to interface on Velos Partition - f5os_interface: - name: "2/1.0" - trunk_vlans: [444,555] - state: present - - - name: Delete vlans on interface on Velos Partition - f5os_interface: - name: "1.0" - trunk_vlans: [444,555] - state: absent - - - name: Attach Vlans to interface on rSeries Platform - f5os_interface: - name: "1.0" - trunk_vlans: [444] - state: present - - - name: Modify Vlans to interface on rSeries Platform - f5os_interface: - name: "1.0" - trunk_vlans: [444,555] - state: present - - - name: Delete vlans on interface on rSeries Platform - f5os_interface: - name: "1.0" - trunk_vlans: [444,555] - state: absent +- name: Creating VLAN444 + f5os_vlan: + name: vlan-444 + vlan_id: 444 + +- name: Creating VLAN555 + f5os_vlan: + name: vlan-555 + vlan_id: 555 + +- name: Attach Vlans to interface on Velos Partition + f5os_interface: + name: "2/1.0" + trunk_vlans: [444] + state: present + +- name: Modify Vlans to interface on Velos Partition + f5os_interface: + name: "2/1.0" + trunk_vlans: [444, 555] + state: present + +- name: Delete vlans on interface on Velos Partition + f5os_interface: + name: "1.0" + trunk_vlans: [444, 555] + state: absent + +- name: Attach Vlans to interface on rSeries Platform + f5os_interface: + name: "1.0" + trunk_vlans: [444] + state: present + +- name: Modify Vlans to interface on rSeries Platform + f5os_interface: + name: "1.0" + trunk_vlans: [444, 555] + state: present + +- name: Delete vlans on interface on rSeries Platform + f5os_interface: + name: "1.0" + trunk_vlans: [444, 555] + state: absent ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py index a1b3e2c..e0a73ab 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_lag.py @@ -64,61 +64,48 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Creating VLAN444 - f5os_vlan: - name: vlan-444 - vlan_id: 444 - - - name: Creating VLAN555 - f5os_vlan: - name: vlan-555 - vlan_id: 555 - - - name: Attach Trunk-vlans to LAG to interface - f5os_lag: - name: "Arista" - lag_type: "lacp" - trunk_vlans: [444] - state: present - - - name: Modify Vlans to LAG interface - f5os_lag: - name: "Arista" - trunk_vlans: [444,555] - state: present - - - name: Add interfaces to LAG on Velos Partition - f5os_lag: - name: "Arista" - config_members: - - "1/1.0" - state: present - - - name: Add interfaces to LAG on rSeries Platform - f5os_lag: - name: "Arista" - config_members: - - "1.0" - state: present - - - name: Delete LAG interface - f5os_lag: - name: "Arista" - trunk_vlans: [444,555] - state: absent +- name: Creating VLAN444 + f5os_vlan: + name: vlan-444 + vlan_id: 444 + +- name: Creating VLAN555 + f5os_vlan: + name: vlan-555 + vlan_id: 555 + +- name: Attach Trunk-vlans to LAG to interface + f5os_lag: + name: "Arista" + lag_type: "lacp" + trunk_vlans: [444] + state: present + +- name: Modify Vlans to LAG interface + f5os_lag: + name: "Arista" + trunk_vlans: [444, 555] + state: present + +- name: Add interfaces to LAG on Velos Partition + f5os_lag: + name: "Arista" + config_members: + - "1/1.0" + state: present + +- name: Add interfaces to LAG on rSeries Platform + f5os_lag: + name: "Arista" + config_members: + - "1.0" + state: present + +- name: Delete LAG interface + f5os_lag: + name: "Arista" + trunk_vlans: [444, 555] + state: absent ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant.py index 45c8296..3a70969 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant.py @@ -119,43 +119,30 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Create tenant 'foo' - f5os_tenant: - name: foo - image_name: BIGIP-bigip14.1.x-miro-14.1.2.3-0.0.182.ALL-VELOS.qcow2.zip - nodes: - - 1 - mgmt_ip: 10.144.3.17 - mgmt_prefix: 19 - mgmt_gateway: 10.146.127.254 - vlans: [245] - cpu_cores: 2 - memory: 4096 - cryptos: disabled - running_state: configured - - - name: Deploy tenant 'foo' - f5os_tenant: - name: foo - running_state: deployed - - - name: Delete tenant 'foo' - f5os_tenant: - name: foo - state: absent +- name: Create tenant 'foo' + f5os_tenant: + name: foo + image_name: BIGIP-bigip14.1.x-miro-14.1.2.3-0.0.182.ALL-VELOS.qcow2.zip + nodes: + - 1 + mgmt_ip: 10.144.3.17 + mgmt_prefix: 19 + mgmt_gateway: 10.146.127.254 + vlans: [245] + cpu_cores: 2 + memory: 4096 + cryptos: disabled + running_state: configured + +- name: Deploy tenant 'foo' + f5os_tenant: + name: foo + running_state: deployed + +- name: Delete tenant 'foo' + f5os_tenant: + name: foo + state: absent ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_image.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_image.py index 6a246e9..76f34d9 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_image.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_image.py @@ -89,39 +89,26 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Import tenant image 'foo' onto the F5OS device - f5os_tenant_image: - image_name: foo - remote_host: builds.mydomain.com - remote_user: admin - remote_password: secret - remote_path: /images/ - local_path: images/tenant - state: import - - - name: Check the status of the image import onto the F5OS device - f5os_tenant_image: - image_name: foo - timeout: 600 - state: present - - - name: Remove tenant image 'foo' - f5os_tenant_image: - name: foo - state: absent +- name: Import tenant image 'foo' onto the F5OS device + f5os_tenant_image: + image_name: foo + remote_host: builds.mydomain.com + remote_user: admin + remote_password: secret + remote_path: /images/ + local_path: images/tenant + state: import + +- name: Check the status of the image import onto the F5OS device + f5os_tenant_image: + image_name: foo + timeout: 600 + state: present + +- name: Remove tenant image 'foo' + f5os_tenant_image: + name: foo + state: absent ''' RETURN = r''' image_name: diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_wait.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_wait.py index 906fd56..c9bc46a 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_wait.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_tenant_wait.py @@ -60,34 +60,21 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Wait for the specified tenant to be in the configured state. - f5os_tenant_wait: - name: bigip_tenant1 - - - name: Wait a maximum of 300 seconds specified tenant to be in the provisioned state. - f5os_tenant_wait: - name: bigip_tenant1 - state: provisioned - timeout: 300 - - - name: Wait 30 seconds before verifying the specified tenant to be in the deployed state. - f5os_tenant_wait: - name: bigip_tenant1 - state: deployed - delay: 30 +- name: Wait for the specified tenant to be in the configured state. + f5os_tenant_wait: + name: bigip_tenant1 + +- name: Wait a maximum of 300 seconds specified tenant to be in the provisioned state. + f5os_tenant_wait: + name: bigip_tenant1 + state: provisioned + timeout: 300 + +- name: Wait 30 seconds before verifying the specified tenant to be in the deployed state. + f5os_tenant_wait: + name: bigip_tenant1 + state: deployed + delay: 30 ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/f5os_vlan.py b/ansible_collections/f5networks/f5os/plugins/modules/f5os_vlan.py index d227dc3..e52ad54 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/f5os_vlan.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/f5os_vlan.py @@ -47,33 +47,20 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Create a vlan on partition - f5os_vlan: - name: foo - vlan_id: 3212 - - - name: Update name of a vlan on partition - f5os_vlan: - name: changed_this - vlan_id: 3212 - - - name: Delete vlan on partition - f5os_vlan: - vlan_id: 3212 - state: absent +- name: Create a vlan on partition + f5os_vlan: + name: foo + vlan_id: 3212 + +- name: Update name of a vlan on partition + f5os_vlan: + name: changed_this + vlan_id: 3212 + +- name: Delete vlan on partition + f5os_vlan: + vlan_id: 3212 + state: absent ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition.py b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition.py index 028ae3d..6fa8fbf 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition.py @@ -83,32 +83,19 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.bigip - ansible_httpapi_use_ssl: yes - - tasks: - - name: Create partition 'foo' - velos_partition: - name: foo - state: present - os_version: 1.1.1-5046 - ipv4_mgmt_address: 10.144.140.124/24 - ipv4_mgmt_gateway: 10.144.140.254 - slots: [4,5] - - - name: Delete partition 'foo' - velos_partition: - name: foo - state: absent +- name: Create partition 'foo' + velos_partition: + name: foo + state: present + os_version: 1.1.1-5046 + ipv4_mgmt_address: 10.144.140.124/24 + ipv4_mgmt_gateway: 10.144.140.254 + slots: [4, 5] + +- name: Delete partition 'foo' + velos_partition: + name: foo + state: absent ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_change_password.py b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_change_password.py index ab01904..2afd5f4 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_change_password.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_change_password.py @@ -38,24 +38,11 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Change password on partition - velos_partition_change_password: - user_name: foo - old_password: admin - new_password: abc123!@ +- name: Change password on partition + velos_partition_change_password: + user_name: foo + old_password: admin + new_password: abc123!@ ''' RETURN = r''' diff --git a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_image.py b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_image.py index 59ebc27..d3b46b1 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_image.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_image.py @@ -92,41 +92,28 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - - tasks: - - name: Import partition image onto the Velos controller - velos_partition_image: - image_name: F5OS-C-1.1.0-3198.PARTITION.iso - remote_host: builds.mydomain.com - remote_user: admin - remote_password: secret - remote_path: /images/ - state: import - - - name: Check for presence of the imported ISO on the Velos controller - velos_partition_image: - image_name: F5OS-C-1.1.0-3198.PARTITION.iso - remote_host: builds.mydomain.com - remote_path: /images/ - protocol: scp - timeout: 600 - state: present - - - name: Remove partition image from the Velos controller - velos_partition_image: - image_name: F5OS-C-1.1.0-3198.PARTITION.iso - state: absent +- name: Import partition image onto the Velos controller + velos_partition_image: + image_name: F5OS-C-1.1.0-3198.PARTITION.iso + remote_host: builds.mydomain.com + remote_user: admin + remote_password: secret + remote_path: /images/ + state: import + +- name: Check for presence of the imported ISO on the Velos controller + velos_partition_image: + image_name: F5OS-C-1.1.0-3198.PARTITION.iso + remote_host: builds.mydomain.com + remote_path: /images/ + protocol: scp + timeout: 600 + state: present + +- name: Remove partition image from the Velos controller + velos_partition_image: + image_name: F5OS-C-1.1.0-3198.PARTITION.iso + state: absent ''' RETURN = r''' image_name: diff --git a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_wait.py b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_wait.py index ed20b2a..001eea0 100644 --- a/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_wait.py +++ b/ansible_collections/f5networks/f5os/plugins/modules/velos_partition_wait.py @@ -56,31 +56,21 @@ ''' EXAMPLES = r''' -- hosts: all - collections: - - f5networks.f5os - connection: httpapi - - vars: - ansible_host: "lb.mydomain.com" - ansible_user: "admin" - ansible_httpapi_password: "secret" - ansible_network_os: f5networks.f5os.f5os - ansible_httpapi_use_ssl: yes - tasks: - - name: Wait for the specified partition to be in the running state. - velos_partition_wait: - name: partition1 - - name: Wait a maximum of 300 seconds specified partition to be in the api_available state. - velos_partition_wait: - name: partition1 - state: ssh-ready - timeout: 300 - - name: Wait 30 seconds before verifying the specified partition to be in the running state. - velos_partition_wait: - name: partition1 - state: running - delay: 30 +- name: Wait for the specified partition to be in the running state. + velos_partition_wait: + name: partition1 + +- name: Wait a maximum of 300 seconds specified partition to be in the api_available state. + velos_partition_wait: + name: partition1 + state: ssh-ready + timeout: 300 + +- name: Wait 30 seconds before verifying the specified partition to be in the running state. + velos_partition_wait: + name: partition1 + state: running + delay: 30 ''' RETURN = r''' elapsed: diff --git a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/rseries_software_version.json b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/rseries_software_version.json new file mode 100644 index 0000000..e8e8744 --- /dev/null +++ b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/rseries_software_version.json @@ -0,0 +1,7 @@ +{ + "f5-system-version:version": { + "os-version": "1.7.0-3518", + "service-version": "1.7.0-3518", + "product": "F5OS-A" + } +} \ No newline at end of file diff --git a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/velos_partition_version.json b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/velos_partition_version.json new file mode 100644 index 0000000..90a7891 --- /dev/null +++ b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/fixtures/velos_partition_version.json @@ -0,0 +1,26 @@ +{ + "openconfig-platform:component": [ + { + "f5-platform:software": { + "state": { + "software-components": { + "software-component": [ + { + "software-index": "blade-os", + "state": { + "version": "1.7.0-5149" + } + }, + { + "software-index": "partition-services", + "state": { + "version": "1.7.0-5149" + } + } + ] + } + } + } + } + ] +} \ No newline at end of file diff --git a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_client.py b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_client.py index ce783c0..0e778ba 100644 --- a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_client.py +++ b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_client.py @@ -200,6 +200,7 @@ def test_get_platform_rseries(self): self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response(load_fixture('f5os_platform_response.json'), 200, xheader), + connection_response(load_fixture('rseries_software_version.json'), 200, xheader), ] self.connection.httpapi.login('foo', 'bar') platform = self.client.platform @@ -225,7 +226,8 @@ def test_get_platform_velos_partition(self): self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response(dict(), 404, xheader), - connection_response(dict(), 200, xheader) + connection_response(dict(), 200, xheader), + connection_response(load_fixture('velos_partition_version.json'), 200, xheader), ] self.connection.httpapi.login('foo', 'bar') platform = self.client.platform diff --git a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_teem.py b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_teem.py index 96b4d4a..bbbd103 100644 --- a/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_teem.py +++ b/ansible_collections/f5networks/f5os/tests/module_utils/network/f5/test_teem.py @@ -82,7 +82,7 @@ def test_teem_client_build_telemetry_no_docker_no_cicd(self, m, mock_plat): assert result[0]['CollectionName'] == 'F5OS' assert result[0]['CollectionVersion'] == CURRENT_COLL_VERSION assert result[0]['CollectionModuleName'] == 'fake_module' - assert result[0]['F5OSPlatform'] == 'rSeries' + assert result[0]['f5Platform'] == 'rSeries' assert result[0]['ControllerAnsibleVersion'] == '2.10' assert result[0]['ControllerPythonVersion'] == self.python_version assert result[0]['ControllerAsDocker'] is False @@ -106,7 +106,7 @@ def test_teem_client_build_telemetry_with_docker_in_cicd(self, m1, m2, mock_plat assert result[0]['CollectionName'] == 'F5OS' assert result[0]['CollectionVersion'] == CURRENT_COLL_VERSION assert result[0]['CollectionModuleName'] == 'bigip_fake' - assert result[0]['F5OSPlatform'] == 'rSeries' + assert result[0]['f5Platform'] == 'rSeries' assert result[0]['ControllerAnsibleVersion'] == '2.10' assert result[0]['ControllerPythonVersion'] == self.python_version assert result[0]['ControllerAsDocker'] is True @@ -127,7 +127,55 @@ def test_teem_client_build_telemetry_fq_name(self, m, mock_plat): assert result[0]['CollectionName'] == 'F5OS' assert result[0]['CollectionVersion'] == CURRENT_COLL_VERSION assert result[0]['CollectionModuleName'] == 'bigip_fake' - assert result[0]['F5OSPlatform'] == 'Velos Partition' + assert result[0]['f5Platform'] == 'Velos Partition' + assert result[0]['ControllerAnsibleVersion'] == '2.10' + assert result[0]['ControllerPythonVersion'] == self.python_version + assert result[0]['ControllerAsDocker'] is False + assert result[0]['DockerHostname'] == 'none' + assert result[0]['RunningInCiEnv'] is False + assert result[0]['CiEnvName'] == 'none' + + @patch.object(F5Client, 'software_version', new_callable=PropertyMock) + @patch.object(F5Client, 'platform', new_callable=PropertyMock) + @patch('ansible_collections.f5networks.f5os.plugins.module_utils.teem.in_cicd', new_callable=Mock()) + def test_teem_client_build_telemetry_velos_software_version(self, m, mock_plat, soft_ver): + soft_ver.return_value = '1.6.0-9817' + m.return_value = m.return_value = (False, None) + mock_plat.return_value = 'Velos Partition' + self.fake_module._name = 'f5networks.f5os.bigip_fake' + + teem = TeemClient(self.client, self.start_time) + result = teem.build_telemetry() + + assert result[0]['CollectionName'] == 'F5OS' + assert result[0]['CollectionVersion'] == CURRENT_COLL_VERSION + assert result[0]['CollectionModuleName'] == 'bigip_fake' + assert result[0]['f5Platform'] == 'Velos Partition' + assert result[0]['f5SoftwareVersion'] == '1.6.0-9817' + assert result[0]['ControllerAnsibleVersion'] == '2.10' + assert result[0]['ControllerPythonVersion'] == self.python_version + assert result[0]['ControllerAsDocker'] is False + assert result[0]['DockerHostname'] == 'none' + assert result[0]['RunningInCiEnv'] is False + assert result[0]['CiEnvName'] == 'none' + + @patch.object(F5Client, 'software_version', new_callable=PropertyMock) + @patch.object(F5Client, 'platform', new_callable=PropertyMock) + @patch('ansible_collections.f5networks.f5os.plugins.module_utils.teem.in_cicd', new_callable=Mock()) + def test_teem_client_build_telemetry_rSeries_software_version(self, m, mock_plat, soft_ver): + soft_ver.return_value = '1.7.0-3518' + m.return_value = m.return_value = (False, None) + mock_plat.return_value = 'rSeries Platform' + self.fake_module._name = 'f5networks.f5os.bigip_fake' + + teem = TeemClient(self.client, self.start_time) + result = teem.build_telemetry() + + assert result[0]['CollectionName'] == 'F5OS' + assert result[0]['CollectionVersion'] == CURRENT_COLL_VERSION + assert result[0]['CollectionModuleName'] == 'bigip_fake' + assert result[0]['f5Platform'] == 'rSeries Platform' + assert result[0]['f5SoftwareVersion'] == '1.7.0-3518' assert result[0]['ControllerAnsibleVersion'] == '2.10' assert result[0]['ControllerPythonVersion'] == self.python_version assert result[0]['ControllerAsDocker'] is False diff --git a/ansible_collections/f5networks/f5os/tests/plugins/httpapi/test_f5os.py b/ansible_collections/f5networks/f5os/tests/plugins/httpapi/test_f5os.py index 4447243..76a978f 100644 --- a/ansible_collections/f5networks/f5os/tests/plugins/httpapi/test_f5os.py +++ b/ansible_collections/f5networks/f5os/tests/plugins/httpapi/test_f5os.py @@ -96,6 +96,7 @@ def test_login_success_properties_populated(self): def test_set_platform_type_rseries_set(self): xheader = {'X-Auth-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'} xheader.update(BASE_HEADERS) + self.connection.httpapi._set_software_version = Mock() self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response({'GOOD': 'RESPONSE'}, 200, xheader) @@ -123,6 +124,7 @@ def test_set_platform_type_controller_set(self): def test_set_platform_type_partition_set(self): xheader = {'X-Auth-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'} xheader.update(BASE_HEADERS) + self.connection.httpapi._set_software_version = Mock() self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response({}, 404, xheader), @@ -137,6 +139,7 @@ def test_set_platform_type_partition_set(self): def test_set_platform_type_raises_empty_response(self): xheader = {'X-Auth-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'} xheader.update(BASE_HEADERS) + # self.connection.httpapi._set_software_version = Mock() self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response({}, 404, xheader), @@ -151,6 +154,7 @@ def test_set_platform_type_raises_empty_response(self): def test_set_platform_type_raises_different_error(self): xheader = {'X-Auth-Token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'} xheader.update(BASE_HEADERS) + # self.connection.httpapi._set_software_version = Mock() self.connection.send.side_effect = [ connection_response(load_fixture('f5os_auth.json'), 200, xheader), connection_response({}, 404, xheader),