You can add your own storage equipment handler to DCImanager 6. To do this, create the handler code and upload it to the platform.
Preparing the environment
The switch handler must be written in Python. We recommend using Python version 3.9.
We recommend creating a handler based on an existing project. To copy a project:
- Connect to the location server via SSH. For more information about connecting via SSH, see Workstation setup.
- Run the command:
docker cp eservice_handler:/opt/ispsystem/equip_handler ./
Project directories can be useful when creating a handler:
- /common — common auxiliary classes and functions;
- /dss_common — auxiliary classes and functions for working with the storage equipment;
You can see the required Python libraries and their versions in the project requirements.txt file. To install the required libraries, run the command:
pip3 install -r requirements.txtTo check the data types in the project, we recommend using the mypy analyzer.
Creating the handler
Inheritance
The switch class is inherited from the class:
- BaseSnmpDSS — for devices that work via SNMP protocol;
- BaseHttpDSS — for devices that work via HTTP protocol;
- BaseDSS — for other devices.
class ExampleHandlerDss(BaseDss):
"""Example handler class for DSS."""
def __init__(self, dss_data: DssData):
"""__init__.
Args:
dss_data (DssData): DSS connection data
"""
super().__init__(dss_data)
self.__logger = get_logger("example_handler_dss")To get the data for connecting to the storage equipment unit, use the self.dss_data method:
handler = make_handler(dss_data, custom_params)
logger.info(handler.dss_data.snmp_params)
logger.info(handler.dss_data.device_type)Methods for working with storage equipment
To allow DCImanager 6 to interact with and gather metrics from the storage equipment, override the get_metrics method:
class ExampleHandlerDss(BaseSnmpDss):
def get_metrics(self) -> DssMetricsView:
"""Returns DSS metrics."""
start_timestamp = int(datetime.datetime.now().timestamp() * 1_000)
metrics = DssMetricsView(start_timestamp)
# Code for gathering metrics
return metricsTo allow DCImanager 6 to interact with and gather metrics from the storage equipment, use the methods from a base class for one of the poll types:
- BaseSnmp:
- snmp_walk;
- snmp_bulkwalk;
- snmp_get;
- snmp_set;
- snmp_set_multiple.
- BaseHttp:
- get;
- post.
Interfaces are described in the BaseSnmpDSS and BaseHtmlDSS base classes.
Handler creation function
Each handler file must contain the make_handler function. This function creates a handler object:
def make_handler(dss_data: DssData) -> "ExampleHandlerDss":
"""Create DSS handler object.
Args:
dss_data (DssData): DSS connection data for selected protocol.
Returns:
BaseDss: Initialized DSS handler object
"""
return ExampleHandlerDss(dss_data)Loading the handler into the platform
To load the handler into the platform:
-
Create a directory with the following structure:
handler_dir/ ├── __init__.py └── my_handler.pyComments -
Create a tar.gz archive with the following directory:
tar -czvf custom_handler.tar.gz handler_dirComments to the command -
Log in to DCImanager 6 with administrator permissions:
curl -o- -k https://example.com/api/auth/v4/public/token \ -H "isp-box-instance: true" \ -d '{ "email": "<admin_email>", "password": "<admin_pass>" }'Comments to the commandA response message in the format below will be received:
{"id":"24","token":"24-cee181d2-ccaa-4b64-a229-234aa7a25db6"}Save the value of the token parameter from the received response.
-
Create a description for the handler:
curl -o- -k https://example.com/api/eservice/v3/custom_equipment \ -H "isp-box-instance: true" \ -H "x-xsrf-token: <token>" \ -d '{ "device_type": "<device>", "handler": "<internal_handler_name>", "name": "<handler_name>", "protocol": ["<handler_protocol>"], "features": [] }'Comments to the commandThe response will contain the id of the created handler. Save this value.
{"id": 1} -
Load the archive with the handler into the platform:
curl -o- -k https://example.com/api/eservice/v3/custom_equipment/<handler_id>/content \ -H "isp-box-instance: true" \ -H "x-xsrf-token: <token>" \ -F "data=@custom_handler.tar.gz" \ -F "handler_import=<import_path>"Comments to the commandYou can also use this command to upload new handler versions to the platform.
Related topics:
En
Es