cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
37
Views
3
Helpful
8
Replies
Cisco Employee

About vrf-list can not config

 

Hi,

 

I have a question about how to config vrf-list, the case are as follows, question is in the last .

 

In ncs device show xml:

 

admin@ncs(config)# show full-configuration devices device node-0 config cisco-ios-xr:vrf | display xml

 

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

 

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

 

  <device>

 

<name>node-0</name>

 

<config>

 

<vrf xmlns="http://tail-f.com/ned/cisco-ios-xr">

 

<vrf-list>

 

<name>tvshow</name>

 

</vrf-list>

 

<vrf-list refcounter="1"  backpointer="[ /ncs:services/cpn:cpn[cpn:name='0'] ]" >

 

<name>voice</name>

 

</vrf-list>

 

</vrf>

 

</config>

 

  </device>

 

  </devices>

 

</config>

 

My yang file:

 

augment /ncs:services {

 

    list cpn {

 

description "This is MBH service";

 

key name;

 

leaf name {

 

type int32;

 

}

 

 

leaf vrf {

 

type string;

 

}

 

My template about vrf config:

 

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

 

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

 

<device  tags="nocreate">

 

<name>{$Device-Name}</name>

 

<config>

 

<vrf xmlns="http://tail-f.com/ned/cisco-ios-xr" tags="merge">

 

<vrf-list >

 

<name>{$Vrf-Value}</name>

 

</vrf-list>

 

</vrf>

 

</config>

 

</device>

 

  </devices>

 

</config-template>

 

My java code about apply this templat:

 

Template vrfTemplate = new Template(context,"cpn-global-vrf");

 

TemplateVariables vrfVar = new TemplateVariables();

 

vrfVar.putQuoted("Device-Name",deviceName);

 

vrfVar.putQuoted("Vrf-Value",vrfValueGlobal);

 

vrfTemplate.apply(service,vrfVar);

 

 

Question, when I run , the old vrf voice is disappeared , so how can I handle this case that only add new vrf not delete old vrf ?

 

admin@ncs(config)# services cpn 0 vrf tvshow

 

admin@ncs(config-cpn-0)# commit dry-run

 

device node-0

 

   config {

 

cisco-ios-xr:vrf {

 

+        vrf-list tvshow {

 

+        }

 

-        vrf-list voice {

 

-        }

 

}

 

   }

 

---------

 

Thanks

 

Hao Fan   

 

 

Everyone's tags (5)
8 REPLIES 8
Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hi,

 

 

Everytime your service create callback runs, it needs to create all vrfs. That's how FASTMAP works.

 

 

You could use a list for vrfs in your service model and then iterate over it in your service create callback.

 

 

Thanks.

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hi Bilal

 

Thanks for your reply. In this way ,how  will wirte template ? Need I write many  vrf-list ?

 

<vrf-list>

 

<name>tvshow</name>

 

</vrf-list>

 

 

Thanks

 

Hao Fan

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

If vrf-list in the NED is a leaf-list, then changing vrf in the service model to leaf-list you type should work.

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hi Bilal,

 

In the NED , vrf is a list, so that how can I write template ?

 

  // vrf *

 

list vrf-list {

 

tailf:cli-mode-name "config-vrf";

 

tailf:cli-drop-node-name;

 

key name;

 

leaf name {

 

tailf:info "WORD;;VRF name";

 

type string;

 

}

 

 

Thanks

 

Hao Fan

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hi Folks,

 

About NSO , I have two questions:

 

  1. I think that nso database  stores the device configuration . However, for service model, have database in NSO ? If I configed service model, do NSO have CLI to show  service model  configuration rather than device model ?
  2. If the device configurations  are changed, could NSO be initiative to sync-from device to NSO rather than manually to run device sync-from in nso cli ?

  

If NSO can do , thanks for replying me.

 

 

Thanks

 

Hao Fan

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hi Folks,

 

About NSO , I have two questions:

 

  1. I think that nso database  stores the device configuration . However, for service model, have database in NSO ? If I configed service model, do NSO have CLI to show  service model  configuration rather than device model ?
  2. If the device configurations  are changed, could NSO be initiative to sync-from device to NSO rather than manually to run device sync-from in nso cli ?

  

If NSO can do , thanks for replying me.

 

 

Thanks

 

Hao Fan

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Hao,

 

 

I will reiterate what Bilal already said with an example.

 

 

You should use XPath expressions in the template whenever possible.

 

Template variables are only intended for values that cannot be expressed in XPath.

 

 

Suppose your service model looks like this

 

 

list myservice {

 

  ...

 

  list device {

 

    key name;

 

    leaf name {

 

      type leafref {

 

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

 

      }

 

    }

 

    leaf-list vrf-values {

 

      type string;

 

    }

 

  }

 

}

 

 

Your template would then look like this. It will iterate over all devices and all vrf-values.

 

 

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

 

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

 

    <device  tags="nocreate">

 

<name>{/device/name}</name>

 

<config>

 

        <vrf xmlns="http://tail-f.com/ned/cisco-ios-xr" tags="merge">

 

          <vrf-list>

 

<name>{vrf-values}</name>

 

</vrf-list>

 

</vrf>

 

</config>

 

    </device>

 

  </devices>

 

</config-template>

 

 

 

Note that the XPath evaluation context ( '/' node) is the service list entry here.

 

 

If you cannot avoid using variables, you will probably have to apply the template multiple times from the Java code. In such case, maybe it is easier to write the service in pure Java?

 

 

/ Denys

 

 

Highlighted
Cisco Employee

Re: About vrf-list can not config

 

Thanks Denys. Follow your suggestions, maybe I will try write the service in pure Java.