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

Can't create an instance using API on NSO 6.1

ron.whitt
Level 1
Level 1

I had this service working on 5.x version of NSO and I was able to list instances and create via the API, something has changed with 6.1

Here is the API call:

--header 'application: vnd.yang-data+json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Content-Type: application/yang-data+json' \
--data '{
  "data": {
    "l2vpn:l2vpn": [
      {
        "name": "APIDeployed",
        "pw-id": 115,
        "ios_device": "ios0",
        "ios_port": "0/9",
        "xr_device": "xr0",
        "xr_port": "0/0/0/9",
        "ios_xconnect_ip": "10.0.0.10",
        "ios_xconnect_encap": "mpls",
        "ios_description": "test",
        "xr_group": "acme",
        "xr_p2p": "acme",
        "xr_xconnect_ip": "10.0.0.11",
        "xr_description": "test"
      }
    ]
  }
}
 
Here is the response:
{
    "ietf-restconf:errors": {
        "error": [
            {
                "error-type": "application",
                "error-tag": "invalid-value",
                "error-path": "/l2vpn:l2vpn",
                "error-message": "POST on list must be on list element"
            }
        ]
    }
}
 
Here is the YANG model:
module l2vpn {
  namespace "http://com/example/l2vpn";
  prefix l2vpn;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ncs {
    prefix ncs;
  }

    description
    "This service creates L2VPNs across Cisco IOSXR and IOS for the NSO Basic Service Model Lab";

  revision 2021-02-11 {
    description
      "V1 all datapoints modeled";
  }
  augment /ncs:services {

    list l2vpn {
      key name;

      uses ncs:service-data;
      ncs:servicepoint "l2vpn";
      // set the service name.
      leaf name {
        tailf:info "Service instance name / Customer name";
          mandatory true;      
        type string;
      }

      // set the pseudo wire ID.    
      leaf pw-id {
        tailf:info "Unique pseudowire or virtual circuit number";
          mandatory true;      
        type uint32 {
          range "1..4294967295";
        }
      }    

      // set the ios device name.
      leaf ios_device {
        tailf:info "Select the Cisco IOS device";
          mandatory true;      
        type leafref {
          path "/ncs:devices/ncs:device/ncs:name";
        }
      }

      // set the ios device port
      leaf ios_port {
        tailf:info "Set the Cisco IOS device port number in form X/X";
          mandatory true;      
        type string;
      }

      // set the xr device name. }
        leaf xr_device {
          tailf:info "Select the Cisco IOSXR dervice";
            mandatory true;      
          type leafref {
            path "/ncs:devices/ncs:device/ncs:name";
        }
      }

      // set the xr device port
      leaf xr_port {
        tailf:info "Set the Cisoc IOSXR dervice port number in the form X/X/X/X";
          mandatory true;      
        type string;
      }
      // set the ios device xconnect IP.
      leaf ios_xconnect_ip {
        tailf:info "Set the neighbor IP for the IOS device (the IOSXR device loopback)";
          mandatory true;      
        type inet:ipv4-address;
      }

      // set the ios device xconnect encapsulation.
      leaf ios_xconnect_encap {
        tailf:info "Select the encapsulation for the IOS device";
          mandatory true;      
        type enumeration {
          enum "l2tpv3";
          enum "mpls";
        }
      }
      // set the ios device port description
      leaf ios_description {
        tailf:info "Set the description for the IOS device side port";
          mandatory true;      
        type string;
      }

      // set the xr device xconnect group name
      leaf xr_group {
        tailf:info "Set the xconnect group name for the IOSXR dervice";
          mandatory true;      
        type string;
      }

      // set the xr device xconnect p2p name
      leaf xr_p2p {
        tailf:info "Set the IOSXR p2p group name";
          mandatory true;      
        type string;
      }
      // set the ios device xconnect neighbor IP.
      leaf xr_xconnect_ip {
        tailf:info "Set the neighbor IP for the IOSXR device (the IOS device loopback) ";
          mandatory true;      
        type inet:ipv4-address;
      }

      // set the xr device port description name
      leaf xr_description {
        tailf:info "Set the description for the IOSXR side port";
          mandatory true;      
        type string;  
      }  
    }
  }
}
 
The service model does compile and I can manually input service instances from the command line.  Just not sure what's going on with the API.  Thanks
1 Accepted Solution

Accepted Solutions

ron.whitt
Level 1
Level 1

Ok... figured it out:

curl --location 'http://192.168.2.100:8080/restconf/data/' \

--header 'application: vnd.yang-data+json' \

--header 'Authorization: Basic YWRtaW46YWRtaW4=' \

--header 'Content-Type: application/yang-data+json' \

--data '{

    "l2vpn:l2vpn": [

      {

        "name": "APIdeployed",

        "pw-id": 118,

        "ios_device": "ios0",

        "ios_port": "0/9",

        "xr_device": "xr0",

        "xr_port": "0/0/0/9",

        "ios_xconnect_ip": "10.0.0.10",

        "ios_xconnect_encap": "mpls",

        "ios_description": "test",

        "xr_group": "acme",

        "xr_p2p": "acme",

        "xr_xconnect_ip": "10.0.0.11",

        "xr_description": "test"

      }

    ]

}

'

Evidently the module name goes in the data payload now... 

 

View solution in original post

1 Reply 1

ron.whitt
Level 1
Level 1

Ok... figured it out:

curl --location 'http://192.168.2.100:8080/restconf/data/' \

--header 'application: vnd.yang-data+json' \

--header 'Authorization: Basic YWRtaW46YWRtaW4=' \

--header 'Content-Type: application/yang-data+json' \

--data '{

    "l2vpn:l2vpn": [

      {

        "name": "APIdeployed",

        "pw-id": 118,

        "ios_device": "ios0",

        "ios_port": "0/9",

        "xr_device": "xr0",

        "xr_port": "0/0/0/9",

        "ios_xconnect_ip": "10.0.0.10",

        "ios_xconnect_encap": "mpls",

        "ios_description": "test",

        "xr_group": "acme",

        "xr_p2p": "acme",

        "xr_xconnect_ip": "10.0.0.11",

        "xr_description": "test"

      }

    ]

}

'

Evidently the module name goes in the data payload now...