示例#1
0
    def start(manager, device, *args, **kwargs):
        """
        Performs install remove operation
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No package list provided")
            return

        deact_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        inactive_pkgs = package_lib.OnboxPackage(installed_inact, "Inactive Packages")

        packages_to_remove = package_lib.package_intersection(deact_pkgs.pkg_list, inactive_pkgs.pkg_list)
        if not packages_to_remove:
            manager.warning("Packages already removed. Nothing to be removed")
            get_package(device, manager)
            return

        to_remove = " ".join(packages_to_remove)

        cmd = 'admin install remove {} prompt-level none async'.format(to_remove)

        manager.log("Remove Package(s) Pending")
        install_add_remove(manager, device, cmd)
        manager.log("Package(s) Removed Successfully")
示例#2
0
    def _get_tobe_activated_pkg_list(manager, device):
        """
           Get list of package which can be activated.
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact, "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act, "Active Packages")

        # Skip operation if to be activated packages are already active
        package_to_activate = package_lib.extra_pkgs(active_pkgs.pkg_list, added_pkgs.pkg_list)

        if package_to_activate:
            # Test If there is anything added but not inactive
            pkg_to_activate = package_lib.package_intersection(
                added_pkgs.pkg_list, inactive_pkgs.pkg_list)
            if not pkg_to_activate:
                # "explicit is better than implicit" being one of the mottos in "The Zen of Python"
                to_activate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo activate :{} \nInactive: {} \nActive: {}".format(
                    to_activate, installed_inact, installed_act
                )
                manager.log(state_of_packages)
                manager.error('To be activated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_activate)
示例#3
0
    def start(manager, device, *args, **kwargs):
        """
        Performs install remove operation
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No package list provided")
            return

        deact_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        inactive_pkgs = package_lib.OnboxPackage(installed_inact,
                                                 "Inactive Packages")

        packages_to_remove = package_lib.package_intersection(
            deact_pkgs.pkg_list, inactive_pkgs.pkg_list)
        if not packages_to_remove:
            manager.warning("Packages already removed. Nothing to be removed")
            get_package(device, manager)
            return

        to_remove = " ".join(packages_to_remove)

        cmd = 'admin install remove {} prompt-level none async'.format(
            to_remove)

        manager.log("Remove Package(s) Pending")
        install_add_remove(manager, device, cmd)
        manager.log("Package(s) Removed Successfully")
示例#4
0
    def _get_tobe_deactivated_pkg_list(manager, device):
        """
        Produces a list of packaged to be deactivated
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact, "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act, "Active Packages")

        package_to_deactivate = package_lib.extra_pkgs(inactive_pkgs.pkg_list, added_pkgs.pkg_list)

        if package_to_deactivate:
            pkg_to_deactivate = package_lib.package_intersection(added_pkgs.pkg_list, active_pkgs.pkg_list)
            if not pkg_to_deactivate:
                to_deactivate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo deactivate :{} \nInactive: {} \nActive: {}".format(
                    to_deactivate, installed_inact, installed_act
                )
                manager.log(state_of_packages)
                manager.error('To be deactivated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_deactivate)
示例#5
0
    def _get_tobe_deactivated_pkg_list(manager, device):
        """
        Produces a list of packaged to be deactivated
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact,
                                                 "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act,
                                               "Active Packages")

        package_to_deactivate = package_lib.extra_pkgs(inactive_pkgs.pkg_list,
                                                       added_pkgs.pkg_list)

        if package_to_deactivate:
            pkg_to_deactivate = package_lib.package_intersection(
                added_pkgs.pkg_list, active_pkgs.pkg_list)
            if not pkg_to_deactivate:
                to_deactivate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo deactivate :{} \nInactive: {} \nActive: {}".format(
                    to_deactivate, installed_inact, installed_act)
                manager.log(state_of_packages)
                manager.error(
                    'To be deactivated package is not in inactive packages list'
                )
            else:
                return " ".join(pkg_to_deactivate)
示例#6
0
    def _get_tobe_activated_pkg_list(manager, device):
        """
           Get list of package which can be activated.
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact,
                                                 "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act,
                                               "Active Packages")

        # Skip operation if to be activated packages are already active
        package_to_activate = package_lib.extra_pkgs(active_pkgs.pkg_list,
                                                     added_pkgs.pkg_list)

        if package_to_activate:
            # Test If there is anything added but not inactive
            pkg_to_activate = package_lib.package_intersection(
                added_pkgs.pkg_list, inactive_pkgs.pkg_list)
            if not pkg_to_activate:
                # "explicit is better than implicit" being one of the mottos in "The Zen of Python"
                to_activate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo activate :{} \nInactive: {} \nActive: {}".format(
                    to_activate, installed_inact, installed_act)
                manager.log(state_of_packages)
                manager.error(
                    'To be activated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_activate)