Code Monkey home page Code Monkey logo

oneview-python's Introduction

HPE OneView SDK for Python

Build Status

OV Version 8.90 8.80 8.70 8.60 8.50 8.40 8.30 8.20 8.10 8.00 7.20 7.10 7.00 6.60 6.50 6.40 6.30 6.20 6.10 6.00 5.60
SDK Version/Tag v8.9.0 v8.8.0 v8.7.0 v8.6.0 v8.5.1 v8.4.0 v8.3.0 v8.2.0 v8.1.0 v8.0.0 v7.2.0 v7.1.0 v7.0.0 v6.6.0 v6.5.0 v6.4.0 v6.3.0 v6.2.0 v6.1.0 v6.0.0 v5.6.0
Build Status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status Build status

Introduction

HPE OneView makes it simple to deploy and manage today’s complex hybrid cloud infrastructure. HPE OneView can help you transform your data center to software-defined, and it supports HPE’s broad portfolio of servers, storage, and networking solutions, ensuring the simple and automated management of your hybrid infrastructure. Software-defined intelligence enables a template-driven approach for deploying, provisioning, updating, and integrating compute, storage, and networking infrastructure.

The HPE OneView Python library provides a pure Python interface to the HPE OneView REST APIs. It depends on the Python-Future library to provide Python 2/3 compatibility.

You can find the latest supported HPE OneView Python SDK here

Refer to

Supported HPE OneView Python APIs Implementation and Latest version of the OneView Python SDK Documentation

What's New

HPE OneView Python library extends support of the SDK to OneView REST API version 6400 (OneView v8.90)

Migration script

Perform migration from HPE OneView 6.x to HPE OneView 7.0 for non-Synergy appliance using below script.

   $ git clone https://github.com/HewlettPackard/oneview-python.git
   $ cd oneview-python/examples/migration/
   $ python migrate.py [<list of server hardwware names to be migrated>] 

Please refer to notes for more information on the changes , features supported and issues fixed in this version

Getting Started

HPE OneView SDK for Python can be installed from Source,Pypi and Docker container installation methods.

From Source

$ git clone https://github.com/HewlettPackard/oneview-python.git
$ cd oneview-python 
$ python setup.py install --user  # to install in the user directory (~/.local)
$ sudo python setup.py install    # to install globally

Or using PIP:

$ git clone https://github.com/HewlettPackard/oneview-python.git 
$ cd oneview-python 
$ pip install . 

From Pypi

$ git clone https://github.com/HewlettPackard/oneview-python.git
$ cd oneview-python 
$ pip install hpeOneView 

From Docker Image / Container

Clone this repo and cd into it:

$ git clone https://github.com/HewlettPackard/oneview-python.git
$ cd oneview-python

Build the docker image:

$ docker build -t oneview-python . 

Now you can run any of the example in this directory: Run the container, passing in your credentials to OneView and specifying which example recipe to run.
-v: The volume on which repo code is mounted
Replace connection_templates with the name of the example you'd like to run
Replace pwd with the path of the example file you'd like to run.

$ docker run -it --rm \ -v $(pwd)/:/root/oneview/ python examples/connection_templates.py

Running Examples with published docker image

We also provide a lightweight and easy way to test and run oneview-python. The hewlettpackardenterprise/hpe-oneview-sdk-for-python: docker image contains an installation of oneview-python installation you can use by just pulling down the Docker Image:

The Docker Store image tag consist of two sections: <sdk_version-OV_version>

Download and store a local copy of hpe-oneview-sdk-for-python and use it as a Docker image.

$ docker pull hewlettpackardenterprise/hpe-oneview-sdk-for-python:v8.9.0-OV8.9

Run docker commands and this will in turn create sh session where you can create files, issue commands and execute the tests

$ docker run -it hewlettpackardenterprise/hpe-oneview-sdk-for-python:v8.9.0-OV8.9 /bin/sh

Configuration

JSON:

Connection properties for accessing the OneView appliance can be set in a JSON file. Before running the samples or your own scripts, you must create the JSON file. An example can be found at: OneView configuration sample.

Note: If you have an active and valid login session and want to use it, define the sessionID in the Credentials. When sessionID is defined, you can remove username and password from your JSON (they will be disregarded anyway).

Once you have created the JSON file, you can initialize the OneViewClient:

from hpeOneView.oneview_client import OneViewClient
oneview_client = OneViewClient.from_json_file('/path/config.json')

🔒 Tip: Check the file permissions because the password is stored in clear-text.

Environment Variables:

Configuration can also be defined through environment variables:

Required

export ONEVIEWSDK_IP='172.16.102.82'
export ONEVIEWSDK_USERNAME='Administrator'
export ONEVIEWSDK_PASSWORD='secret123'

Or sessionID

 export ONEVIEWSDK_SESSIONID='123'

Once you have defined the environment variables, you can initialize the OneViewClient using the following code snippet:

 from hpeOneView.oneview_client import OneViewClient
 oneview_client = OneViewClient.from_environment_variables()

🔒 Tip: Make sure no unauthorized person has access to the environment variables, since the password is stored in clear-text.

Note: If you have an active and valid login session and want to use it, define the ONEVIEWSDK_SESSIONID. When a sessionID is defined, it will be used for authentication (username and password will be ignored in this case).

Dictionary:

# You can also set the configuration using a dictionary. As described above, for authentication you can use username/password:
config = { 
  "ip": "172.16.102.82", 
  "credentials": { 
      "userName": "Administrator",
      "password": "secret123"
  }
}
#Or if you have an active and valid login session and want to use it, define the sessionID in the Credentials:
config = {
  "ip": "172.16.102.82",
  "credentials": { 
      "sessionID": "123" 
  } 
}
# If you need to use a proxy server, You can add the same in config dictionary as below:
config = { 
  "ip": "172.16.102.82",
  "proxy": "1.2.3.4:8080",
  "credentials": {
      "userName": "Administrator",
      "password": "secret123"
  }
}
 from hpeOneView.oneview_client import OneViewClient
 oneview_client = OneViewClient(config) 

🔒 Tip: Check the file permissions because the password is stored in clear-text.

For more details on the Installation , Configuration , Logging , Troubleshooting refer to WIKI# Installation & Configuration section.

HPE Synergy Image Streamer

From Release 8.1, Image streamer is no longer supported.

Getting Help

Are you running into a road block? Have an issue with unexpected bahriov? Feel free to open a new issue on the issue tracker

For more information on how to open a new issue refer to How can I get help & support

License

This project is licensed under the Apache license. Please see LICENSE for more information.

Additional Resources

HPE OneView Documentation

HPE OneView Release Notes

HPE OneView Support Matrix

HPE OneView Installation Guide

HPE OneView User Guide

HPE OneView Online Help

HPE OneView REST API Reference

HPE OneView Firmware Management White Paper

HPE OneView Deployment and Management White Paper

HPE OneView Community

HPE OneView Community Forums

Learn more about HPE OneView at hpe.com/info/oneview

oneview-python's People

Contributors

akshith-gunasheelan avatar alisha-k-kalladassery avatar arthurzenika avatar asisbagga avatar automationforsdk avatar bobfraser1 avatar chebroluharika avatar harikachebrolu avatar nabhajit-ray avatar satyasreenivas avatar shandcruz avatar sijeesh avatar spapinwar12 avatar srija-papinwar avatar srijapapinwar avatar uppadara avatar venkateshravula avatar yuvirani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oneview-python's Issues

line 153, in __update_resource_assignments\nAttributeError: 'NoneType' object has no attribute 'patch'\n"

Hi,

Versions used:

  • Python: 3.8
  • Ansible: 2.9.13
  • hpeOneView: 5.4.0
  • oneview-ansible : latest version
  • Operating System: RHEL 8.2
  • OneView: 5.20.00-0419867

I am using OneView Ansible module on Synergy and I am facing a bug when I am trying to assign a resource to a scope.

Python returns a NoneType error:

"/tmp/ansible_oneview_scope_payload_d5cf8bie/ansible_oneview_scope_payload.zip/ansible/modules/oneview_scope.py", line 153, in __update_resource_assignments\nAttributeError: 'NoneType' object has no attribute 'patch'\n", "module_stdout": "", "msg": "MODULE FAILURE\

The self.current_resource objet is not defined at line 153 of the source code:
https://github.com/HewlettPackard/oneview-ansible/blob/master/library/oneview_scope.py

You will find below my playbook:

---
- hosts: oneview
  vars:
    # Python
    ansible_python_interpreter: /usr/bin/python3.8
    config: "/root/oneview.json"
    uri_scope: "/rest/server-profile-templates/bdbba95d-3272-4eed-8a72-471b8e90120a"
  vars_files:
    - /root/oneview_config.yml

  tasks:
    - name: Get SPT
      oneview_server_profile_template_facts:
        config: "{{ config }}"
        name: "ProfileTemplate102"
      delegate_to: localhost
      register: spt

    - debug: var=spt["ansible_facts"]["server_profile_templates"][0]["uri"]

    - name: Update the scope resource assignments, adding a resource
      oneview_scope:
        config: '{{ config }}'
        state: resource_assignments_updated
        data:
          name: "ScopeDev"
          resourceAssignments:
            addedResourceUris: '{{ spt["ansible_facts"]["server_profile_templates"][0]["uri"] }}'
      delegate_to: localhost

The oneview.json file contains:

[root@rhel82 ~]# cat oneview.json
{
  "ip": "192.168.10.55",
  "credentials": {
    "userName": "Administrator",
    "authLoginDomain": "",
    "password": "****"
  },
  "api_version": 1600
}

I thank you,

Best Regards,
Nicolas Portais

Below the execution of the playbook:

# ansible-playbook -v assign_scope.yml
Using /etc/ansible/ansible.cfg as config file

PLAY [oneview] ***************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************
ok: [192.168.10.222]

TASK [Get SPT] ***************************************************************************************************************************************************************************************************
ok: [192.168.10.222] => {"ansible_facts": {"server_profile_templates": [{"affinity": "Bay", "bios": {"complianceControl": "Unchecked", "manageBios": false, "overriddenSettings": []}, "boot": {"complianceControl": "Unchecked", "manageBoot": false, "order": []}, "bootMode": {"complianceControl": "Unchecked", "manageMode": false, "mode": null, "pxeBootPolicy": null, "secureBoot": "Unmanaged"}, "category": "server-profile-templates", "connectionSettings": {"complianceControl": "CheckedMinimum", "connections": [{"functionType": "Ethernet", "id": 1, "isolatedTrunk": false, "lagName": null, "managed": true, "name": "Prod-NetworkSet-1", "networkName": null, "networkUri": "/rest/ethernet-networks/3f794477-d9f6-45ea-920b-0a18b9c87151", "portId": "Mezz 3:1-c", "requestedMbps": "2500", "requestedVFs": "Auto"}], "manageConnections": true}, "created": "2020-10-01T08:04:39.129Z", "description": "", "eTag": "1601541803405/5", "enclosureGroupUri": "/rest/enclosure-groups/aade80e1-906e-4198-b803-970eb4058de9", "firmware": {"complianceControl": "Unchecked", "forceInstallFirmware": false, "manageFirmware": false}, "hideUnusedFlexNics": true, "iscsiInitiatorNameType": "AutoGenerated", "localStorage": {"complianceControl": "Unchecked", "controllers": [], "sasLogicalJBODs": []}, "macType": "Virtual", "managementProcessor": {"complianceControl": "Unchecked", "manageMp": false, "mpSettings": []}, "modified": "2020-10-01T08:43:23.405Z", "name": "ProfileTemplate102", "osDeploymentSettings": null, "sanStorage": {"complianceControl": "Unchecked", "manageSanStorage": false, "sanSystemCredentials": [], "volumeAttachments": []}, "scopesUri": "/rest/scopes/resources/rest/server-profile-templates/bdbba95d-3272-4eed-8a72-471b8e90120a", "serialNumberType": "Virtual", "serverHardwareTypeUri": "/rest/server-hardware-types/BC459A8E-1818-421F-98F7-BA4C5CCBF840", "serverProfileDescription": "", "state": null, "status": "OK", "type": "ServerProfileTemplateV8", "uri": "/rest/server-profile-templates/bdbba95d-3272-4eed-8a72-471b8e90120a", "wwnType": "Virtual"}]}, "changed": false}

TASK [debug] *****************************************************************************************************************************************************************************************************
ok: [192.168.10.222] => {
    "spt[\"ansible_facts\"][\"server_profile_templates\"][0][\"uri\"]": "/rest/server-profile-templates/bdbba95d-3272-4eed-8a72-471b8e90120a"
}

TASK [Update the scope resource assignments, adding a resource] **************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'patch'
fatal: [192.168.10.222]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1601989582.9783294-31067-40376887274795/AnsiballZ_oneview_scope.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1601989582.9783294-31067-40376887274795/AnsiballZ_oneview_scope.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1601989582.9783294-31067-40376887274795/AnsiballZ_oneview_scope.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.oneview_scope', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.8/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 95, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_oneview_scope_payload_tuf7y14q/ansible_oneview_scope_payload.zip/ansible/modules/oneview_scope.py\", line 184, in <module>\n  File \"/tmp/ansible_oneview_scope_payload_tuf7y14q/ansible_oneview_scope_payload.zip/ansible/modules/oneview_scope.py\", line 180, in main\n  File \"/tmp/ansible_oneview_scope_payload_tuf7y14q/ansible_oneview_scope_payload.zip/ansible/module_utils/oneview.py\", line 475, in run\n  File \"/tmp/ansible_oneview_scope_payload_tuf7y14q/ansible_oneview_scope_payload.zip/ansible/modules/oneview_scope.py\", line 145, in execute_module\n  File \"/tmp/ansible_oneview_scope_payload_tuf7y14q/ansible_oneview_scope_payload.zip/ansible/modules/oneview_scope.py\", line 154, in __update_resource_assignments\nAttributeError: 'NoneType' object has no attribute 'patch'\n", "module_stdout": "#### self.current_resource <__main__.ScopeModule object at 0x7f20eee53400>\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP *******************************************************************************************************************************************************************************************************
192.168.10.222             : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

New Hardware needs attachment to existing SCOPE and PROFILE

2 Questions

I create new server_hardware(iLO IP) in a oneview instance.
I need to attach above to existing SCOPE=FOO_SCOPE and Server Profile="FOO_SVR_PROFILE"
I am confused as to How do I go about doing this?

Do I first Create the empty server hardware without a profile and a scope and then added or do I create a server with the scope in the profile attached as per the options list below
each object has too many Uris??

  
server_hardwares = oneview_client.server_hardware
   # Create a rack-mount server
      options = {
         "hostname": config['server_hostname'],
         "username": config['server_username'],
         "password": config['server_password'],
         "licensingIntent": "OneView",
         "configurationState": "Managed",
         "scopesUri":'/rest/FOO_SCOPES/Uri",
         "serverProfileUri":'/rest/FOO_SVR_PROFILE/Uri"
      }
    try:
        server = server_hardwares.add(options)
        print("Issue: added  successfully!")
    except Exception as ex:
        print("Issue: ERROR: Can't add "+server_name+" ")
        pprint(str(ex))
        sys.exit()

or do I create thr empty server hardware resource and then
find "what" uri?what is resource_uri_1
and attach it to the FOO_SCOPE

        print("\n## Update the scope resource assignments, adding two resources")
        options = {
            "addedResourceUris": [resource_uri_1, resource_uri_2]
        }
        scopes.update_resource_assignments(scope['uri'], options)
        print("  Done.")

loginMsgAck is not handled in python code

When "Require Acknowledgement" is enabled in oneview, loginMsgAck parameter should be provided in config and the same should be handled in oneview library.
loginMsgAck should be true by default.

firmware drivers does not have standard method get_by_uri and get_by_name

oneview_client.firmware_drivers does not support get_by_name nor get_by_uri

Example of code:
\ thisfw = oneview_client.firmware_drivers.get_by_uri('/rest/firmware-drivers/SPP_2018_11_20190405_for_HPE_Synergy_Z7550-96678')
AttributeError: 'FirmwareDrivers' object has no attribute 'get_by_uri'

HPEOneViewTaskError: The selected server hardware does not appear to have an integrated SAS controller.

We are using ansible for Assigning profiles to Servers using HPOneView and in that we are frequently getting the error that server hardware does not appear to have any integreated SAS controller.
{"changed": false, "module_stderr": "/usr/lib/python2.7/site-packages/hpeOneView-5.4.0-py2.7.egg/hpeOneView/init.py:47: Warning: Running unsupported Python version: 2.7.5, unexpected errors might occur. Use of Python v2.7.9+ is advised.\nTraceback (most recent call last):\n File "/home/ibmadm/.ansible/tmp/ansible-tmp-1625899104.61-8027-179377823515946/AnsiballZ_oneview_server_profile.py", line 102, in \n _ansiballz_main()\n File "/home/ibmadm/.ansible/tmp/ansible-tmp-1625899104.61-8027-179377823515946/AnsiballZ_oneview_server_profile.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/ibmadm/.ansible/tmp/ansible-tmp-1625899104.61-8027-179377823515946/AnsiballZ_oneview_server_profile.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.oneview_server_profile', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib64/python2.7/runpy.py", line 176, in run_module\n fname, loader, pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in run_globals\n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/modules/oneview_server_profile.py", line 670, in \n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/modules/oneview_server_profile.py", line 666, in main\n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/module_utils/oneview.py", line 475, in run\n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/modules/oneview_server_profile.py", line 280, in execute_module\n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/modules/oneview_server_profile.py", line 320, in __present\n File "/tmp/ansible_oneview_server_profile_payload_lEqRzF/ansible_oneview_server_profile_payload.zip/ansible/modules/oneview_server_profile.py", line 449, in __create_profile\n File "build/bdist.linux-x86_64/egg/hpeOneView/resources/servers/server_profiles.py", line 74, in create\n resource_data = self._helper.create(data, timeout=timeout, force=force)\n File "build/bdist.linux-x86_64/egg/hpeOneView/resources/resource.py", line 430, in create\n return self.do_post(uri, data, timeout, custom_headers)\n File "build/bdist.linux-x86_64/egg/hpeOneView/resources/resource.py", line 765, in do_post\n return self._task_monitor.wait_for_task(task, timeout)\n File "build/bdist.linux-x86_64/egg/hpeOneView/resources/task_monitor.py", line 82, in wait_for_task\n task_response = self.__get_task_response(task)\n File "build/bdist.linux-x86_64/egg/hpeOneView/resources/task_monitor.py", line 142, in __get_task_response\n raise HPEOneViewTaskError(msg, error_code)\nHPEOneViewTaskError: The selected server hardware does not appear to have an integrated SAS controller.\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

We are manually able to create the RAID and SAS controller is working fine. Please if you could help in troubleshooting this issue.

Incompatability with Python 3.12

    from hpeOneView import HPEOneViewTaskError

  File "/usr/local/lib/python3.12/site-packages/hpeOneView/__init__.py", line 12, in <module>

    from future import standard_library

  File "/usr/local/lib/python3.12/site-packages/future/standard_library/__init__.py", line 65, in <module>

    import imp

ModuleNotFoundError: No module named 'imp'

Hello,

it seams like this Python package is using deprecated packages, which where removed in Python 3.12. "imp" no longer exists in python 3.12.. Could you please update dependencies/ the way you are working with libraries.

Thank You!

How to replicate settings from 1 OV to many OV instances #590

I have say 10 OV Instances in production.
I configure the settings for notifcationsn 1 OV or the network settings.

How cn I replicate this throughtout my 9 OV instances?

a) Is there a file with ALL OneView Attribs and there values, that I can get perhap iva REST API? in json/xml, that i can export and import

Question above spans DL and Synergy. (OV Composer1,2 and esx based image for DL's)

TypeError running examples

I am trying to learn the oneview SDK as I have needing to interface with iLO controls, and which ever examples code I try and runm I always get the following error:

TypeError: string indices must be integers, not unicode.

I am using the latest SDK from the master branch, my ILO is is DL360 G9, & ILO firmware is 2.55, Aug 16 2017,

How to access firmware component names and version num assigned to the current FW bundle in the HPE Hardware?

I want to know which is the current bundle appplied to my Hardware.
What are the ComponentNames and what are there Versions. w.r.t to the bundle

I tried to use, https://github.com/HewlettPackard/oneview-python/blob/master/examples/firmware_drivers.py
but it only gives me the information on the drivers. NOT what i want

Get list of firmwares managed by the appliance.
- HPE_Synergy_Custom_SPP_202005_2020_05_15_ILO233
- HPE Synergy Custom SPP 202005 2020 05 15
- Service Pack for Synergy
- Custom__SSP_2021_02_02_BIOS250_ILO244
- HPE_Synergy_Custom_SPP_201903_2019_05_14_with_ILO_146_and_BIOS_204
- HPE Synergy 480 Gen10 (I42) Compute Module firmware
- HPE Synergy 480 Gen10 (I42) Compute Module firmware
- 

scmb.py authLoginDomain= local is giving out SSL ERRORs?

Here is the code https://github.com/HewlettPackard/oneview-python/blob/master/examples/scmb/scmb.py
Line 173 - 179

config = {
        "ip": args.host,
        "credentials": {
            "userName": args.user,
            "password": args.passwd
        }
    }

is substituted with

 config = {
        "ip": args.host,
        "credentials": {
            "userName": args.user,
            "password": args.passwd,
            "authLoginDomain": 'local'
        }

python scmb.work.py -a 19.14.XXX.XXX -u administrator -p XXXXXX -d
python scmb.work.py -a 19.14.XX.XX  -u administrator -p XXXXXX 
>> python scmb.work.py -a 19.XX.XX.XX -u administrator -p 'XXXXXXX'
Traceback (most recent call last):
  File "scmb.work.py", line 186, in 
    sys.exit(main())
  File "scmb.work.py", line 179, in main
    recv(args.host, args.route)
  File "scmb.work.py", line 81, in recv
    conn.connect()
  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/amqp/connection.py", line 323, in connect
    self.transport.connect()
  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/amqp/transport.py", line 115, in connect
    self.socket_settings, self.read_timeout, self.write_timeout,
  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/amqp/transport.py", line 225, in _init_socket
    self._setup_transport()
  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/amqp/transport.py", line 405, in _setup_transport
    self.sock.do_handshake()
  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)


> pip freeze |grep amqp
amqp==5.0.5

server_profile_template.get_alll

Get Server Profile Template by scope_uris

if oneview_client.api_version >= 600:
server_profile_templates_by_scope_uris = profile_templates.get_all(
scope_uris=""'/rest/scopes/3bb0c754-fd38-45af-be8a-4d4419de06e9'"") #<--HardCoded

I am trying to create list of existing scopes and then cycle thru them .I can't get that to work, becauase of all the escapes/backslahes/quotation marks???

Here is what I m trying to do:
list=['/rest/scopes/d78fa36d-228a-45f9-a7e7-eeb4ace8984','/rest/scopes/43eea8a3-b050-4ee4-a95b-f3952f391fe5',' /rest/scopes/114f5444-6f84-4263-b2b8-5f0dbc39d8d9']

for item in list:
spt_scope=profile_template.get_all('scope_uris='+item) #<<< This causes errors, WHAT IS THE CORRECT WAY, pprint(spt_scope)

If there is documenttion page on this python function (get_all), please forward that too me. looking for swagger generated doc

MISSING_JSON_TYPE error code is thrown when attempting to restore the appliance

For OneView's X-API-VERSION: 1200 the DTO type for restore is RESTOREV1000. I believe this is causing the below error message when attempting to restore a 5.00 OneView appliance with the default X-API-VERSION.

hpOneView.exceptions.HPOneViewException: ('The "type" field is missing from the JSON.', {'errorCode': 'MISSING_JSON_TYPE', 'message': 'The "type" field is missing from the JSON.', 'details': 'The "type" field was not included in the JSON input of this request, so the request is invalid.', 'recommendedActions': ['Include the "type" field in the JSON and try the request again.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

EthernetNetworks Update does not work

I tried the update method provided in the examples.

This should get a specific network by name and edit its purpose to Management

ethernet_network = oneview_client.ethernet_networks.get_by_name(network_entered)
ethernet_data = ethernet_network.data
ethernet_data['purpose'] = "Management"
ethernet_network.update(ethernet_data)

Actually it runs and edits the ethernet_data to the correct new values
e.g. a print shows new values

{'type': 'ethernet-networkV4', 'uri': '/rest/ethernet-networks/d35197eb-5014-4ba2-8733-04f014f1d9ab', 'category': 'ethernet-networks', 'eTag': '9f1eb265-c956-47f0-8d24-441089a20246', 'created': '2020-08-25T10:40:53.928Z', 'modified': '2020-08-25T10:40:53.939Z', 'scopesUri': '/rest/scopes/resources/rest/ethernet-networks/d35197eb-5014-4ba2-8733-04f014f1d9ab', 'vlanId': 777, 'subnetUri': None, 'ipv6SubnetUri': None, 'connectionTemplateUri': '/rest/connection-templates/f427b030-f590-49e1-b2dd-1d9328d6e631', 'privateNetwork': False, 'smartLink': False, 'purpose': 'Management', 'ethernetNetworkType': 'Tagged', 'fabricUri': '/rest/fabrics/3ce1cfbd-d577-485a-9b63-a3556b11a3ad', 'description': None, 'state': 'Active', 'status': 'OK', 'name': 'networkfromCSVone'}

The update runs as well. I can see in OneView a new Activity Task.
But it shows

Update | 8/25/20  1:49:47 pm15 minutes ago | Completed1s | Administrator
No changes are detected during an edit operation. The resource is not changed.

If i do another grep of the ethernet_data right after the update I can see the data unchanged ...
{'type': 'ethernet-networkV4', 'uri': '/rest/ethernet-networks/d35197eb-5014-4ba2-8733-04f014f1d9ab', 'category': 'ethernet-networks', 'eTag': '9f1eb265-c956-47f0-8d24-441089a20246', 'created': '2020-08-25T10:40:53.928Z', 'modified': '2020-08-25T10:40:53.939Z', 'scopesUri': '/rest/scopes/resources/rest/ethernet-networks/d35197eb-5014-4ba2-8733-04f014f1d9ab', 'vlanId': 777, 'subnetUri': None, 'ipv6SubnetUri': None, 'connectionTemplateUri': '/rest/connection-templates/f427b030-f590-49e1-b2dd-1d9328d6e631', 'privateNetwork': False, 'smartLink': False, 'purpose': 'General', 'ethernetNetworkType': 'Tagged', 'fabricUri': '/rest/fabrics/3ce1cfbd-d577-485a-9b63-a3556b11a3ad', 'description': None, 'state': 'Active', 'status': 'OK', 'name': 'networkfromCSVone'}

I tried with name and vlaniD instead ... same result.

hpeOneView.resources.servers.server_profiles.ServerProfiles GET PROBLEM

Hi,

I'm using: hpeOneView 6.3.0

here is my code:

`
#!/usr/bin/python3
from pprint import pprint
from hpeOneView.oneview_client import OneViewClient
from hpeOneView.exceptions import HPEOneViewException
config = {
'ip': '#####',
'credentials': {
'userName': '#####',
'password': '#####'
}
}
oneview_client = OneViewClient(config)
server_hardwares = oneview_client.server_hardware
server_profils = oneview_client.server_profiles
print('===== GET PROFIL ON ACTIF HARDWARE BY URL =====')
for server in server_hardwares.get_by('powerState', 'on'):
pprint(server_profils.get_by_uri(server.get('serverProfileUri')))

print('===== GET PROFIL BY Profile UUID =====')
for server in server_hardwares.get_by('powerState', 'on'):
profiluuid=server.get('serverProfileUri').split('/')[-1]
print('FOUND UUID IS: '+profiluuid)
print(server_profils.get_by('profileUUID', profiluuid))
`

Here is my output:
===== GET PROFIL ON ACTIF HARDWARE BY URL ===== <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18851eab00> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18853dcc88> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18851eaf60> <------ I HAVE REDUCE OUPUT------> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18853dcc88> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18851eaeb8> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18852fffd0> <hpeOneView.resources.servers.server_profiles.ServerProfiles object at 0x7f18851eadd8> ===== GET PROFIL BY Profile UUID ===== FOUND UUID IS: 8ce89e8a-8775-4806-af4a-a1cbc28ca99f Traceback (most recent call last): File "./hpe.py", line 23, in <module> print(server_profils.get_by('profileUUID', profiluuid)) File "/home/nfs/sgargasson/.local/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 244, in get_by results = self.get_all(filter=filter) File "/home/nfs/sgargasson/.local/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 157, in get_all result = self._helper.get_all(start=start, count=count, filter=filter, sort=sort) File "/home/nfs/sgargasson/.local/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 421, in get_all return self.do_requests_to_getall(uri, count, custom_headers=custom_headers) File "/home/nfs/sgargasson/.local/lib/python3.6/site-packages/hpeOneView/resources/resource.py", line 765, in do_requests_to_getall response = self._connection.get(uri, custom_headers=custom_headers) File "/home/nfs/sgargasson/.local/lib/python3.6/site-packages/hpeOneView/connection.py", line 347, in get raise HPEOneViewException(body) hpeOneView.exceptions.HPEOneViewException: ('An unexpected problem occurred while performing this operation.', {'errorCode': None, 'message': 'An unexpected problem occurred while performing this operation.', 'details': '', 'messageParameters': [], 'recommendedActions': ['Please retry the operation. If the problem persists, contact your authorized support representative and provide a support dump.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

As you can see when I search a profil by is uri, it returns me an entire PROFILES object

As you can see when I try on profile UUID it crash...

I'm avaiable if you want a Remote DEBUG

In OneView _ How do I get a list of scopes attached to the server profile not to the server hardware?

OK.    oneview_client = OneViewClient(config)
OK   scopes = oneview_client.scopes
OK    server_hardwares = oneview_client.server_hardware
OK    server_profile_templates = oneview_client.server_profile_templates
OK   server_profiles = oneview_client.server_profiles
Not OK.. server_profille_list = server_profile.scopes 

******************
From Looking at the 
URI value it appears as if they are one and  the same, yet in the GUI we are able to set a scope 
Server_Hardware > Scope="foo_scope"
Server_Hardware>server_profile> Scope ??? .HOW DO WE access this?

*******************

Server Hardware Module - Add multiple servers

Scenario/Intent

Getting error while adding multiple servers.

Environment Details

  • OneView SDK Version: 5.0.0
  • OneView Appliance Version: 5.0
  • OneView Client API Version: [API version listed in your configuration file or dictionary]
  • Python Version: 2.7.17
  • Platform: Ubuntu

Server gets added but the return type for the method is not proper and throws an error.

Oneview WebServer server truncating responses . on REST Calls?

Please see below code
Isssue: The serverhardware object has around 202 members
Yet only a MAX of 32 are returnin. Is there a setting we have to turn on OneView and/or Global Dashboard
VERSION API: LATEST
OV Installation latest

get_server_hardware_url = f'https://{ov_ip}/rest/server-hardware
 headers = {
        'X-Api-Version': '1200',
        'Content-Type': 'application/json',
        'Auth': sessionID
 }
 res = requests.get(get_server_hardware_url, headers = headers, verify=False)
 print(">>Response ")
 print(res['total'])#-->: 202,
 print(res['start'])#-->: 0,
 print(res['count'])#-->: 32,
 print(res['type'])#-->: 'server-hardware-list-10',
**# How can we tell the webserver, with a custom tag to make below:count= {'total'}**
 print(res['uri'])#-->: '/rest/server-hardware?start=0&count=32'}

The field named type near line 1, column 474 is not a valid field in this JSON object.

Hi, I have found an issue with oneview_enclosure_group.py.
Can you investigate please?
Versions;
hpOneView==5.3.0
oneview-ansible==5.7.0
Python 3.8.5
Targeting against onview dcs appliance version 5.30

When running this playbook I get an error;

TASK [hpe.oneview.compute : Ensure that Enclosure Group is present using the default configuration] ********************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: hpOneView.exceptions.HPOneViewException: ('Unrecognized JSON field.', {'errorCode': 'UNRECOGNIZED_JSON_FIELD', 'message': 'Unrecognized JSON field.', 'details': 'The field named type near line 1, column 474 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})


  • name: Ensure that Enclosure Group is present using the default configuration
    oneview_enclosure_group:
    hostname: "{{ ansible_host }}"
    username: "{{ oneview.username }}"
    password: "{{ oneview.password }}"
    api_version: "{{ oneview.apiversion }}"
    state: present
    data:
    name: "EncGrp01"
    ambientTemperatureMode: "Standard"
    enclosureCount: 3
    ipAddressingMode: "DHCP"
    ipv6AddressingMode: "External"
    powerMode: "RedundantPowerFeed"
    # stackingMode: "Enclosure"
    interconnectBayMappings:
    - interconnectBay: 3
    logicalInterconnectGroupUri: "/rest/logical-interconnect-groups/0299a2b4-58aa-4612-966e-87ae2515f1a6"
    - interconnectBay: 6
    logicalInterconnectGroupUri: "/rest/logical-interconnect-groups/0299a2b4-58aa-4612-966e-87ae2515f1a6"

If I uncomment # stackingMode: "Enclosure" and run it again, I get this message;

TASK [hpe.oneview.compute : Ensure that Enclosure Group is present using the default configuration] ********************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: hpOneView.exceptions.HPOneViewException: ('Unrecognized JSON field.', {'errorCode': 'UNRECOGNIZED_JSON_FIELD', 'message': 'Unrecognized JSON field.', 'details': 'The field named stackingMode near line 1, column 195 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

Many thanks in advance ;)
Stephen.

Python SDK:Scopes URI Issue

How do I get scopes assigned to Hardware enrolled in oneview

Assume that I have Four machines enrolled in one view..
Assume that I have two scopes.
Machine _1 -> Scope 1
Machine_2 ->Scope 2
Machine_3 ->NO SCOPE
Machine_4-> Scope 2

How can I access the above relationship,see the example code. The ScopesURI field is differnet between the
Server_Hardware and the scopes object, WHAT is the link betweeen them.see below print out code

def usage():
if len(sys.argv) < 2:
print("You have specified too few arguments","Usage >>"+ sys.argv[0]+ " oneviewIP [sample 19.14.3.210]")
print("FYI: This works on the basis of account readonly/readonly existing with the local domain of the appliance")
sys.exit()
try:
socket.inet_aton(sys.argv[1])
except socket.error:
print("You have an invalid IP Parameter","Usage >>"+ sys.argv[0]+ " oneviewIP [sample 19.14.3.210]")
sys.exit()

def parseandSetLoginParams():
#This is config json sample with all the attribs
#https://github.com/HewlettPackard/oneview-python/blob/master/examples/config-rename.json
config = {
"ip": sys.argv[1],
"credentials": {
"userName":"readonly",
"password":"readonly",
"authLoginDomain":"local"
}
}
return config

################################################################
#Create Session
################################################################

def OneViewAttribs(lconfig):
try:
oneview_client = OneViewClient(lconfig)
except HPOneViewException:
print("ERROR:Cannot Connect OV: >>"+ sys.argv[1]+ " oneviewIP [sample: 19.14.3.210]")
sys.exit()
return oneview_client

#################################################################

#Off of the oneView object return , ov_scopes, server_hardwares and the dict pf scope->resource

################################################################

def returnobjectree(object):
oneview_client2=object
server_hardwares = oneview_client2.server_hardware
server_hardware_all = server_hardwares.get_all()
print("server_hardware_all ")
pprint(server_hardware_all)
#################################################################
# Get scopes
################################################################
#Step A
ov_scopes=oneview_client2.scopes
retlistdict=ov_scopes.get_all()
print ("retlistdict .ovscopes ---> ")
pprint(retlistdict)
return (retlistdict,server_hardware_all)

if name == "main":
usage()
returnobjectree(OneViewAttribs(parseandSetLoginParams()))

certificate_authority.get() does not return certificate string

When running example ov_to_smb.py to download the certificate and write to a file, it throws an exception that "cert" is a dict and not a string.

{'category': 'appliance',
'count': 0,
'created': '2020-11-25T08:47:32.474Z',
'eTag': '2020-11-25T08:47:32.474Z',
'members': [{'category': 'appliance',
'certRevocationConfInfo': None,
'certStatus': 'GOOD',
'certType': 'LEAF_CERT',
'certificateDetails': None,
'created': '2020-11-25T08:47:32.478Z',
'eTag': '2020-11-25T08:47:32.478Z',
'expiryDate': '2030-11-26T04:48:00.000Z',
'modified': '2020-11-25T08:47:32.478Z',
'subjectName': 'CN=pln-n2-hpov.env02.mcloud.entsvcs.net,O=Hewlett '
'Packard Enterprise,L=Palo '
'Alto,ST=California,C=US',
'type': 'CertificateAuthorityInfo',
'uri': '/rest/certificates/ca/localhostSelfSignedCertificate'},
{'category': 'appliance',
'certRevocationConfInfo': None,
'certStatus': 'GOOD',
'certType': 'STANDARD_ROOT',
'certificateDetails': None,
'created': '2020-11-25T08:47:32.478Z',
'eTag': '2020-11-25T08:47:32.478Z',
'expiryDate': '2030-11-26T08:37:08.000Z',
'modified': '2020-11-25T08:47:32.478Z',
'subjectName': 'CN=Infrastructure Management Certificate '
'Authority,O=Hewlett Packard Enterprise,L=Palo '
'Alto,ST=California,C=US',
'type': 'CertificateAuthorityInfo',
'uri': '/rest/certificates/ca/Infrastructure Management '
'Certificate Authority-internalroot'}],
'modified': '2020-11-25T08:47:32.474Z',
'nextPageUri': None,
'prevPageUri': None,
'start': 0,
'total': 2,
'type': 'CertificateAuthorityInfoCollection',
'uri': '/rest/certificates/ca'}
Traceback (most recent call last):
File "ov_to_smb.py", line 337, in
sys.exit(main())
File "ov_to_smb.py", line 326, in main
getCertCa(oneview_client)
File "ov_to_smb.py", line 245, in getCertCa
ca.write(cert)
TypeError: write() argument must be str, not dict

How can I enroll new iLO inside oneview programtically using python SDK?

What infrmation would i need iloip,svr profile ,svr profilr template.
What is the api call that I would be usging , Cna someone throw a aample code in here?
What is the Generation if ilo that cqan be managed by oneview appliance.
iLO5- YES
ilo4 - YES
ilo3 - ?
ilo2- ?
ilo1- ?
I have 2500 unmanged ilo that are going to be enrolled in OneView

License MIT or Apache?

Readme says:

This project is licensed under the MIT license

LICENSE says:

Apache License
Version 2.0, January 2004

Unable to connect to OneView appliance SCMB after certificate download. TSL unknown CA error

Hi,
As usual, i tried to download the certificate and use that to establish connection with OneView SCMB but in vain. Following is the log trace.

Traceback (most recent call last):
File "main.py", line 156, in
sys.exit(main())
File "main.py", line 148, in main
ovscmb.recv(oneviewDetails["host"], oneviewDetails["route"])
File "oneview_syslog_lib/internal/scmb_utils.py", line 219, in recv
conn = amqp.Connection(dest, login_method='EXTERNAL', ssl=ssl_options)
File "/usr/local/lib/python3.6/site-packages/amqplib/client_0_8/connection.py", line 129, in init
self.transport = create_transport(host, connect_timeout, ssl)
File "/usr/local/lib/python3.6/site-packages/amqplib/client_0_8/transport.py", line 279, in create_transport
return SSLTransport(host, connect_timeout, ssl)
File "/usr/local/lib/python3.6/site-packages/amqplib/client_0_8/transport.py", line 179, in init
super(SSLTransport, self).init(host, connect_timeout)
File "/usr/local/lib/python3.6/site-packages/amqplib/client_0_8/transport.py", line 91, in init
self._setup_transport()
File "/usr/local/lib/python3.6/site-packages/amqplib/client_0_8/transport.py", line 191, in _setup_transport
self.sslobj = ssl.wrap_socket(self.sock, **self.sslopts)
File "/usr/lib64/python3.6/ssl.py", line 1117, in wrap_socket
ciphers=ciphers)
File "/usr/lib64/python3.6/ssl.py", line 776, in init
self.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:897)

I am using python 3.6 with following libraries:
amqplib (1.0.2)
pyOpenSSL (20.0.0)
OneView appliance ver - 5.00.00.01-0402787

Wanted to know how to resolve this issue. Thanks in advance.

Support for socks5 type proxy

I can see that one can configure a proxy with export ONEVIEWSDK_PROXY='<proxy_host>:<proxy_port>' or proxy in the config dictionary or JSON. But it seems that there is no way to configure a socks5 proxy.

Would you welcome a contribution to enable this use case ?

Unable ro get session key when user is using Active Direc authentication

Hello
As per article : https://developer.hpe.com/blog/curling-through-the-oneview-api

I am trying to get the session key
USERID=abcna1\$admid
Our admin id are prefaced with $ signs
And the way we login is LOCATION follow with a backslash follow with a $ sign follow with a userid all concatenated
so CALIF1\$admidca

 sessionID=$(curl -s -k -H "accept: application/json" -H "content-type: application/json" -d "{\"authLoginDomain\":\"ABC.com\",\"userName\":\"ABCna1\\$admid\",\"password\":\"abcdq234!345\"}" -X POST https://10.10.10.10/rest/login-sessions)
 

By the way when this is run on the GUI , it works just fine

Exact Error:

{"errorCode":"MALFORMED_JSON","message":"Malformed JSON cannot be parsed.","details":"The JSON sent in the request is malformed and cannot be parsed. There is a problem on line 1 near column -1.","recommendedActions":["Correct the malformed JSON and retry the request."],"errorSource":null,"nestedErrors":[],"data":{}}

server_profile update doesnt modify the values

I'm writing exactly what I am trying to modify on the server profile. this is executed on the IDE.

i'm setting the server profile to set managed manually , and the update doesnt reflect the required settings.

server_profile["firmware"]={u'firmwareBaselineUri': "", u'manageFirmware': False, u'forceInstallFirmware': False, u'firmwareInstallType': ""}

server_profile.update(force=True)

Please help to fix the issue.

What's the API CALL?

I have got 10 enclosures/frame/with 9 Computer modules
.Syn. Gen 10

In all thee enclosure/Frames I have virtual connect nodules,FrameLink Modules and Powersupply to the enclosure/chassis.

I need access the installed Firmware version And the Component Name
for
i)virtual connect module,
ii) The Frame link Module
iiii) The Power supply

How do I go about getting this via the python SDK ?
I have looked at the examples and I am starting from looping so I don''t hav any names
Below does not get me what I want

   logical_interconnects = oneview_client.logical_interconnects
 
   # Get all logical interconnects
   print("\nGet all logical interconnects")
   all_logical_interconnects = logical_interconnects.get_all()
   for logical_interconnect in all_logical_interconnects:
      #print('  Name: {name}').format(**logical_interconnect)
      #Get a logical interconnect by name
      #logical_interconnect = logical_interconnects.get_by_name(logical_interconnect_name)
      print("\nFound logical interconnect by name {name}.\n URI: {uri}").format(**logical_interconnect.data)
      print("who is jerry antrell 3rd try ")
      #print(logical_interconnect.data)
      #fw=logical_interconnect.get_firmware()
      pprint(logical_interconnect)



  
  """

Too many sessions error. Python library for HPE OneView doesn't close connections

Hello,

I'm using Python library for HPE OneView v5.4.0 to monitor HPE OneView , last firmware version, with Nagios but I'm getting this error two days later I had configured monitoring:

HPEOneViewException: (u'Login denied. The client xxx.xxx.xxx.xxx has too many active sessions.', {u'errorSource': None, u'recommendedActions': [u'Do one of the following: log out of existing sessions. Log in from a different IP address. Contact the administrator to increase the maximum number of sessions per client IP address. Wait 24 hours for idle sessions created by scripts to time out and then retry logging in.'], u'data': {u'clientip': u'xxx.xxx.xxx.xxx'}, u'errorCode': u'AUTHN_SESSION_CLIENT_LIMIT_CROSSED', u'messageParameters': [u'xxx.xxx.xxx.xxx'], u'details': u'The client xxx.xxx.xxx.xxx has the maximum number of active sessions allowed.', u'message': u'Login denied. The client xxx.xxx.xxx.xxx has too many active sessions.', u'nestedErrors': []})

Python library for HPE OneView doesn't appear to close connections on HPE OneView before OneViewClient is destroyed.

Thanks.

Problems connecting with OneViewClient

Hi,

I currently face a problem in connecting to one of our servers and I'm out of any ideas. Maybe you have one.

The situation is that whenever I try to build a connection using OneViewClient to that specific server, a connection isn't established, a timeout is thrown. Testing the REST API on command line with the same server IP using curl works as expected. I get a session ID, I can do all queries, whatever I want, so it seems not to be a firewall issue.
I have other servers with the exact versions installed and they work pretty fine.

Summary: connecting with curl works, the Python module not, but only on this one server. Also tested with Insomnia (REST API test application)

So, any ideas what it could be? Python version is 3.8.10, hpeOneView is 8.0.0 (previously 7.2.0).

Regards, Thomas

enclosure_groups.create() Does not take valid data and returns JSON error

I am facing the same issue while EG creation, The JSON is valid and Creates a EG if the REST endpoint.
uri2="https://"+IP+"/rest/enclosure-groups"
response2 = requests.post(uri2,verify=False,json=EG_data,headers=Headers)

But it gives an error when using the Python SDK.

This is the same issue as Issue #84

File size is zero when downloading appliance backup

The GET call to download a backup returns 302 which is not handled by download_to_stream method in connections module. This results in zero size backup files.

Used the script found in the examples backups.py

response = oneview_client.backups.download(backup_details['downloadUri'], filename)

Add appliance ha-nodes endpoint to sdk

Hello,
I really like this oneview package! I noticed the rest api reference has documentation about getting the appliance ha nodes information (via /rest/appliance/ha-nodes). This shows quite some information about appliances ha mode, which is useful in our scenario.
I am talking about ha-nodes.
Can I submit a PR containing this info?
Regards,

enclosure_groups.create() Does not take valid data and returns JSON error

Tried the examples in enclosure_groups

...

data = {
"name": "Enclosure Group 1",
"ipAddressingMode": "External",
"interconnectBayMappings":
[
{
"interconnectBay": 1,
},
{
"interconnectBay": 2,
},
{
"interconnectBay": 3,
},
{
"interconnectBay": 4,
},
{
"interconnectBay": 5,
},
{
"interconnectBay": 6,
}
]
}

This should create an empty EG.

Used this to create it
enclosure_groups.create(data)

Gives JSON error:
hpOneView.exceptions.HPOneViewException: ('Unrecognized JSON field.', {'errorCode': 'UNRECOGNIZED_JSON_FIELD', 'message': 'Unrecognized JSON field.', 'details': 'The field named type near line 1, column 52 is not a valid field in this JSON object.', 'messageParameters': [], 'recommendedActions': ['Check the valid fields for this JSON object and remove or correct the unrecognized field.'], 'errorSource': None, 'nestedErrors': [], 'data': {}})

Seems like the REST API expects some different information.

Also tried the examples from the REST API Reference 1800:
_{
"name": "eg-2-lig-sideA-sideB-bayset-2",
"ipAddressingMode": "External",
"interconnectBayMappings":
[
{
"interconnectBay": 2,
"logicalInterconnectGroupUri": "/rest/logical-interconnect-groups/7d860164-266b-408a-9ceb-59be6f27b3f8"
},
{
"interconnectBay": 5,
"logicalInterconnectGroupUri": "/rest/logical-interconnect-groups/74942c3d-e132-4976-bf5f-fd2967c3f47d"
},
{
"enclosureIndex": 1,
"interconnectBay": 1,
"logicalInterconnectGroupUri": "/rest/sas-logical-interconnect-groups/aeef7314-527d-4053-868c-17b87df1b57c"
},
{
"enclosureIndex": 2,
"interconnectBay": 1,
"logicalInterconnectGroupUri": "/rest/sas-logical-interconnect-groups/beef7314-527d-4053-868c-17b87df1b57a"
},
{
"enclosureIndex": 2,
"interconnectBay": 4,
"logicalInterconnectGroupUri": "/rest/sas-logical-interconnect-groups/beef7314-527d-4053-868c-17b87df1b57a"
},

],
"enclosureCount": 3

}_

As this does not works as well. Same JSON error i suspect there is some problem with the create(data) itself.
Have seens this with the networks.create(data) as well ... but was able to workaround this.

Also ... Logical_Interconnects.create(data) works just fine ..

Regards

Missing methods in certificate_authority.py

Hi,
I would like to highlight that there are missing methods in the file hpeOneView/resources/security/certificate_authority.py in release 5.5.0; The get_all() method is missing which is used in the example scmb.py.
The code present in the github is different from the one present in the release bundle 5.5.0. Please find attached pics for reference.

We have fixed this issue internally but wanted to highlight. Thanks.

Regards,
Karthik VR ([email protected] / [email protected])

get_all_method_present_in_github
get_all_method_absent_in_release_5 5 0

how to detach a profile from a hardware resource?

I have an existing server hardware and it is assigjned to a server profile.
I want to "DETACH" This profile from the server hardware. I cannot find how do I do this via the API

# Add server hardware with scope uri
#server = server_hardwares.get_by_name(server_name)
server = server_hardwares.get_by_name('ILO2M20050BV.XYZFIII.com')
if server: 
   print(server_name+" Already Exist")
   server.remove(force=True)

ERROR

aceback (most recent call last):

  File "/Users/mzeshan/OneDrive - azureford/dev/OMS_ROVReducedOneView_OMS/pythonway/AddRemoveSingleHardware/github_issue_139.py", line 80, in 
    server.remove(force=True)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/resources/servers/server_hardware.py", line 99, in remove
    return self.delete(force=force, timeout=timeout)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/resources/resource.py", line 63, in __call__
    return self.method(obj, *args, **kwargs)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/resources/resource.py", line 198, in delete
    custom_headers=custom_headers, force=force)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/resources/resource.py", line 446, in delete
    task, body = self._connection.delete(uri, custom_headers=custom_headers)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/connection.py", line 380, in delete
    return self.__do_rest_call('DELETE', uri, {}, custom_headers=custom_headers)

  File "/Users/mzeshan/opt/anaconda3/lib/python3.7/site-packages/hpeOneView/connection.py", line 413, in __do_rest_call
    raise HPEOneViewException(body)

HPEOneViewException: Server /rest/server-hardware/37393150-3032-4D32-3230-303530425633 has an active profile and thus cannot be removed.


TypeError: get_all() got an unexpected keyword argument 'filter'

Info

Python Version : 3.8.2
OS: Fedora 32 (Workstation Edition)

Bug Description

When trying to use the SDK directly, we encountered the issue with the get_by_name function on the Resource object.

Test Script

#!/usr/bin/env python

import argparse
import getpass
from hpOneView.oneview_client import OneViewClient


def main(args):
    config = dict(ip=args.server, api_version=1600, credentials=dict(userName=args.username, password=args.password))
    client = OneViewClient(config)
    scope = client.scopes.get_by_name('PreProd')
    if scope:
        print("Scope already exists.")
    else:
        scope = client.scopes.create(data=dict(name="PreProd"))
        print("Created new scope")


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Create Scope in OneView')
    parser.add_argument('-s', '--server', required=True, help='OneView Endpoint')
    parser.add_argument('-u', '--username', required=True, help='Device Username')
    parser.add_argument('-p', '--password', help='Device Password')
    args = parser.parse_args()
    if args.password is None:
        args.password = getpass.getpass("Password: ")
    main(args)

Output

Password: 
Traceback (most recent call last):
  File "createscope.py", line 27, in <module>
    main(args)
  File "createscope.py", line 11, in main
    scope = client.scopes.get_by_name('PreProd')
  File "/home/nsidhu/.local/lib/python3.8/site-packages/hpOneView/resources/resource.py", line 261, in get_by_name
    result = self.get_by("name", name)
  File "/home/nsidhu/.local/lib/python3.8/site-packages/hpOneView/resources/resource.py", line 244, in get_by
    results = self.get_all(filter=filter)
TypeError: get_all() got an unexpected keyword argument 'filter'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.