DungKHoang / Import-Export-OneView-Resources

5 stars 2 forks source link

Import and Export OneView resources

Import-OVResources.ps1 and Export-OVResources.ps1 are PowerShell scripts that leverage HPE OneView PowerShell library and Excel to automate configuration of OneView resources

Export-OVresources.ps1 queries OneView to collect OV resources settings and save them in Excel spreadsheets.

Import-OVResources.ps1 reads Excel sheets for values of OV resources and generate PowerShell scripts to create OV resources in OneView destination.

Prerequisites

Both scripts require:

Those modules can be pulled from the Microsoft PowerShell Gallery.

Excel spreadsheet

OV-Template.xlsx is required and used by Export-OVResources.ps1. It must reside in the same folder as the scripts

OneView environment

The scripts have been tested on

OneView scripts

You need to download/use the corresponding OneView PowerShell library. You can search for the POSH version on powerShellGallery using the keyword OneView.

Here is an example on how to install OneView 5.20

Install-Module -Name HPOneView.520 -RequiredVersion 5.20.2452.2750

Install-Module -Name ImportExcel

Export-OVResources.PS1

Export-OVResources.ps1 is a PowerShell script that exports OV resources into Excel spreadsheets including:

Syntax

To export OneView resources

    .\Export-OVResources.ps1 -jsonConfigFiles <list-of-jsonfiles>

where jsonfile uses the following syntax:

{                                         
     "ip":              "<OV-IP>",  
     "loginAcknowledge": "true",      
     "credentials" :    {               
         "userName":    "<admin-account>",         
         "password":    "<admin-password>",   
         "authDomain":  "<LDAP-domain> or <LOCAL>"       
      },                                  
     "api_version" :     "2000"         
}

The script will read the OV-Template located in the same folder and jsonfiles to connect to multiple Oneview instances, if needed.

It will then write down values to Excel spreadsheets with names ExportFrom-.xlsx

For example: .\Export-OVResources.ps1 -jsonConfigFiles 192.168.1.51.json, 192.168.1.175.json will generate Excel files named as : ExportFrom-192.168.1.51.xlsx and ExportFrom-192.168.1.175.xlsx

Note: Ensure that you have OV-Template.xlsx in the same folder as the script

Import-OVResources.PS1

Import-OVResources.ps1 is a PowerShell script that configures OV resources based on Excel sheets. It generates scripts for the follwoing resources:

OneView resource PowerShell script Ansible playbook
Address Pool X X
Ethernet networks X X
FC/FCOE networks X X
Network set X X
Logical InterConnect Groups X X
Uplink sets X X
Enclosure group X X
Logical enclosure with EBIPA X X
Network connections X X
Local Storage connections X
iLO settings in profiles X X
Server profile - Templates X X
Appliance SNMP Settings X X
Backup configuration X
Time & Locale Settings X
Proxy settings X
Backup Settings X
Firmware bundles X

Syntax

There are 2 use cases:

The Import-OVResources.ps1 will read the 'OV destination' to generate commands to connect to the OneView instance at destination

To generate the scripts for importing, run the command

    .\Import-OVResources.ps1 -workbook < Excel file>

The script will:

Examples

The ZIp file provides examples of PowerShell scrips and Ansible playbooks genefrated by the Import script. For addtional examples of Ansible playbooks, please visit this github site: https://github.com/DungKHoang/Examples-OneView-Ansible-Playbook

Actions

Enjoy!

Updates

Date Description
June 2021 - Fix issue #5
- Validate custom MAC/WWPN in SP
- Fix Boot from SAN with Target Lun