Only show available share protocols on share creation modal

Do not show share protocols in Shares drop-down menu if
the backend is not available.
This patch set is a workaround for this bug. We are using the
settings override feature. Operators will need to place a
'enabled_share_protocols: ['proto1', 'proto2', ...]' setting
on the OPENSTACK_MANILA_SETTINGS files.
The correct fix for this bug would be to add a capabilities
endpoint in the controller plane in order to get the available
backends.

Change-Id: I13637491994e6f074e66fe0f3026a303944892ec
Closes-Bug: #1622732
This commit is contained in:
Victoria Martinez de la Cruz 2016-09-19 20:08:30 -03:00 committed by Tom Barron
parent f75eed27ba
commit 85d17c9bad
4 changed files with 38 additions and 6 deletions

View File

@ -96,6 +96,21 @@ where you can redefine the values of the OPENSTACK_MANILA_FEATURES dict::
* enable_replication
* enable_migration
* enable_public_share_type_creation
* enabled_share_protocols
By default, enabled_share_protocols within the OPENSTACK_MANILA_FEATURES
dict contains a list with all the supported protocols. The operator can
change this to display to users only those protocols that has been deployed
and are available to use. E.g. if only NFS is available, the operator is
expected to redefine enabled_share_protocols as follows:
.. code-block:: python
OPENSTACK_MANILA_FEATURES = {
'enable_replication': True,
'enable_migration': True,
'enabled_share_protocols': ['NFS'],
}
Contributing
------------

View File

@ -200,10 +200,9 @@ class ManageShare(forms.SelfHandlingForm):
max_length=255, label=_("Export location"), required=True,
help_text=_("Export location of share. Example for NFS: "
"1.2.3.4:/path/to/share"))
protocol = forms.ChoiceField(
label=_("Share Protocol"), required=True,
choices=(('NFS', 'NFS'), ('CIFS', 'CIFS'), ('GlusterFS', 'GlusterFS'),
('HDFS', 'HDFS'), ('CephFS', 'CephFS')))
protocol = forms.ChoiceField(label=_("Share Protocol"), required=True)
share_type = forms.ChoiceField(label=_("Share Type"), required=True)
driver_options = forms.CharField(
@ -228,6 +227,17 @@ class ManageShare(forms.SelfHandlingForm):
if dhss and dhss.lower() in strutils.FALSE_STRINGS:
st_choices.append((st.name, st.name))
self.fields['share_type'].choices = st_choices
# NOTE(vkmc): choose only those share protocols that are enabled
# FIXME(vkmc): this should be better implemented by having a
# capabilities endpoint on the control plane.
manila_features = getattr(settings, 'OPENSTACK_MANILA_FEATURES', {})
self.enabled_share_protocols = manila_features.get(
'enabled_share_protocols',
['NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS'])
self.fields['protocol'].choices = ([(' ', ' ')] +
[(enabled_proto, enabled_proto)
for enabled_proto in
self.enabled_share_protocols])
def handle(self, request, data):
try:

View File

@ -47,10 +47,15 @@ class CreateForm(forms.SelfHandlingForm):
def __init__(self, request, *args, **kwargs):
super(CreateForm, self).__init__(request, *args, **kwargs)
# NOTE(vkmc): choose only those share protocols that are enabled
# FIXME(vkmc): this should be better implemented by having a
# capabilities endpoint on the control plane.
manila_features = getattr(settings, 'OPENSTACK_MANILA_FEATURES', {})
self.enabled_share_protocols = manila_features.get(
'enabled_share_protocols',
['NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS'])
self.enable_public_shares = manila_features.get(
'enable_public_shares', True)
share_protos = ('NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS')
share_networks = manila.share_network_list(request)
share_types = manila.share_type_list(request)
self.fields['share_type'].choices = (
@ -105,7 +110,8 @@ class CreateForm(forms.SelfHandlingForm):
help_text=(
"If set then all tenants will be able to see this share."))
self.fields['share_proto'].choices = [(sp, sp) for sp in share_protos]
self.fields['share_proto'].choices = [(sp, sp) for sp in
self.enabled_share_protocols]
if "snapshot_id" in request.GET:
try:
snapshot = self.get_snapshot(request,

View File

@ -17,4 +17,5 @@
OPENSTACK_MANILA_FEATURES = {
'enable_replication': True,
'enable_migration': True,
'enabled_share_protocols': ['NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS'],
}