fix syntax issue and formatting for mysql_grants state

We may want to consider merging these mysql states into 1
This commit is contained in:
Thomas S Hatch 2012-01-27 14:02:24 -07:00
parent 96e0c64210
commit 90a74c33a3

View File

@ -28,17 +28,33 @@ def present(name,
ret = {'name': name,
'changes': {},
'result': True,
'comment': 'Grant {0} for {1}@{2} on {3} is already present'.format(grant,user,host,database,)}
'comment': 'Grant {0} for {1}@{2} on {3} is already present'.format(
grant,
user,
host,
database
)
}
# check if grant exists
if __salt__['mysql.grant_exists'](grant,database,user,host):
return ret
# The grant is not present, make it!
if __salt__['mysql.grant_add'](grant,database,user,host)
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been added'.format(grant,user,host,database,)
if __salt__['mysql.grant_add'](grant,database,user,host):
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been added'.format(
grant,
user,
host,
database
)
ret['changes'][name] = 'Present'
else:
ret['comment'] = 'Failed to grant {0} for {1}@{2} on {3}'.format(grant,user,host,database,)
ret['comment'] = 'Failed to grant {0} for {1}@{2} on {3}'.format(
grant,
user,
host,
database
)
ret['result'] = False
return ret
@ -62,10 +78,22 @@ def absent(name,
#check if db exists and remove it
if __salt__['mysql.grant_exists'](grant,database,user,host,):
if __salt__['mysql.grant_revoke'](grant,database,user,host):
ret['comment'] = 'Grant {0} for {1}@{2} on {3} has been revoked'.format(grant,user,host,database,)
ret['comment'] = ('Grant {0} for {1}@{2} on {3} has been'
' revoked').format(
grant,
user,
host,
database
)
ret['changes'][name] = 'Absent'
return ret
# fallback
ret['comment'] = 'Grant {0} for {1}@{2} on {3} is not present, so it cannot be revoked'.format(grant,user,host,database,)
ret['comment'] = ('Grant {0} for {1}@{2} on {3} is not present, so it'
' cannot be revoked').format(
grant,
user,
host,
database
)
return ret