If you go with the fix you have now you will have follow up with a fix to the python-troveclient to handle the error response.
ubuntu@ubuntu:~/trove-integration/scripts$ trove user-grant-access 3603282e-6788-403b-b2a7-f0534c404852 loco mysql
ERROR: An error occurred communicating with the guest: Remote error: BadRequest Grant access to mysql is not allowed
[u'Traceback (most recent call last):\n', u' File "/home/ubuntu/trove/trove/openstack/common/rpc/amqp.py", line 440, in _process_data\n **args)\n', u' File "/home/ubuntu/trove/trove/openstack/common/rpc/dispatcher.py", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n', u' File "/home/ubuntu/trove/trove/guestagent/datastore/mysql/manager.py", line 70, in grant_access\n return MySqlAdmin().grant_access(username, hostname, databases)\n', u' File "/home/ubuntu/trove/trove/guestagent/datastore/mysql/service.py", line 388, in grant_access\n "Grant access to %s is not allowed") % database)\n', u'BadRequest: Grant access to mysql is not allowed\n']..
Alternatively you could just "ignore" the dbs by moving the code into the try/except block.
...
def grant_access(self, username, hostname, databases):
"""Grant a user permission to use a given database."""
user = self._get_user(username, hostname)
mydb = models.ValidatedMySQLDatabase()
with LocalSqlClient(get_engine()) as client:
for database in databases: try: mydb.name = database
g = sql_query.Grant(permissions='ALL', database=mydb.name, user=user.name, host=user.host, hashed=user.password) t = text(str(g)) client.execute(t)
except ValueError: LOG.info(_( "Grant access to %s is not allowed") % database)
...
This might have the advantage of allowing you to skip over bad databases if databases contains more than 1 database rather than stopping at the first error. (not a big deal)
If you go with the fix you have now you will have follow up with a fix to the python-troveclient to handle the error response.
ubuntu@ ubuntu: ~/trove- integration/ scripts$ trove user-grant-access 3603282e- 6788-403b- b2a7-f0534c4048 52 loco mysql
ERROR: An error occurred communicating with the guest: Remote error: BadRequest Grant access to mysql is not allowed ubuntu/ trove/trove/ openstack/ common/ rpc/amqp. py", line 440, in _process_data\n **args)\n', u' File "/home/ ubuntu/ trove/trove/ openstack/ common/ rpc/dispatcher. py", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n', u' File "/home/ ubuntu/ trove/trove/ guestagent/ datastore/ mysql/manager. py", line 70, in grant_access\n return MySqlAdmin( ).grant_ access( username, hostname, databases)\n', u' File "/home/ ubuntu/ trove/trove/ guestagent/ datastore/ mysql/service. py", line 388, in grant_access\n "Grant access to %s is not allowed") % database)\n', u'BadRequest: Grant access to mysql is not allowed\n']..
[u'Traceback (most recent call last):\n', u' File "/home/
Alternatively you could just "ignore" the dbs by moving the code into the try/except block.
...
def grant_access(self, username, hostname, databases): user(username, hostname) ValidatedMySQLD atabase( ) get_engine( )) as client:
try:
mydb. name = database
"""Grant a user permission to use a given database."""
user = self._get_
mydb = models.
with LocalSqlClient(
for database in databases:
...
This might have the advantage of allowing you to skip over bad databases if databases contains more than 1 database rather than stopping at the first error. (not a big deal)