Code Monkey home page Code Monkey logo

python-storage-clients's Introduction

https://travis-ci.org/HewlettPackard/python-storage-clients.svg?branch=latest https://readthedocs.org/projects/hpestorapi/badge/?version=latest

hpestorapi

Package description

hpestorapi is a python library that allows a simple way to use Rest API services for HPE storage and disk backup devices. Current version supports:

  • HPE 3PAR StoreServ disk arrays
  • HPE Primera disk arrays
  • HPE XP7 and P9500 (Command View AE Configuration manager is required)
  • HPE StoreOnce G3 disk backup device
  • HPE StoreOnce G4 disk backup device

Installation

Requirements

hpestorapi library requires:

Installation from PyPI

To download and install hpestorapi you can use pip:

# pip install hpestorapi

Installation from GitHub

Get a copy of source code

# git clone https://github.com/HewlettPackard/python-storage-clients.git
# cd python-storage-clients

Install the package with dependencies:

# python setup.py install

Import hpestorapi library to your python script:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import hpestorapi

Usage example

from hpestorapi import StoreServ

with StoreServ('10.0.0.1', '3paruser', '3parpass') as array:
    array.open()
    status, data = array.get('system')
    if status == 200:
        print('Name=%s' % data["name"],
              'SerialNumber=%s' % data["serialNumber"],
              'Address=%s' % data["IPv4Addr"]
              )

Documentation

The latest version of the documentation can be found here: html

Issues

If you encounter any problems, please open an issue along with a detailed description. Your questions are welcomed in gitter chat.

Package Version Numbers

This project follows Semantic Versioning.

Unit Tests

You should install docker prior to running tests. To run all unit tests:

# pip install -r requirements/development.txt
# docker build -t storeserv test/storeserv
# docker build -t storeonce3 test/storeonce3
# tox

python-storage-clients's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar ivanvsmirnov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-storage-clients's Issues

StoreServ self signed SSL cert support

Describe the bug

There is no way to use SSL protected connection to HPE 3PAR disk array with self-signed SSL certificate.

Expected behavior

Additional parameter for hpestorapi.StoreServ constructor or open() method is required.

Python environment

All environments.

StoreOnceG3: get CPU utilization status

Describe the bug
Suspected issue with Useragent string being sent to storeonce and later storeonce version. Issue is not seen when using identical URL in curl or browser

  1. when talking to Storeonce device using hpestoreapi "softwareVersion 4.1.2-1914.50"
    response status "HTTP 406 Not Acceptable"

  2. when talking to Storeonce device using hpestoreapi "softwareVersion 3.18.7-1841.1"
    response status "HTTP 200" and data (see curl output example)

...
3) But when using simple curl command line (or a browser) on EITHER storeonce device, ie 4.1.2-1914.50 OR 3.18.7-1841.1 BOTH devices response HTTP 200 and data. eg
$ curl --user USERNAME:PASSWORD -k "https://A.B.C.D/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06:00:00Z&endTime=2020-05-07T06:15:00Z&media=xml
Response:



28.1226
2020-05-07T06:00:00Z


28.0885
2020-05-07T06:01:00Z


25.8031
2020-05-07T06:02:00Z

Note the version 4.1.2-1914.50 device always returns JSON, the media parameter seems to be ignored even when using curl

Expected behavior
HTTP 200 and either xml or json formated data, depending on the parameter.

code example:
with hpestorapi.StoreOnceG3(*Device) as so:
try:
so.open()
...
url = f'/cluster/node/{node}/resourceMonitoring/cpu/min/'
params = {'startTime' : '2020-05-07T06:00:00Z', 'endTime' : '2020-05-07T06:15:00Z','media' : 'xml'}
status, data = so.get(url,params = params)
print('{}'.format(data))

Python environment

  • Python language version: [e.g. 3.7]
    $ /usr/local/bin/python3 --version
    Python 3.6.10
  • Python installed packages: ["# pip list" output]
    $ /usr/local/bin/python3 -m pip list
    Package Version

certifi 2020.4.5.1
chardet 3.0.4
hpestorapi 0.9.7
idna 2.9
influxdb 5.3.0
msgpack 0.6.1
pip 20.1
python-dateutil 2.8.1
pytz 2019.3
requests 2.23.0
setuptools 40.6.2
six 1.14.0
urllib3 1.25.9

  • Operation system version: [e.g. Centos Linux 7.6]
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 18.10
    Release: 18.10
    Codename: cosmic

  • Python interpreter typew: [e.g. CPython, PyPy, ...]

Trace log

Please enable hpestorapi debug log according documentation (see section "Debug" -> "Enable logging") and provide trace log.

Additional context

  1. Version 4 device
    the cluster properties tag + text
    properties None
    applianceName ********
    capacity 359526.3541248
    capacityBytes 359526354124800
    dedupeRatio 0.0
    diskBytes 200925789847552
    freeBytes 158600564277248
    freeSpace 158600.564277248
    health OK
    healthLevel 1
    productClass HPE StoreOnce 5650
    repHealth OK
    repHealthLevel 1
    repStatus Running
    serialNumber *********
    sizeOnDisk 200925.789847552
    softwareVersion 4.1.2-1914.50
    status Running
    uptimeSeconds 600
    userDataStored 0.0
    DEBUG:hpestorapi.storeonce:It was last page. Iteration stopped.
    DEBUG:hpestorapi.storeonce:GET("https://:443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/", timeouts=(1.0, None))
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): :443
    DEBUG:urllib3.connectionpool:https://
    :443 "GET /storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml HTTP/1.1" 406 52
    DEBUG:hpestorapi.storeonce:StoreOnce return status 406, delay 0.81 sec
    WARNING:hpestorapi.storeonce:resp.url=https://
    :443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml
    WARNING:hpestorapi.storeonce:resp.content=b'status=406,exception message=HTTP 406 Not Acceptable'
    WARNING:hpestorapi.storeonce:resp.reason=Not Acceptable
    DEBUG:root:/cluster/node/0/resourceMonitoring/cpu/min/ 406 status=406,exception message=HTTP 406 Not Acceptable
    DEBUG:hpestorapi.storeonce:GET("https://:443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/", timeouts=(1.0, None))
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): :443
    DEBUG:urllib3.connectionpool:https://
    :443 "GET /storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml HTTP/1.1" 406 52
    DEBUG:hpestorapi.storeonce:StoreOnce return status 406, delay 0.82 sec
    WARNING:hpestorapi.storeonce:resp.url=https://
    :443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml
    WARNING:hpestorapi.storeonce:resp.content=b'status=406,exception message=HTTP 406 Not Acceptable'
    WARNING:hpestorapi.storeonce:resp.reason=Not Acceptable
    ERROR:root:/cluster/node/0/resourceMonitoring/cpu/min/ 406 status=406,exception message=HTTP 406 Not Acceptable

  2. CURL from Version 4 Device, notice the output is JSON eventhough we request xml
    $ curl -XGET --user : -k "https://***********/storeonceservices/cluster/node/0/resourceMonitoring/cpu/hour/?startTime=2020-05-07T07:00:00Z&endTime=2020-05-07T07:15:00Z&media=xml"
    {"cpuStats":[{"timestamp":"2020-05-07T07:00:00Z","user":10.8334,"nice":3.24564E-4,"sys":4.53731,"idle":81.7032,"hardIRQ":0.0,"softIRQ":0.0593238,"steal":0.0,"guest":0.0,"ioWait":2.86646,"cpuUsage":18.2968}]}

  3. Version 3 device
    the cluster properties tag + text
    applianceName **********
    networkName **********
    serialNumber **********
    softwareVersion 3.18.7-1841.1
    productClass HPE StoreOnce 6500 Backup
    userDataStored 3077242.66549604
    sizeOnDisk 278075.449699008
    dedupeRatio 11.066214830639964
    healthLevel 1
    health OK
    status Running
    repHealthLevel 1
    repHealth OK
    repStatus Running
    uptimeSeconds 15191100
    isMixedCluster false
    cloudCapacityBytes 0
    cloudDiskBytes 0
    cloudReadWriteLicensedDiskBytes 0
    cloudFreeBytes 0
    cloudUserBytes 0
    localCapacityBytes 478512269884294
    localDiskBytes 278075449699008
    localFreeBytes 171471906282374
    localUserBytes 3077242665496064
    combinedCapacityBytes 478512269884294
    combinedDiskBytes 278075449699008
    combinedFreeBytes 171471906282374
    combinedUserBytes 3077242665496064
    DEBUG:hpestorapi.storeonce:It was last page. Iteration stopped.
    DEBUG:hpestorapi.storeonce:GET("https://:443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/", timeouts=(1.0, None))
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): :443
    DEBUG:urllib3.connectionpool:https://:443 "GET /storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml HTTP/1.1" 400 None
    DEBUG:hpestorapi.storeonce:StoreOnce return status 400, delay 0.113 sec
    WARNING:hpestorapi.storeonce:resp.url=https://
    :443/storeonceservices/cluster/node/0/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml
    WARNING:hpestorapi.storeonce:resp.content=b'\n \n \n Zero is not a valid node number\n \n \n\n'
    WARNING:hpestorapi.storeonce:resp.reason=Bad Request
    ERROR:root:/cluster/node/0/resourceMonitoring/cpu/min/ 400

Zero is not a valid node number

DEBUG:hpestorapi.storeonce:GET("https://:443/storeonceservices/cluster/node/1/resourceMonitoring/cpu/min/", timeouts=(1.0, None))
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): :443
DEBUG:urllib3.connectionpool:https://:443 "GET /storeonceservices/cluster/node/1/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml HTTP/1.1" 200 None
DEBUG:hpestorapi.storeonce:StoreOnce return status 200, delay 0.120 sec
WARNING:hpestorapi.storeonce:resp.url=https://
:443/storeonceservices/cluster/node/1/resourceMonitoring/cpu/min/?startTime=2020-05-07T06%3A00%3A00Z&endTime=2020-05-07T06%3A15%3A00Z&media=xml
WARNING:hpestorapi.storeonce:resp.content=b'\n \n \n 0.718915\n 2020-05-07T06:00:00Z\n \n \n 1.16404\n 2020-05-07T06:01:00Z\n \n \n 0.952517\n 2020-05-07T06:02:00Z\n \n \n 0.831018\n 2020-05-07T06:03:00Z\n \n \n 0.824164\n 2020-05-07T06:04:00Z\n \n \n 0.948315\n 2020-05-07T06:05:00Z\n \n \n 1.74306\n 2020-05-07T06:06:00Z\n \n \n 1.21877\n 2020-05-07T06:07:00Z\n \n \n 0.940965\n 2020-05-07T06:08:00Z\n \n \n 0.944355\n 2020-05-07T06:09:00Z\n \n \n 0.653561\n 2020-05-07T06:10:00Z\n \n \n 1.21736\n 2020-05-07T06:11:00Z\n \n \n 0.9655\n 2020-05-07T06:12:00Z\n \n \n 0.817127\n 2020-05-07T06:13:00Z\n \n \n 0.931526\n 2020-05-07T06:14:00Z\n \n \n 0.916305\n 2020-05-07T06:15:00Z\n \n \n\n'
WARNING:hpestorapi.storeonce:resp.reason=OK



0.718915
2020-05-07T06:00:00Z


1.16404
2020-05-07T06:01:00Z


0.952517
2020-05-07T06:02:00Z

  1. CURL from version 3 device
    $ curl -XGET --user " -k "https://**********/storeonceservices/cluster/node/0/resourceMonitoring/cpu/hour/?startTime=2020-05-07T07:00:00Z&endTime=2020-05-07T07:15:00Z&media=xml"
Zero is not a valid node number $ curl -XGET --user ********:******** -k "https://********/storeonceservices/cluster/node/1/resourceMonitoring/cpu/hour/?startTime=2020-05-07T07:00:00Z&endTime=2020-05-07T07:15:00Z&media=xml" 0.984886 2020-05-07T07:00:00Z 1.09986 2020-05-07T08:00:00Z $ curl -XGET --user ********:******** -k "https://********/storeonceservices/cluster/node/1/resourceMonitoring/cpu/min/?startTime=2020-05-07T07:00:00Z&endTime=2020-05-07T07:15:00Z&media=xml" 0.861089 2020-05-07T07:00:00Z 1.3527 2020-05-07T07:01:00Z 0.974153 2020-05-07T07:02:00Z 0.900603 2020-05-07T07:03:00Z 0.896514 2020-05-07T07:04:00Z 0.900946 2020-05-07T07:05:00Z

Add any other context about the problem here.
Also tried after upgrade to 0.9.8, same behaviour is seen

StoreOnce G3 zabbix monitoring templates

Hello Ivan

Any suggested way to monitor the HPE Store Once Storage device in Zabbix

Could you help me out with any exisitng teamplates and scripts via which monitoring the Storage device could be established

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.