Fix assumptions in subcloud network reconfig

This commit fixes a few issues found during the testing of a subcloud
update containing network reconfig parameters.

- There are several places where admin network and address pool are
  assumed to be named 'admin'.  The network and address pool are
  user defined and can be named almost anything.  To fix this, we
  need to always use the network type as the key and branch out
  from there to get uuid, names, etc to generate associations.

- Old routes weren't being deleted from controller-1 in an AIO-DX
  system.

- General clean-up / simplification

Test Plan:

The following were performed on both an AIO-SX and AIO-DX system

- Update a subcloud from management -> admin networks
- Update a subcloud back to management from admin network
- Update a subcloud from one admin network to another admin network
- Update a subcloud to use a network 'type' of 'admin' with network
  named 'foo' and address pool named 'bar'

Story: 2010319
Task: 47707

Change-Id: I68c5b493c4839742f633eedc7061493fe473c734
Signed-off-by: Steven Webster <steven.webster@windriver.com>
This commit is contained in:
Steven Webster
2023-07-14 08:15:41 -04:00
parent 41bf9b743c
commit ef15b1f2b4
4 changed files with 84 additions and 53 deletions

View File

@@ -10,8 +10,8 @@
- name: Get previous subcloud admin network address pool uuid
shell: >-
source /etc/platform/openrc;
system addrpool-list | awk '/admin/{ print$2 }'
source /etc/platform/openrc; system network-list |
awk '$8 == "admin" { print $12 }'
register: subcloud_admin_pool_uuid
- name: Delete previous subcloud admin network address pool

View File

@@ -138,16 +138,22 @@
when: system_mode != "simplex"
- name: Get existing admin address pool
shell: >-
source /etc/platform/openrc; system network-list |
awk '$8 == "admin" { print $12 }'
register: admin_address_pool_uuid
- name: Get existing admin floating address
shell: >-
source /etc/platform/openrc; system addrpool-list |
awk ' $4 == "admin" && $14 == "{{ admin_floating_address }}" '
awk ' $2 == "{{ admin_address_pool_uuid.stdout }}" && $14 == "{{ admin_floating_address }}" '
register: check_existing_admin_floating_address
- name: Get existing admin gateway
shell: >-
source /etc/platform/openrc; system addrpool-list |
awk ' $4 == "admin" && $20 == "{{ admin_gateway_address }}" '
awk ' $2 == "{{ admin_address_pool_uuid.stdout }}" && $20 == "{{ admin_gateway_address }}" '
register: check_existing_admin_gateway
- name: Set admin gateway and floating address update required facts

View File

@@ -8,48 +8,24 @@
# in the post network reconfiguration
#
- block:
- name: Check admin address pool uuid
shell: >-
source /etc/platform/openrc; system addrpool-list |
awk '$4 == "admin" { print $2 }'
register: admin_addrpool_uuid
- name: Delete the admin address pool if the target network is mgmt
shell: >-
source /etc/platform/openrc; system addrpool-delete
{{ admin_addrpool }}
when: admin_addrpool and target_net == mgmt_net
- name: Delete admin address pool if is configured
shell: >-
source /etc/platform/openrc; system addrpool-delete
{{ admin_addrpool_uuid.stdout }}
when: admin_addrpool_uuid.stdout != ""
- name: Check admin host route
shell: >-
source /etc/platform/openrc; system host-route-list controller-0 |
awk '$4 == "admin0" { print $2 }'
register: admin_route_uuid
- name: Delete admin host route if is configured
shell: >-
source /etc/platform/openrc; system host-route-delete
{{ admin_route_uuid.stdout }}
when: admin_route_uuid.stdout != ""
# TODO(nicodemos) This should be removed after sysinv/puppet handle removing
# the admin-ip service if admin network and interface doesn't exist
- name: Unmanage admin-ip service
command: sm-unmanage service admin-ip
become: yes
when: target_net == 'mgmt'
- name: Delete old routes on controller-0
shell: >-
source /etc/platform/openrc; system host-route-delete
{{ item }}
with_items: "{{ existing_routes_c0.stdout_lines }}"
when: existing_routes_c0.stdout_lines | length > 0
- block:
- name: Check mgmt host route
shell: >-
source /etc/platform/openrc; system host-route-list controller-0 |
awk '$4 == "mgmt0" { print $2 }'
register: mgmt_route_uuid
- name: Delete mgmt host route if is configured
- name: Delete old routes on controller-1
shell: >-
source /etc/platform/openrc; system host-route-delete
{{ mgmt_route_uuid.stdout }}
when: mgmt_route_uuid.stdout != ""
when: target_net == 'admin'
{{ item }}
with_items: "{{ existing_routes_c1.stdout_lines }}"
when: existing_routes_c1.stdout_lines | length > 0
when: system_mode != "simplex"

View File

@@ -46,36 +46,79 @@
set_fact:
config_permdir: "{{ platform_path + '/config/' + software_version }}"
- name: Get target subcloud network
- name: Set the management and admin network types
set_fact:
mgmt_net: "mgmt"
admin_net: "admin"
- name: Get target subcloud address pool uuid
shell: >-
source /etc/platform/openrc; system addrpool-list |
grep "{{ sc_floating_address }}" | awk '{print $4}'
register: target_net_raw
awk '$14 == "{{ sc_floating_address }}" {print $2}'
register: target_address_pool
- name: Set the target network name variable
- name: Fail if the subcloud has no compatible address pool
fail:
msg: "No address pool found with floating address {{ sc_floating_address }}"
when: target_address_pool.stdout == ""
- name: Get target network type for subcloud address pool
shell: >-
source /etc/platform/openrc; system network-list |
grep "{{ target_address_pool.stdout }}" | awk '{print $8}'
register: target_net_type
- name: Fail if subcloud network is not assigned to an address pool
fail:
msg: "No network is assigned to address pool {{ target_address_pool.stdout }}"
when: target_net_type.stdout == ""
- name: Set the target network type variable
set_fact:
target_net: "{{ 'mgmt' if target_net_raw.stdout == 'management' else target_net_raw.stdout }}"
target_net: "{{ target_net_type.stdout }}"
- name: Get ifname of the existing subcloud network of controller-0
- name: Get target network name for subcloud address pool
shell: >-
source /etc/platform/openrc; system network-list |
grep "{{ target_address_pool.stdout }}" | awk '{print $6}'
register: target_net_name
- name: Get ifname of the target subcloud network of controller-0
shell: >-
source /etc/platform/openrc; system interface-network-list controller-0 |
awk '$8 == "{{ target_net }}" { print $6 }'
awk '$8 == "{{ target_net_name.stdout }}" { print $6 }'
register: controller_0_sc_network_if
- name: Fail if subcloud network interface of controller-0 is not assigned
fail:
msg: "No interface is assigned to {{ target_net }} on controller-0"
msg: "No interface is assigned to {{ target_net_name.stdout }} on controller-0"
when: controller_0_sc_network_if.stdout == ""
- name: Set sc_if_c0 fact
set_fact:
sc_if_c0: "{{ controller_0_sc_network_if.stdout_lines[0] }}"
- name: Get admin address pool uuid if it exists
shell: >-
source /etc/platform/openrc; system network-list |
awk '$8 == "{{ admin_net }}" { print $12 }'
register: admin_addrpool_uuid
- name: Set admin_addrpool fact
set_fact:
admin_addrpool: "{{ admin_addrpool_uuid.stdout }}"
- name: Get existing system controller gateway route(s) on controller-0
shell: >-
source /etc/platform/openrc; system host-route-list controller-0 |
awk '$6 == "{{ system_controller_network }}" && $10 != "{{sc_gateway_address}}" { print $2 }'
register: existing_routes_c0
- block:
- name: Get ifname of the existing subcloud network of controller-1
shell: >-
source /etc/platform/openrc; system interface-network-list controller-1 |
awk '$8 == "{{ target_net }}" { print $6 }'
awk '$8 == "{{ target_net_name.stdout }}" { print $6 }'
register: controller_1_sc_network_if
- name: Fail if subcloud network interface of controller-1 is not assigned
@@ -87,4 +130,10 @@
set_fact:
sc_if_c1: "{{ controller_1_sc_network_if.stdout_lines[0] }}"
- name: Get existing system controller gateway route(s) on controller-1
shell: >-
source /etc/platform/openrc; system host-route-list controller-1 |
awk '$6 == "{{ system_controller_network }}" && $10 != "{{sc_gateway_address}}" { print $2 }'
register: existing_routes_c1
when: system_mode != "simplex"