HPE StoreOnce Gen 4 disk backup

API references

class hpestorapi.StoreOnceG4(address, username, password)[source]

HPE StoreOnce Gen 4 backup device implementation class.

__init__(address, username, password)[source]

HPE StoreOnce Gen 4 disk backup constructor.

Parameters:
  • address (str) – Hostname or IP address of HPE StoreOnce device.
  • username (str) – Username for HPE StoreOnce device.
  • password (str) – Password for HPE StoreOnce device.
Returns:

None.

open(verify=False)[source]

Open new Rest API session for HPE StoreOnce Gen 4 disk backup.

You should call it prior any other requests. Do not forget to call
StoreOnceG4.close() if you don’t plan to use current session anymore.
Parameters:verify (bool|str) – (optional) Either a boolean, in which case it controls whether we verify the Rest server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. By default: False (do not check certificate).
Returns:None
close()[source]

Close Rest API session.

You don’t need to run it manually if you use context manager.

Returns:None
get(url, **kwargs)[source]

Perform HTTP GET request to HPE Storeonce G4 disk backup device.

This method used to get information about objects.

Parameters:
  • url (str) – URL address. Base part of url address is generated automatically and you should not care about it. Example of valid url: ‘/rest/alerts’ or ‘/api/v1/management-services/licensing’. All available url’s and requests result are described in HPE StoreOnce REST API
  • json (dict) – (optional) A JSON serializable object to send in the body of request.
  • params (dict) – (optional) Dictionary with url encoded parameters.
  • timeout (float|tuple) – (optional) How many second to wait for the Rest server response before giving up. By default use same value as StoreOnceG4.timeout.
Return type:

tuple(int, dict())

Returns:

Tuple with HTTP status code and dict with request result. For example: (200, {…}) or (204, None).

post(url, **kwargs)[source]

Perform HTTP POST request to HPE StoreOnce G4 disk backup device.

This method used to create new object.

Parameters:
  • url (str) –

    URL address. Base part of url address is generated automatically and you should not care about it. Example of valid url: ‘/rest/alerts’ or ‘/api/v1/management-services/licensing’. All available url’s and requests result are described in HPE StoreOnce REST API

  • json (dict) – (optional) A JSON serializable object to send in the body of request.
  • params (dict) – (optional) Dictionary with url encoded parameters.
  • timeout (float|tuple) – (optional) How many second to wait for the Rest server response before giving up. By default use same value as StoreOnceG4.timeout.
Return type:

tuple(int, dict())

Returns:

Tuple with HTTP status code and dict with request result. For example: (200, {…}) or (204, None).

delete(url, **kwargs)[source]

Perform HTTP DELETE request to HPE StoreOnce G4 disk backup device array.

This method used to remove objects.

Parameters:
  • url (str) –

    URL address. Base part of url address is generated automatically and you should not care about it. Example of valid url: ‘/rest/alerts’ or ‘/api/v1/management-services/licensing’. All available url’s and requests result are described in HPE StoreOnce REST API

  • json (dict) – (optional) A JSON serializable object to send in the body of request.
  • params (dict) – (optional) Dictionary with url encoded parameters.
  • timeout (float|tuple) – (optional) How many second to wait for the Rest server response before giving up. By default use same value as StoreOnceG4.timeout.
Return type:

tuple(int, dict())

Returns:

Tuple with HTTP status code and dict with request result. For example: (200, {…}) or (204, None).

put(url, **kwargs)[source]

Perform HTTP PUT request to HPE StoreOnce G4 disk backup device array.

This method used to modify objects.

Parameters:
  • url (str) –

    URL address. Base part of url address is generated automatically and you should not care about it. Example of valid url: ‘/rest/alerts’ or ‘/api/v1/management-services/licensing’. All available url’s and requests result are described in HPE StoreOnce REST API

  • json (dict) – (optional) A JSON serializable object to send in the body of request.
  • params (dict) – (optional) Dictionary with url encoded parameters.
  • timeout (float|tuple) – (optional) How many second to wait for the Rest server response before giving up. By default use same value as StoreOnceG4.timeout.
Return type:

tuple(int, dict())

Returns:

Tuple with HTTP status code and dict with request result. For example: (200, {…}) or (204, None).

timeout

Rest API client timeout.

Number of seconds that Rest API client waits for a response from Rest API server before generating a timeout exception. Different timeouts for connection setup and for getting first piece of data can be used. In this case, use tuple(float, float) with the first value being a connection delay and with the second value being a read delay. Alternatively, you can use one float value for both types of timeouts. ‘None’ value can be used instead not to limit the device response time. Default value: (1, None).

Usage examples

Session management

Open Rest API session for StoreOnce Gen 4 disk backup device:

import hpestorapi

with hpestorapi.StoreOnceG4('10.0.0.1', 'Admin', 'password') as so:
    try:
        print('Something went wrong:')
        so.open()
    except Exception as error:
        print(error)
    else:
        # Perform requests to StoreOnce (get/post/put/delete)
        # ...

GET request

Simple GET request usage. This code print StoreOnce G4 groups:

import hpestorapi

with hpestorapi.StoreOnceG4('10.0.0.1', 'Admin', 'password') as so:
    try:
        so.open()
        status, data = so.get('/rest/groups')
    except Exception as error:
        print('Something went wrong:')
        print(error)
    else:
        if status == 200:
            for group in data['members']:
                print(group['groupName'])

POST request

This code will create new Catalyst client:

import hpestorapi

with hpestorapi.StoreOnceG4('10.0.0.1', 'Admin', 'password') as so:
    new_client = {'name': 'sqlserver', 'description': 'New host',
                  'password': 'secretpass'
    }
    try:
        so.open()
        status, data = so.post('/api/v1/data-services/cat/clients',
                               json=new_client)
    except Exception as error:
        print('Something went wrong:')
        print(error)
    else:
        if status == 201:
            print('Host succefully added.')
        else:
            print('Fail! Cannot add new catalyst client. Details:', data)

DELETE request

This code remove CIFS share:

import hpestorapi

with hpestorapi.StoreOnceG4('10.0.0.1', 'Admin', 'password') as so:
    share = 'CifsShare01'
    try:
        so.open()
        status, _ = so.delete('/api/v1/data-services/nas/shares'
                              '/share/{id}'.format(id=share))
    except Exception as error:
        print('Something went wrong:')
        print(error)
    else:
        if status == 204:
            print('Share succefully removed.')
        elif status == 404:
            print('Fail! Share does not exist.')
        else:
            print('Fail! Cannot remove share.')

PUT request

This code will update current SMTP configuration:

import hpestorapi

with hpestorapi.StoreOnceG4('10.0.0.1', 'Admin', 'password') as so:
    body = {'emailConfigurations': {
        'smtpPort': 25,
        'enabled': 'true',
        'senderEmailAddress': 'sender@company.com',
        'password': 'secretpassword',
        'smtpServer': 'email.company.com'
    }
    }
    try:
        so.open()
        status, data = so.put('/rest/email', json=body)
    except Exception as error:
        print('Something went wrong:')
        print(error)
    else:
        print('SMTP configuration succefully updated.')