Giter Site home page Giter Site logo

hewlettpackard / python-hponeview Goto Github PK

View Code? Open in Web Editor NEW
86.0 46.0 60.0 185.3 MB

DEPRECATED - no longer actively maintained. New repository: https://github.com/HewlettPackard/oneview-python

License: MIT License

Python 99.86% Shell 0.14%
devops composable-infrastructure hpe-oneview python bare-metal infrastructure-as-code

python-hponeview's People

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  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  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  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-hponeview's Issues

call to hpOneView version reports 3.3.0 on hpOneView 4.1.0 and appliance_node_information is unknown

Scenario/Intent

trying to run the script below:

from pprint import pprint
import hpOneView
from hpOneView.oneview_client import OneViewClient
from hpOneView.exceptions import HPOneViewException

config = {
'ip': 'ov-ff',
'api_version': 300,
'credentials': {
'userName': 'administrator',
'password': 'ff123123'
}
}

print('hpOneView version: {}'.format(hpOneView.version))
ov_conn = OneViewClient(config)
pprint(ov_conn.appliance_node_information.get_status())

Environment Details

  • OneView SDK Version: [Version of this SDK for which you are encountering the issue]

4.1.0 installed with pip:
pip install --upgrade hpOneView
Collecting hpOneView
Requirement already up-to-date: future>=0.15.2 in ./redfish-venv/lib/python3.4/site-packages (from hpOneView)
Installing collected packages: hpOneView
Found existing installation: hpOneView 4.0.0
Uninstalling hpOneView-4.0.0:
Successfully uninstalled hpOneView-4.0.0
Successfully installed hpOneView-4.1.0

  • OneView Appliance Version: [Version of the OneView appliance you're interacting with]
    3.00.07-0288219 - DCS with 3 enclosures simulation

  • OneView Client API Version: [API version listed in your configuration file or dictionary]

  • Python Version: [Version of Python in your environment]
    python 3.4

  • Platform: [OS distribution and release version]
    OpenSuse 42.3

Steps to Reproduce

install hpOpenView 4.1.0 using pip
run the script above

Expected Result

[What do you expect to happen after taking the steps above?]
print version: expect 4.1.0

pprint(ov_conn.appliance_node_information.get_status()): expect appliance information not an
exception

Actual Result

python teste.py

hpOneView version: 3.3.0
Traceback (most recent call last):
File "./teste.py", line 24, in
pprint(ov_conn.appliance_node_information.get_status())
AttributeError: 'OneViewClient' object has no attribute 'appliance_node_information'
(redfish-venv) ff@darkvm:~/dev/redfish>

Python version 2.7.5 not supported with TLS Backports

We run our systems on CentOS7 which uses 2.7.5. This library does not work with this version unless the init.py file is changed from:

if PY2:
if PYTHON_VERSION < (2, 7, 9):

to:

if PY2:
if PYTHON_VERSION < (2, 7, 5):

RHELs version of 2.7.5 has tls 1.2 back-ported so connections work as expected.

Unable to unassign Server Hardware from a Server Profile

Scenario/Intent

Change the server hardware field on a server profile from whatever it is assigned to unassigned

Environment Details

  • OneView SDK Version: 4.0.0 and earlier
  • OneView Appliance Version: 300 & 500
  • Platform: centos7

Steps to Reproduce

  1. Retrieve a Server Profile that has a Server Hardware assigned to it.
profile = oneview_client.server_profiles.get_by_name("my_sp")
  1. Set its serverHardwareUri to None or remove it.
profile.pop('serverHardwareUri')
  1. Run update to remove the Server Hardware in OneView:
profile = oneview_client.server_profiles.update(profile, profile['uri'])

Expected Result

It should list Server hardware as unassigned in the UI:

untitled

Actual Result

Even though the update completes successfully, there's no change to the Server hardware assigned:

untitled2

Authorization error: User not authorized for this operation.

Hi Experts,
I am trying to upgrade oneview appliance through python script and function is "upload_fw()", The file uploading process showing successfully,finally I am getting the exception like below:

Appliance Version : 1.20.05-0201918
Patch file : HP_OneView_1.20.05_upgrade_from_any_previous_version_Z7550-96169.bin

Traceback (most recent call last):
File "hp_nfvsys_upload_fw.py", line 12, in
upload_details = OneView_Settings.upload_fw("/root/venkat/HP_OneView_1.20.05_upgrade_from_any_previous_version_Z7550-96169.bin","HP_OneView",verbose=True)
File "/root/venkat/hpOneView/settings.py", line 58, in upload_fw
raise HPOneViewException(body)
hpOneView.exceptions.HPOneViewException: {'errorCode': 'AUTHORIZATION', 'recommendedActions': ['Please verify your credentials and re-authenticate before attempting the operation again.'], 'data': {}, 'nestedErrors': [], 'message': 'Authorization error: User not authorized for this operation.', 'errorSource': None, 'details': 'User not authorized for this operation.'}

Please provide solution...

Thanks,
Venkat.

Must set API version 500 in order to see OS Deployment Plan in Synergy template

Scenario/Intent

I have a Synergy OneView template with an OS Deployment Plan, but when query the template with oneview_client.server_profile_templates.get_by_name, the OS Deployment Plan is missing from the output. API version is set to 300 in config.json, per the OneView SDK GitHub README.md.

HPE has informed me that setting API version to 500 fixes the issue (and I have verified that is the case), but this is not clear from the README.md. So this may be a combination of documentation fix plus code fix to automatically detect highest API version supported?

Environment Details

  • OneView SDK Version: 3.3.0
  • OneView Appliance Version: 3.10.04-0299553
  • OneView Client API Version: 300
  • Python Version: 3.4.5
  • Platform: CentOS 7.3 x86_64

Steps to Reproduce

Create template with an OS Deployment Plan.
Read the template in via Python SDK:
oneview_client = OneViewClient.from_json_file('connect.json')
my_template = oneview_client.server_profile_templates.get_by_name('test-template')
pprint(my_template)

Expected Result

See the complete template, including OS Deployment Plan

Actual Result

OS Deployment Plan is missing

Backup - Error in settings.py

Hi,

The backup scripts don't work:

  • backup-restore.py
  • get-backup.py.

In fact there are a spell error in the file settings.py line 117 (get_task_associated_resource)
117c117

< backupResource = self._activity.get_task_assocaited_resource(task)

    backupResource = self._activity.get_task_associated_resource(task)

Can't make a connection behind a proxy

this line self._validateVersion() does a GET to the server
https://github.com/HewlettPackard/python-hpOneView/blob/master/hpOneView/connection.py#L77

but that won't work if you are behind a proxy because the proxy attributes have not been set yet.

con = hpov.connection('15.126.200.41')
Traceback (most recent call last):
File "", line 1, in
File "/home/oreillyd/swiss/automation/venv/lib/python3.4/site-packages/hpOneView/connection.py", line 77, in init
self._validateVersion()
File "/home/oreillyd/swiss/automation/venv/lib/python3.4/site-packages/hpOneView/connection.py", line 80, in _validateVersion
version = self.get(uri['version'])
File "/home/oreillyd/swiss/automation/venv/lib/python3.4/site-packages/hpOneView/connection.py", line 242, in get
resp, body = self.do_http('GET', uri, '')
File "/home/oreillyd/swiss/automation/venv/lib/python3.4/site-packages/hpOneView/connection.py", line 142, in do_http
conn.request(method, path, body, self._headers)
File "/usr/lib/python3.4/http/client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request
self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 922, in _send_output
self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 857, in send
self.connect()
File "/usr/lib/python3.4/http/client.py", line 1223, in connect
super().connect()
File "/usr/lib/python3.4/http/client.py", line 834, in connect
self.timeout, self.source_address)
File "/usr/lib/python3.4/socket.py", line 512, in create_connection
raise err
File "/usr/lib/python3.4/socket.py", line 503, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

Could not find mappings for OneView's Index Resources

Hi...

Scenario/Intent

The thing I'm trying to answer here is: given an UUID, does it refers to a server hardware, an enclosure or a rack?

Environment Details

We're using OneView 3.00.05-0271823 and it seems the search bar queries this endpoint

I've taken a look at hpOneView and I could not find it... is it already implemented? If not, are there any plans on including this in a near version?

Thanks!

restore-backup.py fails when tries to create the task and start with the restore

Hi,

If i try to run the script, will successfully upload the backup file but after this will fail with the following error message:

[root@arch scripts]# ./restore-backup.py -a 10.102.144.70 -u Administrator -p admin123 -f hpotest1_backup_2015-10-15_100224.bkp
Uploading backup: hpotest1_backup_2015-10-15_100224.bkp
Traceback (most recent call last):
File "./restore-backup.py", line 130, in
sys.exit(main())
File "./restore-backup.py", line 125, in main
restore_backup(sts, args.file, name)
File "./restore-backup.py", line 68, in restore_backup
ret = sts.upload_backup(path, name)
File "/usr/lib/python3.5/site-packages/hpOneView/settings.py", line 159, in upload_backup
task, backup = self._activity.make_task_entity_tuple(body)
File "/usr/lib/python3.5/site-packages/hpOneView/activity.py", line 101, in make_task_entity_tuple
task = self._con.get(obj['taskUri'])
File "/usr/lib/python3.5/site-packages/hpOneView/connection.py", line 241, in get
raise HPOneViewException(body)
hpOneView.exceptions.HPOneViewException: {'errorSource': None, 'nestedErrors': [], 'details': 'The requested resource not found, ID = /rest/tasks/0D048E83-E13D-410D-83CD-111DF66DB6A6.', 'data': {}, 'recommendedActions': ['Confirm resource ID/URI and try the call again.'], 'message': 'Resource not found, ID/URI = /rest/tasks/0D048E83-E13D-410D-83CD-111DF66DB6A6.\nResource with requested ID could not be retrieved.', 'errorCode': 'RESOURCE_NOT_FOUND'}

{
"type": "SimplePaginatedCollection",
"members": [
{
"type": "BACKUP",
"taskUri": "/rest/tasks/0D048E83-E13D-410D-83CD-111DF66DB6A6",
"hardwareModel": "HP OneView VM - KVM ",
"platformType": "vm",
"backupType": "UPLOADED",
"firmwareVersionMajor": "1",
"firmwareVersionMinor": "20",
"backupSize": 0,
"downloadUri": null,
"downloadStatus": "DOWNLOAD_REQUESTED",
"downloadUserName": "",
"downloadTime": "",
"backupStartTime": "2015-10-15T10:02:24.322Z",
"status": "SUCCEEDED",
"percentComplete": 100,
"fullyQualifiedHostName": "hpotest1.osp.poc",
"resolutionKey": "",
"errorKey": "",
"errorParms": [],
"resolutionParms": [],
"errorMessage": "",
"resolutionMessage": "",
"userName": "Administrator",
"id": "hpotest1_backup_2015-10-15_100224",
"hostName": "ci-FA163E718BB6",
"created": "2015-10-15T10:02:24.322Z",
"eTag": null,
"modified": "2015-10-15T10:03:01.616Z",
"category": "backups",
"uri": "/rest/backups/hpotest1_backup_2015-10-15_100224"
}
],
"start": 0,
"prevPageUri": null,
"nextPageUri": null,
"total": 1,
"count": 1,
"created": "2015-10-15T10:18:06.704Z",
"eTag": null,
"modified": "2015-10-15T10:03:01.616Z",
"category": "backups",
"uri": "/rest/backups/"
}

{
"details": "The requested resource not found, ID = /rest/tasks/0D048E83-E13D-410D-83CD-111DF66DB6A6.",
"errorSource": null,
"recommendedActions": [
"Confirm resource ID/URI and try the call again."
],
"nestedErrors": [],
"errorCode": "RESOURCE_NOT_FOUND",
"data": {},
"message": "Resource not found, ID/URI = /rest/tasks/0D048E83-E13D-410D-83CD-111DF66DB6A6.\nResource with requested ID could not be retrieved."
}

[root@arch scripts]# curl -i -k -H Accept:application/json -H X-Api-Version:100 -H Auth:iMKyQ83tCZfC8V8BMLc5LB0ZqQI2zD0z -X POST https://10.102.144.70/rest/restores -H Content-Type:application/json -d '{"type":"RESTORE","uriOfBackupToRestore":"/rest/backups/hpotest1_backup_2015-10-15_100224"}'
HTTP/1.1 202 Accepted
Date: Thu, 15 Oct 2015 11:09:47 GMT
Content-Type: application/json;charset=UTF-8
Via: 1.1 ci-fa163e718bb6.local
Vary: Accept-Encoding
cache-control: no-cache
Transfer-Encoding: chunked

{"type":"RESTORE","uriOfBackupToRestore":"/rest/backups/hpotest1_backup_2015-10-15_100224","status":"IN_PROGRESS","restoreStartTime":"2015-10-15T11:09:47.863Z","progressStep":"PREPARING_TO_RESTORE","backupIdToRestore":"hpotest1_backup_2015-10-15_100224","userName":"Administrator","errorMessage":"","resolutionKey":"","fullyQualifiedHostName":"ci-fa163e718bb6.local","errorKey":"","errorParms":[],"resolutionParms":[],"resolutionMessage":"","percentComplete":0,"id":"ci-fa163e718bb6_restore_2015-10-15_110947","hostName":"ci-fa163e718bb6","category":"restores","created":"2015-10-15T11:09:47.863Z","eTag":null,"modified":"2015-10-15T11:09:47.863Z","uri":"/rest/restores/ci-fa163e718bb6_restore_2015-10-15_110947"}

Acknowledgment of Login Message

Hi guys,

is there a way of acknowledge the login message with the restful api? It is the ok button when you open the OneView before you login

BR

OneViewClient doesn't allow using a token (sessionId)

Scenario/Intent

OneViewClient doesn't allow using a token for authentication.
To create an OneviewClient, you need to provide a login and password.

Environment Details

  • OneView SDK Version: 3.1.1
  • OneView Appliance Version: Any
  • OneView Client API Version: 300

Steps to Reproduce

There is no way to instantiate OneViewClient with this configuration:

  1. No username / password
  2. A token (session ID)

Expected Result

When the token is already known by the users, they may prefer use it instead of username/password credentials.

Actual Result

oneview_client.py doesn't have token support, although connections.py supports it.

Timeout

Is there a way to set timeout for requests when using Restful API?

Error in Generating RabbitMQ Key Pair on the appliance

Command used for Kay pair generation:
./scmb.py -a [HP OneView Appliance IP] -u Administrator -p MyPass -g

Error Reported : From file security.py

Resolution:
I modified the file python-hpOneView/blob/master/hpOneView/security.py
Funtion: def gen_rabbitmq_ca(self)
request = {'type': 'RabbitMqClientCert', 'commonName': 'default'}

I replaced new value to type key: RabbitMqClientCertV2 and the generation of key pair was successful.

The instance of OneViewClient doesn't detect that the session idle time has expired

When an instance of OneViewClient is created, a session is created to that instance. We assume that the session is considered valid until there is an explicit call to the method logout within the connection class (https://github.com/HewlettPackard/python-hpOneView/blob/master/hpOneView/connection.py#L500). However, after 24 hours (default value for the idle time) the session expired, OneViewClient didn't detect it, which resulted in the exception HPOneViewException with Authorization error.

Is there a way to verify if the session expired using hpOneView?

Seeing EncodingError with HPOneViewException (unable to pickle class

Scenario/Intent

I'm running python-hpOneView as a Celery task. I have 3 containers, one running Celery/python-hpOneView, another running an application that fires-off the Celery task, and a third running Redis. I want to process HPOneViewExceptions to add the exception string to a database. This is what I see in Celery logs:

celery_1 | [2017-10-02 09:49:13,683: ERROR/ForkPoolWorker-9] Task ncsappman.servers.remove_sp_from_server[d9cf7888-6fe3-4c17-af2f-81bcb647eec1] raised unexpected: HPOneViewException(u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}})
celery_1 | Traceback (most recent call last):
celery_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 374, in trace_task
celery_1 | R = retval = fun(*args, **kwargs)
celery_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 629, in protected_call
celery_1 | return self.run(*args, **kwargs)
celery_1 | File "/app/ncsappman/servers.py", line 153, in remove_sp_from_server
celery_1 | client.server_profiles.delete(content['serverProfileUri'])
celery_1 | File "/python-hpOneView/hpOneView/resources/servers/server_profiles.py", line 121, in delete
celery_1 | return self._client.delete(resource=resource, timeout=timeout)
celery_1 | File "/python-hpOneView/hpOneView/resources/resource.py", line 259, in delete
celery_1 | task, body = self._connection.delete(uri, custom_headers=custom_headers)
celery_1 | File "/python-hpOneView/hpOneView/connection.py", line 359, in delete
celery_1 | return self.__do_rest_call('DELETE', uri, {}, custom_headers=custom_headers)
celery_1 | File "/python-hpOneView/hpOneView/connection.py", line 441, in __do_rest_call
celery_1 | raise HPOneViewException(body)
celery_1 | HPOneViewException: (u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}})
celery_1 | [2017-10-02 09:49:13,692: ERROR/MainProcess] Task handler raised error: <MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: HPOneViewException(u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}})>, None)"'. Reason: ''PicklingError("Can't pickle <class 'hpOneView.exceptions.HPOneViewException'>: it's not the same object as hpOneView.exceptions.HPOneViewException",)''.>
celery_1 | Traceback (most recent call last):
celery_1 | File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 362, in workloop
celery_1 | put((READY, (job, i, result, inqW_fd)))
celery_1 | File "/usr/local/lib/python2.7/dist-packages/billiard/queues.py", line 366, in put
celery_1 | self.send_payload(ForkingPickler.dumps(obj))
celery_1 | File "/usr/local/lib/python2.7/dist-packages/billiard/reduction.py", line 82, in dumps
celery_1 | cls(buf, protocol).dump(obj)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 224, in dump
celery_1 | self.save(obj)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 562, in save_tuple
celery_1 | save(element)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 562, in save_tuple
celery_1 | save(element)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 562, in save_tuple
celery_1 | save(element)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 562, in save_tuple
celery_1 | save(element)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 331, in save
celery_1 | self.save_reduce(obj=obj, *rv)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
celery_1 | save(state)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
celery_1 | self._batch_setitems(obj.iteritems())
celery_1 | File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
celery_1 | save(v)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 331, in save
celery_1 | self.save_reduce(obj=obj, *rv)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 400, in save_reduce
celery_1 | save(func)
celery_1 | File "/usr/lib/python2.7/pickle.py", line 286, in save
celery_1 | f(self, obj) # Call unbound method with explicit self
celery_1 | File "/usr/lib/python2.7/pickle.py", line 753, in save_global
celery_1 | (obj, module, name))
celery_1 | MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: HPOneViewException(u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}})>, None)"'. Reason: ''PicklingError("Can't pickle <class 'hpOneView.exceptions.HPOneViewException'>: it's not the same object as hpOneView.exceptions.HPOneViewException",)''.

Environment Details

OV API version 500, python-hpOneView v4

Steps to Reproduce

[What are the complete steps needed to do in order to reproduce your problem?]

Expected Result

This is what I expect to see instead of the above:

celery_1 | [2017-10-02 10:21:22,469: ERROR/ForkPoolWorker-9] Task ncsappman.servers.remove_sp_from_server[f2c7f252-50a1-44b8-b190-532a529907e6] raised unexpected: HPOneViewException(u"Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149., {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}}",)
celery_1 | Traceback (most recent call last):
celery_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 374, in trace_task
celery_1 | R = retval = fun(*args, **kwargs)
celery_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 629, in protected_call
celery_1 | return self.run(*args, **kwargs)
celery_1 | File "/app/ncsappman/servers.py", line 153, in remove_sp_from_server
celery_1 | client.server_profiles.delete(content['serverProfileUri'])
celery_1 | File "/python-hpOneView/hpOneView/resources/servers/server_profiles.py", line 121, in delete
celery_1 | return self._client.delete(resource=resource, timeout=timeout)
celery_1 | File "/python-hpOneView/hpOneView/resources/resource.py", line 259, in delete
celery_1 | task, body = self._connection.delete(uri, custom_headers=custom_headers)
celery_1 | File "/python-hpOneView/hpOneView/connection.py", line 359, in delete
celery_1 | return self.__do_rest_call('DELETE', uri, {}, custom_headers=custom_headers)
celery_1 | File "/python-hpOneView/hpOneView/connection.py", line 441, in __do_rest_call
celery_1 | raise HPOneViewException(body)
celery_1 | HPOneViewException: Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149., {u'errorSource': None, u'recommendedActions': [u'Confirm resource ID/URI and try the call again.'], u'nestedErrors': [], u'errorCode': u'RESOURCE_NOT_FOUND', u'details': u'The requested resource not found, ID = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'message': u'Resource not found, ID/URI = ed84ee6f-5c0f-43e8-99f7-8520189cb149.', u'data': {}}

What is happening

The problem seems to be in the init method of HPOneViewException:

class HPOneViewException(Exception):
"""
OneView base Exception.

Attributes:
   msg (str): Exception message.
   oneview_response (dict): OneView rest response.

"""

def __init__(self, data):
    self.msg = None
    self.oneview_response = None

    if isinstance(data, basestring):
        self.msg = data
    else:
        self.oneview_response = data

        if data and isinstance(data, dict):
            self.msg = data.get('message')

    if self.oneview_response:
        Exception.__init__(self, self.msg, self.oneview_response)
    else:
        Exception.__init__(self, self.msg)

When self.oneview_response exists. Exception is called with two arguments, when HPOneViewException is defined to take one argument. The easiest way to fix this, I think, is to do something like the following:

[eamonn@z620-eamonn hpOneView (fix-pickle)]$ git diff exceptions.py
diff --git a/hpOneView/exceptions.py b/hpOneView/exceptions.py
index 5aa5c48..d2f7cd1 100644
--- a/hpOneView/exceptions.py
+++ b/hpOneView/exceptions.py
@@ -78,11 +78,9 @@ class HPOneViewException(Exception):

         if data and isinstance(data, dict):
             self.msg = data.get('message')
  •            self.msg += ', %s' % self.oneview_response
    
  •    if self.oneview_response:
    
  •        Exception.__init__(self, self.msg, self.oneview_response)
    
  •    else:
    
  •        Exception.__init__(self, self.msg)
    
  •    Exception.__init__(self, self.msg)
    

I've verified that this change will produce the desired output above. It may be possible to fix by overriding the reduce method, I didn't try that.

Banner page prevents scripts from running.

Hi,

Have been working with the SDK, and it works well, when you do not have a Login banner banner page. This is the page that all users see before they login. It is configigured under Settings -> security -> Actions -> Edit -> Login -> Message -> Require acknowledgment.

What would be the command to say ok and contiue to the normal login?

When this is not set, I am able to execute the scripts. I get the following error when I try to use the SDK when it is set:

[root@ustlvcmsm0023 scripts]# python3 get-datacenters.py -a dcs.mycompany.com -u apiuser -p XXXXXXX
Login failed
Traceback (most recent call last):
File "get-datacenters.py", line 117, in
sys.exit(main())
File "get-datacenters.py", line 112, in main
get_datacenters(fac)
File "get-datacenters.py", line 66, in get_datacenters
dcs = fac.get_datacenters()
File "/opt/rh/rh-python34/root/usr/lib/python3.4/site-packages/hpOneView-3.1.0-py3.4.egg/hpOneView/facilities.py", line 54, in wrapper
return func(*args, **kwargs)
File "/opt/rh/rh-python34/root/usr/lib/python3.4/site-packages/hpOneView-3.1.0-py3.4.egg/hpOneView/facilities.py", line 65, in get_datacenters
body = self._con.get(uri['datacenters'])
File "/opt/rh/rh-python34/root/usr/lib/python3.4/site-packages/hpOneView-3.1.0-py3.4.egg/hpOneView/connection.py", line 327, in get
raise HPOneViewException(body)
hpOneView.exceptions.HPOneViewException: ("Authorization error: Missing 'auth' header.", {'nestedErrors': [], 'errorCode': 'AUTHORIZATION_MISSING_AUTH_HEADER', 'data': {}, 'errorSource': None, 'message': "Authorization error: Missing 'auth' header.", 'details': "Missing 'auth' header from the request.", 'recommendedActions': ["Please provide the missing 'auth' header value and try again."]})
[root@ustlvcmsm0023 scripts]#

When the login banner is disabled:

[root@ustlvcmsm0023 scripts]# python3 get-datacenters.py -a dcs.mycompany.com -u apiuser -p XXXXXX
{'category': 'datacenters',
'count': 1,
'created': '2017-06-02T11:17:37.722Z',
'eTag': None,
'members': [{'category': 'datacenters',
'contents': [],
'coolingCapacity': None,
'coolingMultiplier': 1.5,
'costPerKilowattHour': None,
'created': '2017-04-24T14:01:05.746Z',
'currency': 'USD',
'defaultPowerLineVoltage': 220,
'depth': 3000,
'deratingPercentage': 20.0,
'deratingType': 'NaJp',
'eTag': '2017-04-24T14:01:05.750Z',
'id': '2f51ff69-7ca8-4e38-9aa1-10769999999',
'modified': '2017-04-24T14:01:05.750Z',
'name': 'Datacenter 1',
'remoteSupportUri': '/rest/support/datacenters/2f51ff69-7ca8-4e38-9aa1-109999999',
'state': 'Unmanaged',
'status': 'OK',
'uri': '/rest/datacenters/2f51ff69-7ca8-4e38-9aa1-107629999999',
'uuid': '2f51ff69-7ca8-4e38-9aa1-107623729999',
'width': 7200}],
'modified': '2017-06-02T11:17:37.722Z',
'nextPageUri': None,
'prevPageUri': None,
'start': 0,
'total': 1,
'type': 'ErmResourceCollection',
'uri': '/rest/datacenters?start=0&count=1000'}

Johnson Hays
hays @ hpe.com

'create' in network_sets.py missing input argument

Found on line 121, self._client.create(data, blocking) is missing an argument for 'create' in resource.py. create is expecting resource, uri, and a timeout value; on line 121 network_sets.py it is only being given a resource and a Boolean value (presumably for timeout). Due to argument order, the Boolean value is being read in as the URI value and cannot be interpreted.
I was able to modify this line and change it from:
return self._client.create(data, blocking)
to:
return self._client.create(data, None, blocking)
and the function started working again. I do not believe a Boolean value is appropriate for the timeout argument but that is a decision best left for the dev team.

Future >=0.15.2 Not Found

Hello,

I tried to install HPE OV library by running:
python setup.py install

I got the following error message:
Couldn't find index page for 'future' (maybe misspelled?0
.....
No local packages or download links found for future>=0.15.2

I checked the https://pypi.python.org/simple/, I didn't see future-0.15.2.

Please help.

Remove unused/legacy code from connection.py

Scenario/Intent

With the newest rule from Flake8, the methods get_entities_byfield and get_entity_byfield started failing on rule 'E722 do not use bare except'.

Taking a more in depth look in the code, I see these methods, as well as a few other, are not called anywhere in the repository and are likely remnants used by deprecated/removed classes now.

Since whatever code was using them has been removed, and these methods do not seem necessary nor do they seem to add any value, I'd suggest removing them.

Methods to be removed:

  • get_entities_byfield
  • get_entity_byfield
  • get_entities_byrange
  • conditional_post

Environment Details

  • OneView SDK Version: 4.2.0

python-hpOneView BUG

If I use amqp version 2.0 and just copy paste the code from github without any modification I got this trace:

[root@sanyichef ov]# ./scmb.py -a 192.168.x.x -u Administrator -p xxxxxxxx
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/amqp/connection.py", line 377, in channel
    return self.channels[channel_id]
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./scmb.py", line 199, in <module>
    sys.exit(main())
  File "./scmb.py", line 194, in main
    recv(args.host, args.route)
  File "./scmb.py", line 106, in recv
    ch = conn.channel()
  File "/usr/lib/python3.4/site-packages/amqp/connection.py", line 380, in channel
    channel.open()
  File "/usr/lib/python3.4/site-packages/amqp/channel.py", line 455, in open
    spec.Channel.Open, 's', ('',), wait=spec.Channel.OpenOk,
  File "/usr/lib/python3.4/site-packages/amqp/abstract_channel.py", line 62, in send_method
    conn._frame_writer.send((1, self.channel_id, sig, args, content))
AttributeError: 'Connection' object has no attribute '_frame_writer'
[root@sanyichef ov]#

If I upgrade the amqp from 2.0.0 to 2.1.4 I got this error message:
/usr/lib/python3.4/site-packages/amqp/connection.py:304: AMQPDeprecationWarning: The .frame_writer attribute on the connection was accessed before
the connection was established.  This is supported for now, but will
be deprecated in amqp 2.2.0.
Since amqp 2.0 you have to explicitly call Connection.connect()
before using the connection.

So, I have to added this line:

# Connect to RabbitMQ
    conn = amqp.Connection(dest, login_method='EXTERNAL', ssl=ssl_options)
    conn.connect() ###NEW LINE
    ch = conn.channel()

However after that I got this message:

Traceback (most recent call last):
  File "./scmb.py", line 199, in <module>
    sys.exit(main())
  File "./scmb.py", line 194, in main
    recv(args.host, args.route)
  File "./scmb.py", line 113, in recv
    ch.wait()
TypeError: wait() missing 1 required positional argument: 'method'

I was trying to find the description of the channel class but what I have found missed the wait() and callbacks() method. I have found java docs which explains this/similar methods but nothing for python.
https://www.rabbitmq.com/amqp-0-9-1-reference.html
https://www.rabbitmq.com/releases/rabbitmq-java-client/v1.7.0/rabbitmq-java-client-javadoc-1.7.0/com/rabbitmq/client/Channel.html

Because it said a positional argument is missing I just added an argument ‘1’ and voilà it just started to work. And I don’t really understand this. Can you shed some light on this for me?

while ch.callbacks:
     ch.wait(1)

get ethernet network does not return all attributes

Scenario/Intent

Query OneView to get Ethernet networks

Environment Details

  • OneView SDK Version: 3.3.0
  • **OneView Appliance Version 3.10.02-0298793
  • OneView Client API Version: [API version listed in your configuration file or dictionary]
  • Python Version: 3.43
  • Platform: Windows server 2016

Steps to Reproduce

Looking at the example Ethernet_networks.py , you can specify maximumbandwidth and typicalbandwidth to create an Ethernet network.
But a call to get does not return any bandwidth information

Expected Result

a call to get should return all attributes of Ethernet networks

Actual Result

Example:
listofnetworks = ovconnection.ethernet_networks.get_all()

for net in listofnetworks:
    print(net.keys())

Result:
dict_keys(['uri', 'status', 'scopeUris', 'vlanId', 'privateNetwork', 'name', 'description', 'connectionTemplateUri', 'smartLink', 'eTag', 'subnetUri', 'created', 'type', 'modified', 'fabricUri', 'state', 'purpose', 'category', 'ethernetNetworkType'])

HPOneViewException not raised when connection with paused VM fails

Hi guys,

When I try to create the OneView client but my VM is paused, an OSError exception is raised instead of a HPOneViewException. The HPOneViewException should not cover this type of exception in this scenario? For treat this exception is only possible if I catch an OSError, but is seems odd for me since this also could be used as a HPOneViewException maybe.

Code example:

#VM paused
config = {
	"ip": "x.x.x.x",
	"credentials": {
		"userName": "user_name",
		"password": "pass"
	}
}

oneview_client = OneViewClient(config)

Result:

Traceback (most recent call last):
  File "one_view.py", line 89, in <module>
    one_view = OneView(config)
  File "one_view.py", line 12, in __init__
    self.oneview_client = OneViewClient(config)
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/oneview_client.py", line 118, in __init__
    self.__connection.login(config["credentials"])
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 483, in login
    self.validateVersion()
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 79, in validateVersion
    version = self.get(uri['version'])
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 324, in get
    resp, body = self.do_http('GET', uri, '')
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 126, in do_http
    conn.request(method, path, body, http_headers)
  File "/usr/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/usr/lib/python3.5/http/client.py", line 1252, in connect
    super().connect()
  File "/usr/lib/python3.5/http/client.py", line 849, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.5/socket.py", line 711, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 702, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host

Synergy profile provisioned from template using Python SDK is not consistent

Scenario/Intent

Provisioning a Synergy profile from template using Python SDK should result in a profile containing the OS Deployment Plan, connections, and local storage that was defined in the template.

Environment Details

  • OneView SDK Version: 3.3.0
  • OneView Appliance Version: 3.10.04-0299553
  • OneView Client API Version: 500
  • Python Version: 3.4.5
  • Platform: CentOS 7.3 x86_64

Steps to Reproduce

Create a template in OneView containing an OS Deployment Plan, connections, and local storage
Provision a profile in Python:
oneview_client = OneViewClient.from_json_file('connection.json')
new_profile_options = dict(
name=PROFILE_NAME,
serverProfileTemplateUri=TEMPLATE_URI,
serverHardwareUri=SRVR_HWARE_URI
)
new_profile = oneview_client.server_profiles.create(new_profile_options)

Expected Result

New profile contains same OS Deployment Plan, connections, and local storage as the template

Actual Result

New profile has OS Deployment Plan set to "None", no connections, and no local storage

Python 2.7.9 requirement too restrictive for CentOS 7

I note that in version 3.2.1 of the Python hpOneView library that a check is made at module start to verify that the running Python is at least version 2.7.9. I assume this is because the SSL support was retooled in 2.7.9 to support certificate validation. However, Python 2.7.9 is not available in CentOS 7; the system Python is 2.7.5. Furthermore, the newer SSL stack was backported by RedHat from 2.7.9 to 2.7.5 for this distribution. Would you consider a PR to make this check more specific so that the default system Python on Cent7 can be used with python-hpOneView?

Delete login sessions

Scenario/Intent

We should be able to delete login sessions used by this module

Environment Details

  • OneView SDK Version: 4.2.0
  • OneView Appliance Version: 3.10.04
  • OneView Client API Version: 500
  • Python Version: 2.7.9
  • Platform: SLES 12 SP2

Steps to Reproduce

There does not seem to be a function to logout a session (which would translate to DELETE on /rest/login-sessions with the auth header set to the session token)

Expected Result

I want to be able to clean up login sessions. Either explicitly with a logout function on the OneView client, and/or, better, automatically when the OneView client object is destroyed so that we don't rely on the script author remembering to write some cleanup code

Actual Result

Sessions are not logged out and remain in the OneView db. This has caused problems in the past, specifically: http://h20564.www2.hpe.com/hpsc/doc/public/display?docId=emr_na-a00021788en_us&sp4ts.oid=5410258

example scmb.py is broken with v4.x libray

Scenario/Intent

tried running example/scmb.py with master version and it break at sec = security(con)

Environment Details

  • **OneView SDK Version: master
  • **OneView Appliance Version: 3.1
  • **OneView Client API Version: 500
  • **Python Version: 3.5
  • **Platform: rhel 7.x

Steps to Reproduce

try to run examples/scmb.py

Expected Result

  • examples should work with master version SDK library v4.x
  • Even though i'm raising issue with scmb.py but all examples should be updated to make it with current version of library
  • It might be good idea to provide support for backward compatibility or document it

Actual Result

getting python error:
NameError: name 'security' is not defined

from scmb.py line # 282 ( which is sec = security(con)

servers object methods depend on /rest/server-hardware returning all servers

The servers object methods rely on /rest/server-hardware returning a list of all servers. Unfortunately my experience with OneView 2.x this isn't the case.

When I issue the following get: /rest/server-hardware?start-0&count=-1 it only returns 32 items.

Reviewing the oneview api doc:
The number of resources to return. A count of -1 requests all the items. The actual number of items in the response may differ from the requested count if the sum of start and count exceed the total number of items, or if returning the requested number of items would take too long.

I tested by passing count values >32 and the OneView API returned >32 servers... So I'm not sure why passing -1 only returns 32. This behavior is inconsistent.

None-the-less even if OneView was returning all servers it Looks like the python sdk needs to be enhanced to support when not all servers are returned as the endpoint does not promise to return a complete list.

oneview_server_profile doesn't work with Python 2.7.13 from RHSCL

Scenario/Intent

I wrote a playbook to deploy a synergy server profile. It worked great until I had to re-install the ansible host. I re-installed the python27 package from the RHSCL repo too and followed the orders to install the oneView python SDK.

So I thought that I am now using python-2.7.13 instead of the previously installed 2.7.5.

The following modules are working great:

  • oneview_os_deployment_plan_facts
  • oneview_server_profile_facts

But the module oneview_server_profile is crashing:

fatal: [myhost.local -> localhost]: FAILED! => {
"changed": false,
"module_stderr": "/usr/lib/python2.7/site-packages/hpOneView/init.py:53: Warning: Running unsupported Python version: 2.7.5, unexpected errors might occur. Use of Python v2.7.9+ is advised.\n warnings.warn(warning_message % '.'.join(map(str, PYTHON_VERSION)), Warning)\nTraceback (most recent call last):\n File "/tmp/ansible_MHyqgH/ansible_module_oneview_server_profile.py", line 205, in \n from ansible.module_utils.oneview import (OneViewModuleBase,\nImportError: cannot import name ServerProfileReplaceNamesByUris\n",
"module_stdout": "",
"rc": 0
}

The output of ansible --version looks good:

[ansible@localhost ~]$ ansible --version
ansible 2.4.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/oneview-ansible/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.13 (default, Feb 8 2017, 06:57:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]

The Python binary is version 2.7.13:

[ansible@localhost ~]$ /usr/bin/python --version
Python 2.7.13

What is wrong here?

Environment Details

  • OneView SDK Version: 4.4.0
  • OneView Appliance Version: 3.10.07-0310774
  • OneView Client API Version: 500
  • Python Version: 2.7.13 from RHSCL
  • Platform: RHEL 7.4

Steps to Reproduce

I don't know how to reproduce it, I installed just the way it is advised in the hpOneView Python SDK site.

Expected Result

The expected result is that ansible is using the python-2.7.13 binary from the RHSCL

Actual Result

The actual result is that ansible is using the python-2.7.5 binary from the RHEL 7.4 distro.

Profile local storage is not working

Configuring local storage from define profile isn't working correctly. It looks like make_LocalStorageEmbeddedController from common does nothing. Maybe this has not be implemented yet?

Validate secure connection to OneView using a certificate file

Scenario/Intent

I want to establish a secure HTTPS connection with OneView validating it with a given certificate file passed as one of the configuration credentials parameters.

Environment Details

  • OneView SDK Version: 4.3.0
  • OneView Appliance Version: 3.00.07_288219
  • OneView Client API Version: 300
  • Python Version: 2.7.13 and 3.5.3
  • Platform: Ubuntu Server 16.04 LTS

Steps to Reproduce

The code below opens an insecure connection to OneView, relying only on username+password for authentication, which is ok for development environments.

from hpOneView.oneview_client import OneViewClient
oneview_client = OneViewClient({'ip': '<host>', 'credentials': {'userName': '<user>', 'password': '<passwod>'})

There should be way to inform the certificate file in the credentials to ensure the SDK is really connecting to OneView. Something like:

from hpOneView.oneview_client import OneViewClient
oneview_client = OneViewClient({'ip': '<host>', 'credentials': {'userName': '<user>', 'password': '<passwod>', 'cert': 'cacertfile.crt'}})

Expected Result

I expect the SDK to:

  • open an insecure connection if the user does not specify a certificate
  • open a secure connection if the user specified a valid certificate
  • reject the OneViewClient instantiation if the certificate does not verify with the server (using a wrong cert OR somebody deployed a malicious fake OneView)

Actual Result

The client provides only a non-validated secure connection mode.

Feature Request: Support allocator/collector methods in IPv4 ranges.

Scenario/Intent

The HP OneView API supports a primitive IPAM system for allocating IP addresses within the
ranges defined on the appliance.

The API docs show a PUT /rest/id-pools/ipv4/ranges/{id}/allocator which will allocate an IP
address from the specified range, and PUT /rest/id-pools/ipv4/ranges/{id}/collector to release
it back into the pool.

Environment Details

  • OneView SDK Version: 500 (but this has been there for a while, I think)
  • OneView Client API Version: Latest client (head of tree)
  • Python Version: Python 2.7.12
  • Platform: Ubuntu 16.04.3 LTS

Steps to Reproduce

No support for the above API methods.

Happy to add the functionality and submit upstream.

Server Profile task creation is aborting

I'm trying to create multiple server profiles at once and do not want to wait for each task to complete so I'm adding a timeout of 5 seconds to server_profiles create. However, after the 5 seconds is reached, the task is aborted. This is what I'm reading in the server_profile create usage for the timeout:

timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView, just stop waiting for its completion.

but this is what I'm seeing when trying to create a profile with the 5 second timeout:

2017-06-01 06:27:10,110 ERROR hpOneView Waited 5 seconds for task to complete, aborting when creating server profile Encl4, bay 10 Compliant Profile KZPKYJ

It looks like the task_monitor __wait_task_completion is aborting the task after the timeout.

Am I reading the timeout usage incorrectly in the server_profile create function?

Allow python 2.7.5 support for RHEL/CENTOS/OL7

Scenario/Intent

Add code to setup.py to check for python version. No need to require futures if you actually use python3. This code will bypass future if you are already using 3.

from setuptools import find_packages
from setuptools import setup
import sys

is_future = 'future>=0.15.2' if sys.version_info[0] < 3 else ''

setup(name='hpOneView',
      version='4.0.0',
      description='HPE OneView Python Library',
      url='https://github.com/HewlettPackard/python-hpOneView',
      download_url="https://github.com/HewlettPackard/python-hpOneView/tarball/v4.0.0",
      author='Hewlett Packard Enterprise Development LP',
      author_email='[email protected]',
      license='MIT',
      packages=find_packages(exclude=['examples*', 'tests*']),
      keywords=['oneview', 'hpe'],
      install_requires=[is_future])

Program running twice when importing hpOneView

We are facing a weird problem when using python-hpOneView. All statements are running twice after adding the import.

Example:

Before importing:

print 'hello'

Output:

$ python test.py 
hello

After importing:

from hpOneView.oneview_client import OneViewClient

print 'hello'

Expected Output:

$ python test.py 
hello

Actual Output:

$ python test.py 
hello
hello

UPDATE:

It worked as expected after adding if __name__ == '__main__':

from hpOneView.oneview_client import OneViewClient

if __name__ == '__main__':
    print 'hello'

Output:

$ python test.py 
hello

Example Scripts do not support Active Directory Users

The provided example scripts seem to only work with local user accounts. I was able to modify the example pythons scripts to work with AD credentials. Here are the changes (or, at least, my version) to get the scripts to work:

In the main definition, add:

    parser.add_argument('-d', dest='domain', required=False,
                        default='Local',
                        help='''
    HP OneView Authorized Login Domain''')

Modify the following line:
credential = {'userName': args.user, 'password': args.passwd}
to:
credential = {'authLoginDomain': args.domain.upper(), 'userName': args.user, 'password': args.passwd}

Feature request -- allow updating of single custom attribute instead of whole list

Scenario/Intent

I wolud like to be able to update select custom attributes in a profile instead of having to update the entire list of custom attributes. Sometimes an OS Plan Script can have many custom attributes, so this woud be a nice feature.

Environment Details

  • OneView SDK Version: 3.3.0
  • OneView Appliance Version: 3.10.04-0299553
  • OneView Client API Version: 500
  • Python Version: 3.4.5
  • Platform: CentOS 7.3 x86_64

Steps to Reproduce

Create a profile with an OS Deployment Plan that requires 3 custom attributes named 'key1', 'key2', and 'key3' with corresponding values 'value1', 'value2', and 'value3'
Update the profile with Python SDK and change the 'key2' custom attributes to have value of 'new2':
oneview_client = OneViewClient.from_json_file('connection.json')
profile_to_update['osDeploymentSettings']['osCustomAttributes'] = dict(name='key2',value='new2')
profile_updated = oneview_client.server_profiles.update(resource=profile_to_update, id_or_uri=profile_to_update['uri'])

Expected Result

The resulting profile would have all custom attributes left unchanged, except the attribute 'key2', which would have the value 'new2'

Actual Result

No custom attributes are changed. In order to change 'key2' custom attribute, all custom attributes have to be supplied, like:
profile_to_update['osDeploymentSettings']['osCustomAttributes'] = dict(name='key1',value='value1'),dict(name='key2',value='new2'),dict(name='key3',value='key3')

Is it possible to login with session token?

Scenario/Intent

I have a RESTful service that queries OneView resources via python-hpOneView and I want to provide session resources in this service using OneView credentials. The simple scenario is, considering each RESTful service corresponds to a single OneView appliance:

  • the service knows OneView ip address;
  • the user post to the service a username+password combination; it creates a hpOneView client instance and gives back the x-auth-token on the service header
  • the user access other services resources passing x-auth-token header which is used to build another hpOneView client instance and perform requests.

I know that python-hpOneView POSTs username+password to OneView's /rest/login-sessions when creating a new client instance and I think that a similar approach can be used with the session token and a PUT request to validate it.

Would you consider providing this additional authentication in a near version?

Add utilization to Racks

Scenario/Intent

Retrieve hardware utilization for racks

Environment Details

  • OneView SDK Version: All versions
  • OneView Appliance Version: All

'delete' in network_sets.py has incorrect keyword

Found on line 95 in network_sets.py this line has an incorrect keyword. I was able to get this function working by changing the line from:
return self._client.delete(resource, force=force, blocking=blocking)
to:
return self._client.delete(resource, force=force, timeout=blocking)

I believe that a Boolean value for blocking is not appropriate but this is a decision best left to the dev team.

Add functionality to enclosures.py

Hi all,

I have an existing repository that is useful for adding multiple enclosures, creating SPTs, and then using these SPTs to create SPs. The process, for the most part, is automated from end-to-end.

I would, however, like to see about being incorporated in the python-hpOneView SDK. I have modified enclosures.py to also allow the addition of multiple enclosures and would like to include it.

Is this something that would be of interest to you?

Katherine

Bug in index_resources.get_all()

Scenario/Intent

List all resources of a given category (disks in my case) using the Index Service

Environment Details

  • OneView SDK Version: 4.4
  • OneView Appliance Version: 3.1
  • OneView Client API Version: 500
  • Python Version: 2.7
  • Platform: Running on Ubuntu

Note that this bug is independent of the Environment, and purely a function of the SDK.

Steps to Reproduce

Try to list all of the drives on a multi-enclosure Synergy (for example). You only get the first page of results.

Expected Result

We should get all disks

Actual Result

Only get the first-page of results.

The essential issue is that index_resource.get_all() calls the get method, not the get_all method. The complication is that index_resource.get_all() builds its own URI complete with filtering. A proposed fix follows.

scmb example script is unable to connect to rabbit. raises exception with AMQPLAIN auth-mod

Scenario/Intent

I'm working on https://github.com/HewlettPackard/oneview-redfish-toolkit project and need to access the rabbitMQ of OneView.
Run the scmb.py script in the examples\scmb folder of the project.

Environment Details

  • OneView SDK Version:: 4.4.0
  • OneView Appliance Version: DCS_3.00.07_288219_GGyQP
  • OneView Client API Version: 300
  • Python Version: 3.5.4
  • Platform: OpenSuSE 42.3

Python environment:
amqp==2.2.2
asn1crypto==0.24.0
cffi==1.11.4
click==6.7
configparser==3.5.0
cryptography==2.1.4
Flask==0.12.2
Flask-API==1.0
future==0.16.0
hpOneView==4.4.0
idna==2.6
itsdangerous==0.24
Jinja2==2.10
jsonschema==2.6.0
MarkupSafe==1.0
-e git+https://github.com/HewlettPackard/oneview-redfish-toolkit@0d1fd2da27c5c61cb8a1606f95981f873430662c#egg=oneview_redfish_toolkit
pbr==3.1.1
pycparser==2.18
pyOpenSSL==17.5.0
six==1.11.0
vine==1.1.4
Werkzeug==0.14.1

Steps to Reproduce

  1. download the script:
    https://github.com/HewlettPackard/python-hpOneView/blob/master/examples/scmb/scmb.py
  2. install the dependencies (see list above in my venv)
  3. generate rabbit key pair
    ./scmb.py -a [HPE OneView Appliance IP] -u Administrator -p MyPass -g
  4. download rabbit key pair and root ca cert
    ./scmb.py -a [HPE OneView Appliance IP] -u Administrator -p MyPass -d
  5. run the scmb.py script to listen to rabbit:
    ./scmb.py -a [HPE OneView Appliance IP] -u Administrator -p MyPass

Expected Result

Oneview alerts printed in the screen

Actual Result

Traceback (most recent call last):
File "./scmb.py", line 203, in
sys.exit(main())
File "./scmb.py", line 196, in main
recv(args.host, args.route)
File "./scmb.py", line 103, in recv
conn.connect()
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/connection.py", line 288, in connect
self.drain_events(timeout=self.connect_timeout)
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/connection.py", line 471, in drain_events
while not self.blocking_read(timeout):
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/connection.py", line 477, in blocking_read
return self.on_inbound_frame(frame)
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/method_framing.py", line 55, in on_frame
callback(channel, method_sig, buf, None)
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/connection.py", line 481, in on_inbound_method
method_sig, payload, content,
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/abstract_channel.py", line 128, in dispatch_method
listener(*args)
File "/home/ff/dev/oneview-redfish-toolkit/.venv/lib/python3.5/site-packages/amqp/connection.py", line 603, in _on_close
(class_id, method_id), ConnectionError)
amqp.exceptions.AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.

Query string required to force extract_bundle

Scenario/Intent

I want to extract an artifact bundle using the function extract_bundle https://github.com/HewlettPackard/python-hpOneView/blob/master/hpOneView/image_streamer/resources/artifact_bundles.py#L265

Environment Details

  • OneView SDK Version: 3.3.0
  • OneView Appliance Version: 3.10.02-0298793
  • OneView Client API Version: [API version listed in your configuration file or dictionary]
  • Python Version: Python 3.5.2
  • Platform: Ubuntu 16.04

Steps to Reproduce

Using the python-hpOneview example code. Add an artifact bundle. Extract that artifact bundle. You will see a pop up window appear that asks for an 'OK' before extracting.

Expected Result

Successful extract in the activity panelPlan Scripts and Build Plans to appear in the UI

Actual Result

I have to navigate to Image Streamer's 'Artifact Bundle' section and this pop up appears:

image

Possible Solution

You will need to attach a query string onto the end of the URI to ensure that the extract call is forced:

# Extract an Artifact Bundle
artifact_bundle['uri'] += '?extract=true&forceImport=true'
response = image_streamer_client.artifact_bundles.extract_bundle(artifact_bundle)

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.