Quantcast
Channel: THWACK: Popular Discussions - Network Configuration Manager
Viewing all articles
Browse latest Browse all 4266

Junos Routing Instance

$
0
0

Hi

 

I'm trying to get NCM to deploy new routing instances to some Juniper kit.  I've managed to get a script together that seems to output what looks like readable config however when it tried to execute it on the device the result is different.

Is there an issue with NCM deploying routing instances or have I missed something in my script?

 

My script (be gentle its my first go):

 

/*

.CHANGE_TEMPLATE_DESCRIPTION

        Create new Customer with 1 VRF on PEs

.PLATFORM_DESCRIPTION

        Juniper JUNOS

 

 

.PARAMETER_LABEL @ContextNode

        NCM Node

.PARAMETER_DESCRIPTION @ContextNode

        The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.

 

 

.PARAMETER_LABEL @custName

        Customer

.PARAMETER_DESCRIPTION @custName

        Customer short name for VRF

 

 

.PARAMETER_LABEL @cid

        Full cid

.PARAMETER_DESCRIPTION @cid

        Full Customer ID  - 4 digits

 

 

.PARAMETER_LABEL @scid

        Short cid

.PARAMETER_DESCRIPTION @scid

        Short Customer ID just for LAB

        Needed to build customer host network

 

 

.PARAMETER_LABEL @swfwip

        Switch to Firewall IP

.PARAMETER_DESCRIPTION @swfwip

        IP on switch for P2P to firewall including / prefix

        Part of the 10.200.x.x/17 block

        Switch is always last usable IP in /29

 

 

*/

      

 

 

script CreateNewCustomer(  

                             NCM.Nodes @ContextNode,

                             string @custName,

                             string @cid,

                             string @scid,

                             string @swfwip

                        )

 

 

 

 

{

  //Enter config mode

  CLI

  {

  configure

  }

 

  //Define variables for creating interfaces

  {

  string @loopback

  @loopback = '10.201.'

  @loopback = @loopback + @ContextNode.SiteID + '.'

  @loopback = @loopback + @ContextNode.PEID

  }

 

 

  {

  string @desc

  @desc = '"Customer' + ' '

  @desc = @desc + @custName + '"'

  }

 

 

  //Create Interfaces

  CLI

  {

  set interfaces lo0 unit @cid description @desc

  set interfaces lo0 unit @cid family inet address @loopback

  set interfaces ge-0/0/7 unit @cid vlan-id @cid

  set interfaces ge-0/0/7 unit @cid family inet address @swfwip

  }

 

 

  //Define variables for creating routing instance

  {

  string @subinterface

  @subinterface = '.' + @cid

  }

 

  {

  string @rd

  @rd = ':' + @cid

  }

 

  {

  string @vrftarget

  @vrftarget = 'target:65000:' + @cid

  }

 

 

  //Create routing instance

  CLI

  {

  set routing-instance @custName instance-type vrf

  set routing-instance @custName interface ge-0/0/7@subinterface

  set routing-instance @custName interface lo0@subinterface

  set routing-instance @custName route-distinguisher 65000@rd

  set routing-instance @custName vrf-target import @vrftarget

  set routing-instance @custName vrf-target export @vrftarget

  set routing-instance @custName vrf-table-label

  set routing-instance @custName routing-options router-id @loopback

  set routing-instance @custName routing-options autonomous-system 65000

  set routing-instance @custName routing-options autonomous-system independent-domain

  }

 

 

  //Commit config and quit

  CLI

  {

  commit and-quit

  }

}

The output this produces in the NCM preview is:

 

configure

 

 

set routing-instance AutoTest instance-type vrf
set routing-instance AutoTest interface ge-0/0/7.1002
set routing-instance AutoTest interface lo0.1002
set routing-instance AutoTest route-distinguisher 65000:1002
set routing-instance AutoTest vrf-target import target:65000:1002
set routing-instance AutoTest vrf-target export target:65000:1002
set routing-instance AutoTest vrf-table-label
set routing-instance AutoTest routing-options router-id 10.201.1.1
set routing-instance AutoTest routing-options autonomous-system 65000
set routing-instance AutoTest routing-options autonomous-system independent-domain

 

 

set interfaces lo0 unit 1002 description "Customer AutoTest"
set interfaces lo0 unit 1002 family inet address 10.201.1.1
set interfaces ge-0/0/7 unit 1002 vlan-id 1002
set interfaces ge-0/0/7 unit 1002 family inet address 10.200.0.14/29

 

 

commit and-quit

If I copy and paste that in to the switch it works fine however according to the log this is what gets applied:

 

User 'admin', command 'set cli complete-on-space off '

User 'admin', command 'set cli screen-width 0 '

User 'admin', command 'set cli screen-length 0 '

User 'admin', command 'configure '

User 'admin' entering configuration mode

User 'admin', command 'set interfaces lo0 unit 1002 description "Customer AutoTest" '

User 'admin', command 'set interfaces lo0 unit 1002 family inet address 10.201.1.1 '

User 'admin', command 'set interfaces ge-0/0/7 unit 1002 vlan-id 1002 '

User 'admin', command 'set interfaces ge-0/0/7 unit 1002 family inet address 10.200.0.14/29 '

User 'admin', command 'set instance-typevrfrouting-instance '

User 'admin', command 'set interface '

User 'admin', command 'set interface '

User 'admin', command 'set route-distinguisher65000:1002routing-instance '

User 'admin', command 'set vrf-targetimporttarget:65000:1002routing-instance '

User 'admin', command 'set vrf-targetexporttarget:65000:1002routing-instance '

User 'admin', command 'set vrf-table-labelrouting-instance '

User 'admin', command 'set routing-options router-id 10.201.1.1routing-instance '

User 'admin', command 'set routing-options autonomous-system 65000routing-instance '

User 'admin', command 'set routing-options autonomous-system independent-domainrouting-instance '

User 'admin', command 'commit and-quit '

 

The result is, the switch happily takes the interface config but then rejects the commit as the loopback hasnt been put into a routing instance.  I've tried swapping the order round and preserving white space or not but the result always seems to be the same.

 

Anyone got any pointers?


Viewing all articles
Browse latest Browse all 4266

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>