|
16 | 16 | import six |
17 | 17 |
|
18 | 18 | from pyinfra.api import MaskString, operation, OperationError, StringCommand |
19 | | -from pyinfra.facts.mysql import make_execute_mysql_command, make_mysql_command |
| 19 | +from pyinfra.facts.mysql import ( |
| 20 | + make_execute_mysql_command, |
| 21 | + make_mysql_command, |
| 22 | + MysqlDatabases, |
| 23 | + MysqlUserGrants, |
| 24 | + MysqlUsers, |
| 25 | +) |
20 | 26 |
|
21 | 27 |
|
22 | 28 | @operation(is_idempotent=False) |
@@ -137,8 +143,12 @@ def user( |
137 | 143 | if require_subject: |
138 | 144 | raise OperationError('Cannot set `require_subject` if `require` is not "X509"') |
139 | 145 |
|
140 | | - current_users = host.fact.mysql_users( |
141 | | - mysql_user, mysql_password, mysql_host, mysql_port, |
| 146 | + current_users = host.get_fact( |
| 147 | + MysqlUsers, |
| 148 | + mysql_user=mysql_user, |
| 149 | + mysql_password=mysql_password, |
| 150 | + mysql_host=mysql_host, |
| 151 | + mysql_port=mysql_port, |
142 | 152 | ) |
143 | 153 |
|
144 | 154 | user_host = '{0}@{1}'.format(user, user_hostname) |
@@ -325,9 +335,12 @@ def database( |
325 | 335 | ) |
326 | 336 | ''' |
327 | 337 |
|
328 | | - current_databases = host.fact.mysql_databases( |
329 | | - mysql_user, mysql_password, |
330 | | - mysql_host, mysql_port, |
| 338 | + current_databases = host.get_fact( |
| 339 | + MysqlDatabases, |
| 340 | + mysql_user=mysql_user, |
| 341 | + mysql_password=mysql_password, |
| 342 | + mysql_host=mysql_host, |
| 343 | + mysql_port=mysql_port, |
331 | 344 | ) |
332 | 345 |
|
333 | 346 | is_present = database in current_databases |
@@ -439,10 +452,14 @@ def privileges( |
439 | 452 | ).format(database, table)) |
440 | 453 |
|
441 | 454 | database_table = '{0}.{1}'.format(database, table) |
442 | | - user_grants = host.fact.mysql_user_grants( |
443 | | - user, user_hostname, |
444 | | - mysql_user, mysql_password, |
445 | | - mysql_host, mysql_port, |
| 455 | + user_grants = host.get_fact( |
| 456 | + MysqlUserGrants, |
| 457 | + user=user, |
| 458 | + user_hostname=user_hostname, |
| 459 | + mysql_user=mysql_user, |
| 460 | + mysql_password=mysql_password, |
| 461 | + mysql_host=mysql_host, |
| 462 | + mysql_port=mysql_port, |
446 | 463 | ) |
447 | 464 |
|
448 | 465 | existing_privileges = [] |
|
0 commit comments