Adding an ability to set target for mysql user grant.

Change-Id: I793a25750c39f70aa26415e7e6a95100b33373fe
diff --git a/README.rst b/README.rst
index 3f603ff..552c50c 100644
--- a/README.rst
+++ b/README.rst
@@ -36,6 +36,7 @@
               password: 'password'
               host: 'localhost'
               rights: 'all privileges'
+              target: '*.*'
 
 
 MySQL replication master with SSL
diff --git a/mysql/server/database.sls b/mysql/server/database.sls
index 49c0c2b..a54af13 100644
--- a/mysql/server/database.sls
+++ b/mysql/server/database.sls
@@ -29,7 +29,11 @@
 mysql_grants_{{ user.name }}_{{ database_name }}_{{ user.host }}:
   mysql_grants.present:
   - grant: {{ user.rights }}
+  {%- if user.target is defined %}
+  - database: '{{ user.target }}'
+  {%- else %}
   - database: '{{ database_name }}.*'
+  {%- endif %}
   - user: '{{ user.name }}'
   - host: '{{ user.host }}'
   - connection_user: {{ mysql_connection_args.user }}
diff --git a/tests/pillar/server_client_database.sls b/tests/pillar/server_client_database.sls
index 2cb29ea..ca85cfb 100644
--- a/tests/pillar/server_client_database.sls
+++ b/tests/pillar/server_client_database.sls
@@ -18,6 +18,7 @@
           password: password
           host: '%'
           rights: all
+          target: 'nova.*'
         - name: nova
           password: password
           host: 127.0.0.1