Browse Source

Issue #416: Configuring Mellanox InfiniBand Switches and Dell PowerSwitches

Signed-off-by: sakshiarora13 <sakshi_arora1@dell.com>
Lucas A. Wilson 3 years ago
parent
commit
f67d17643b

+ 1 - 1
README.md

@@ -24,7 +24,7 @@ For Omnia documentation, including installation and contribution instructions, p
 <img src="docs/images/pisa.png" height="100px" alt="Universita di Pisa"> <img src="https://user-images.githubusercontent.com/83095575/117071024-64956c80-ace3-11eb-9d90-2dac7daef11c.png" height="80px" alt="Arizona State University"> <img src="https://www.vizias.com/uploads/1/1/8/9/118906653/published/thick-blue-white-ring-letters-full.png" height="60px" alt="Vizias">
 
 ## Contributors
-Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
+Thanks goes to everyone who makes Omnia possible ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
 <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
 <!-- prettier-ignore-start -->
 <!-- markdownlint-disable -->

+ 166 - 1
control_plane/input_params/ib_vars.yml

@@ -32,4 +32,169 @@
 
 subnet_manager:
   cache_directory: /var/cache/opensm
-  log_directory: /var/log
+  log_directory: /var/log
+
+# mellanox_switch_config: list of configuration lines to apply to the switch.
+  # Example:
+    # mellanox_switch_config:
+      # - Command 1
+      # - Command 2
+  # By default, the list is empty.
+mellanox_switch_config:
+
+# mellanox_switch_interface_config: contains interface configuration.
+  # It is a dict mapping switch interface names to configuration dicts.
+  # Each dict may contain the following items:
+    # description - a description to apply to the interface.
+    # config - a list of per-interface configuration.
+mellanox_switch_interface_config:
+  ib 1/1:
+    description: port 1
+    config:
+      - "no shutdown"
+  ib 1/2:
+    description: port 2
+    config:
+      - "no shutdown"
+  ib 1/3:
+    description: port 3
+    config:
+      - "no shutdown"
+  ib 1/4:
+    description: port 4
+    config:
+      - "no shutdown"
+  ib 1/5:
+    description: port 5
+    config:
+      - "no shutdown"
+  ib 1/6:
+    description: port 6
+    config:
+      - "no shutdown"
+  ib 1/7:
+    description: port 7
+    config:
+      - "no shutdown"
+  ib 1/8:
+    description: port 8
+    config:
+      - "no shutdown"
+  ib 1/9:
+    description: port 9
+    config:
+      - "no shutdown"
+  ib 1/10:
+    description: port 10
+    config:
+      - "no shutdown"
+  ib 1/11:
+    description: port 11
+    config:
+      - "no shutdown"
+  ib 1/12:
+    description: port 12
+    config:
+      - "no shutdown"
+  ib 1/13:
+    description: port 13
+    config:
+      - "no shutdown"
+  ib 1/14:
+    description: port 14
+    config:
+      - "no shutdown"
+  ib 1/15:
+    description: port 15
+    config:
+      - "no shutdown"
+  ib 1/16:
+    description: port 16
+    config:
+      - "no shutdown"
+  ib 1/17:
+    description: port 17
+    config:
+      - "no shutdown"
+  ib 1/18:
+    description: port 18
+    config:
+      - "no shutdown"
+  ib 1/19:
+    description: port 19
+    config:
+      - "no shutdown"
+  ib 1/20:
+    description: port 20
+    config:
+      - "no shutdown"
+  ib 1/21:
+    description: port 21
+    config:
+      - "no shutdown"
+  ib 1/22:
+    description: port 22
+    config:
+      - "no shutdown"
+  ib 1/23:
+    description: port 23
+    config:
+      - "no shutdown"
+  ib 1/24:
+    description: port 24
+    config:
+      - "no shutdown"
+  ib 1/25:
+    description: port 25
+    config:
+      - "no shutdown"
+  ib 1/26:
+    description: port 26
+    config:
+      - "no shutdown"
+  ib 1/27:
+    description: port 27
+    config:
+      - "no shutdown"
+  ib 1/28:
+    description: port 28
+    config:
+      - "no shutdown"
+  ib 1/29:
+    description: port 29
+    config:
+      - "no shutdown"
+  ib 1/30:
+    description: port 30
+    config:
+      - "no shutdown"
+  ib 1/31:
+    description: port 31
+    config:
+      - "no shutdown"
+  ib 1/32:
+    description: port 32
+    config:
+      - "no shutdown"
+  ib 1/33:
+    description: port 33
+    config:
+      - "no shutdown"
+  ib 1/34:
+    description: port 34
+    config:
+      - "no shutdown"
+  ib 1/35:
+    description: port 35
+    config:
+      - "no shutdown"
+  ib 1/36:
+    description: port 36
+    config:
+      - "no shutdown"
+
+# save_changes_to_startup: is a boolean flag. By default, this option is set to false.
+# When set to true, it will save the switch's running configuration to the startup configuration file
+# after the role applies its configuration. This will allow the configuration to persist after a
+# restart or power failure.
+save_changes_to_startup: false

+ 3 - 0
control_plane/roles/network_ethernet/tasks/main.yml

@@ -25,6 +25,9 @@
     - name: Configure switch
       include_tasks: apply_config.yml
 
+    - name: Configure SNMP
+      include_tasks: snmp_config.yml
+
     - name: Save current switch configuration to startup-configuration
       dellos10_command:
         commands: "copy running-configuration startup-configuration"

+ 1 - 1
control_plane/roles/network_ethernet/tasks/pre_requisites.yml

@@ -26,7 +26,7 @@
 - name: Include switch config variable file
   include_vars: "{{ config_file }}"
 
-- name: Assert save_config variable
+- name: Assert save_changes_to_startup variable
   assert:
     that: "save_changes_to_startup == true or save_changes_to_startup == false"
     success_msg: "{{ success_msg_save_config }}"

+ 42 - 0
control_plane/roles/network_ethernet/tasks/snmp_config.yml

@@ -0,0 +1,42 @@
+# 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: Configure SNMP
+  block:
+  - name: Set parameters for SNMP configuration
+    set_fact:
+      os10_snmp:
+        snmp_community:
+          - name: "{{ snmp_community_name }}"
+            access_mode: ro
+            state: present
+        snmp_traps:
+          - name: all
+            state: present
+        snmp_host:
+          - ip: "{{ snmp_trap_destination }}"
+            communitystring: "{{ snmp_community_name }}"
+            version: "1"
+            state: present
+    when: snmp_trap_destination | length > 1
+
+- name: Apply SNMP configuration
+  include_role:
+    name: dellemc.os10.os10_snmp
+  vars:
+    - hostname: "{{ inventory_hostname }}"
+      os10_cfg_generate: true
+  when: os10_snmp is defined

+ 1 - 1
control_plane/roles/network_ethernet/vars/main.yml

@@ -19,4 +19,4 @@ base_vars_file: "{{ role_path }}/../../input_params/base_vars.yml"
 config_file: "{{ role_path }}/../../input_params/ethernet_vars.yml"
 fail_msg_config_file: Ethernet config file doesn't exist.
 success_msg_save_config: Ethernet config file validated.
-fail_msg_save_config: save_config variable can only be set to true or false.
+fail_msg_save_config: save_changes_to_startup variable can only be set to true or false.

+ 31 - 0
control_plane/roles/network_ib/tasks/apply_config.yml

@@ -0,0 +1,31 @@
+# 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: Apply global configuration
+  include_tasks: global_config.yml
+  with_items: "{{ mellanox_switch_config }}"
+  when: mellanox_switch_config is defined and mellanox_switch_config
+
+- name: Set empty dictionary if not defined
+  set_fact:
+    mellanox_switch_interface_config: {}
+  when: mellanox_switch_interface_config is not defined or not mellanox_switch_interface_config
+
+- name: Apply interface configuration
+  include_tasks: interface_config.yml
+  with_dict: "{{ mellanox_switch_interface_config }}"
+  loop_control:
+    label: "{{ item.key }}"
+  when: mellanox_switch_interface_config is defined and mellanox_switch_interface_config

+ 55 - 0
control_plane/roles/network_ib/tasks/authenticate.yml

@@ -0,0 +1,55 @@
+# 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: Set Credentials for IB switch
+  set_fact:
+    username: "{{ lookup('env','ANSIBLE_NET_USERNAME') }}"
+    password: "{{ lookup('env','ANSIBLE_NET_PASSWORD') }}"
+    global_config: false
+    interface_config: false
+    filtered_dict: {}
+  no_log: true
+
+- name: Authenticate
+  block:
+    - name: Authenticate to switch- "{{ inventory_hostname }}"
+      uri:
+        url: http://{{ inventory_hostname }}/admin/launch?script=rh&template=login&action=login
+        method: POST
+        body_format: form-urlencoded
+        body:
+          f_user_id: "{{ username }}"
+          f_password: "{{ password }}"
+          enter: Sign in
+        status_code: 302
+      register: login
+      no_log: true
+
+    - name: Verify authentication status
+      fail:
+        msg: "Authentication failed"
+      when: login.set_cookie is undefined
+
+  rescue:
+    - name: Filtered response creation
+      set_fact:
+        filtered_dict: "{{filtered_dict |combine({item.key: item.value})}}"
+      when: item.key not in 'invocation'
+      with_dict: "{{ login }}"
+      no_log: true
+
+    - name: Authentication failure response
+      fail:
+        msg: "{{ filtered_dict }}"

+ 35 - 0
control_plane/roles/network_ib/tasks/global_config.yml

@@ -0,0 +1,35 @@
+# 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: Apply configuration for- "{{ inventory_hostname }}" - "{{ item }}"
+  uri:
+    url: http://{{ inventory_hostname }}/admin/launch?script=json
+    method: POST
+    body_format: json
+    headers:
+      Cookie: "{{ login.set_cookie.split(';')[0] }}"
+    body:
+      {
+      "commands":
+       [
+         "{{ item }}"
+       ]
+      }
+  register: global_conf
+
+- name: Status check for - "{{ inventory_hostname }}" - "{{ item }}"
+  fail:
+    msg: "{{ global_conf.json }}"
+  when: global_conf.json.status != "OK"

+ 41 - 0
control_plane/roles/network_ib/tasks/interface_config.yml

@@ -0,0 +1,41 @@
+# 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: Apply interface configuration for- "{{ inventory_hostname }}"
+  uri:
+    url: http://{{ inventory_hostname }}/admin/launch?script=json
+    method: POST
+    body_format: json
+    headers:
+      Cookie: "{{ login.set_cookie.split(';')[0] }}"
+    body:
+      {
+      "commands":
+       [
+         "interface {{ item.key}}",
+         "description {{ item.value.description | default('<none>') }}",
+         "{{ item.value.config | default([]) |join(', ') }}"
+       ]
+      }
+  register: interface_conf
+
+- name: Status check for- "{{ inventory_hostname }}"
+  fail:
+    msg: "{{ results }}"
+  when:  results.status != "OK"
+  loop: "{{ interface_conf.json.results }}"
+  loop_control:
+    loop_var: results
+    label: "{{ results.executed_command }}"

+ 31 - 13
control_plane/roles/network_ib/tasks/main.yml

@@ -1,19 +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
+# 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
+#     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.
+# 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.
 ---
+# tasks file for infiniband
 
-# Will be updated later in each PR
-- name: Pass
-  debug:
-    msg: "Pass"
+- name: Include base variable file
+  include_vars: "{{ base_vars_file }}"
+
+- name: Check if infiniband switch is supported
+  block:
+    - name: Check pre-requisites
+      include_tasks: pre_requisites.yml
+
+    - name: Authenticate to IB switch
+      include_tasks: authenticate.yml
+
+    - name: Configure IB switch
+      include_tasks: apply_config.yml
+
+    - name: Configure SNMP
+      include_tasks: snmp_config.yml
+
+    - name: Save running-config to startup-config
+      include_tasks: save_config.yml
+
+  when: ib_switch_support

+ 33 - 0
control_plane/roles/network_ib/tasks/pre_requisites.yml

@@ -0,0 +1,33 @@
+# 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: Check if ib_vars.yml exists
+  stat:
+    path: "{{ config_file }}"
+  register: stat_result
+
+- name: Fail if config file doesn't exist
+  fail:
+    msg: "{{ fail_msg_config_file }}"
+  when: not stat_result.stat.exists
+
+- name: Include switch config variable file
+  include_vars: "{{ config_file }}"
+
+- name: Assert save_changes_to_startup variable
+  assert:
+    that: "save_changes_to_startup == true or save_changes_to_startup == false"
+    success_msg: "{{ success_msg_save_config }}"
+    fail_msg: "{{ fail_msg_save_config }}"

+ 26 - 0
control_plane/roles/network_ib/tasks/save_config.yml

@@ -0,0 +1,26 @@
+# 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: Save configuration
+  block:
+  - name: Set parameters to save configuration
+    set_fact:
+      save_config: "configuration write"
+
+  - name: Save current switch configuration to startup-configuration
+    include_tasks: global_config.yml
+    with_items: "{{ save_config }}"
+
+  when: save_changes_to_startup

+ 30 - 0
control_plane/roles/network_ib/tasks/snmp_config.yml

@@ -0,0 +1,30 @@
+# 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: Configure SNMP
+  block:
+  - name: Set parameters for SNMP configuration
+    set_fact:
+      snmp_config:
+        - "snmp-server enable"
+        - "snmp-server enable notify"
+        - "snmp-server community {{ snmp_community_name }} ro"
+        - "snmp-server host {{ snmp_trap_destination }} traps version 1 {{ snmp_community_name }}"
+
+  - name: Configure SNMP on Switch
+    include_tasks: global_config.yml
+    with_items: "{{ snmp_config }}"
+
+  when: snmp_trap_destination | length > 1

+ 22 - 0
control_plane/roles/network_ib/vars/main.yml

@@ -0,0 +1,22 @@
+# 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.
+---
+# vars file for network_ib
+
+# Usage: pre_requisites.yml
+base_vars_file: "{{ role_path }}/../../input_params/base_vars.yml"
+config_file: "{{ role_path }}/../../input_params/ib_vars.yml"
+fail_msg_config_file: Inifiniband config file doesn't exist.
+success_msg_save_config: Infiniband config file validated.
+fail_msg_save_config: save_changes_to_startup variable can only be set to true or false.