Example #1
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 ""
Example #2
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"])
Example #3
0
def diff(params):
    """
    Show the ports that need to be updated.
    """

    # Get the path to the cache files which contain the information on what
    # is to be upgraded. Also, get the jajil names (which are at the same time
    # the file names in the cache directory).
    jails = normalize_params(__pluginname__, "jails", params)
    pippy_cachedir = get_config_option(__pluginname__, "pippy_cachedir")

    if "base" in jails:
        # Print the packages that need to be updated.
        _print_updates(pippy_cachedir + os.sep + "base", "the base system")

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

    for jail in jails:
        _print_updates(pippy_cachedir + os.sep + jail, jail)
Example #4
0
def upgrade(params):
    """
    Upgrade the base system and some of the jails. Get the list of systems to 
    upgrade from the command line. Usage:
    
        # czokomaster pippy upgrade base jail1 jail2
      
    This would upgrade the base system only:
    
        # czokomaster pippy upgrade base
          
    This would upgrade all jails. Caution! Jails' names must be put into
    the config file:
    
        # czokomaster pippy upgrade all
    """

    # Get the list of jails that need to be upgraded.
    jails = normalize_params(__pluginname__, "jails", params)

    # If the base system's python packages are to be upgraded as well, do it 
    # now. In order to upgrade the base system's python packages, add "base" to 
    # the "jails" option within the config file.
    if "base" in jails:
        _print_upgrade_messages("the base system")
        _upgrade("base")

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

    # Upgrade specified jails.
    for jail in jails:
        _print_upgrade_messages(jail)
        _upgrade(jail)
        print ""