hyperglass icon indicating copy to clipboard operation
hyperglass copied to clipboard

Directive examples in documentation does not work as expected

Open AliMickey opened this issue 1 year ago • 7 comments

Deployment Type

Docker

Version

v2.0.4

Steps to Reproduce

  1. Copy contents of example from documentation into /etc/hyperglass/directives.yaml
  2. Start container and check logs

One example:

show-bgp-summary:
    name: BGP Summary
    rules:
        - condition: null
          command: show bgp all summary
    field: null

Expected Behavior

The directive should be parsed correctly and not throw errors.

Observed Behavior

Error shown. Defining/undefining the directive on the device does not matter, same error.

Have tried many different custom directive configs but one way or another it throws a validation error.

Configuration

No response

Devices

No response

Logs

╭─────────────────────────────── locals ────────────────────────────────╮    │
│ │ data = {                                                              │    │
│ │        │   'id': 'show-bgp-summary',                                  │    │
│ │        │   'name': 'BGP Summary',                                     │    │
│ │        │   'rules': [                                                 │    │
│ │        │   │   {                                                      │    │
│ │        │   │   │   'condition': None,                                 │    │
│ │        │   │   │   'command': 'show bgp all summary'                  │    │
│ │        │   │   }                                                      │    │
│ │        │   ],                                                         │    │
│ │        │   'field': None                                              │    │
│ │        }                                                              │    │
│ │ self = Directive()                                                    │    │
│ ╰───────────────────────────────────────────────────────────────────────╯    │
╰──────────────────────────────────────────────────────────────────────────────╯
ValidationError: 3 validation errors for Directive
rules.condition
  Input should be a valid string [type=string_type, input_value=None, 
input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/string_type
field.Text
  Input should be a valid dictionary or instance of Text [type=model_type, 
input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/model_type
field.Select
  Input should be a valid dictionary or instance of Select [type=model_type, 
input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/model_type

AliMickey avatar Jul 25 '24 01:07 AliMickey

I am also receiving the same error.

arhippa11 avatar Aug 10 '24 16:08 arhippa11

Me too.

gondimcodes avatar Aug 13 '24 21:08 gondimcodes

This works for me

show-ip-bgp-summary:
    name: Show BGP Neighbor Summary
    rules:
        - condition: ""
          commands: show ip bgp summary
    field:
        description: ""
        options:
        - value: ""

for FRR

show-ip-bgp-summary:
    name: Show BGP Neighbor Summary
    rules:
        - condition: ""
          commands: vtysh -c "show ip bgp summary"
    field:
        description: ""
        options:
        - value: ""

enkrispi avatar Aug 21 '24 06:08 enkrispi

The way you did it worked. The documentation has errors because look: you used "commands" and in the documentation it says "command". Another detail is how the "field" is defined. It only worked defining it the way you did.

gondimcodes avatar Aug 24 '24 01:08 gondimcodes

If documentation has errors you can submit a PR to fix that

LucaTheHacker avatar Oct 29 '24 08:10 LucaTheHacker

I had submitted a PR to fix this bug. Can someone merge it?

Jimmy01240397 avatar Oct 31 '24 10:10 Jimmy01240397

We need to wait for @thatmattlove

LucaTheHacker avatar Oct 31 '24 10:10 LucaTheHacker

I still have an issue with this.

show-ip-bgp-summary: name: Show BGP Neighbor Summary rules: - condition: "" commands: show ip bgp summary field: description: "" options: - value: ""

This will still require entering a value in the GUI for me and as no values are declared I cant enter one. The command doesnt require any inputs or fields.

warriorsoul15 avatar Sep 05 '25 13:09 warriorsoul15

Fixed in #299.

jdhall75 avatar Sep 30 '25 01:09 jdhall75