Exemplo n.º 1
0
 def get_active_version(self):
     if self._active is not None:
         return self.supported[self._active]
     key = getattr(settings, self.SETTINGS_KEY, {}).get(self.service_type)
     if key is None:
         # TODO(gabriel): support API version discovery here; we'll leave
         # the setting in as a way of overriding the latest available
         # version.
         key = self.preferred
     # Since we do a key lookup in the supported dict the type matters,
     # let's ensure people know if they use a string when the key isn't.
     if isinstance(key, six.string_types):
         msg = ('The version "%s" specified for the %s service should be '
                'either an integer or a float, not a string.' %
                (key, self.service_type))
         raise exceptions.ConfigurationError(msg)
     # Provide a helpful error message if the specified version isn't in the
     # supported list.
     if key not in self.supported:
         choices = ", ".join(str(k) for k in six.iterkeys(self.supported))
         msg = ('%s is not a supported API version for the %s service, '
                ' choices are: %s' % (key, self.service_type, choices))
         raise exceptions.ConfigurationError(msg)
     self._active = key
     return self.supported[self._active]
    def __init__(self, request, *args, **kwargs):
        super(CreateEnvironmentForm, self).__init__(request, *args, **kwargs)
        env_fixed_network = getattr(settings, 'USE_FIXED_NETWORK', False)
        if env_fixed_network:
            net_choices = net.get_project_assigned_network(request)
            help_text = None
            if not net_choices:
                msg = _("Default network is either not specified for "
                        "this project, or specified incorrectly, "
                        "please contact administrator.")
                messages.error(request, msg)
                raise exceptions.ConfigurationError(msg)
            else:
                self.fields['net_config'].required = False
                self.fields['net_config'].widget.attrs['readonly'] = True
        else:
            net_choices = net.get_available_networks(
                request, murano_networks='translate')

            if net_choices is None:  # NovaNetwork case
                net_choices = [((None, None), _('Unavailable'))]
                help_text = net.NN_HELP
            else:
                net_choices.insert(0, ((None, None), _('Create New')))
                help_text = net.NEUTRON_NET_HELP
        self.fields['net_config'].choices = net_choices
        self.fields['net_config'].help_text = help_text
Exemplo n.º 3
0
def _open_ldap():
    ldapHost = _getLdapInfo("uri")
    sslType = _getLdapInfo("ssl")

    binddn = getattr(settings, "LDAP_USER", '')
    bindpw = getattr(settings, "LDAP_USER_PASSWORD", '')

    ds = ldap.initialize(ldapHost)
    ds.protocol_version = ldap.VERSION3
    if sslType == "start_tls":
        ds.start_tls_s()

    try:
        ds.simple_bind_s(binddn, bindpw)
        return ds
    except ldap.CONSTRAINT_VIOLATION:
        LOG.error("LDAP bind failure:  Too many failed attempts.\n")
    except ldap.INVALID_DN_SYNTAX:
        LOG.error("LDAP bind failure:  The bind DN is incorrect... \n")
    except ldap.NO_SUCH_OBJECT:
        LOG.error("LDAP bind failure:  "
                  "Unable to locate the bind DN account.\n")
    except ldap.UNWILLING_TO_PERFORM as msg:
        LOG.error("LDAP bind failure:  "
                  "The LDAP server was unwilling to perform the action"
                  " requested.\nError was: %s\n" % msg[0]["info"])
    except ldap.INVALID_CREDENTIALS:
        LOG.error("LDAP bind failure:  Password incorrect.\n")

    LOG.error("Failed to connect to ldap.")
    raise exceptions.ConfigurationError()
Exemplo n.º 4
0
 def get_active_version(self):
     if self._active is not None:
         return self.supported[self._active]
     key = settings.OPENSTACK_API_VERSIONS.get(self.service_type)
     if key is None:
         # TODO(gabriel): support API version discovery here; we'll leave
         # the setting in as a way of overriding the latest available
         # version.
         key = self.preferred
     version = Version(key)
     # Provide a helpful error message if the specified version isn't in the
     # supported list.
     if version not in self.supported:
         choices = ", ".join(str(k) for k in self.supported)
         msg = ('%s is not a supported API version for the %s service, '
                ' choices are: %s' % (version, self.service_type, choices))
         raise exceptions.ConfigurationError(msg)
     self._active = version
     return self.supported[self._active]