def add_lock(packages, root=None, **kwargs):  # pylint: disable=unused-argument
    '''
    Add a package lock. Specify packages to lock by exact name.

    root
        operate on a different root directory.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.add_lock <package name>
        salt '*' pkg.add_lock <package1>,<package2>,<package3>
        salt '*' pkg.add_lock pkgs='["foo", "bar"]'
    '''
    salt.utils.versions.warn_until('Sodium', 'This function is deprecated. Please use hold() instead.')
    locks = list_locks(root)
    added = []
    try:
        packages = list(__salt__['pkg_resource.parse_targets'](packages)[0].keys())
    except MinionError as exc:
        raise CommandExecutionError(exc)

    for pkg in packages:
        if not locks.get(pkg):
            added.append(pkg)

    if added:
        __zypper__(root=root).call('al', *added)

    return {'added': len(added), 'packages': added}
def add_lock ( packages , root = None , ** kwargs ) : salt . utils . versions . warn_until ( 'Sodium' , 'This function is deprecated. Please use hold() instead.' ) locks = list_locks ( root ) added = [ ] try : packages = list ( __salt__ [ 'pkg_resource.parse_targets' ] ( packages ) [ 0 ] . keys ( ) ) except MinionError as exc : raise CommandExecutionError ( exc ) for pkg in packages : if not locks . get ( pkg ) : added . append ( pkg ) if added : __zypper__ ( root = root ) . call ( 'al' , * added ) return { 'added' : len ( added ) , 'packages' : added }
Add a package lock. Specify packages to lock by exact name.

    root
        operate on a different root directory.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.add_lock <package name>
        salt '*' pkg.add_lock <package1>,<package2>,<package3>
        salt '*' pkg.add_lock pkgs='["foo", "bar"]'