Module Expr Str Import alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd CompareIn Str AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Str Str Assign AttributeStore NameLoad attr BoolOpOr BoolOpAnd CompareIn Str AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Str Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str With Call AttributeLoad NameLoad attr NameLoad NameStore body Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str If NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Str If AttributeLoad NameLoad attr body Assign NameStore BinOpMod Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Str If AttributeLoad NameLoad attr body Assign NameStore BinOpMod Str AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore ListLoad Assign NameStore NameLoad For NameStore Call AttributeLoad NameLoad attr Str body If UnaryOpNot Call AttributeLoad NameLoad attr body Continue If Call AttributeLoad NameLoad attr Str body If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Dict Str SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Index Num orelse Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Num Assign SubscriptStore NameLoad Index Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad NameLoad attr Assign NameStore ListLoad If NameLoad body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Return CompareIn NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str body Expr Str If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore NameLoad If NameLoad body For NameStore NameLoad body If CompareEq Call AttributeLoad SubscriptLoad NameLoad Index Str attr Call AttributeLoad NameLoad attr body Assign NameStore NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Assign NameStore ListLoad For NameStore NameLoad body Assign NameStore Call NameLoad Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad For NameStore NameLoad body If CompareIn NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq NameLoad Str body Assign NameStore Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Str If NameLoad body Assign NameStore Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore ListLoad BinOpMod Str NameLoad BinOpMod Str NameLoad BinOpMod Str NameLoad Assign NameStore ListComp BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Str NameLoad body Expr Str If Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad body Return NameLoad Assign NameStore Str If NameLoad body Assign NameStore Str If UnaryOpNot CompareIn Str NameLoad body Assign NameStore BinOpMod Str NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list decorator_list
N/A N/A 
Roles in this namespace are meant to provide `MySQL <http://www.mysql.com/>`_ database management utilities for CentOS distributions.
 N/A re provy.core Role provy.more.centos.package.yum YumRole MySQLRole N/A Role N/A N/A 
    This role provides `MySQL <http://www.mysql.com/>`_ database management utilities for CentOS distributions.

    This role uses two context keys: `mysql_root_user` and `mysql_root_pass`. If none are found, it uses 'root' and empty password.

    Example:
    ::

        from provy.core import Role
        from provy.more.centos import MySQLRole

        class MySampleRole(Role):
            def provision(self):
                with self.using(MySQLRole) as role:
                    role.ensure_user(username=self.context['mysql_user'], identified_by=self.context['mysql_password'])
                    role.ensure_database(self.context['mysql_database'], owner=self.context['mysql_user'])
     __init__ N/A N/A self prov context N/A N/A N/A N/A N/A N/A super MySQLRole self __init__ prov context N/A N/A self mysql_root_user N/A N/A N/A mysql_root_user N/A self context N/A N/A self context N/A mysql_root_user root N/A N/A self mysql_root_pass N/A N/A N/A mysql_root_pass N/A self context N/A N/A self context N/A mysql_root_pass N/A provision N/A N/A self N/A N/A N/A 
        Installs `MySQL <http://www.mysql.com/>`_ Server and its dependencies.
        This method should be called upon if overriden in base classes, or MySQL won't work properly in the remote server.

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    self.provision_role(MySQLRole) # no need to call this if using with block.
         N/A N/A N/A self using YumRole role N/A N/A N/A N/A role ensure_up_to_date N/A result N/A N/A role ensure_package_installed mysql-server N/A N/A N/A role ensure_package_installed mysql-devel N/A N/A N/A role ensure_package_installed mysql-libs N/A result N/A N/A N/A N/A self log N/A setting root user %s password... N/A self mysql_root_user N/A N/A N/A self execute N/A mysqladmin -u %s -p'temppass' password '%s' N/A N/A self mysql_root_user N/A self mysql_root_pass stdout False sudo True N/A __execute_non_query N/A N/A self query N/A N/A N/A pass_string N/A N/A self mysql_root_pass N/A N/A pass_string N/A --password="%s"  N/A self mysql_root_pass N/A N/A N/A self execute N/A mysql -u %s %s-e "%s" mysql N/A N/A self mysql_root_user pass_string query stdout False sudo True N/A __execute_query N/A N/A self query N/A N/A N/A pass_string N/A N/A self mysql_root_pass N/A N/A pass_string N/A --password="%s"  N/A self mysql_root_pass N/A result N/A N/A self execute N/A mysql -u %s %s-E -e "%s" mysql N/A N/A self mysql_root_user pass_string query stdout False sudo True N/A rows N/A N/A self __get_rows result N/A rows N/A __get_rows N/A N/A self result N/A N/A N/A index_re N/A N/A re compile (\d+)[.] N/A items N/A N/A item None N/A line N/A N/A result split N/A N/A N/A N/A N/A line strip N/A N/A N/A N/A N/A line startswith * N/A N/A item N/A N/A N/A N/A items append item N/A item N/A index N/A N/A N/A N/A N/A index_re search line groups N/A 0 N/A N/A N/A key value N/A N/A line split : 1 N/A N/A item N/A N/A N/A key strip N/A N/A value strip N/A item N/A N/A N/A N/A items append item N/A items N/A get_user_hosts N/A N/A self username N/A N/A N/A 
        Returns all the available hosts that this user can login from.

        :param username: Name of the user to be verified.
        :type username: :class:`str`
        :return: The user hosts.
        :rtype: :class:`list`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        if not '%' in role.get_user_hosts('someuser'):
                            pass
         N/A users N/A N/A self __execute_query N/A select Host from mysql.user where LOWER(User)='%s' N/A N/A username lower N/A hosts N/A N/A users N/A N/A user users N/A N/A N/A N/A hosts append N/A user N/A Host N/A hosts N/A user_exists N/A N/A self username login_from N/A % N/A N/A 
        Returns :data:`True` if the given user exists for the given location in mysql server.

        :param username: Name of the user to be verified.
        :type username: :class:`str`
        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).
        :type login_from: :class:`str`
        :return: Whether the user exists.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        if not role.user_exists('someuser'):
                            pass
         N/A N/A login_from N/A N/A self get_user_hosts username N/A ensure_user N/A N/A self username identified_by login_from N/A % N/A N/A 
        Ensure the given user is created in the database and can login from the specified location.

        :param username: Name of the user to be created.
        :type username: :class:`str`
        :param identified_by: Password that the user will use to login to mysql server.
        :type identified_by: :class:`str`
        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).
        :type login_from: :class:`str`
        :return: Whether the user had to be created or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        role.ensure_user('someuser', 'somepass', 'localhost')
         N/A N/A N/A N/A self user_exists username login_from N/A N/A N/A N/A self __execute_non_query N/A CREATE USER '%s'@'%s' IDENTIFIED BY '%s'; N/A username login_from identified_by N/A N/A N/A self log N/A User %s not found with login access for %s. User created! N/A username login_from N/A True N/A False N/A is_database_present N/A N/A self database_name N/A N/A N/A 
        Returns :data:`True` if the database is already created.

        :param database_name: Database to verify.
        :type database_name: :class:`str`
        :return: Whether the database is present or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        if role.is_database_present('database'):
                            pass
         N/A result N/A N/A self __execute_query SHOW DATABASES N/A is_there False N/A result N/A N/A row result N/A N/A N/A N/A N/A N/A row N/A Database lower N/A N/A database_name lower N/A N/A is_there True N/A is_there N/A ensure_database N/A N/A self database_name N/A N/A N/A 
        Creates the database if it does not exist.

        :param database_name: Database to create.
        :type database_name: :class:`str`
        :return: Whether the database had to be created or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        role.ensure_database('database')
         N/A N/A N/A N/A self is_database_present database_name N/A N/A N/A N/A self __execute_non_query N/A CREATE DATABASE %s database_name N/A N/A N/A self log N/A Database %s not found. Database created! database_name N/A True N/A False N/A get_user_grants N/A N/A self username login_from N/A % N/A N/A 
        Returns all grants for the given user at the given location.

        :param username: Name of the user to be verify.
        :type username: :class:`str`
        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).
        :type login_from: :class:`str`
        :return: The user grants.
        :rtype: :class:`list`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        if role.get_user_grants('user', login_from='%'):
                            pass
         N/A grants N/A N/A self __execute_query N/A SHOW GRANTS FOR '%s'@'%s'; N/A username login_from N/A only_grants N/A N/A grant grants N/A N/A filtered_grants N/A filter N/A N/A N/A x N/A N/A N/A x startswith GRANT  N/A N/A grant itervalues N/A N/A N/A only_grants extend filtered_grants N/A only_grants N/A has_grant N/A N/A self privileges on username login_from with_grant_option N/A N/A N/A 
        Returns :data:`True` if the user has the specified privileges on the specified object in the given location.

        :param privileges: Privileges that are being verified.
        :type privileges: :class:`str`
        :param on: Database object that the user holds privileges on.
        :type on: :class:`str`
        :param username: Name of the user to be verify.
        :type username: :class:`str`
        :param login_from: Locations that this user can login from. Defaults to '%' (anywhere).
        :type login_from: :class:`str`
        :param with_grant_option: Indicates if we are verifying against grant option.
        :type with_grant_option: :class:`bool`
        :return: Whether the user has the privileges or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        if role.has_grant('ALL PRIVILEGES',
                                          'database',
                                          'user',
                                          login_from='%',
                                          with_grant_option=True):
                            pass
         N/A grants N/A N/A self get_user_grants username login_from N/A grant_option_string N/A N/A self _get_grant_option_string with_grant_option N/A privileges N/A N/A self _get_privileges privileges N/A grant_strings N/A N/A self _get_possible_grant_strings on username privileges login_from grant_option_string N/A grant_string grant_strings N/A N/A N/A grant_string grants N/A N/A True N/A False N/A _get_privileges N/A N/A self privileges N/A N/A N/A privileges N/A N/A privileges upper N/A N/A privileges ALL N/A N/A privileges ALL PRIVILEGES N/A privileges N/A _get_grant_option_string N/A N/A self with_grant_option N/A N/A N/A grant_option_string N/A with_grant_option N/A N/A grant_option_string  WITH GRANT OPTION N/A grant_option_string N/A _get_possible_grant_strings N/A N/A self on username privileges login_from grant_option_string N/A N/A N/A possible_on_tokens N/A N/A `%s`.* on N/A `%s`.`*` on N/A %s.* on N/A grant_strings N/A N/A GRANT %s ON %s TO '%s'@'%s'%s N/A privileges on_token username login_from grant_option_string N/A on_token possible_on_tokens N/A grant_strings N/A ensure_grant N/A N/A self privileges on username login_from with_grant_option N/A % False N/A N/A 
        Ensures that the given user has the given privileges on the specified location.

        :param privileges: Privileges to assign to user (e.g.: "ALL PRIVILEGES").
        :type privileges: :class:`str`
        :param on: Object to assign privileges to. If only the name is supplied, '.*' will be appended to the name. If you want all databases pass '*.*'.
        :type on: :class:`str`
        :param username: User to grant the privileges to.
        :type username: :class:`str`
        :param login_from: Location where the user gets the grants. Defaults to '%' (anywhere).
        :type login_from: :class:`str`
        :param with_grant_option: If :data:`True`, indicates that this user may grant other users the same privileges. Defaults to :data:`False`.
        :type with_grant_option: :class:`bool`
        :return: Whether the grant had to be added or not.
        :rtype: :class:`bool`

        Example:
        ::

            class MySampleRole(Role):
                def provision(self):
                    with self.using(MySQLRole) as role:
                        role.ensure_grant('ALL PRIVILEGES',
                                          on='database',
                                          username='backend',
                                          login_from='%',
                                          with_grant_option=True)
         N/A N/A N/A self has_grant privileges on username login_from with_grant_option N/A N/A False N/A grant_option_string N/A with_grant_option N/A N/A grant_option_string  WITH GRANT OPTION N/A N/A N/A . on N/A N/A on N/A %s.* on N/A grant_string N/A GRANT %s ON %s TO '%s'@'%s'%s N/A privileges on username login_from grant_option_string N/A N/A N/A self __execute_non_query grant_string N/A N/A N/A self log N/A User %s@%s did not have grant '%s' on %s. Privileges granted! N/A username login_from privileges on N/A True N/A N/A