cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
731
Views
0
Helpful
1
Replies

json-rpc create new service instance

robert.lee2
Level 1
Level 1

Below is a yang snippet for a small service that works right now -

list loopback {

    description "This is an RFS skeleton service";

     key serv-id;

     leaf serv-id {

      tailf:info "Unique service id";

       type uint16;

    }

    leaf device-name {

      type leafref {

        path "/ncs:devices/ncs:device/ncs:name";

      }

    }

    uses ncs:service-data;

    ncs:servicepoint loopback-servicepoint;

    leaf lp-inf-num {

      tailf:info "Enter loopback interface num";

      mandatory true;

      type uint16;

    }

    leaf loopback-ip {

      tailf:info "Assign loopback Interface-IP";

      mandatory true;

      type inet:ipv4-address;

    }

  }

Then in a python script, after I have created a login session, obtained the cookie and transaction handle, etc, I try to execute - the following -

# Set service id

set_lpserv_id = {'jsonrpc': '2.0', 'id': 1, 'method': 'set_value', 'params': {'th': th, 'path': '/loopback:loopback/loopback:serv-id', 'value': '77'}}

set_lpserv_id_response = requests.post(url, json=set_lpserv_id, headers=headers);

print 'set serv id:::' + str(set_lpserv_id_response.json())

This generates the error msg - below -  What causes this error ?  Should I be able to set the leaf that serves as the key of a list, in this manner ?

set serv id:::{u'jsonrpc': u'2.0', u'id': 1, u'error': {u'data': {u'reason': u'wrong number of identifiers', u'param': u'path'}, u'message': u'Invalid parameters', u'code': -32602, u'type': u'rpc.method.invalid_params', u'internal': u'webui_util585'}}

1 Accepted Solution

Accepted Solutions

robert.lee2
Level 1
Level 1

Answer- Need to use create method, not the way, I was doing it .......

View solution in original post

1 Reply 1

robert.lee2
Level 1
Level 1

Answer- Need to use create method, not the way, I was doing it .......

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: