Shorten swift-internal:// to swift://
The internal/external distinction can be handled with meta-data instead of encoding it within the url. So we can simply start using swift://. This patch keeps the swift-internal:// option around until we decide it can simply be removed. Change-Id: I5ea3d93319daf426539abc78ae826b6594035df9 Implements: blueprint swift-url-proto-cleanup
This commit is contained in:
parent
1d32744e7e
commit
8919808cc1
@ -578,7 +578,7 @@ This operation does not require a request body.
|
|||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
},
|
},
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
||||||
"created_at": "2013-10-15 14:25:04.970513",
|
"created_at": "2013-10-15 14:25:04.970513",
|
||||||
"updated_at": null,
|
"updated_at": null,
|
||||||
@ -624,7 +624,7 @@ This operation does not require a request body.
|
|||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
},
|
},
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
||||||
"created_at": "2013-10-15 14:25:04.970513",
|
"created_at": "2013-10-15 14:25:04.970513",
|
||||||
"updated_at": null,
|
"updated_at": null,
|
||||||
@ -654,7 +654,7 @@ This operation shows information about the created Job Binary.
|
|||||||
.. sourcecode:: json
|
.. sourcecode:: json
|
||||||
|
|
||||||
{
|
{
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"name": "jar-example.jar",
|
"name": "jar-example.jar",
|
||||||
"description": "This is job binary",
|
"description": "This is job binary",
|
||||||
"extra": {
|
"extra": {
|
||||||
@ -679,7 +679,7 @@ This operation shows information about the created Job Binary.
|
|||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
},
|
},
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
||||||
"created_at": "2013-10-15 14:49:20.106452",
|
"created_at": "2013-10-15 14:49:20.106452",
|
||||||
"id": "07f86352-ee8a-4b08-b737-d705ded5ff9c",
|
"id": "07f86352-ee8a-4b08-b737-d705ded5ff9c",
|
||||||
@ -853,7 +853,7 @@ This operation does not require a request body.
|
|||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
},
|
},
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
||||||
"created_at": "2013-10-15 16:03:37.979630",
|
"created_at": "2013-10-15 16:03:37.979630",
|
||||||
"updated_at": null,
|
"updated_at": null,
|
||||||
@ -911,7 +911,7 @@ This operation does not require a request body.
|
|||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
},
|
},
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
"tenant_id": "11587919cc534bcbb1027a161c82cf58",
|
||||||
"created_at": "2013-10-15 16:03:37.979630",
|
"created_at": "2013-10-15 16:03:37.979630",
|
||||||
"updated_at": null,
|
"updated_at": null,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"url": "swift-internal://container/jar-example.jar",
|
"url": "swift://container/jar-example.jar",
|
||||||
"name": "jar-example.jar",
|
"name": "jar-example.jar",
|
||||||
"description": "This is job binary",
|
"description": "This is job binary",
|
||||||
"extra": {
|
"extra": {
|
||||||
"password": "swordfish",
|
"password": "swordfish",
|
||||||
"user": "admin"
|
"user": "admin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ def get_raw_binary(job_binary):
|
|||||||
if url.startswith("savanna-db://"):
|
if url.startswith("savanna-db://"):
|
||||||
res = db.get_raw_data(context.ctx(), job_binary)
|
res = db.get_raw_data(context.ctx(), job_binary)
|
||||||
|
|
||||||
if url.startswith(su.SWIFT_INTERNAL_PREFIX):
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
|
if url.startswith(su.SWIFT_INTERNAL_PREFIX) or (
|
||||||
|
url.startswith(su.OLD_SWIFT_INTERNAL_PREFIX)):
|
||||||
res = i_swift.get_raw_data(context.ctx(), job_binary)
|
res = i_swift.get_raw_data(context.ctx(), job_binary)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@ -39,14 +39,16 @@ def get_raw_data(context, job_binary):
|
|||||||
|
|
||||||
conn = _get_conn(user, password)
|
conn = _get_conn(user, password)
|
||||||
|
|
||||||
if not job_binary.url.startswith(su.SWIFT_INTERNAL_PREFIX):
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
|
if not (job_binary.url.startswith(su.SWIFT_INTERNAL_PREFIX) or
|
||||||
|
job_binary.url.startswith(su.OLD_SWIFT_INTERNAL_PREFIX)):
|
||||||
# This should have been guaranteed already,
|
# This should have been guaranteed already,
|
||||||
# but we'll check just in case.
|
# but we'll check just in case.
|
||||||
raise ex.BadJobBinaryException("Url for binary in internal swift "
|
raise ex.BadJobBinaryException("Url for binary in internal swift "
|
||||||
"must start with %s"
|
"must start with %s"
|
||||||
% su.SWIFT_INTERNAL_PREFIX)
|
% su.SWIFT_INTERNAL_PREFIX)
|
||||||
|
|
||||||
names = job_binary.url[len(su.SWIFT_INTERNAL_PREFIX):].split("/", 1)
|
names = job_binary.url[job_binary.url.index("://")+3:].split("/", 1)
|
||||||
if len(names) == 1:
|
if len(names) == 1:
|
||||||
# We are getting a whole container, return as a dictionary.
|
# We are getting a whole container, return as a dictionary.
|
||||||
container = names[0]
|
container = names[0]
|
||||||
|
@ -51,7 +51,9 @@ JOB_BINARY_SCHEMA = {
|
|||||||
def check_job_binary(data, **kwargs):
|
def check_job_binary(data, **kwargs):
|
||||||
job_binary_location_type = data["url"]
|
job_binary_location_type = data["url"]
|
||||||
extra = data.get("extra", {})
|
extra = data.get("extra", {})
|
||||||
if job_binary_location_type.startswith(su.SWIFT_INTERNAL_PREFIX):
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
|
if job_binary_location_type.startswith(su.SWIFT_INTERNAL_PREFIX) or (
|
||||||
|
job_binary_location_type.startswith(su.OLD_SWIFT_INTERNAL_PREFIX)):
|
||||||
if not extra.get("user") or not extra.get("password"):
|
if not extra.get("user") or not extra.get("password"):
|
||||||
raise e.BadJobBinaryException()
|
raise e.BadJobBinaryException()
|
||||||
if job_binary_location_type.startswith("savanna-db"):
|
if job_binary_location_type.startswith("savanna-db"):
|
||||||
|
@ -23,10 +23,9 @@ from savanna.utils.openstack import base
|
|||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
SWIFT_INTERNAL_PREFIX = "swift-internal://"
|
SWIFT_INTERNAL_PREFIX = "swift://"
|
||||||
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
#TODO(tmckay): support swift-external in a future version
|
OLD_SWIFT_INTERNAL_PREFIX = "swift-internal://"
|
||||||
# SWIFT_EXTERNAL_PREFIX = "swift-external://"
|
|
||||||
|
|
||||||
|
|
||||||
def _get_service_address(service_type):
|
def _get_service_address(service_type):
|
||||||
|
@ -47,6 +47,17 @@ class TestJobBinaryValidation(u.ValidationTestCase):
|
|||||||
"To work with JobBinary located in internal "
|
"To work with JobBinary located in internal "
|
||||||
"swift add 'user' and 'password' to extra"))
|
"swift add 'user' and 'password' to extra"))
|
||||||
|
|
||||||
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
|
def test_job_binary_create_swift_with_old_prefix(self):
|
||||||
|
self._assert_create_object_validation(
|
||||||
|
data={
|
||||||
|
"name": "j_o_w",
|
||||||
|
"url": su.OLD_SWIFT_INTERNAL_PREFIX+"o.savanna/k"
|
||||||
|
},
|
||||||
|
bad_req_i=(1, "BAD_JOB_BINARY",
|
||||||
|
"To work with JobBinary located in internal "
|
||||||
|
"swift add 'user' and 'password' to extra"))
|
||||||
|
|
||||||
def test_job_binary_create_internal(self):
|
def test_job_binary_create_internal(self):
|
||||||
self._assert_create_object_validation(
|
self._assert_create_object_validation(
|
||||||
data={
|
data={
|
||||||
|
@ -48,8 +48,10 @@ def validate_name_format(entry):
|
|||||||
def validate_job_location_format(entry):
|
def validate_job_location_format(entry):
|
||||||
if entry.startswith('savanna-db://'):
|
if entry.startswith('savanna-db://'):
|
||||||
return uuidutils.is_uuid_like(entry[len("savanna-db://"):])
|
return uuidutils.is_uuid_like(entry[len("savanna-db://"):])
|
||||||
if entry.startswith(su.SWIFT_INTERNAL_PREFIX):
|
|
||||||
#TODO(tmckay):allow su.SWIFT_EXTERNAL_PREFIX in a future version
|
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
|
||||||
|
if entry.startswith(su.SWIFT_INTERNAL_PREFIX) or (
|
||||||
|
entry.startswith(su.OLD_SWIFT_INTERNAL_PREFIX)):
|
||||||
#TODO(nprivalova):add hostname validation
|
#TODO(nprivalova):add hostname validation
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user