Pārlūkot izejas kodu

Merge branch 'devel' into test_control_plane

Lucas A. Wilson 3 gadi atpakaļ
vecāks
revīzija
33571bc63f

+ 37 - 0
control_plane/roles/control_plane_common/tasks/count_component_roles.yml

@@ -0,0 +1,37 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# limitations under the License.
+---
+
+- name: Count of manager nodes defined
+  set_fact:
+    count_of_manager: "{{ count_of_manager| int + 1 }}"
+  when: item == group_name_manager
+  tags: install
+
+- name: Count of compute nodes defined
+  set_fact:
+    count_of_compute: "{{ count_of_compute| int + 1 }}"
+  when: item == group_name_compute
+  tags: install
+
+- name: Count of login nodes defined
+  set_fact:
+    count_of_login: "{{ count_of_login| int + 1 }}"
+  when: item == group_name_login
+  tags: install
+
+- name: Count of NFS nodes defined
+  set_fact:
+    count_of_nfs_node: "{{ count_of_nfs_node| int + 1 }}"
+  when: item == group_name_nfs
+  tags: install

+ 9 - 1
control_plane/roles/control_plane_common/tasks/main.yml

@@ -38,8 +38,16 @@
   import_tasks: fetch_sm_inputs.yml
   when: ib_switch_support
 
+- name: Host mapping file validation
+  import_tasks: validate_host_mapping_file.yml
+  when: host_mapping_file_path |length >0
+
+- name: Device mapping file validation
+  import_tasks: validate_device_mapping_file.yml
+  when: mngmnt_mapping_file_path |length >0
+
 - name: Encrypt idrac_tools_vars.yml
   import_tasks: encrypt_idrac_tools_vars.yml
 
 - name: NFS Server setup for offline repo and awx
-  import_tasks: nfs_server_setup.yml
+  import_tasks: nfs_server_setup.yml

+ 82 - 0
control_plane/roles/control_plane_common/tasks/validate_device_mapping_file.yml

@@ -0,0 +1,82 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# limitations under the License.
+---
+- name: Check that device mapping file exists at mentioned path
+  stat:
+    path: "{{ mngmnt_mapping_file_path }}"
+  register: stat_result
+  tags: install
+
+- name: Fail if config file doesn't exist
+  fail:
+    msg: "{{ fail_msg_mapping_file + mngmnt_mapping_file_path }}"
+  when: not stat_result.stat.exists
+  tags: install
+
+- name: Read device mapping file from CSV file and return a dictionary
+  read_csv:
+    path: "{{ mngmnt_mapping_file_path }}"
+    key: "{{ mapping_file_key }}"
+  register: device_mapping_file
+  delegate_to: localhost
+  tags: install
+
+- name: Check if header is present in mapping file
+  shell:  set -o pipefail && awk 'NR==1 { print $1}' "{{ mngmnt_mapping_file_path }}"
+  register: mngmnt_header
+  changed_when: false
+  tags: install
+
+- name: Fail if header not in correct format
+  fail:
+    msg: "{{ fail_device_mapping_file_header }}"
+  when: mngmnt_header.stdout !=  device_mapping_header_format
+  tags: install
+
+- name: Check if mapping file is comma seperated
+  shell: awk -F\, '{print NF-1}' "{{ mngmnt_mapping_file_path }}"
+  register: mngmnt_comma_seperated
+  changed_when: false
+  tags: install
+
+- name: Fail if not comma seperated or if all fields are not given
+  fail:
+    msg: "{{ fail_mapping_file_field_seperation }}"
+  when: not(item =="1")
+  with_items: "{{ mngmnt_comma_seperated.stdout_lines }}"
+  tags: install
+
+- name: Initialize count variables
+  set_fact:
+    list_of_ips: []
+    count_total_items: "{{ device_mapping_file.dict |length }}"
+  tags: install
+
+- name: Create list of IPs in mapping file
+  set_fact:
+    list_of_ips: "{{ [ item.value.IP ] + list_of_ips }}"
+  loop: "{{ device_mapping_file.dict | dict2items }}"
+  loop_control:
+    label: "{{ item.value.MAC }}"
+  tags: install
+
+- name: Find count of unique IPs
+  set_fact:
+    count_of_unique_ip : "{{ list_of_ips| unique| length }}"
+  tags: install
+
+- name: Validation to check if unique IPs are provided for each node
+  fail:
+    msg: "{{ fail_mapping_file_duplicate_ip + mngmnt_mapping_file_path }}"
+  when: not(count_of_unique_ip|int == count_total_items|int)
+  tags: install

+ 179 - 0
control_plane/roles/control_plane_common/tasks/validate_host_mapping_file.yml

@@ -0,0 +1,179 @@
+# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# limitations under the License.
+---
+- name: Check that host mapping file exists at mentioned path
+  stat:
+    path: "{{ host_mapping_file_path }}"
+  register: stat_result
+  tags: install
+
+- name: Fail if config file doesn't exist
+  fail:
+    msg: "{{ fail_msg_mapping_file + host_mapping_file_path }}"
+  when: not stat_result.stat.exists
+  tags: install
+
+- name: Read host mapping file from CSV file and return a dictionary
+  read_csv:
+    path: "{{ host_mapping_file_path }}"
+    key: "{{ mapping_file_key }}"
+  register: mapping_file
+  delegate_to: localhost
+  tags: install
+
+- name: Initialize variable for role support in mapping file
+  set_fact:
+    component_role_support: false
+  tags: install
+
+- name: Check if header is present in mapping file
+  shell:  set -o pipefail && awk 'NR==1 { print $1}' "{{ host_mapping_file_path }}"
+  register: mngmnt_header
+  changed_when: false
+  tags: install
+
+- name: Fail if header not in correct format
+  assert:
+    that: (mngmnt_header.stdout ==  host_mapping_header_format) or (mngmnt_header.stdout == host_mapping_header_with_role_format)
+    fail_msg: "{{ fail_mapping_file_header }}"
+  tags: install
+
+- name: Check if mapping file is comma seperated
+  shell: awk -F\, '{print NF-1}' "{{ host_mapping_file_path }}"
+  register: mngmnt_comma_seperated
+  changed_when: false
+  tags: install
+
+- name: Set variable if component roles given in mapping file
+  set_fact:
+    component_role_support: true
+  when: mngmnt_header.stdout == host_mapping_header_with_role_format
+  tags: install
+
+- name: Fail if not comma seperated or if all fields are not given for MAC,Hostname,IP,Component_role
+  fail:
+    msg: "{{ fail_mapping_file_field_seperation }}"
+  when: not(item =="3") and not (item == "-1") and component_role_support
+  with_items: "{{ mngmnt_comma_seperated.stdout_lines }}"
+  tags: install
+
+- name: Fail if not comma seperated or if all fields are not given for MAC,Hostname,IP
+  fail:
+    msg: "{{ fail_mapping_file_field_seperation }}"
+  when: not(item =="2") and not (item == "-1") and not(component_role_support)
+  with_items: "{{ mngmnt_comma_seperated.stdout_lines }}"
+  tags: install
+
+- name: Initialize count variables
+  set_fact:
+    list_of_ips: []
+    list_of_roles: []
+    list_of_hostnames: []
+    count_of_manager: 0
+    count_of_compute: 0
+    count_of_nfs_node: 0
+    count_of_login: 0
+    count_total_items: "{{ mapping_file.dict |length }}"
+  tags: install
+
+- name: Create list of IPs and component roles and hostnames defined in mapping file
+  set_fact:
+    list_of_ips: "{{ [ item.value.IP ] + list_of_ips }}"
+    list_of_hostnames: "{{ [ item.value.Hostname ] + list_of_hostnames }}"
+  loop: "{{ mapping_file.dict | dict2items }}"
+  loop_control:
+    label: "{{ item.value.MAC }}"
+  tags: install
+
+- name: Create list of component roles defined in mapping file
+  set_fact:
+    list_of_roles: "{{ [ item.value.Component_role ] + list_of_roles }}"
+  loop: "{{ mapping_file.dict | dict2items }}"
+  loop_control:
+    label: "{{ item.value.MAC }}"
+  when: component_role_support
+  tags: install
+
+- name: Assert hostnames
+  assert:
+    that:
+      - '"_" not in item'
+      - '"." not in item'
+      - '" " not in item'
+    quiet: yes
+    fail_msg: "{{ fail_mapping_file_hostname_chars + item }}"
+  with_items: "{{ list_of_hostnames }}"
+  tags: install
+
+- name: Find count of unique IPs
+  set_fact:
+    count_of_unique_ip : "{{ list_of_ips| unique| length }}"
+  tags: install
+
+- name: Validation to check if unique IPs are provided for each node
+  fail:
+    msg: "{{ fail_mapping_file_duplicate_ip + host_mapping_file_path }}"
+  when: not(count_of_unique_ip|int == count_total_items|int)
+  tags: install
+
+- name: Find count of unique hostnames
+  set_fact:
+    count_of_unique_hostnames : "{{ list_of_hostnames | unique | length }}"
+  tags: install
+
+- name: Validation to check if unique hostnames are provided for each node
+  fail:
+    msg: "{{ fail_mapping_file_duplicate_hostname }}"
+  when: not(count_of_unique_hostnames|int == count_total_items| int)
+  tags: install
+
+- name: Find count of each component role defined in mapping file
+  include_tasks: count_component_roles.yml
+  loop: "{{ list_of_roles }}"
+  when: component_role_support
+  tags: install
+
+- block:
+  - name: Validation to check if component roles for each node is defined
+    fail:
+      msg: "{{ fail_mapping_file_roles_error }}"
+    when: not( count_total_items|int == (count_of_manager|int + count_of_compute|int + count_of_login|int + count_of_nfs_node|int))
+
+  - name: Validation to check number of manager nodes defined
+    fail:
+      msg: "{{ fail_mapping_file_manager_role }}"
+    when: not (count_of_manager | int  == 1)
+
+  - name: Validation to check number of compute nodes defined
+    fail:
+      msg: "{{ fail_mapping_file_compute_role }}"
+    when: count_of_compute|int  < 1
+
+  - name: Validation to check number of login nodes defined
+    fail:
+      msg: "{{ fail_mapping_file_login_role }}"
+    when: not ( count_of_login|int == 1)
+
+  - name: Validation to check number of nfs nodes defined
+    fail:
+      msg: "{{ fail_mapping_file_nfs_role }}"
+    when: powervault_support and not (count_of_nfs_node|int == 1)
+  tags: install
+
+  rescue:
+  - name: Count of roles defined
+    fail:
+      msg: "{{ count_of_roles_defined }}"
+    tags: install
+
+  when: component_role_support

+ 30 - 0
control_plane/roles/control_plane_common/vars/main.yml

@@ -140,3 +140,33 @@ nfs_services:
   - mountd
   - rpc-bind
   - nfs
+
+# Usage: validate_host_mapping_file.yml
+fail_msg_mapping_file: "Mapping file doesn't exist at given path: "
+mapping_file_key: "MAC"
+fail_mapping_file_header: "Header of csv file is not in correct format.
+                          It should be of the format: MAC,Hostname,IP,Component_role or MAC,Hostname,IP"
+host_mapping_header_format: "MAC,Hostname,IP"
+host_mapping_header_with_role_format: "MAC,Hostname,IP,Component_role"
+fail_mapping_file_field_seperation: "Failed: Mapping file should be comma separated and all fields must be filled."
+fail_mapping_file_duplicate_ip: "Failed: Duplicate ip exists. Please verify following mapping file again: "
+fail_mapping_file_duplicate_hostname: "Failed: Duplicate hostname exists. Please verify host mapping file again."
+fail_mapping_file_hostname_chars: "Hostname should not contain _ or . or space as it will cause error with slurm and K8s. Found in: "
+fail_mapping_file_roles_error: "Failed. Define correct Component Roles for each node.
+                                Component roles can only take values: {{ group_name_manager }}, {{group_name_compute}},
+                                 {{ group_name_login }}, {{ group_name_nfs }}"
+fail_mapping_file_manager_role: "Exactly 1 manager node must be defined"
+fail_mapping_file_compute_role: "Atleast 1 compute node must be defined"
+fail_mapping_file_login_role: "Exactly 1 login node must be defined"
+fail_mapping_file_nfs_role: "Exactly 1 nfs node must be defined"
+count_of_roles_defined: "Component Roles defined: Manager Node: {{ count_of_manager }},
+                        Compute Nodes: {{ count_of_compute }}, Login Node: {{ count_of_login }},
+                        Nfs Node: {{ count_of_nfs_node }}, Total Nodes: {{ count_total_items }} "
+group_name_manager: "manager"
+group_name_compute: "compute"
+group_name_login: "login_node"
+group_name_nfs: "nfs_node"
+
+# Usage: validate_device_mapping_file.yml
+fail_device_mapping_file_header: "Failed: Header (MAC,IP) should be present in the mapping file."
+device_mapping_header_format: "MAC,IP"

+ 47 - 0
control_plane/test/test_eth_mtu.yml

@@ -0,0 +1,47 @@
+#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+---
+- name: Get running config and reload PS
+  hosts: ethernet
+  connection: network_cli
+  gather_facts: no
+  collections:
+   - dellemc.os10
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+  tasks:
+   - name: Set facts
+     set_fact:
+       ansible_ssh_user: "{{ username }}"
+       ansible_ssh_pass: "{{ password }}"
+     tags: mtu,reload
+
+   - name: View running configurations
+     dellos10_command:
+       commands: show interface ethernet {{ validation_port }}
+     register: var1
+     tags: mtu
+
+   - name: Print config
+     debug:
+       msg: "{{ var1 }}"
+     tags: mtu
+
+   - name: Reload switch
+     dellos10_command:
+       commands: 
+          - command: 'reload'
+            prompt: '\[confirm yes/no\]:?$'
+            answer: 'yes'
+     tags: reload

+ 346 - 0
control_plane/test/test_ethernet_config.yml

@@ -0,0 +1,346 @@
+#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+---
+# Testacase OMNIA_1.1_EF_TC_007
+# Execute ethernet.yml with both valid Global and interface configs in ethernet_config.yml
+- name: OMNIA_1.1_EF_TC_007
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_007
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Back up of ethernet_config.yml
+      copy:
+        src: "{{ ethernet_config_dir }}"
+        dest: "{{ ethernet_config_backup_dir }}"
+        mode: "{{ file_perm }}"
+      tags: TC_007
+
+    - name: Executing ethernet role with default ethernet_config
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"      
+
+    - block:
+       - name: Validate default flow
+         assert:
+           that:
+             - ethernet_success_msg in job_status.status
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+
+    - name: Set MTU of port {{ port_num }}
+      lineinfile:
+       dest: "{{ ethernet_config_dir }}"
+       insertbefore: "{{ search_line }}"
+       line: "{{ add_mtu_line }}"
+    
+    - name: Executing ethernet role with default ethernet_config
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+      
+    - name: Getting MTU of ethernet {{ validation_port }}
+      command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
+      changed_when: false
+      register: mtu_out
+      tags: TC_007,TC_002
+       
+    - name: Validate role exec output pre and post MTU addition
+      assert:
+        that:          
+          - validate_mtu_line in mtu_out.stdout
+        success_msg: "{{ success_message }}"
+        fail_msg: "{{ fail_case }}"
+      changed_when: false
+      failed_when: false
+      tags: TC_007
+
+# Testacase OMNIA_1.1_EF_TC_005
+# Execute ethernet.yml with save_config set to False
+- name: OMNIA_1.1_EF_TC_005
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_005
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Reload switch
+      command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'reload'
+      changed_when: false
+    
+    - name: Pausing for switch to come up
+      pause:
+        minutes: "{{ time_to_pause }}"
+        
+    - name: Getting MTU of ethernet {{ validation_port }}
+      command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
+      changed_when: false
+      register: mtu_out
+      
+    - block:
+       - name: Validate that MTU is changed
+         assert:
+           that:
+             - validate_mtu_line not in mtu_out.stdout
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+         failed_when: false
+                
+# Testacase OMNIA_1.1_EF_TC_006
+# Execute ethernet.yml with save_config set to True
+- name: OMNIA_1.1_EF_TC_006
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_006
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Set save_changes_to_startup to True in ethernet_vars
+      ansible.builtin.replace:
+        dest: "{{ ethernet_config_dir }}"
+        regexp: 'save_changes_to_startup: false'
+        replace: 'save_changes_to_startup: True'
+        
+    - name: Execute network_ethernet role as port 4 has mtu set in ethernet_vars
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+      
+    - name: Reload switch
+      command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'reload'
+      changed_when: false
+    
+    - name: Pausing for switch to come up
+      pause:
+        minutes: "{{ time_to_pause }}"
+        
+    - name: Getting MTU of ethernet {{ validation_port }}
+      command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
+      changed_when: false
+      register: mtu_out
+    
+    - block:
+       - name: Validate that MTU is changed
+         assert:
+           that:
+             - validate_mtu_line in mtu_out.stdout
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+
+# Testcase OMNIA_1.1_EF_TC_010
+# Execute ethernet.yml with invalid Global and correct interface configs in ethernet_config.yml
+- name: OMNIA_1.1_EF_TC_010
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_010
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Making interface config invalid
+      lineinfile:
+        path: "{{ ethernet_config_dir }}"
+        insertafter: 'os10_config:'
+        line: 'gibberish inserted'
+      tags: TC_007
+
+    - name: Executing ethernet role with invalid global config
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+
+    - block:
+       - name: Validate role exec output
+         assert:
+           that:
+             - ethernet_fail_msg in job_status.status
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+
+# Testcase OMNIA_1.1_EF_TC_009
+# Validation of ethernet default configuration
+- name: OMNIA_1.1_EF_TC_009
+  hosts: ethernet
+  gather_facts: false
+  tags: VERIFY_OMNIA_01
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml    
+  tasks:
+    - name: Executing ethernet role
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}" 
+    
+    - block:
+       - name: Validate default flow
+         assert:
+           that:
+             - ethernet_success_msg in job_status.status
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+         
+# Testcase OMNIA_1.1_EF_TC_011
+# Execute ethernet.yml with valid Global  and incorrect interface configs in ethernet_config.yml 
+- name: OMNIA_1.1_EF_TC_011
+  hosts: ethernet
+  gather_facts: false
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Making interface config invalid
+      lineinfile:
+        path: "{{ ethernet_config_dir }}"
+        insertafter: 'os10_interface:'
+        line: 'gibberish inserted'
+        
+    - name: Executing ethernet role with invalid interface config
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+
+    - block:
+       - name: Validate role exec output
+         assert:
+           that:
+             - ethernet_fail_msg in job_status.status
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"      
+
+
+# Testcase OMNIA_1.1_EF_TC_008
+# Execute ethernet.yml with only Global and no interface configs in ethernet_config.yml 
+- name: OMNIA_1.1_EF_TC_008
+  hosts: ethernet
+  gather_facts: false
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Retrieving ethernet_config backup
+      copy:
+        src: "{{ ethernet_config_backup_dir }}"
+        dest: "{{ ethernet_config_dir }}"
+        mode: "{{ file_perm }}"
+      tags: TC_008
+    
+    - name: Removing interface config from ethernet_config
+      ansible.builtin.command: sed -i '22,117d' "{{ ethernet_config_dir }}"
+      args:
+       warn: no
+      changed_when: false
+      tags: TC_008
+      
+    - name: Executing ethernet role with no interface config
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+      
+    - block:
+       - name: Validate default flow
+         assert:
+           that:
+             - ethernet_success_msg in job_status.status
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+
+    - name: Restoring original ethernt_config
+      copy:
+        src: "{{ ethernet_config_backup_dir }}"
+        dest: "{{ ethernet_config_dir }}"
+        mode: "{{ file_perm }}"
+      tags: TC_008
+      
+    - name: Set save_changes_to_startup to True in ethernet_vars
+      ansible.builtin.replace:
+        dest: "{{ ethernet_config_dir }}"
+        regexp: 'save_changes_to_startup: false'
+        replace: 'save_changes_to_startup: True'
+        
+    - name: Execute network_ethernet role as port 4 has mtu set in ethernet_vars
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ eth_template_value }}"
+       job_template_name: "{{ eth_job_name }}"
+       playbook_path: "{{ eth_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+      
+    - name: Set save_changes_to_startup to False in ethernet_vars
+      ansible.builtin.replace:
+        dest: "{{ ethernet_config_dir }}"
+        regexp: 'save_changes_to_startup: True'
+        replace: 'save_changes_to_startup: False'

+ 157 - 0
control_plane/test/test_ethernet_fact.yml

@@ -0,0 +1,157 @@
+#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+---
+# Testcase OMNIA_1.1_EF_TC_002
+# Execute ethernetfacts.yml with valid IP with valid credentials in ethernet inventory group
+- name: OMNIA_1.1_EF_TC_002
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_002
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Execute ethernet_facts with valid creds and valid IP
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ fact_template_value }}"
+       job_template_name: "{{ fact_job_name }}"
+       playbook_path: "{{ eth_facts_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+      tags: TC_002
+   
+    - block:
+       - name: Validate default flow with valid IP and valid credentials
+         assert:
+           that:
+             - "'successful' in job_status.status"
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+
+# Testcase OMNIA_1.1_EF_TC_003
+# Execute ethernetfacts.yml with Invalid IP in ethernet inventory group
+- name: OMNIA_1.1_EF_TC_003
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_003
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: setting ip
+      set_fact:
+        eth_host_name: "{{ random_ip }}"
+         
+    - name: Execute ethernet_facts with random IP
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ fact_template_value }}"
+       job_template_name: "{{ fact_job_name }}"
+       playbook_path: "{{ eth_facts_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+
+    - block:
+        - name: Validate invalid IP and valid credentials
+          assert:
+            that:
+              - "'failed' in job_status.status"
+            success_msg: "{{ success_message }}"
+            fail_msg: "{{ fail_case }}"
+          changed_when: false
+
+# Testcase OMNIA_1.1_EF_TC_001
+# Execute ethernetfacts.yml with no hosts in ethernet inventory group
+- name: OMNIA_1.1_EF_TC_001
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_001
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Execute ethernet_facts with no host details
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"       
+       template_name: "{{ fact_template_value }}"
+       job_template_name: "{{ fact_job_name }}"
+       playbook_path: "{{ eth_facts_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+    
+    - block:
+       - name: Validate no hosts and valid credentials
+         assert:
+           that:
+             - "'successful' in job_status.status"
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+
+# Testcase OMNIA_1.1_EF_TC_004
+# Execute ethernetfacts.yml with valid IP in ethernet inventory group with incorrect credentials
+- name: OMNIA_1.1_EF_TC_004
+  hosts: ethernet
+  gather_facts: false
+  tags: TC_004
+  connection: local
+  vars_files:
+    - test_vars/test_ethernet_vars.yml
+    - ../roles/webui_awx/vars/main.yml    
+    - ../input_params/base_vars.yml
+  tasks:
+    - name: Making ethernet_credentials invalid
+      tower_credential:
+        name: "ethernet_credential"
+        credential_type: "Machine"
+        inputs:
+          username: "{{ invalid_username }}"
+       
+    - name: Execute ethernet_facts with invalid credentials
+      vars:
+       inventory_name: "{{ eth_inventory_name }}"
+       host_name: "{{ eth_host_name }}"
+       template_name: "{{ fact_template_value }}"
+       job_template_name: "{{ fact_job_name }}"
+       playbook_path: "{{ eth_facts_playbook_path }}"
+       delete_status: true
+      include_tasks: "{{ awx_script_path }}"
+     
+    - block:
+       - name: Validate valid IP and invalid credentials
+         assert:
+           that:
+             - "'failed' in job_status.status"
+           success_msg: "{{ success_message }}"
+           fail_msg: "{{ fail_case }}"
+         changed_when: false
+         
+    - name: Set credentials back to default
+      tower_credential:
+        name: "ethernet_credential"
+        credential_type: "Machine"
+        inputs:
+          username: "{{ username }}"
+          password: "{{ password }}"

+ 5 - 0
control_plane/test/test_ethernet_inventory

@@ -0,0 +1,5 @@
+[ethernet]
+1.2.3.4
+
+[ethernet:vars]
+ansible_network_os= dellemc.os10.os10

+ 56 - 0
control_plane/test/test_vars/test_ethernet_vars.yml

@@ -0,0 +1,56 @@
+#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+---
+# Usage : test_ethernet_facts.yml
+failed_msg: "Unexpected scenario"
+success_message: "Execution successful"
+eth_inventory_name: "ethernet_inventory"
+eth_host_name: "100.96.23.241"
+fact_template_value: "ethernet_template"
+fact_job_name: "ethernet_template"
+eth_facts_playbook_path: "control_plane/tools/ethernet_facts.yml"
+awx_script_path: "test_prepare.yml"
+random_ip: 100.100.100.100
+invalid_username: "invalid_username"
+username: admin
+password: admin
+
+# Usage : test_ethernet_config.yml
+ethernet_dir: "ethernet.yml"
+ethernet_config_dir: "../input_params/ethernet_vars.yml"
+ethernet_config_backup_dir: "ethernet_config_backup.yml"
+get_mtu_dir: "test_eth_mtu.yml"
+appliance_dir: "/root/ethernet/control_plane"
+fail_case: "Expected error, please check the configurations"
+sed_condition: '/Port 4/a mtu2345'
+eth_template_value: "ethernet_template"
+eth_job_name: "ethernet_template"
+eth_playbook_path: "control_plane/ethernet.yml"
+inventory_dir: "test_ethernet_inventory"
+login_vars_path: "../input_params/login_vars.yml"
+login_vars_vault_path: "../input_params/.login_vault_key"
+tower_config_file_path: "../roles/webui_awx/files/.tower_cli.cfg"
+tower_vault_file_path: "../roles/webui_awx/files/.tower_vault_key"
+file_perm: '0644'
+
+# Usage : test_eth_mtu.yml, test_ethernet_config.yml
+validation_port: 1/1/4:1
+port_num: 4
+search_line: "    ethernet 1/1/5:"
+add_mtu_line: "      mtu: 2345"
+time_to_pause: 4
+validate_mtu_line: "MTU 2345 bytes"
+ethernet_success_msg: "successful"
+ethernet_fail_msg: "failed"

+ 3 - 0
examples/host_mapping_file_one_touch.csv

@@ -0,0 +1,3 @@
+MAC,Hostname,IP,Component_role
+xx:yy:zz:aa:bb,server,1.2.3.4,manager
+aa:bb:cc:dd:ee,server2,10.10.11.12,nfs_node

+ 3 - 0
examples/host_mapping_file_os_provisioning.csv

@@ -0,0 +1,3 @@
+MAC,Hostname,IP
+xx:yy:zz:aa:bb,server,1.2.3.4
+aa:bb:cc:dd:ee,server2,10.10.11.12

+ 2 - 0
examples/mapping_device_file.csv

@@ -0,0 +1,2 @@
+MAC,IP
+xx:yy:zz:aa:bb,1.2.3.4

+ 0 - 2
examples/mapping_file.csv

@@ -1,2 +0,0 @@
-MAC,Hostname,IP
-xx:yy:zz:aa:bb,server,1.2.3.4