Exemple #1
0
def pkg_tobe_activated(added_pkgs,inactive_pkgs,active_pkgs):
    tobe_added = []
    # All added packages should either be active or inactive
    
    # Get the added package which is not in inactive state
    missing_in_inactive = missing_pkgs(added_pkgs,inactive_pkgs)

    # If package to be activated is not in inactive state , see if that's already active
    if missing_in_inactive :
        missing_in_inactive = missing_pkgs(missing_in_inactive,active_pkgs)

    # For debug purpose only 
    aulog.debug("Package to be activated")
    for i in added_pkgs :
        aulog.debug(i.pkg)
    aulog.debug("Package inactive state")
    for i in inactive_pkgs :
        aulog.debug(i.pkg)
    aulog.debug("Package active state")
    for i in added_pkgs :
        aulog.debug(i.pkg)

    # End of debug

    if not missing_in_inactive :
        for pk1 in added_pkgs:
            for pk2 in inactive_pkgs:
                if pk1.pkg == pk2.pkg and pk1.version == pk2.version :
                    if len(pk2.pkg) == 10 and pk2.pkg[:3] == "CSC" or pk2.pkg[:2] == "sp" or pk2.pkg[:2] == 'fp':
                        # It's a SMU format is
                        #disk0:asr9k-px-4.3.2.CSCuj61599-1.0.0
                        pkg = "%s:%s-%s-%s.%s-%s"%(pk2.partition,pk2.platform,pk2.arch,
                            pk2.version,pk2.pkg,"1.0.0")
                    else :
                        pkg = "%s:%s-%s-%s-%s"%(pk2.partition,pk2.platform,pk2.pkg,pk2.arch,
                            pk2.version)
                    tobe_added.append(pkg)
    return tobe_added
Exemple #2
0
def pkg_tobe_activated(added_pkgs, inactive_pkgs, active_pkgs):
    tobe_added = []
    # All added packages should either be active or inactive

    # Get the added package which is not in inactive state
    missing_in_inactive = missing_pkgs(added_pkgs, inactive_pkgs)

    # If package to be activated is not in inactive state , see if that's already active
    if missing_in_inactive:
        missing_in_inactive = missing_pkgs(missing_in_inactive, active_pkgs)

    # For debug purpose only
    aulog.debug("Package to be activated")
    for i in added_pkgs:
        aulog.debug(i.pkg)
    aulog.debug("Package inactive state")
    for i in inactive_pkgs:
        aulog.debug(i.pkg)
    aulog.debug("Package active state")
    for i in added_pkgs:
        aulog.debug(i.pkg)

    # End of debug

    if not missing_in_inactive:
        for pk1 in added_pkgs:
            for pk2 in inactive_pkgs:
                if pk1.pkg == pk2.pkg and pk1.version == pk2.version:
                    if len(
                            pk2.pkg
                    ) == 10 and pk2.pkg[:
                                        3] == "CSC" or pk2.pkg[:
                                                               2] == "sp" or pk2.pkg[:
                                                                                     2] == 'fp':
                        # It's a SMU format is
                        #disk0:asr9k-px-4.3.2.CSCuj61599-1.0.0
                        pkg = "%s:%s-%s-%s.%s-%s" % (
                            pk2.partition, pk2.platform, pk2.arch, pk2.version,
                            pk2.pkg, "1.0.0")
                    else:
                        pkg = "%s:%s-%s-%s-%s" % (pk2.partition, pk2.platform,
                                                  pk2.pkg, pk2.arch,
                                                  pk2.version)
                    tobe_added.append(pkg)
    return tobe_added
Exemple #3
0
    def start(self, **kwargs):

        # Get the session
        host = kwargs['session']

        if kwargs['options'].device:
            dev_string = kwargs['options'].device.replace(" ", "_")
        else:
            name = kwargs['session'].name
            dev_string = ".".join(
                re.findall(r"[\w']+", "_".join(name.split(" ")[1:])))

        CFG_BKP_FILE = dev_string + ".cfg_bkup"
        aulog.debug("Backing up configurations in file %s..." % (CFG_BKP_FILE))
        try:
            host.expect_exact("#", timeout=15)
        except:
            pass

        try:
            # Set terminal length
            host.sendline("terminal length 0")
            host.expect_exact("#")

            # Pass CLI's to box
            host.sendline("show running")

            status = host.expect_exact(["end\r\n", INVALID_INPUT, EOF],
                                       timeout=tout_cmd)
            self.save_configs(host.before, CFG_BKP_FILE)
            if status != 0:
                aulog.info("Unxpected statements")
                return -1

            status = host.expect_exact("#", timeout=tout_cmd)

        except Exception as e:
            aulog.debug(
                "Command: Timed out, before considering this as failure")
            aulog.debug(str(e))
            aulog.debug(host.before)
            return -1

        # reset terminal length
        host.sendline("terminal length 100")
        try:
            host.expect_exact("#")
        except:
            aulog.debug(host.before)
            aulog.debug(
                "Command: Timed out, before considering this as failure")
            return -1

        return 0
Exemple #4
0
	def start(self, **kwargs):


                # Get the session
                host = kwargs['session']

                if kwargs['options'].device :
                    dev_string = kwargs['options'].device.replace(" ","_")
                else :
                    name = kwargs['session'].name
                    dev_string = ".".join(re.findall(r"[\w']+","_".join(name.split(" ")[1:])))

                CFG_BKP_FILE = dev_string + ".cfg_bkup"
		aulog.debug("Backing up configurations in file %s..."%(CFG_BKP_FILE))
                try :
                   host.expect_exact("#", timeout = 15)
                except:
                   pass

                try: 
                    # Set terminal length
                    host.sendline("terminal length 0")
                    host.expect_exact("#")

	    	    # Pass CLI's to box
                    host.sendline("show running")

                    status = host.expect_exact( ["end\r\n", INVALID_INPUT, EOF], timeout = tout_cmd)
		    self.save_configs(host.before, CFG_BKP_FILE)
                    if status != 0:
                        aulog.info("Unxpected statements")
                        return -1

                    status = host.expect_exact( "#", timeout = tout_cmd)

                except Exception as e:
                    aulog.debug("Command: Timed out, before considering this as failure")
                    aulog.debug(str(e))
		    aulog.debug(host.before)
                    return -1

                # reset terminal length
                host.sendline("terminal length 100")
                try: 
                    host.expect_exact("#")
                except :
		    aulog.debug(host.before)
                    aulog.debug("Command: Timed out, before considering this as failure")
                    return -1

		return 0
Exemple #5
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)