Fix for private flavor list

Closes-issue: https://mirantis.jira.com/browse/PROD-35763
Change-Id: If25297ef8d3f06f82622b30ef2ed2209af6ace00
(cherry picked from commit d37f2c878488ab985e78d3ee001062d5cb0edc6b)
diff --git a/_modules/novav21/flavors.py b/_modules/novav21/flavors.py
index 53cd7a4..7cf62fa 100644
--- a/_modules/novav21/flavors.py
+++ b/_modules/novav21/flavors.py
@@ -10,6 +10,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import six.moves.urllib.parse as urllib_parse
+
 import common
 
 # Function alias to not shadow built-ins
@@ -78,4 +80,6 @@
     url = '/flavors'
     if detail:
         url = '%s/detail' % url
+    url = '%(base_url)s?%(query_args)s' % {
+        "base_url": url, "query_args": urllib_parse.urlencode(kwargs)}
     return url, {}
diff --git a/_states/novav21.py b/_states/novav21.py
index 138d295..a699874 100644
--- a/_states/novav21.py
+++ b/_states/novav21.py
@@ -72,14 +72,18 @@
 
 @_error_handler
 def flavor_present(name, cloud_name, vcpus=1, ram=256, disk=0, flavor_id=None,
-                   extra_specs=None):
+                   extra_specs=None, is_public=False):
     """Ensures that the flavor exists"""
     extra_specs = extra_specs or {}
-    # There is no way to query flavors by name
+    # There is no way to query flavors by name. And we always list both
+    # public and private flavors
     flavors = _call_nova_salt_module('flavor_list', name)(
-        detail=True, cloud_name=cloud_name)
+        detail=True, is_public=None, cloud_name=cloud_name)
     flavor = [flavor for flavor in flavors if flavor['name'] == name]
     # Flavor names are unique, there is either 1 or 0 with requested name
+    # TODO: check all the vcpus, ram etc. and delete the existing flavor if
+    # something does not match, as it is impossible to update exising flavor
+    # apart from its extra specs
     if flavor:
         flavor = flavor[0]
         current_extra_specs = _call_nova_salt_module(
@@ -98,7 +102,8 @@
             ret = _no_change(name, 'Flavor')
     else:
         flavor = _call_nova_salt_module('flavor_create', name)(
-            name, vcpus, ram, disk, id=flavor_id, cloud_name=cloud_name)
+            name, vcpus, ram, disk, id=flavor_id, cloud_name=cloud_name,
+            **{"os-flavor-access:is_public": is_public})
         _call_nova_salt_module('flavor_add_extra_specs', name)(
             flavor['id'], cloud_name=cloud_name, **extra_specs)
         flavor['extra_specs'] = extra_specs
diff --git a/nova/client/resources/v21.sls b/nova/client/resources/v21.sls
index 256c8f4..6f5d214 100644
--- a/nova/client/resources/v21.sls
+++ b/nova/client/resources/v21.sls
@@ -25,6 +25,9 @@
     {%- if flavor.extra_specs is defined %}
     - extra_specs: {{ flavor.extra_specs }}
     {%- endif %}
+    {%- if flavor.is_public is defined %}
+    - is_public: {{ flavor.is_public }}
+    {%- endif %}
 
   {%- endfor %}
   {%- endif %}