<commit_before>###
# Copyright (2016) Hewlett Packard Enterprise Development LP
#
# 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.
###
---
- hosts: all
  vars:
    config: "{{ playbook_dir }}/oneview_config.json"
    permitted_interconnect_type_uri: "/rest/sas-interconnect-types/Synergy12GbSASConnectionModule"
  vars_files:
    # The hostnames and credentials of the enclosure and storage system must be defined in the file /vars/config.yml
    - '{{ playbook_dir }}/vars/config.yml'

  tasks:
    - name: Create a SAS Logical Interconnect Group
      oneview_sas_logical_interconnect_group:
        config: "{{ config }}"
        state: present
        data:
          name: "Test SAS Logical Interconnect Group"
          state: "Active"
          interconnectMapTemplate:
            interconnectMapEntryTemplates:
              - logicalLocation:
                  locationEntries:
                    - type: "Bay"
                      relativeValue: "1"
                    - type: "Enclosure"
                      relativeValue: "1"
                enclosureIndex: "1"
                permittedInterconnectTypeUri: "{{ permitted_interconnect_type_uri }}"
              - logicalLocation:
                  locationEntries:
                    - type: "Bay"
                      relativeValue: "4"
                    - type: "Enclosure"
                      relativeValue: "1"
                enclosureIndex: "1"
                permittedInterconnectTypeUri: "{{ permitted_interconnect_type_uri }}"
          enclosureType: "SY12000"
          enclosureIndexes: [1]
          interconnectBaySet: "1"
      delegate_to: localhost

    - name: Create an Enclosure Group
      oneview_enclosure_group:
        config: "{{ config }}"
        state: present
        data:
            name: "Test Enclosure Group"
            stackingMode: "Test Enclosure"
            ipAddressingMode: "DHCP"
            enclosureCount: 3
            interconnectBayMappingCount: 6
            stackingMode : "Enclosure"
            powerMode: "RedundantPowerFeed"
            interconnectBayMappings:
                - interconnectBay: 1
                  enclosureIndex: 1
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 1
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 1
                  enclosureIndex: 2
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 2
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 1
                  enclosureIndex: 3
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 3
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
      delegate_to: localhost

      #- name: Gather facts about all Server Hardwares
      #oneview_server_hardware_facts:
      #  config: "{{ config }}"
      #delegate_to: localhost

      #- name: 'Validate exist server hardwares'
      #fail: msg="Please verify the hardware setup."
      #when: (server_hardwares.0 is undefined or server_hardwares.0 is none)

<commit_msg>Adds plays to ensure Logical Enclosure and Server Profile with Local Storage are present<commit_after>###
# Copyright (2016) Hewlett Packard Enterprise Development LP
#
# 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.
###
---
- hosts: all
  vars:
    config: "{{ playbook_dir }}/oneview_config.json"
    permitted_interconnect_type_uri: "/rest/sas-interconnect-types/Synergy12GbSASConnectionModule"
    sas_logical_interconnect_group_name: "SAS Logical Interconnect Group Oneview Ansible"
    enclosure_group_name: "Enclosure Group Oneview Ansible"
    enclosure_name: 'encl-oneview-ansible'
    server_profile_name: 'Server Profile with Local Storage Oneview Ansible'
  tasks:
    - name: Ensure the SAS Logical Interconnect Group is present
      oneview_sas_logical_interconnect_group:
        config: "{{ config }}"
        state: present
        data:
          name: "{{ sas_logical_interconnect_group_name }}"
          state: "Active"
          interconnectMapTemplate:
            interconnectMapEntryTemplates:
              - logicalLocation:
                  locationEntries:
                    - type: "Bay"
                      relativeValue: "1"
                    - type: "Enclosure"
                      relativeValue: "1"
                enclosureIndex: "1"
                permittedInterconnectTypeUri: "{{ permitted_interconnect_type_uri }}"
              - logicalLocation:
                  locationEntries:
                    - type: "Bay"
                      relativeValue: "4"
                    - type: "Enclosure"
                      relativeValue: "1"
                enclosureIndex: "1"
                permittedInterconnectTypeUri: "{{ permitted_interconnect_type_uri }}"
          enclosureType: "SY12000"
          enclosureIndexes: [1]
          interconnectBaySet: "1"
      delegate_to: localhost

    - name: Ensure the Enclosure Group is present
      oneview_enclosure_group:
        config: "{{ config }}"
        state: present
        data:
            name: "{{ enclosure_group_name }}"
            ipAddressingMode: "DHCP"
            enclosureCount: 3
            interconnectBayMappingCount: 6
            stackingMode : "Enclosure"
            powerMode: "RedundantPowerFeed"
            interconnectBayMappings:
                - interconnectBay: 1
                  enclosureIndex: 1
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 1
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 1
                  enclosureIndex: 2
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 2
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 1
                  enclosureIndex: 3
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
                - interconnectBay: 4
                  enclosureIndex: 3
                  logicalInterconnectGroupUri: '{{ sas_logical_interconnect_group.uri }}'
      delegate_to: localhost

    - name: Gather facts about all Enclosures
      oneview_enclosure_facts:
        config: "{{ config }}"
      delegate_to: localhost

    - name: Validate the Enclosures
      fail: msg="Three enclosures are required to run this example."
      when: (enclosures|length < 3)

    - name: Sort the enclosures by name
      set_fact: enclosures_ordered="{{enclosures | sort(attribute='name') | list }}"

    - name: Ensure the Logical Enclosure is present
      oneview_logical_enclosure:
        config: "{{ config }}"
        state: present
        data:
            name: "{{ enclosure_name }}"
            enclosureUris:
              - "{{ enclosures_ordered.0.uri }}"
              - "{{ enclosures_ordered.1.uri }}"
              - "{{ enclosures_ordered.2.uri }}"
            enclosureGroupUri: "{{ enclosure_group.uri }}"
      delegate_to: localhost

    - name: Gather facts about all Server Hardwares
      oneview_server_hardware_facts:
       config: "{{ config }}"
      delegate_to: localhost

    - name: Validate the Hardware Setup
      fail: msg="No server hardware found. Please verify the Hardware Setup."
      when: (server_hardwares.0 is undefined or server_hardwares.0 is none)

    - name : Ensure the Server Profile with Local Storage is present
      oneview_server_profile:
         config: "{{ config }}"
         state: "present"
         data:
           name: '{{  server_profile_name }}'
           localStorage:
             sasLogicalJBODs:
               - id: 1
                 deviceSlot: "Mezz 1"
                 name: "Data Storage"
                 numPhysicalDrives: 1
                 driveMinSizeGB: 44
                 driveMaxSizeGB: 4444
                 driveTechnology: "SasHdd"
                 sasLogicalJBODUri: null
               - id: 2
                 deviceSlot: "Mezz 1"
                 name: "Recovery Volume"
                 numPhysicalDrives: 2
                 driveMinSizeGB: 44
                 driveMaxSizeGB: 4444
                 driveTechnology: "SasHdd"
                 sasLogicalJBODUri: null
             controllers:
               - deviceSlot: "Embedded"
                 mode: "RAID"
                 initialize: False
                 importConfiguration: false
                 logicalDrives:
                   - name: "Operating System"
                     raidLevel: "RAID1"
                     bootable: false
                     numPhysicalDrives: 2
                     driveTechnology: null
                     sasLogicalJBODId: null
               - deviceSlot: "Mezz 1"
                 mode: "RAID"
                 initialize: false
                 importConfiguration: false
                 logicalDrives:
                   - name: null
                     raidLevel: "RAID0"
                     bootable: false
                     numPhysicalDrives: null
                     driveTechnology: null
                     sasLogicalJBODId: 1
                   - name: null
                     raidLevel: "RAID1"
                     bootable: false
                     numPhysicalDrives: null
                     driveTechnology: null
                     sasLogicalJBODId: 2

{'fraction_non_alphanumeric': 0.07295585941084702, 'fraction_numerical': 0.009819216298063687, 'mean_word_length': 1.7772680937818552, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1995232', 'n_tokens_mistral': 2943, 'n_tokens_neox': 2734, 'n_words': 731}