# Copyright (C) 2007 Platform Computing Inc # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # import os import glob import string from kusu.ngedit.ngedit import NGPluginLibBase MAXIBIFCNT=8 numInterfaceKey = "num_interfaces" class NGPluginLib(NGPluginLibBase): def __init__(self, database, kusuApp, **kwargs): NGPluginLibBase.__init__(self, database, kusuApp, **kwargs) # Plugin data self.__numInterfaces = None if kwargs.has_key(numInterfaceKey): try: self.__numInterfaces = int(kwargs[numInterfaceKey]) except ValueError: self.__numInterfaces = None def validate(self): msgPrefix = "Plugin error ('%s'): " % self.compName errMsg = msgPrefix + "Number of interfaces must be >=0 and <=%s" % MAXIBIFCNT cnt = self.__numInterfaces if not isinstance(cnt,int): return False, errMsg else: if cnt<0 or cnt>MAXIBIFCNT: return False, errMsg return True, "Success" def add(self): # Nothing to do pass def remove(self): assert(self.ngid) query = '''DELETE FROM ng_has_net WHERE ngid = %s and netid in ( select netid from networks where device like 'ib%%')''' %self.ngid try: self.database.execute(query) except: #if delete fails - just forge on pass