Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

HPE OneView Python Windows Setup Guide

Gustavo Augusto Hennig edited this page May 31, 2016 · 1 revision

Table of Contents generated with DocToc

Windows Setup Guide

Objectives

This setup guide is designed to provide you with basic understanding of the installation of Python and the python-hpOneView library with example scripts in a Microsoft Windows environment.

Description

In this guide, you will install the necessary components to utilize the HPE OneView Appliance with the OneView Python libraries.

Exercise 1: Install the Required Components

Description

In this section you will install Python, validate that the correct version of Python is installed, verify that Python is in the system path and that the HPE OneView appliance is installed and ready for use.

Task 1. Install version 3.4.x of the Python Interpreter

  1. Download the Windows Python 64-bit installer and run it to start the installation

    https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi

  2. During the installation accept all of the defaults until the following screen comes up. Make sure to install the “Add python.exe to Path” feature.

Windows Python Setup Screen

Task 2. Download and install the latest version of the Python library for HPE OneVew.

  1. Download the latest version of the Python library for HPE OneView from GitHub. When you download from this URL the current top of tree source will be downloaded. In other words if you download the file today and download it again tomorrow it may be different:

    https://github.com/HewlettPackard/python-hpOneView/archive/master.zip

  2. Unpack the python-hpOneView zip file that you downloaded

  3. Open a command prompt and cd to the directory where you unpacked the python-hpOneView.zip file and run the command “python setup.py install” to install the library.

Screen capture running the command "python setup.py install"

Task 3. Validate Python version and connect to the Appliance

Open a command prompt and type python to validate that Python 3.4.x is installed and in the system path:

  1. This will launch the python interpreter and show the version. Type “exit()” and press return to exit back to the command prompt.

  2. If you get the message ‘python’ is not recognized as an internal or external interpreter see “Case 3” in the troubleshooting appendix.

Screen capture showing that running python starts the python interpreter"

  1. Change directory to the location where you unzipped the OneView Python library and to the examples/scripts sub folder. For example:
   cd C:\Users\Administrator\Downloads\python-hpOneView-master\examples\scripts

Screen capture showing the location of the examples scripts folder"

  1. Run the “get-xapi.py” script to verify that communication and authentication with the OneView appliance.

Screen capture showing the execution of the get-xai.py script"

Verify that you see a current and minimum version and do not have a login failed message. If you do see a login failed ensure that the username and password options are correctly specified.

Appendix A: Troubleshooting

Case 1. UnicodeEncodeError: ‘charmap’ codec can’t encode character

If you get an error that looks like this it is because the default Windows terminal is not set to display Unicode characters.

Screen capture showing the error "UnicodeEncodeError: 'charmap' codec can't encode character '\u2013'"

This can be resolved by changing the code page that is used for the console display by using the “Change Code Page” command in the command prompt “chcp 65001”. 65001 is Microsoft’s name for the UTF-8 character encoding scheme.

Screen capture showing command "chcp 65001"

NOTE: Entering this command only temporarily changes the code page for this single instance of the command prompt. There is a registry entry that can be modified to make the default code page be UTF-8 instead of ASCII but that is beyond the scope of this document.

Case 2. ‘python’ is not recognized as an internal or external command

When you try to run “python” you get the following error message:

Screen capture showing command "chcp 65001"

This means that the Python interpreter is not in the system path. You can add it by going to computer properties -> Advanced Settings -> Advanced tab -> Environment Variables button -> Scroll down in the System variables list select Path -> Edit and add “C:\Python34;” without the quotes to the front of the “Variable value” line. Close and reopen the command prompt and you should now be able to run pyton.

Screen capture showing command "chcp 65001"

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.