Пример #1
0
    def load_plugins(self, **kwargs):

        aulog.debug("Checking plugins :")
        for p in plugins_list :
            aulog.debug("\t%s" % (p))
        plugins =  [os.path.abspath(p) for p in plugins_list if p]

        del self.plugins[:]
        del self.active[:]    

        for p in plugins:
            loaded = False
            skipped = False
            directory = os.path.dirname(p)
            if not directory in sys.path:
                sys.path.append(directory)


            name = p.split("/")[-1].split(".py")[0]
            aulog.debug("... inspecting '%s'"% name)
            f, file, desc = imp.find_module(name, [directory])
            plugin = __import__(name)


            name = p.split("/")[-1].split(".py")[0]
            aulog.debug("... inspecting '%s'"% name)
            f, file, desc = imp.find_module(name, [directory])
            plugin = __import__(name)

            for k,v in inspect.getmembers(plugin):
                if k == KeyPluginClass :
                    try:
                        assert (not self.VerifyClass(IPlugin, v))
                    except NotImplementedError, e:
                        aulog.warning("Broken implementation of : %s, skipping it.." % name)
                        continue
                    if self.should_load_plugin(v,**kwargs):
                        aulog.debug("Loading plugin %s .."%(v.plugin_name))
                        instance = v()
                        aulog.debug("Adding an instance of %s" % (k,))
                        self.plugins.append((k, instance))
                        loaded = True
                    else : 
                        skipped = True
                        aulog.debug("Skipping plugin %s .."%(v.plugin_name))
            if not loaded and not skipped :
                aulog.debug("Plugin %s is not loaded due to error(s) in its format."% name)
Пример #2
0
    def start(self, **kwargs):
        """
        Start the plugin
        Return -1 if the plugin has found a fatal error, 0 otherwise.
        """
        host = kwargs['session']
        pkg_path = kwargs['repository']
        if (not pkg_path):
            aulog.error(
                "Couldn't ping, package repository path is not provided")
            return -1
        try:
            host.expect_exact("#", timeout=30)

        except:
            pass
        pat = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
        ipaddr = re.findall(pat, pkg_path)
        protocol = ['tftp:', 'sftp:', 'ftp:']
        list = [' ']
        list = pkg_path.split('/')
        if not len(ipaddr):
            aulog.error("Invalid TFTP address ")
            return -1

        if (len(list[0]) if list[0] else list[1] in protocol):
            cmd = "ping " + ipaddr[0]
            aulog.info(cmd)
            host.sendline(cmd)
            try:
                status = host.expect_exact(
                    [INVALID_INPUT, MORE, "#", PROMPT, EOF], timeout=tout_cmd)
            except:
                aulog.warning(
                    """Command: Timed out, before considering this as failure.
                                 Please check consolelog file for details""")
                return 0

        out = host.before
        if (out.find('Success rate is 0') != -1
                or out.find('Bad hostname or protocol not running') != -1
                or out.find('UUUUU') != -1):
            aulog.warning("TFTP server %s is not reachable from device" %
                          (ipaddr))
            return 0
        return 0
Пример #3
0
    def start(self, **kwargs):
        """
        Start the plugin
        Return -1 if the plugin has found a fatal error, 0 otherwise.
        """
        host = kwargs['session']
        pkg_path = kwargs['repository']
        if (not pkg_path):
           aulog.error("Couldn't ping, package repository path is not provided")
           return -1 
        try :
            host.expect_exact("#", timeout=30)
            
        except :
            pass
        pat = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
        ipaddr = re.findall(pat, pkg_path)
        protocol =['tftp:', 'sftp:', 'ftp:']
        list = [' '];
        list = pkg_path.split('/')
        if not len(ipaddr) :
            aulog.error("Invalid TFTP address ") 
            return -1

        if ( len(list[0]) if list[0] else list[1] in protocol):
            cmd = "ping "+ipaddr[0]
            aulog.info(cmd)
            host.sendline(cmd)
            try :
                status = host.expect_exact( [INVALID_INPUT, MORE, "#", PROMPT, EOF], timeout = tout_cmd)
            except :
	        aulog.warning("""Command: Timed out, before considering this as failure.
                                 Please check consolelog file for details""")
                return 0

        out = host.before
        if (out.find('Success rate is 0') != -1 or
            out.find('Bad hostname or protocol not running') != -1 or 
            out.find('UUUUU') != -1):
            aulog.warning("TFTP server %s is not reachable from device"%(ipaddr)) 
            return 0
        return 0
Пример #4
0
def print_warning(str):
    aulog.warning(str)
Пример #5
0
def print_warning(str):
    aulog.warning(str)