diff --git a/README.rst b/README.rst index bd7e1e5e..99f0b73d 100644 --- a/README.rst +++ b/README.rst @@ -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 ------------ diff --git a/manila_ui/dashboards/admin/shares/forms.py b/manila_ui/dashboards/admin/shares/forms.py index 8fc50115..5252acd3 100644 --- a/manila_ui/dashboards/admin/shares/forms.py +++ b/manila_ui/dashboards/admin/shares/forms.py @@ -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: diff --git a/manila_ui/dashboards/project/shares/shares/forms.py b/manila_ui/dashboards/project/shares/shares/forms.py index 5d515539..1be37555 100644 --- a/manila_ui/dashboards/project/shares/shares/forms.py +++ b/manila_ui/dashboards/project/shares/shares/forms.py @@ -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, diff --git a/manila_ui/local/local_settings.d/_90_manila_shares.py b/manila_ui/local/local_settings.d/_90_manila_shares.py index f643aae0..0ea64f79 100644 --- a/manila_ui/local/local_settings.d/_90_manila_shares.py +++ b/manila_ui/local/local_settings.d/_90_manila_shares.py @@ -17,4 +17,5 @@ OPENSTACK_MANILA_FEATURES = { 'enable_replication': True, 'enable_migration': True, + 'enabled_share_protocols': ['NFS', 'CIFS', 'GlusterFS', 'HDFS', 'CephFS'], }