Exemplo n.º 1
0
def _upgrade(system_name):
    """
    Do the actual upgrade.
    """

    # Get the path to the cache files which contain the information on what
    # is to be upgraded. Also, get the command by which the system is to be
    # upgraded.
    pippy_cachedir = get_config_option(__pluginname__, "pippy_cachedir")
    py_upgrade_cmd = get_config_option(__pluginname__, "py_upgrade_cmd")

    # Get the list of packages that need to be upgraded.
    updates = _get_updates(pippy_cachedir + os.sep + system_name)
 
    # Do the actual upgrade.
    if updates:
        if system_name == "base":
            for update in updates:
                HERE
                execute_command(["%s %s" % (py_upgrade_cmd, update.split()[0])])
        else:
            # It means we operate on jails now.
            for update in updates:
                execute_command(["jexec %s %s %s" % \
                                (system_name, py_upgrade_cmd, \
                                 update.split()[0])])

        # Do postupgrade update if specified in the config.
        _postupgrade_update(system_name)
    else:
        print colored("->", "green"), \
              colored("Nothing to upgrade.", attrs=["bold"])
Exemplo n.º 2
0
    def get_updates(self, system_name=None):
        """
        Get the information which python packages need to be updated. Use 
        "yolk -U" to get this info.

        Attributes:

        system_name = give the name of the base system or a jail in order to
                      process just one unit. REMINDER: system_name must be given
                      as a list. Thus, get_updates("jail") will not work, while
                      get_updates(["jail"]) will.
        """

        self.jails = system_name

        if self.jails == None:
            # Get the names of the jails. Afterwards, list and save the update list.
            self.jails = get_config_option("pippy", "jails")

        # Show updates for the base system.
        if "base" in self.jails:
            update, error = execute_command(["yolk -U"], func_return=True)
            self._save_updates("base", update)

            # Remove "base" from the list, so it is not invoked in the loop
            # below.
            self.jails.remove("base")

        for jail in self.jails:
            update, error = execute_command(["jexec %s yolk -U" % \
                                            jail], func_return=True)

            self._save_updates(jail, update)
Exemplo n.º 3
0
def upgrade(params):
    """
    Upgrade base system and some of the jails. Get the list of systems to 
    upgrade from the command line. Usage:
    
        # czokomaster ports upgrade base jail1 jail2
      
    This would upgrade the base system only:
    
        # czokomaster ports upgrade base
          
    This would upgrade all jails. Caution! Jails' names must be put into
    the config file:
    
        # czokomaster ports upgrade all
    """

    # Get base or/and jails that are to be upgraded.
    # normalize_params() requires config section, config variable and params.
    jails = normalize_params(__pluginname__, "jails", params)

    # Get the upgrade command.
    ports_upgrade_cmd = get_config_option(__pluginname__, "ports_upgrade_cmd")

    # If the base system is to be upgraded as well, do it now. In order
    # to upgrade the base system, add "base" to the "jails" option within
    # the config file.
    if "base" in jails:
        # Both "colored(...)" shall be displayed as one text line.
        print colored("\n==>", "green"), \
              colored("Upgrading the base system", attrs=["bold"]) + \
              colored(":\n", attrs=["bold"])

        execute_command([ports_upgrade_cmd])

        # Drop "base" from the list, so it does not interfere with the loop below.
        # Print new line as well.
        jails.remove("base")
        print ""

    # Upgrade specified jails.
    for jail in jails:
        print colored("\n==>", "green"), \
              colored("Upgrading", attrs=["bold"]), \
              colored(jail, "cyan") + colored(":\n", attrs=["bold"])
        
        execute_command(["jexec %s %s" % (jail, ports_upgrade_cmd)])

    # Print new line.
    print ""
Exemplo n.º 4
0
def update(params):
    """
    Update the port tree on the base system as well as in jails. 
    """

    # First, update the base system. 
    print colored("==>", "green"), \
          colored("Updating ports on the base system", attrs=["bold"]) + \
          colored(":\n", attrs=["bold"])

    execute_command(["portsnap fetch update"])

    #Update the ports tree for jails now.
    print colored("\n==>", "green"), \
          colored("Updating ports for the jails", attrs=["bold"]) + \
          colored(":\n", attrs=["bold"])

    execute_command(["ezjail-admin update -P"])
Exemplo n.º 5
0
def diff(params):
    """
    Show the ports that need to be updated.
    """

    jails = normalize_params(__pluginname__, "jails", params)
    
    # Get the command to show the ports that need updating.
    show_updates_cmd = get_config_option(__pluginname__, "show_updates_cmd")

    # First, the base system, if it is supplied either on the command line
    # or in the config file.
    if "base" in jails:
        print "Available updates for", colored("the base system", "cyan") + ":"

        # Pass the 'func_return=True' as a function argument, so the output is
        # not printed but returned to stdout and stderr variables.
        stdout, stderr = execute_command([show_updates_cmd], func_return=True)

        # If stdout is nil, don't print red '->'. Print green '-> None'.
        if stdout:
            print colored("->", "red"), stdout[:-2].replace("\n", \
                  colored("\n-> ", "red"))
        else:
            print colored("->", "green"), colored("None", "white", \
                                                  attrs=["bold"])

        # Remove "base", so it does not interfere with the loop below.
        jails.remove("base")

    for jail in jails:
        # Print available updates.
        print "\nAvailable updates for", \
              colored(jail, "cyan") + ":"

        stdout, stderr = execute_command(["jexec %s %s" % (jail,
                         show_updates_cmd)], func_return=True)

        # If stdout is nil, don't print red '->'. Print green '-> None'.
        if stdout:
            print colored("->", "red"), stdout[:-2].replace("\n", \
                  colored("\n-> ", "red"))
        else:
            print colored("->", "green"), colored("None", attrs=["bold"])