Skip to content

HyperviewHQ/hvcli

Repository files navigation

Hyperview CLI

Note

This project is under active development. Please remember to check for new releases often.

Hyperview CLI (hvcli) is a command-line program for interacting with data in Hyperview.

Important Reminders

  • Powerful Capabilities: This tool can modify data in Hyperview. Please take the time to familiarize yourself with its features.
  • Check Twice, Act Once: Ensure that all your inputs are accurate. A small oversight can lead to unintended consequences.
  • Test with a small sample first: Test and verify bulk changes with a small sample before making big changes.

Your success is important to us! Enjoy using the Hyperview CLI (hvcli), and remember to proceed with caution!

Download

To use this tool, simply download a pre-built binary from the Releases section.

Configuration

A valid Hyperview API client must be used. The API client must have the appropriate access. The configuration file must be placed in $HOME/.hyperview/hyperview.toml.

Example

client_id = 'c33472d0-c66b-4659-a8f8-73c289ba4dbe'
client_secret = '2c239e21-f81b-472b-a8c3-82296d5f250d'
scope = 'HyperviewManagerApi'
auth_url = 'https://example.hyperviewhq.com/connect/authorize'
token_url = 'https://example.hyperviewhq.com/connect/token'
instance_url = 'https://example.hyperviewhq.com'

Usage

Run the command with the --help option to get usage information.

hvcli --help

Commands

1. list-asset-properties

List all available properties for an asset identified by its unique id.

2. list-custom-asset-properties

List all available custom properties for an asset identified by its unique id.

3. search-assets

Search for assets in Hyperview. Also available as the alias list-assets.

4. list-any-of

List assets that match a specific set of property values. For example, a list of serial numbers. Please note that the matches are exact.

5. update-asset-name

Update the display name of an asset identified by its unique id.

6. bulk-update-asset-name

Update multiple assets from a CSV file. Example data is in the example_input folder.

7. update-asset-location

Update the location of an asset identified by its unique id.

8. bulk-update-asset-location

Update the location of multiple assets from a CSV file. Example data is in the example_input folder.

9. update-asset-serial-number

Update the serial number of an asset identified by its unique id. Applies to manually created assets and assets discovered without a serial number.

10. bulk-update-asset-serial-number

Update the serial numbers of multiple assets from a CSV file. Applies to manually created assets and assets discovered without a serial number. Example data is in the example_input folder.

11. update-asset-tag

Update the asset tag of an asset identified by its unique id.

12. bulk-update-asset-tag

Update the asset tag of multiple assets from a CSV file. Example data is in the example_input folder.

13. update-power-design-value

Update the power design value property of an asset identified by its unique id. This applies to Rack and Location asset types.

14. bulk-update-power-design-value

Update the power “design value” property of multiple assets from a CSV file. This applies to Rack and Location asset types. Example data is in the example_input folder.

15. list-asset-ports

List the physical network ports of an asset identified by its unique id.

16. bulk-update-patch-panel-ports

Update the physical network port names of patch panel assets from a CSV file. Example data is in the example_input folder.

17. bulk-update-asset-ports

Update the physical network port names of other (non-patch-panel) assets from a CSV file, e.g. a network switch. Example data is in the example_input folder.

18. update-custom-asset-property

Update the value of a custom property of an asset identified by its unique id.

19. bulk-update-custom-asset-property

Update the custom property value of multiple assets using a CSV file. Example data is in the example_input folder.

20. list-alarms

List alarm events. By default, it will list active events. It can also list unacknowledged events via a command-line option.

21. manage-alarms

Acknowledge or close alarm events using a CSV file generated by the list-alarms command. By default, this command closes the events; it can also acknowledge them via a command-line option.

22. add-rack-accessory

Add a blanking panel or cable management panel to a rack identified by its unique id.

23. bulk-add-rack-accessory

Add blanking panels or cable management panels to multiple racks using a CSV file. Example data is in the example_input folder.

24. list-asset-sensors

List sensors for an asset identified by its unique id.

25. bulk-update-asset-sensor

Update asset sensor name and/or access policy using a CSV file. IMPORTANT: Keep the access policy field empty to maintain the original and only change the name. Use a NIL UUID (00000000-0000-0000-0000-000000000000) to reset to the parent access policy. Example data is in the example_input folder.

26. list-rack-pdu-outlets

List Rack PDU outlets for an asset identified by its unique id.

27. list-busway-tapoffs

List busway tap-offs for an asset identified by its unique id.

28. list-pdu-rpp-breakers

List PDU/RPP Breakers for an asset identified by its unique id.

29. add-power-association

Add power association. Note that associations are asset-to-asset. For example, when associating with a specific outlet or tap-off, you need its id.

30. bulk-add-power-association

Add power associations between assets using a CSV. Example data is in the example_input folder.

31. generate-sensor-report

Generate a monthly (or arbitrary date-range) report of daily-summary statistics (avg/max/min/last) for a named sensor across all assets of a given type. Optionally enrich each row with a custom-property value. Defaults to CSV output.

32. list-bacnet-definitions

List current BACnet IP sensor definitions.

33. add-bacnet-definition

Add a new BACnet IP sensor definition.

34. list-bacnet-numeric-sensor-definitions

List numeric sensors for a BACnet IP sensor definition.

35. list-bacnet-non-numeric-sensor-definitions

List non-numeric sensors for a BACnet IP sensor definition.

36. bulk-import-bacnet-numeric-sensor-definitions

Bulk create or update numeric sensors on a BACnet IP sensor definition from a CSV file. Rows with a blank id are created; rows with a valid UUID id are updated. Example data is in the example_input folder.

37. bulk-import-bacnet-non-numeric-sensor-definitions

Bulk create or update non-numeric sensors on a BACnet IP sensor definition from a CSV file. Rows with a blank id are created; rows with a valid UUID id are updated. Example data is in the example_input folder.

38. list-modbus-definitions

List current Modbus TCP sensor definitions.

39. add-modbus-definition

Add a new Modbus TCP sensor definition.

40. list-modbus-numeric-sensor-definitions

List numeric sensors for a Modbus TCP sensor definition.

41. list-modbus-non-numeric-sensor-definitions

List non-numeric sensors for a Modbus TCP sensor definition.

42. bulk-import-modbus-numeric-sensor-definitions

Bulk create or update numeric sensors on a Modbus TCP sensor definition from a CSV file. Rows with a blank id are created; rows with a valid UUID id are updated. Example data is in the example_input folder.

43. bulk-import-modbus-non-numeric-sensor-definitions

Bulk create or update non-numeric sensors on a Modbus TCP sensor definition from a CSV file. Rows with a blank id are created; rows with a valid UUID id are updated. Example data is in the example_input folder.

44. list-sensor-definition-types

List valid sensor types for an asset type, optionally filtered by sensor class (numeric or enum).

45. list-modbus-components

List the components of a Modbus TCP sensor definition. Modbus sensors are grouped under components; a sensor references its component via the component_id column.

46. add-modbus-component

Add a new component to a Modbus TCP sensor definition. Prints the new component's id, which can then be used as the component_id for imported Modbus sensors.

47. update-modbus-component

Rename an existing component of a Modbus TCP sensor definition.

48. delete-modbus-component

Delete a component from a Modbus TCP sensor definition.

49. get-bacnet-definition

Get a single BACnet IP sensor definition by its id.

50. update-bacnet-definition

Update the name, asset type, and (optional) description of a BACnet IP sensor definition.

51. delete-bacnet-definition

Delete a BACnet IP sensor definition by its id.

52. get-modbus-definition

Get a single Modbus TCP sensor definition by its id.

53. update-modbus-definition

Update the name, asset type, and (optional) description of a Modbus TCP sensor definition.

54. delete-modbus-definition

Delete a Modbus TCP sensor definition by its id.

55. delete-bacnet-numeric-sensor-definition

Delete a numeric sensor from a BACnet IP sensor definition.

56. delete-bacnet-non-numeric-sensor-definition

Delete a non-numeric sensor from a BACnet IP sensor definition.

57. delete-modbus-numeric-sensor-definition

Delete a numeric sensor from a Modbus TCP sensor definition.

58. delete-modbus-non-numeric-sensor-definition

Delete a non-numeric sensor from a Modbus TCP sensor definition.

Note

The BACnet/Modbus numeric sensor import CSVs accept optional offset and order_of_operations (scaleThenOffset | offsetThenScale) columns, and the Modbus sensor import CSVs accept an optional component_id column. Leave any of these blank to let the server apply its default. The bulk-import commands also accept --create-as-new, which ignores the id column and creates every row as a new sensor — use it to clone an exported definition's sensors into a different definition. The associated assets shown when listing a definition is a read-only count of how many assets use it; the API provides no way to manage that association.

Note

Use --help to explore the various options available within the main command and each subcommand.

Command help

Every command has a --help option for more information.

Examples

$ hvcli list-alarms --help
List alarm events. By default, it will list active events. It can also list unacknowledged events via a command-line option

Usage: hvcli list-alarms [OPTIONS]

Options:
  -s, --skip <SKIP>                  Number of records to skip (0 -> 1_000_000_000), e.g. 100 [default: 0]
  -l, --limit <LIMIT>                Record limit (1 -> 100_000), e.g. 100 [default: 100]
  -a, --alarm-filter <ALARM_FILTER>  Asset alarm event filter option, e.g. active [default: active] [possible values: unacknowledged, active]
  -o, --output-type <OUTPUT_TYPE>    Output type, e.g. csv-file [default: record] [possible values: csv-file, json, record]
  -f, --filename <FILENAME>          Output filename, e.g. output.csv
  -h, --help                         Print help
  -V, --version                      Print version

$ hvcli manage-alarms --help
Acknowledge or close alarm events using a CSV file generated by the list-alarms command. By default, this command closes the events; it can also acknowledge them via a command-line option

Usage: hvcli manage-alarms [OPTIONS] --filename <FILENAME>

Options:
  -f, --filename <FILENAME>            Input filename, e.g. input.csv
  -m, --manage-action <MANAGE_ACTION>  Manage action to use, e.g. close [default: close] [possible values: acknowledge, close]
  -h, --help                           Print help
  -V, --version                        Print version

Debugging

For troubleshooting, a master debug level can be set using -d or --debug-level. Accepted values are error (default), warn, info, debug, and trace.

Output options

Some commands allow the user to set the output to record, json, or csv-file. Refer to the command help for more information.

Output examples

The following samples were captured against a live Hyperview instance and have been anonymized. Identifiers and hostnames are placeholders; brand names are preserved so the shape of a real response is easy to recognize.

Search by property (JSON output)
$ hvcli search-assets -P serialNumber=SERIALNUMBEREXAMPLE1234 -o json
[
  {
    "id": "aaaaaaaa-0000-0000-0000-000000000001",
    "name": "UpsExample",
    "assetLifecycleState": "active",
    "assetTypeId": "ups",
    "manufacturerId": "bbbbbbbb-0000-0000-0000-000000000001",
    "manufacturerName": "Liebert",
    "monitoringState": "on",
    "parentId": "cccccccc-0000-0000-0000-000000000001",
    "parentName": "DatacenterExample",
    "productId": "dddddddd-0000-0000-0000-000000000001",
    "productName": "eXM",
    "status": "normal",
    "path": "All/DatacenterExample/",
    "serialNumber": "[\"SERIALNUMBEREXAMPLE1234\"]",
    "property": null
  }
]
Search by text pattern (record output)
$ hvcli search-assets -p "UpsExampl*"
---- [0] ----

id                    : aaaaaaaa-0000-0000-0000-000000000001
name                  : UpsExample
asset_lifecycle_state : active
asset_type_id         : ups
manufacturer_id       : bbbbbbbb-0000-0000-0000-000000000001
manufacturer_name     : Liebert
monitoring_state      : on
parent_id             : cccccccc-0000-0000-0000-000000000001
parent_name           : DatacenterExample
product_id            : dddddddd-0000-0000-0000-000000000001
product_name          : eXM
status                : normal
path                  : All/DatacenterExample/
serial_number         : ["SERIALNUMBEREXAMPLE1234"]
property              :
Combination search (JSON output)
$ hvcli search-assets -p "UpsExample" --location-path "All/DatacenterExample/" -M "Liebert" -o json
[
  {
    "id": "aaaaaaaa-0000-0000-0000-000000000001",
    "name": "UpsExample",
    "assetLifecycleState": "active",
    "assetTypeId": "ups",
    "manufacturerId": "bbbbbbbb-0000-0000-0000-000000000001",
    "manufacturerName": "Liebert",
    "monitoringState": "on",
    "parentId": "cccccccc-0000-0000-0000-000000000001",
    "parentName": "DatacenterExample",
    "productId": "dddddddd-0000-0000-0000-000000000001",
    "productName": "eXM",
    "status": "normal",
    "path": "All/DatacenterExample/",
    "serialNumber": "[]",
    "property": null
  }
]

Building from source

Linux, Windows, and macOS

Debug build

cargo build

The binary will be under target/debug/hvcli.

Release build

cargo build --release

The binary will be under target/release/hvcli.

Linux static binary

Install the x86_64-unknown-linux-musl target and run the command to build a statically-linked version:

PKG_CONFIG_SYSROOT_DIR=/ RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-musl --release

Docker

docker build --tag hvcli:latest -f docker/Dockerfile .

Running the Docker image

To run the Docker image generated, you need to:

  1. Map the application configuration directory to the container.
  2. Optional, map an output folder to the container.
Example

Assuming the username is albert:

docker run -v /home/albert/.hyperview:/root/.hyperview hvcli search-assets

If you are planning to output to csv:

docker run -v /home/albert/.hyperview:/root/.hyperview -v /tmp:/output hvcli search-assets -o csv-file -f /output/assets.csv

About

Hyperview CLI (hvcli) is a command line program to interact with data within Hyperview.

Resources

License

Stars

1 star

Watchers

2 watching

Forks

Packages

 
 
 

Contributors