HewlettPackard / oneview-ansible

This project is no longer being developed and has limited support. Please use the newer Ansible Collection project: https://github.com/HewlettPackard/oneview-ansible-collection
Apache License 2.0
104 stars 65 forks source link

How to start using #429

Closed bradawk1 closed 5 years ago

bradawk1 commented 5 years ago

Scenario/Intent

Just trying to understand the mechanics of starting to use the python OneView interface.

Environment Details

Steps to Reproduce

I've downloaded the sdk to ~/python-hpOneView. Not wanting to alter the sdk code, I created my working directory as ~/tasks and a ~/config.json with contents:

config = {
  "ip": "1.2.3.4",
  "credentials": {
    "userName": "Administrator",
    "authLoginDomain": "",
    "password": 'mypassword'
  },
  "api_version": 1000,
  "ssl_certificate": "~/oneview.crt"
}

I ran python setup.py install --user I then copied one of the examples over to my tasks directory and edited it. Contents of server_hardware_types.py:

import sys
sys.path.append('/home/mysid/python-hpOneView/examples')
from pprint import pprint
from hpOneView.oneview_client import OneViewClient
from config_loader import try_load_from_file
config = try_load_from_file('/home/mysid/config.json')
oneview_client = OnceViewClient(config)
server_hardware_types - oneview_client.server_hardware_types
print("\nGet all server hardware types")
server_hardware_types_all = server_hardware_types.get_all()
pprint(server_hardware_types_all, depth=3)

Expected Result

A listing of the server hardware types

Actual Result

Traceback (most recent call last): File "server_hardware_types.py", line 9, in oneview_client = OneViewClient(config) File "build/bdist.linux-x86_64/egg/hpOneView/oneview_client.py", line 124, in init self.__connection = connection(config["ip"], config.get('api_version", self.DEFAULT_API_VERSION), config.get('ssl_certificate', False), TypeError: string indices must be integers, not unicode

I've programmed in a lot of languages, but python is rather new to me. I'm not sure which indice it is referring to?

sijeesh commented 5 years ago

@bradawk1, You have opened this issue on the wrong repository.

Please refer the Python repository of OneView - https://github.com/HewlettPackard/python-hpOneView

bradawk1 commented 5 years ago

Sorry, I put this in the wrong repository. I meant to put it in the OneView SDK for Python.

sijeesh commented 5 years ago

NP, Closing it, please open an issue on Python package.