Child pages
  • noc csv-import
Skip to end of metadata
Go to start of metadata

Name

noc csv-import – load data from CSV file

Synopsis

noc csv-import [options] <model> <path1> [ .. <pathN>]

Description

Upload data from CSV files <path1> .. <pathN> to database model <model>

To see the list of available models, run

/opt/noc$ ./noc csv-import

without parameters

 

Options:

-v VERBOSITY
--verbosity=VERBOSITY 

Verbosity level:

  • 0 - minimal output
  • 1 - normal output
  • 2 - all output
--tracebackPrint traceback on exception
--r <action>
--resolve=<action>

When loaded record is already exists in database do:

  • fail - stop loading and display an error message
  • skip - skip duplicated record and continue processing (do not update)
  • update - update changed fields and continue processing

CSV file format

CSV file must be in UTF8, columns separated by commas (,). First row must contain field names, following rows contain records, one row per one record. Rows must be separated by newlines (\n).

To dereference foreign key use doubled underscore notation. i.e. to dereference foreign key user by username set user__username as field name.

To get a list of all available fields in model use

/opt/noc$ ./noc csv-export --template <model>

Examples

Display as list of models

 /opt/noc$ ./noc csv-import 

Import file f1 to ip.address, fail if duplicated addresses found

/opt/noc$ ./noc csv-import ip.address f1

Update ip.address from file f1

/opt/noc$ ./noc csv-import --resolve=update ip.address f1

See Also

noc csv-export

  • No labels

1 Comment

  1. Сетки

    Несколько моментов касательно импорта сеток.

    • afi всегда 4
    • vrf default или свой
    • asn можно указать свой. это AS

    style это красивость таблички

     

    vrfafiprefixasndescriptiontagsstyle
    default4212.xx.xx.xxx/280Город"city" 
    default4109.193.0.0/290NS Ядро сети
    default4109.193.24.0/210 "belg" 

     

    Хосты

    Несколько моментов касательно импорта хостов.

    • afi всегда 4
    • vrf -  default или свой
    • fqdn обязателен. это полностью квалифицированное доменное имя. потенциально либо генерируемое, либо везде одинаковое.

       

      vrfafiaddressfqdndescriptiontagsstyle
      default410.120.2.168adm-sw-mgs14.xxx,telecom.ru   
      default494.124.144.84lo0.vprn400.bsr01.xx.telecom.ru   
      default4172.24.16.105xxxx.telecom.ru   
      default4211.34.233.41xxx33.telecom.ru   
      default410.99.241.97test1.oms.telecom.ru   
      default4211.35.233.42serv.telecom.ru