vlvassilev / yuma123

The yuma123 repository
Other
24 stars 26 forks source link

How to use list in rpc input ? #126

Closed ian0113 closed 2 years ago

ian0113 commented 2 years ago

Hi, @vlvassilev

I don't know how to input a list, do you have any examples?

yang module:

module test-module {
  grouping test-list {
    container list {
      list list-entry {
        leaf a {
          type string;
        }
        leaf b {
          type string;
        }
      }
    }
  }
  rpc test-module-list-input {
    input  {
      uses test-list;
    }
  }
}

in yangcli:

yangcli ian@localhost> load test-module
yangcli ian@localhost> mgrload test-module
yangcli ian@localhost> test-module-list-input list=

Error: 'missing value string
Error: invalid value (list)
Error in the parameters for 'test-module-list-input' command (invalid value)

yangcli ian@localhost> 

Thanks, Ian

vlvassilev commented 2 years ago

I just tried to use interactive fill with a file variable. If you are using the latest code this will work:

yangcli vladimir@localhost> @tmp/x.xml = fill test-module-list-input optional

Fill non-mandatory container list?
Enter Y for yes, N for no, or C to cancel: [default: N]
yangcli vladimir@localhost:fill> Y

Filling container /test-module-list-input/input/list:
Filling list /test-module-list-input/input/list/list-entry:
Enter string value for leaf <a>
yangcli vladimir@localhost:fill> foo1

Enter string value for leaf <b>
yangcli vladimir@localhost:fill> bar1

Add another list?
Enter Y for yes, N for no, or C to cancel: [default: N]
yangcli vladimir@localhost> N

yangcli vladimir@localhost> test-module-list-input @tmp/x.xml

RPC Request 2 for session 1:

<test-module-list-input xmlns="http://yuma123.org/ns/test/yangcli/fill/mod1">
  <list>
    <list-entry>
      <a>foo1</a>
      <b>bar1</b>
    </list-entry>
  </list>
</test-module-list-input>

RPC OK Reply 2 for session 1:

yangcli vladimir@localhost> quit
ian0113 commented 2 years ago

Hi, @vlvassilev

Thanks for your reply. The example worked, so I closed this issue.

Thanks, Ian