Send Netdot-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://osl.uoregon.edu/mailman/listinfo/netdot-users
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-users digest..."


Today's Topics:

   1. importing closets with import_closets.pl (John St.Martin)
   2. Re: importing closets with import_closets.pl (John St.Martin)
   3. Re: importing closets with import_closets.pl (Carlos Vicente)
   4. Import scripts (Mike Wilder)
   5. Re: Import scripts (Andreas Kunberger)
   6. Python script to import site > subnets relation from      existing
      IPPPLAN database (Nico)
   7. Re: Python script to import site > subnets relation from
      existing IPPPLAN database (Carlos Vicente)


----------------------------------------------------------------------

Message: 1
Date: Mon, 9 Dec 2013 16:33:03 -0500
From: "John St.Martin" <[email protected]>
Subject: [Netdot-users] importing closets with import_closets.pl
To: [email protected]
Message-ID:
        <CAAmaV7ZEWVY0SGLYy3BS3BHTpL4=2ip9pogdjq4f4c-eckg...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

is the import_closets.pl script in ./imports/ supported?  Anyone
successfully use it?


I initially tried this using the example line in the :
    $ perl /usr/local/netdot/import/import_closets.pl.orig ~/closets2.csv
    Can't locate object method "insert" via package "Netdot::UI" at
    /usr/local/netdot/import/import_closets.pl.orig line 43, <FILE> line 1.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20131209/4ee00df0/attachment-0001.html
 

------------------------------

Message: 2
Date: Mon, 9 Dec 2013 16:41:50 -0500
From: "John St.Martin" <[email protected]>
Subject: Re: [Netdot-users] importing closets with import_closets.pl
To: [email protected]
Message-ID:
        <CAAmaV7axULu9BN=afAamYbewCLqk-c+tux1-=nPeTWfVFkqr=w...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

sorry, I clicked send before I was finished composing.


is the import_closets.pl script in ./imports/ supported?  Anyone
successfully use it?

I initially tried this using the example line in the script for my .csv:

    $ perl /usr/local/netdot/import/import_closets.pl.orig ~/closets2.csv
    Can't locate object method "insert" via package "Netdot::UI" at
    /usr/local/netdot/import/import_closets.pl.orig line 43, <FILE> line 1.

I modified the file as the diff below shows:
43c43
<     unless ( $floorid = $ui->new(table=>"Floor", state => \%tmp) ){
---
>     unless ( $floorid = $ui->insert(table=>"Floor", state => \%tmp) ){

then when I try it again:
    $ perl /usr/local/netdot/import/import_closets.pl ~/closets2.csv
    Can't retrieve a reference at
/usr/local/netdot/import/import_closets.plline 48

the line it refers to is "$floorobj = Floor->retrieve($floorid);" which
appears there is no retrieve in Floor.pm

I am open to any suggestions on other ways folks have imported data in.  I
don't mind doing direct to sql if needed.

thank you,
John


On Mon, Dec 9, 2013 at 4:33 PM, John St.Martin
<[email protected]>wrote:

> is the import_closets.pl script in ./imports/ supported?  Anyone
> successfully use it?
>
>
> I initially tried this using the example line in the :
>     $ perl /usr/local/netdot/import/import_closets.pl.orig ~/closets2.csv
>     Can't locate object method "insert" via package "Netdot::UI" at
>     /usr/local/netdot/import/import_closets.pl.orig line 43, <FILE> line 1.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20131209/e9d9f663/attachment-0001.html
 

------------------------------

Message: 3
Date: Mon, 09 Dec 2013 14:13:28 -0800
From: Carlos Vicente <[email protected]>
Subject: Re: [Netdot-users] importing closets with import_closets.pl
To: "John St.Martin" <[email protected]>,
        [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hello John,

On 12/9/13, 1:41 PM, John St.Martin wrote:
> is the import_closets.pl <http://import_closets.pl> script in
> ./imports/ supported?  Anyone successfully use it?

Unfortunately, it was written many moons ago and has not been updated to
reflect changes in Netdot internals.

cv


------------------------------

Message: 4
Date: Tue, 10 Dec 2013 10:43:13 -0500
From: Mike Wilder <[email protected]>
Subject: [Netdot-users] Import scripts
To: [email protected]
Message-ID:
        <CADg4paQC1wfbJ=buyb_yn2c87+q2c-snk40rnqckwxinvpq...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Does anyone have import scripts for the NetDot 1.0.4?  I'm particularly
interested in importing horizontal cables.


Thanks,

Mike Wilder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20131210/fd0ea76f/attachment-0001.html
 

------------------------------

Message: 5
Date: Tue, 10 Dec 2013 16:58:45 +0100
From: Andreas Kunberger <[email protected]>
Subject: Re: [Netdot-users] Import scripts
To: [email protected]        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Yes, I have. 

I uploaded them once for coming version, but if needed I can send them again to 
you.

?
?
Andreas Kunberger

?
-- 

?
Deutsche Institute f?r Textil- und Faserforschung Denkendorf

?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20131210/39b07fa2/attachment-0001.html
 

------------------------------

Message: 6
Date: Tue, 10 Dec 2013 18:10:42 +0100
From: Nico <[email protected]>
Subject: [Netdot-users] Python script to import site > subnets
        relation from   existing IPPPLAN database
To: [email protected]
Message-ID:
        <cakxqfmv8e6g+-96ln7uqywme7nqhnod6uwyjgkmgf2cmfu7...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I've done a quick script in python to import the site <> networks
relations on my existing ipplan database into netdot.

It needs a db account with access to both netdot and ipplan databases.

An important note: i modded ipplan base table with a cutom field "sat"
wich is a unique name for each of our sites, previously i imported my
sites from ipplan to netdot with that sat field as the site.name in
netdot site table.  And also imported the networks (bases) i had in
ipplan via export to csv and then imported it via import_ip_block.pl
script included with netdot.

It's ugly and probably prone to errors, and i'd not use in a
production environment, but it did the work for me for an initial
load, so i thought to share.

----------------------

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import MySQLdb
import MySQLdb.cursors

def get_site_id (db, sat):
   SELECT = 'SELECT netdot.site.id FROM netdot.site WHERE name =
"{}";'.format(sat)
   c = db.cursor()
   r = c.execute (SELECT)
   if r == 1:
     id = c.fetchone()
     c.close()
     return id['id']
   else:
     c.close()
     return False

def get_subnet_id (db, subnet, prefix):
   SELECT = 'SELECT netdot.ipblock.id FROM netdot.ipblock WHERE
address = {} and prefix = {};'.format(subnet,prefix)
   c = db.cursor()
   r = c.execute(SELECT)
   if r == 1:
     id = c.fetchone()
     c.close()
     return id['id']
   else:
     c.close()
     return False


db = MySQLdb.connect(host='localhost', user='root', passwd='xxx',
db='netdot', use_unicode = True, init_command="SET NAMES utf8",
charset="utf8", cursorclass=MySQLdb.cursors.DictCursor)

BASE_SELECT = 'SELECT INET_ATON(baseaddr) as baseaddr,subnetsize,sat
FROM ipplan.base WHERe sat != "None" and customer = "2" order by sat;'
c = db.cursor()
r_BASE_SELECT = c.execute (BASE_SELECT)
nets = c.fetchall()
for net in nets:
  print net
  site_id = get_site_id(db, net['sat'])
  if site_id:
    subnet_id = get_subnet_id(db,net['baseaddr'],net['subnetsize'])
    if subnet_id:
      print subnet_id," => ",site_id
      INSERT = "INSERT IGNORE into netdot.sitesubnet (site,subnet)
VALUES ({},{});".format(site_id,subnet_id)
      print INSERT
      c.execute (INSERT)
    else:
      print "ERROR: no subnet id",net
  else:
    print "ERROR: no sat code: ",net
db.commit()
c.close()
db.close()
-----------------------

Greetings
-- 
Nico


------------------------------

Message: 7
Date: Tue, 10 Dec 2013 09:20:15 -0800
From: Carlos Vicente <[email protected]>
Subject: Re: [Netdot-users] Python script to import site > subnets
        relation from existing IPPPLAN database
To: Nico <[email protected]>, [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Nico,

It's always nice to see folks sharing such things. I'm sure it will be
useful to others.

Best,

cv

On 12/10/13, 9:10 AM, Nico wrote:
> Hello,
>
> I've done a quick script in python to import the site <> networks
> relations on my existing ipplan database into netdot.
>
> It needs a db account with access to both netdot and ipplan databases.
>
> An important note: i modded ipplan base table with a cutom field "sat"
> wich is a unique name for each of our sites, previously i imported my
> sites from ipplan to netdot with that sat field as the site.name in
> netdot site table.  And also imported the networks (bases) i had in
> ipplan via export to csv and then imported it via import_ip_block.pl
> script included with netdot.
>
> It's ugly and probably prone to errors, and i'd not use in a
> production environment, but it did the work for me for an initial
> load, so i thought to share.
>
> ----------------------
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import MySQLdb
> import MySQLdb.cursors
>
> def get_site_id (db, sat):
>    SELECT = 'SELECT netdot.site.id FROM netdot.site WHERE name =
> "{}";'.format(sat)
>    c = db.cursor()
>    r = c.execute (SELECT)
>    if r == 1:
>      id = c.fetchone()
>      c.close()
>      return id['id']
>    else:
>      c.close()
>      return False
>
> def get_subnet_id (db, subnet, prefix):
>    SELECT = 'SELECT netdot.ipblock.id FROM netdot.ipblock WHERE
> address = {} and prefix = {};'.format(subnet,prefix)
>    c = db.cursor()
>    r = c.execute(SELECT)
>    if r == 1:
>      id = c.fetchone()
>      c.close()
>      return id['id']
>    else:
>      c.close()
>      return False
>
>
> db = MySQLdb.connect(host='localhost', user='root', passwd='xxx',
> db='netdot', use_unicode = True, init_command="SET NAMES utf8",
> charset="utf8", cursorclass=MySQLdb.cursors.DictCursor)
>
> BASE_SELECT = 'SELECT INET_ATON(baseaddr) as baseaddr,subnetsize,sat
> FROM ipplan.base WHERe sat != "None" and customer = "2" order by sat;'
> c = db.cursor()
> r_BASE_SELECT = c.execute (BASE_SELECT)
> nets = c.fetchall()
> for net in nets:
>   print net
>   site_id = get_site_id(db, net['sat'])
>   if site_id:
>     subnet_id = get_subnet_id(db,net['baseaddr'],net['subnetsize'])
>     if subnet_id:
>       print subnet_id," => ",site_id
>       INSERT = "INSERT IGNORE into netdot.sitesubnet (site,subnet)
> VALUES ({},{});".format(site_id,subnet_id)
>       print INSERT
>       c.execute (INSERT)
>     else:
>       print "ERROR: no subnet id",net
>   else:
>     print "ERROR: no sat code: ",net
> db.commit()
> c.close()
> db.close()
> -----------------------
>
> Greetings



------------------------------

_______________________________________________
Netdot-users mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-users


End of Netdot-users Digest, Vol 61, Issue 6
*******************************************

Reply via email to