cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4705
Views
5
Helpful
6
Replies

How can I remove from NSO a device associated with device groups or services?

FBellei
Level 1
Level 1

I am trying to find an easy way to remove a device from NSO when the device is assigned to certain device groups or services. We are using NSO to manage a client's network and we recently started deploying services to push configuration changes. As the client's network is a brownfield, there are devices that need to be decommissioned. When that happens we need to remove them from NSO.

 

If I try using the command 

no devices device <device-name>

after I run

commit dry-run

I get an error saying.

Aborted: illegal reference 'devices device-group <group-name> device-name'

The same happens with devices associated with services. It seems like NSO is asking me to remove the device from the services and the device groups first, and then remove the device from NSO. That seems quite cumbersome when we are trying to deploys several services to devices and we may find ourselves decommissioning devices in the future.

 

Is there a command or a script that can be used to remove a device and all of its references in one go from NSO?

6 Replies 6

atriyant
Cisco Employee
Cisco Employee

you have to remove the device from the group <group-name> first, by updating the device-group:

 

(config) devices device-group <group-name> device-name [ device1 device2 device3 ]

(config) commit

 

 

@atriyant, that is actually what we already figured out and where our issue stands. Because of the large network that we help manage, we will devices belonging to several device groups and services, so if one device needs to be removed, it could take some time to identify and remove the device form those groups and services.

 

Our plan is to create a script that can do this operation automatically, but before doing that we wanted to check if someone in the community had already worked on this.

It would be interesting for us/me to understand what sort of behavior you would have expected. NSO will never tolerate a configuration that violates the YANG model (e.g. with dangling pointers), so what would you have liked the system to do in this situation?

The behavior that we were expecting was for NSO to automatically recognize what dangling pointers a change would create and ask the user if it was OK to remove them, rather than having the user manually find them and remove them before removing the device. That would preserve the YANG model and provide a useful feature to users that need to remove devices from NSO. It is possible for us to script that functionality ourselves, but I wanted to check if it was already available. From our prospective, this is a very common use case, but if that is not the case from your prospective, I can understand why it was not implemented.

tsiemers1
Spotlight
Spotlight

Would it be possible to expose an api for this? I created an tailf-query restconf call but just seems clunky. In the cli you can run this:

 show devices device-group member [ DeviceName ]                  
NAME            MEMBER                         INDETERMINATES  CRITICALS  MAJORS  MINORS  WARNINGS  ID                  RPC  
-----------------------------------------------------------------------------------------------------------------------------
ASR920-24SZ-IM  [ DeviceName Device2 ]  0               15         0       0       0         cisco-ios-cli-6.64  -    
                                                                                                    cisco-ios-cli-6.66  -    

 

{
"immediate-query": {
"foreach": "/devices/device-group",
"select": [
{
"label": "name",
"expression": "name",
"result-type": ["string"]
},
{
"label": "name",
"expression": "member[contains(., 'DeviceName')]",
"result-type": ["string"]
}
],
"sort-by": ["member"],
"limit": 1000,
"offset": 1
}
}

You can technically get the answer via "an API" - the NETCONF one:

 

Using this payload saved as get_groups_filter.xml:

 

<get-config xmlns:nc='urn:ietf:params:xml:ns:netconf:base:1.0'>
<source><running/></source>
<filter xmlns:ncs="http://tail-f.com/ns/ncs" type="xpath" select="/ncs:devices/ncs:device-group[ncs:device-name='<DEVICE-NAME>']/ncs:name"/>
</get-config>

 

and using the netconf-console binary shipped with NSO for instance (you may need to adapt host/port/credentials..):

 

netconf-console --rpc get_groups_filter.xml 

 I would retrieve:

 

<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
<data>
<devices xmlns="http://tail-f.com/ns/ncs">
<device-group>
<name>group1</name>
</device-group>
<device-group>
<name>group2</name>
</device-group>
</devices>
</data>
</rpc-reply>

Unfortunately this kind of XPATH filter is not available through RESTCONF so it would be more difficult to do this via RESTCONF

however you can always write some actions that does exactly this.