Beispiel #1
0
def _check_swift_data_source_create(data):
    if len(data['url']) == 0:
        raise ex.InvalidDataException(_("Swift url must not be empty"))
    url = urlparse.urlparse(data['url'])
    if url.scheme != "swift":
        raise ex.InvalidDataException(_("URL scheme must be 'swift'"))

    # The swift url suffix does not have to be included in the netloc.
    # However, if the swift suffix indicator is part of the netloc then
    # we require the right suffix.
    # Additionally, the path must be more than '/'
    if (su.SWIFT_URL_SUFFIX_START in url.netloc and not url.netloc.endswith(
            su.SWIFT_URL_SUFFIX)) or len(url.path) <= 1:
        raise ex.InvalidDataException(
            _("URL must be of the form swift://container%s/object") %
            su.SWIFT_URL_SUFFIX)

    if not CONF.use_domain_for_proxy_users and "credentials" not in data:
        raise ex.InvalidCredentials(_("No credentials provided for Swift"))
    if not CONF.use_domain_for_proxy_users and ("user"
                                                not in data["credentials"]):
        raise ex.InvalidCredentials(
            _("User is not provided in credentials for Swift"))
    if not CONF.use_domain_for_proxy_users and ("password"
                                                not in data["credentials"]):
        raise ex.InvalidCredentials(
            _("Password is not provided in credentials for Swift"))
Beispiel #2
0
    def validate(self, data):
        self._validate_url(data['url'])

        if not CONF.use_domain_for_proxy_users and "credentials" not in data:
            raise ex.InvalidCredentials(_("No credentials provided for Swift"))
        if not CONF.use_domain_for_proxy_users and (
                "user" not in data["credentials"]):
            raise ex.InvalidCredentials(
                _("User is not provided in credentials for Swift"))
        if not CONF.use_domain_for_proxy_users and (
                "password" not in data["credentials"]):
            raise ex.InvalidCredentials(
                _("Password is not provided in credentials for Swift"))
Beispiel #3
0
def _check_swift_data_source_create(data):
    if len(data['url']) == 0:
        raise ex.InvalidException("Swift url must not be empty")
    url = urlparse.urlparse(data['url'])
    if url.scheme != "swift":
        raise ex.InvalidException("URL scheme must be 'swift'")

    # We must have the suffix, and the path must be more than '/'
    if not url.netloc.endswith(su.SWIFT_URL_SUFFIX) or len(url.path) <= 1:
        raise ex.InvalidException(
            "URL must be of the form swift://container%s/object"
            % su.SWIFT_URL_SUFFIX)

    if "credentials" not in data:
        raise ex.InvalidCredentials("No credentials provided for Swift")
    if "user" not in data["credentials"]:
        raise ex.InvalidCredentials(
            "User is not provided in credentials for Swift")
    if "password" not in data["credentials"]:
        raise ex.InvalidCredentials(
            "Password is not provided in credentials for Swift")
Beispiel #4
0
def _check_swift_data_source_create(data):
    if "credentials" not in data or (not ("user" in data["credentials"] and
                                          "password" in data["credentials"])):
        raise ex.InvalidCredentials("Invalid credentials for Swift")