Name

nnmdeleteattributes.sh — delete custom attributes from a comma separated values (CSV) file or line for Nodes, Interfaces, and PhysComps (Cards/Chassis).

SYNOPSIS

nnmdeleteattributes.sh [-?] [-i <ifname | ifindex | ifalias | ifdesc>] -t <type> (-f <path & filename of csv file>) | (-s <"csv formatted line">) [-u <username> -p <password>] [-jndiHost <hostName> Default: localhost] [-jndiPort <port> Default: 1099]

DESCRIPTION

nnmdeleteattributes.sh allows custom attributes to be deleted from a comma separated values (CSV) file, such as a .csv file from Microsoft™ Excel. This command is useful if you have previously created custom attributes that are no longer needed. This command will delete attributes from either nodes, interfaces, or phys comps. For nodes, once the attributes are deleted, any nodes in a node group formed by referencing those attributes will disappear from the node group.

Parameters

nnmdeleteattributes.sh supports the following options:

-?

Prints the usage statement.

-i <ifname | ifindex | ifalias | ifdesc>

Specify the interface identifier to override default search. Must be either "ifname", "ifindex", "ifalias" or "ifdesc".

-t <type>

Supply the object type to delete attributes on. Must be either "node", "interface", or "physcomp".

-f <path & filename of csv file>

Supply the CSV file name (with path, e.g. /tmp/csvfile.csv) that contains the custom attributes to delete.

-s <"csv formatted line">

Supply a single CSV formatted line. Eliminates the need to create a file for a small change.

-u <username>

Supply the NNMi administrator username to run the script.

-p <password>

Supply the NNMi administrator password to run the script.

-jndiHost <serverName>

The server JNDI host; default is localhost.

-jndiPort <port>

The server JNDI port; default is 1099.

Syntax of Comma Separated File for Nodes

The CSV file you supply must have the following syntax for deleting attributes from nodes.

Empty lines are ignored.

Lines that being with the # character are ignored.

  • Column 1(A) : Node DNS | IP Address

    Specify the DNS name of the node OR the IP address. This field is compulsory.

  • Column 2(B) : Attribute Name

    The name of the custom attribute.

Additional attribute names may be specified on the same line or on a separate line with the same node DNS | IP Address.

Example lines:

192.168.1.1,Project,Service Type

192.168.1.1,Asset Tracking

192.168.2.2,Project,Service Type,Asset Tracking

Syntax of Comma Separated File for Interfaces

The CSV file you supply must have the following syntax for deleting attributes from interfaces.

Empty lines are ignored.

Lines that being with the # character are ignored.

  • Column 1(A) : Node DNS | IP Address

    Specify the DNS name of the node OR the IP address. This field is compulsory.

  • Column 2(B) : Interface Id

    Specify the identifier of the interface on the node specified in the previous field. The value may be the interface index, alias, name or description and is searched in this same order. All matching interfaces have the attribute(s) deleted. This field is compulsory.

  • Column 3(C) : Attribute Name

    The name of the custom attribute.

Additional attribute names may be specified on the same line or on a separate line with the same node DNS | IP Address and Interface Id.

Example lines:

192.168.1.1,1001,Project,Service Type

192.168.1.1,1001,Asset Tracking

192.168.2.2,A1,Project,Service Type,Asset Tracking

Syntax of Comma Separated File For PhysComp Attributes

The CSV file you supply must have the following syntax for adding attributes on PhysComps (Cards/Chassis).

Empty lines are ignored.

Lines that being with the # character are ignored.

  • Column 1(A) : Node DNS | IP Address

    Specify the DNS name of the node OR the IP address. This field is compulsory.

  • Column 2(B) : PhysComp Id

    Specify the identifier of the phys comp on the node specified in the previous field. The value may be the phys comp physical index, name or description and is searched in this same order. All matching phys comps will have the attribute(s) deleted. This field is compulsory.

  • Column 3(C) : PhysComp Type

    The name to identify the type of PhysComp. "card" and "chassis" are valid types.

  • Column 4(D) : Attribute Name

    The name of the custom attribute.

Additional attribute name and value pairs may be specified on the same line or on a separate line with the same node DNS | IP Address, PhysComp Id, and PhysComp Type.

Example lines:

192.168.1.1,7,chassis,Location,Service Type

192.168.1.1,7,chassis,Asset Tracking

192.168.2.2,/AmdFE,card,Location,Service Type,Asset Tracking

Use of Microsoft Excel

Microsoft Excel is a handy tool to create comma separated files, but .csv files do not maintain the Excel spreadsheet's column width, comments, etc. It is recommended that you store a nnmdeleteattributes.sh input file as a native .xls format, and then perform File:Save As... to create a .csv file. Then you can add Excel comments to the file, make columns wider, and you do not need to worry about escaping the comma character.

EXAMPLES

Sample CSV file contents for nodes:

192.168.2.2,Project,Service Type,Asset Tracking

To delete the Node custom attributes from a CSV file:

nnmdeleteattributes.sh -t node -f /tmp/test.csv

To delete the Node custom attributes from the command line:

nnmdeleteattributes.sh -t node -s "192.168.1.1,Project"

Sample CSV file contents for interfaces:

192.168.2.2,1001,Project,Service Type,Asset Tracking

To delete the Interface custom attributes from a CSV file:

nnmdeleteattributes.sh -t interface -f /tmp/test.csv

To delete the Interface custom attributes from a CSV file based on only ifname search:

nnmdeleteattributes.sh -t interface -i ifname -f /tmp/test.csv

To delete the Interface custom attributes from the command line:

nnmdeleteattributes.sh -t interface -s "192.168.1.1,1001,Project"

To delete a custom attribute for a single interface with ifindex:

nnmdeleteattributes.sh -t interface -i ifindex -s "192.168.1.1,1001,Project"

Sample phys comp CSV file (/tmp/test.csv) contents:

192.168.2.2,7,chassis,Location,Service Type,Asset Tracking

To delete the Phys Comp custom attributes from a CSV file:

nnmdeleteattributes.sh -t physcomp -f /tmp/test.csv

To load a single PhysComp custom attributes line from the command line:

nnmdeleteattributes.sh -t physcomp -s "192.168.1.1,/AmdFE,card,Project"

Error Codes

There are several error codes that help identify problems:

  • INFO : information message.

  • ATTR_ERROR : A problem was found with the specified attribute.

  • DEL_FAIL_ERROR : An attempt to delete the specified attribute failed.

  • OBJECT_ERROR : The specified object was not found.

  • BAD_LINE_ERROR : The line provided is not properly formatted.

  • IO_ERROR : The CSV file was not found or is not readable.

  • BAD_NAME_WARNING : The specified attribute name is too long (50 character maximum).

  • BAD_VALUE_WARNING : The specified value is too long (2000 character maximum).

AUTHOR

nnmdeleteattributes.sh was developed by Hewlett Packard Enterprise.

FILES

$NMS_BIN/nnmdeleteattributes.sh

Return to Reference Pages Index