Merge remote-tracking branch 'target/master'
diff --git a/README.rst b/README.rst
index a1f929c..5b601e4 100644
--- a/README.rst
+++ b/README.rst
@@ -273,6 +273,25 @@
 Client role
 -----------
 
+Nova configured with NFS
+
+.. code-block:: yaml
+
+    nova:
+      compute:
+        instances_path: /mnt/nova/instances
+
+    linux:
+      storage:
+        enabled: true
+        mount:
+          nfs_nova:
+            enabled: true
+            path: ${nova:compute:instances_path}
+            device: 172.31.35.145:/data
+            file_system: nfs
+            opts: rw,vers=3
+
 Nova flavors
 
 .. code-block:: yaml
diff --git a/_states/novang.py b/_states/novang.py
index 3433d16..d5bcb35 100644
--- a/_states/novang.py
+++ b/_states/novang.py
@@ -68,13 +68,14 @@
     api_db_version = __salt__['cmd.shell']('nova-manage api_db version 2>/dev/null')
     try:
         api_db_version = int(api_db_version)
+        version = int(version)
     except:
         # nova is not installed
         ret = _no_change('api_db --version', None, test=True)
         return ret
     if api_db_version < version:
         try:
-            __salt__['cmd.shell']('nova-manage api_db sync --version ' + version)
+            __salt__['cmd.shell']('nova-manage api_db sync --version ' + str(version))
             ret['result'] = True
             ret['comment'] = 'Nova-manage api_db sync --version {0} was successfuly executed'.format(version)
             ret['changes']['api_db'] = 'api_db sync --version {0}'.format(version)
@@ -96,6 +97,7 @@
     db_version = __salt__['cmd.shell']('nova-manage db version 2>/dev/null')
     try:
         db_version = int(db_version)
+        version = int(version)
     except:
         # nova is not installed
         ret = _no_change('db --version', None, test=True)
@@ -103,7 +105,7 @@
 
     if db_version < version:
         try:
-            __salt__['cmd.shell']('nova-manage db sync --version ' + version)
+            __salt__['cmd.shell']('nova-manage db sync --version ' + str(version))
             ret['result'] = True
             ret['comment'] = 'Nova-manage db sync --version {0} was successfuly executed'.format(version)
             ret['changes']['db'] = 'db sync --version {0}'.format(version)
@@ -113,6 +115,37 @@
             ret['changes']['db'] = 'Failed to execute db sync --version {0}'.format(version)
     return ret
 
+def online_data_migrations_present(name=None, api_db_version="20", db_version="334"):
+    '''
+    Ensures that online_data_migrations are enforced if specific version of api_db and db is present
+    '''
+    ret = {'name': 'online_data_migrations',
+           'changes': {},
+           'result': True,
+           'comment': 'Current api_db version != {0} a db version != {1}.'.format(api_db_version, db_version)}
+    cur_api_db_version = __salt__['cmd.shell']('nova-manage api_db version 2>/dev/null')
+    cur_db_version = __salt__['cmd.shell']('nova-manage db version 2>/dev/null')
+    try:
+        cur_api_db_version = int(cur_api_db_version)
+        cur_db_version = int(cur_db_version)
+        api_db_version = int(api_db_version)
+        db_version = int(db_version)
+    except:
+        # nova is not installed
+        ret = _no_change('online_data_migrations', None, test=True)
+        return ret
+    if cur_api_db_version == api_db_version and cur_db_version == db_version:
+        try:
+            __salt__['cmd.shell']('nova-manage db online_data_migrations')
+            ret['result'] = True
+            ret['comment'] = 'nova-manage db online_data_migrations was successfuly executed'
+            ret['changes']['online_data_migrations'] = 'online_data_migrations on api_db version {0} and db version {1}'.format(api_db_version, db_version)
+        except:
+            ret['result'] = False
+            ret['comment'] = 'Error while executing nova-manage db online_data_migrations'
+            ret['changes']['online_data_migrations'] = 'Failed to execute online_data_migrations on api_db version {0} and db version {1}'.format(api_db_version, db_version)
+    return ret
+
 def quota_present(tenant_name, profile, name=None, **kwargs):
     '''
     Ensures that the nova quota exists
diff --git a/nova/compute.sls b/nova/compute.sls
index 226df97..f2e9f18 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -133,8 +133,9 @@
   {%- else %}
   - shell: /bin/false
   {%- endif %}
-  - uid: 303
-  - gid: 303
+  {# note: nova uid/gid values would not be evaluated after user is created. #}
+  - uid: {{ compute.get('nova_uid', 303) }}
+  - gid: {{ compute.get('nova_gid', 303) }}
   - system: True
   - groups:
     {%- if salt['group.info']('libvirtd') %}
@@ -150,7 +151,8 @@
 group_nova_compute:
   group.present:
     - name: nova
-    - gid: 303
+    {# note: nova gid value would not be evaluated after user is created. #}
+    - gid: {{ compute.get('nova_gid', 303) }}
     - system: True
     - require_in:
       - user: user_nova_compute
diff --git a/nova/controller.sls b/nova/controller.sls
index 664cb2b..73cc55d 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -30,8 +30,9 @@
   - name: nova
   - home: /var/lib/nova
   - shell: /bin/false
-  - uid: 303
-  - gid: 303
+  {# note: nova uid/gid values would not be evaluated after user is created. #}
+  - uid: {{ controller.get('nova_uid', 303) }}
+  - gid: {{ controller.get('nova_gid', 303) }}
   - system: True
   - require_in:
     - pkg: nova_controller_packages
@@ -39,7 +40,8 @@
 group_nova:
   group.present:
     - name: nova
-    - gid: 303
+    {# note: nova gid value would not be evaluated after user is created. #}
+    - gid: {{ controller.get('nova_gid', 303) }}
     - system: True
     - require_in:
       - user: user_nova
@@ -137,6 +139,16 @@
   - require:
     - file: /etc/nova/nova.conf
 
+{#- the following db online_data_migrations executes only if the current db version == 334 && api_db version == 20 #}
+
+online_data_migrations_for_apidb20_and_db334:
+  novang.online_data_migrations_present:
+  - api_db_version: "20"
+  - db_version: "334"
+  - require:
+    - novang: nova_controller_api_db_sync_version_20
+    - novang: nova_controller_db_sync_version_334
+
 nova_controller_map_cell0:
   cmd.run:
   - name: nova-manage cell_v2 map_cell0
diff --git a/nova/files/juno/nova-compute.conf.Debian b/nova/files/juno/nova-compute.conf.Debian
index bb4dba5..2220177 100644
--- a/nova/files/juno/nova-compute.conf.Debian
+++ b/nova/files/juno/nova-compute.conf.Debian
@@ -107,6 +107,8 @@
 
 {% endif %}
 
+instances_path = {{ compute.instances_path }}
+
 {%- if compute.notification is defined %}
 notification_driver = {{ compute.notification.driver }}
 
diff --git a/nova/files/kilo/nova-compute.conf.Debian b/nova/files/kilo/nova-compute.conf.Debian
index fcf3ae3..c3e197a 100644
--- a/nova/files/kilo/nova-compute.conf.Debian
+++ b/nova/files/kilo/nova-compute.conf.Debian
@@ -96,6 +96,8 @@
 
 {% endif %}
 
+instances_path = {{ compute.instances_path }}
+
 {%- if compute.notification is defined %}
 notification_driver = {{ compute.notification.driver }}
 
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index 283f9c4..21654cd 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -100,6 +100,8 @@
 instance_usage_audit_period = hour
 {% endif %}
 
+instances_path = {{ compute.instances_path }}
+
 {%- if compute.get('notification', {}).notify_on is defined %}
 {%- for key, value in compute.notification.notify_on.iteritems() %}
 notify_on_{{ key }} = {{ value }}
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 3195bbd..ba31a2e 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -65,6 +65,8 @@
 instance_usage_audit_period = hour
 {%- endif %}
 
+instances_path = {{ compute.instances_path }}
+
 {%- if compute.get('notification', {}).notify_on is defined %}
 {%- for key, value in compute.notification.notify_on.iteritems() %}
 notify_on_{{ key }} = {{ value }}
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index 09cd0d0..30667de 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -82,6 +82,8 @@
 instance_usage_audit_period = hour
 {%- endif %}
 
+instances_path = {{ compute.instances_path }}
+
 {%- if compute.get('notification', {}).notify_on is defined %}
 {%- for key, value in compute.notification.notify_on.iteritems() %}
 notify_on_{{ key }} = {{ value }}
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index 0cd91e5..ae358f6 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -646,6 +646,7 @@
 #   Any string representing directory path.
 #  (string value)
 #instances_path=$state_path/instances
+instances_path = {{ compute.instances_path }}
 
 #
 # This option enables periodic compute.instance.exists notifications. Each
diff --git a/nova/map.jinja b/nova/map.jinja
index 8e19b15..3b66daf 100644
--- a/nova/map.jinja
+++ b/nova/map.jinja
@@ -48,6 +48,7 @@
         'bind': compute_bind_defaults,
         'debug': false,
         'libvirt': [],
+        'instances_path': '$state_path/instances',
         'notification': false,
         'availability_zone': None,
         'aggregates': [],