cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
591
Views
1
Helpful
3
Replies

Multi-Stage Service Model

Andrew Horrigan
Cisco Employee
Cisco Employee

I am trying to create a multi-stage service model where certain selections provide the user with different choices and/or different templates.  For example, assume the following YANG:

      leaf device-size {

        type enumeration {

            enum small;

            enum medium;

            enum large;

        }

      leaf vnf-device-type {

        type enumeration {

            enum 1-arm;

            enum 2-arm;

            enum 3-arm;

        }


Would it be possible to "dynamically" create a device template such that a user could select small / 1-arm and get one device configuration, but then select large / 2-arm and get another template? Or, do I need a seperate template for every permutation?  I am assuming that some of this can be done in Python with variables, but I wasn't sure if NSO had any built in features to handle this kind of model natively.

1 Accepted Solution

Accepted Solutions

So, if I am understanding this correctly, the following lines dictate when a certain section of the XML is actually "applicable"? 

  <config-template xmlns="http://tail-f.com/ns/config/1.0"

                   servicepoint="template-svc">

    <devices xmlns="http://tail-f.com/ns/ncs">

      <device>

        <name>{/device}</name>

        <config>

          <fooo>

           ...

          </fooo>

          <bar when="{/device-size='medium' && /vnf-device-type='1-arm'}">

           ....

          </bar>

          <baz when="{/vnf-device-type='2-arm'}">

           ....

          </baz>

        </config>

      </device>

    </devices>

  </config-template>

Let me give this a test - this seems super handy!  Thanks.

View solution in original post

3 Replies 3

frjansso
Cisco Employee
Cisco Employee

Maybe a simple template service:

  list template-svc {

    key name;

    uses ncs:service-data;

    ncs:servicepoint "template-svc";

    leaf name {

      type string;

    }

    leaf device {

      type leafref {

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

      }

    }

    leaf device-size {

      type enumeration {

        enum small;

        enum medium;

        enum large;

      }

      leaf vnf-device-type {

        type enumeration {

          enum 1-arm;

          enum 2-arm;

          enum 3-arm;

        }

      }

    }

  }

  <config-template xmlns="http://tail-f.com/ns/config/1.0"

                   servicepoint="template-svc">

    <devices xmlns="http://tail-f.com/ns/ncs">

      <device>

        <name>{/device}</name>

        <config>

          <fooo>

           ...

          </fooo>

          <bar when="{/device-size='medium' && /vnf-device-type='1-arm'}">

           ....

          </bar>

          <baz when="{/vnf-device-type='2-arm'}">

           ....

          </baz>

        </config>

      </device>

    </devices>

  </config-template>

So, if I am understanding this correctly, the following lines dictate when a certain section of the XML is actually "applicable"? 

  <config-template xmlns="http://tail-f.com/ns/config/1.0"

                   servicepoint="template-svc">

    <devices xmlns="http://tail-f.com/ns/ncs">

      <device>

        <name>{/device}</name>

        <config>

          <fooo>

           ...

          </fooo>

          <bar when="{/device-size='medium' && /vnf-device-type='1-arm'}">

           ....

          </bar>

          <baz when="{/vnf-device-type='2-arm'}">

           ....

          </baz>

        </config>

      </device>

    </devices>

  </config-template>

Let me give this a test - this seems super handy!  Thanks.

Yes, exactly like that. Between the {} you can put XPATH 1.0 expressions that are evaluated. The XML tags where the expressions evaluating to "false" are skipped.