Skip to content

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

License

Notifications You must be signed in to change notification settings

HyperviewHQ/hvcli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 make 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.

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.

22. 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.

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

Usage: hvcli list-alarms [OPTIONS]

Options:
  -s, --skip <SKIP>                  Number of records to skip (0 -> 99999), e.g. 100 [default: 0]
  -l, --limit <LIMIT>                Record limit (1 -> 100000), 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 CSV file output from the list-alarms command

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

Options:
  -f, --filename <FILENAME>            Input filename, e.g. port_name_update.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.

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

Search by property (JSON output)

$ hvcli search-assets -P serialNumber=SERIALNUMBEREXAMPLE1234 -o json
[
  {
    "id": "\"58af63dc-1e9e-4b8b-b2b7-e0451aaca8fb\"",
    "name": "\"UpsExample\"",
    "assetLifecycleState": "\"Active\"",
    "assetTypeId": "\"Ups\"",
    "manufacturerId": "\"cd85e92d-869c-470a-a3ba-df8b2b7196e3\"",
    "manufacturerName": "\"Liebert\"",
    "monitoringState": "\"On\"",
    "parentId": "\"9a877a93-1f21-4895-a078-5c67f531ea0b\"",
    "parentName": "\"Simulated SNMP Devices\"",
    "productId": "\"aedbd4b9-06ae-4768-ba4a-64847b60d334\"",
    "productName": "\"eXM\"",
    "status": "\"Normal\"",
    "path": "\"All/Simulated SNMP Devices/UpsExample\"",
    "serialNumber": "[\"SERIALNUMBEREXAMPLE1234\"]"
  }
]

Search by text pattern (record output)

$ hvcli search-assets -p "UpsExampl*"
---- [0] ----
id: "58af63dc-1e9e-4b8b-b2b7-e0451aaca8fb"
name: "UpsExample"
asset_lifecycle_state: "Active"
asset_type_id: "Ups"
manufacturer_id: "cd85e92d-869c-470a-a3ba-df8b2b7196e3"
manufacturer_name: "Liebert"
monitoring_state: "On"
parent_id: "9a877a93-1f21-4895-a078-5c67f531ea0b"
parent_name: "Simulated SNMP Devices"
product_id: "aedbd4b9-06ae-4768-ba4a-64847b60d334"
product_name: "eXM"
status: "Normal"
path: "All/Simulated SNMP Devices/UpsExample"
serial_number: ["SERIALNUMBEREXAMPLE1234"]

Combination search (JSON output)

$ hvcli search-assets -p "UpsExample" --location-path "All/Simulated SNMP Devices/" -M "Liebert" -o json
[
  {
    "id": "\"58af63dc-1e9e-4b8b-b2b7-e0451aaca8fb\"",
    "name": "\"UpsExample\"",
    "assetLifecycleState": "\"Active\"",
    "assetTypeId": "\"Ups\"",
    "manufacturerId": "\"cd85e92d-869c-470a-a3ba-df8b2b7196e3\"",
    "manufacturerName": "\"Liebert\"",
    "monitoringState": "\"On\"",
    "parentId": "\"9a877a93-1f21-4895-a078-5c67f531ea0b\"",
    "parentName": "\"Simulated SNMP Devices\"",
    "productId": "\"aedbd4b9-06ae-4768-ba4a-64847b60d334\"",
    "productName": "\"eXM\"",
    "status": "\"Normal\"",
    "path": "\"All/Simulated SNMP Devices/UpsExample\"",
    "serialNumber": "[\"SERIALNUMBEREXAMPLE1234\"]"
  }
]

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

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •