@@ -0,0 +1,1640 @@
+%0A%0A__version__ = '0.9'%0A__author__ = 'Remi Batist'%0A%0A# Importing interface-settings from pre-defined csv-file%0A%0A# used row format shown in the example below%0A# csv delimiter ' ; '%0A%0A# interface%09                %09  description%09  linktype%09%09  permitvlan     %09pvid%0A# GigabitEthernet1/0/21%09        server-1%09    access%09%09                %09  23%0A# GigabitEthernet1/0/22%09        server-2%09    trunk%09        10 12%09          10%0A%0A%0A#### Importing python modules%0A%0Aimport csv%0Aimport comware%0Aimport os%0Aimport sys%0Aimport termios%0A%0A#### File input function%0A%0Afd = sys.stdin.fileno();%0Anew = termios.tcgetattr(fd)%0Anew%5B3%5D = new%5B3%5D %7C termios.ICANON %7C termios.ECHO%0Anew%5B6%5D %5Btermios.VMIN%5D = 1%0Anew%5B6%5D %5Btermios.VTIME%5D = 0%0Atermios.tcsetattr(fd, termios.TCSANOW, new)%0Atermios.tcsendbreak(fd,0)%0A%0Aprint ''%0Afile_in = raw_input(%22 csv-file to import: %22)%0A%0A%0A#### Importing rows%0Aitem_in_1 = 'interface'%0Aitem_in_2 = 'description'%0Aitem_in_3 = 'linktype'%0Aitem_in_4 = 'permitvlan'%0Aitem_in_5 = 'pvid'%0A%0A%0A#### Open file%0A%0Awith open(file_in,'r') as f:%0A%09reader = csv.DictReader(f, delimiter=';')%0A%09rows = list(reader)%0A%0A#### Reading file%0Afor row in rows:%0A%0A#### Setting link-type%0A%0A%09if row%5Bitem_in_3%5D == 'access':%0A%09%09linktype = 'port link-type access'%0A%09%09set_pvid = 'port access vlan '%0A%09%09set_permit =''%0A%09else:%0A%09%09linktype = 'port link-type trunk'%0A%09%09set_pvid = 'port trunk pvid vlan '%0A%09%09set_permit ='port trunk permit vlan '%0A%09%0A#### Deploying settings%0A%0A%09print ''%0A%09print 'Deploying settings...'%0A%09print ''%0A%09strcli = %22system ;%25s ;%25s ;%25s ;%25s ;%25s%22 %25 ('interface '+row%5Bitem_in_1%5D, 'description ' +row%5Bitem_in_2%5D, linktype, set_pvid + row%5Bitem_in_5%5D, set_permit + row%5Bitem_in_4%5D)%0A%09comware.CLI(strcli)%0A%0A%0A%09%09%0A%09%09%0A%09%09%0A%0A%0A%0A

Set interface-config from pre-defined csv-file