oopt-goldstone / goldstone-mgmt

TIP Goldstone management layer implementation
Apache License 2.0
7 stars 9 forks source link

interface counter is not working on gscli #81

Open r-suke opened 10 months ago

r-suke commented 10 months ago

Now I'm testing GFT and I found interface counter is not working on gscli.

# gscli
> interface Interface1/0/1
interface(Interface1/0/1)> show counters
Traceback (most recent call last):
  File "/usr/local/bin/gscli", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/main.py", line 198, in main
    asyncio.run(_main())
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/main.py", line 194, in _main
    await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/main.py", line 107, in loop_async
    await shell.exec(line)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/main.py", line 56, in exec
    ret = self.context.exec(cmd, no_fail=no_fail)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/base.py", line 410, in exec
    return self._command(line, self.fuzzy_completion)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/base.py", line 284, in __call__
    return cmd(line[1:], fuzzy)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/base.py", line 284, in __call__
    return cmd(line[1:], fuzzy)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/base.py", line 273, in __call__
    return self.exec(line)
  File "/usr/local/lib/python3.10/site-packages/goldstone/north/cli/interface.py", line 1090, in exec
    show_counters(self.conn, ifnames, table)
TypeError: show_counters() missing 1 required positional argument: 'model'

and I changed /usr/local/lib/python3.10/site-packages/goldstone/north/cli/interface.py

# diff interface.py interface.py_
1050,1051d1049
<         self.model = options.get("model", "goldstone-interfaces")
<
1091d1088
<             model   = self.model
1093c1090
<         show_counters(self.conn, ifnames, table, model)
---
>         show_counters(self.conn, ifnames, table)
interface(Interface1/0/1)> show counters
  in-octets: 36338662426254
  in-unicast-pkts: 53171120684
  in-broadcast-pkts: 0
  in-multicast-pkts: 0
  in-errors: 0
  out-octets: 135778516800
  out-unicast-pkts: 0
  out-broadcast-pkts: 0
  out-multicast-pkts: 2121539325
  out-discards: 324009
  out-errors: 0

it looks work (I don't know well it is correct or not) . I could not find interface.py code (Is it packaged some where?) and could not make pull request.
First, I'd like to report that there is a syntax error in the interface.py and that it's not working clearly.

ishidawataru commented 10 months ago

@r-suke Thanks for the report. This is related to the management framework. I transferred the issue to the mgmt repo. You can find interface.py here

ishidawataru commented 10 months ago

@r-suke This is a bug introduced by this commit. Your fix seems good to me. Could you open a PR? I'd appreciate it if you could add a test here.

r-suke commented 10 months ago

I'd appreciate it if you could add a test here.

Sorry, now we have no CI environment for goldstone. Now I'm changing code directly on GFT. Maybe It takes time to prepare it (and I have to understand how the test code works).

ishidawataru commented 10 months ago

Sure, no problem. Basically, you only need Docker for the CI environment.

$ make tester # build the tester image
$ docker run -t -v `pwd`:`pwd` -w `pwd` ghcr.io/oopt-goldstone/mgmt/tester make unittest

This will run the unittest.

r-suke commented 10 months ago

Thank you for telling. I'll prepare it.