diff --git a/glare/api/versions.py b/glare/api/versions.py index 9c89e89..12dc4a7 100644 --- a/glare/api/versions.py +++ b/glare/api/versions.py @@ -25,9 +25,9 @@ from glare.i18n import _ versions_opts = [ cfg.StrOpt('public_endpoint', help=_(""" -Public url endpoint to use for Glance/Glare versions response. +Public url endpoint to use for Glare versions response. -This is the public url endpoint that will appear in the Glance/Glare +This is the public url endpoint that will appear in the Glare "versions" response. If no value is specified, the endpoint that is displayed in the version's response is that of the host running the API service. Change the endpoint to represent the proxy URL if the diff --git a/glare/cmd/api.py b/glare/cmd/api.py index 6084c7f..aed17a5 100755 --- a/glare/cmd/api.py +++ b/glare/cmd/api.py @@ -16,7 +16,7 @@ """ -Glare (Glance Artifact Repository) API service +Glare (Glare Artifact Repository) API service """ import os diff --git a/glare/common/config.py b/glare/common/config.py index 7144bd6..60dc2e3 100644 --- a/glare/common/config.py +++ b/glare/common/config.py @@ -14,7 +14,7 @@ # under the License. """ -Routines for configuring Glance +Routines for configuring Glare """ import logging @@ -23,7 +23,6 @@ import logging.handlers import os from oslo_config import cfg -from oslo_middleware import cors from oslo_policy import policy from paste import deploy @@ -112,8 +111,8 @@ def load_paste_app(app_name, flavor=None, conf_file=None): if not conf_file: conf_file = _get_deployment_config_file() + logger = logging.getLogger(__name__) try: - logger = logging.getLogger(__name__) logger.debug("Loading %(app_name)s from %(conf_file)s", {'conf_file': conf_file, 'app_name': app_name}) @@ -132,37 +131,3 @@ def load_paste_app(app_name, flavor=None, conf_file=None): 'e': e}) logger.error(msg) raise RuntimeError(msg) - - -def set_config_defaults(): - """This method updates all configuration default values.""" - set_cors_middleware_defaults() - - -def set_cors_middleware_defaults(): - """Update default configuration options for oslo.middleware.""" - # CORS Defaults - # TODO(krotscheck): Update with https://review.openstack.org/#/c/285368/ - cfg.set_defaults(cors.CORS_OPTS, - allow_headers=['Content-MD5', - 'X-Image-Meta-Checksum', - 'X-Storage-Token', - 'Accept-Encoding', - 'X-Auth-Token', - 'X-Identity-Status', - 'X-Roles', - 'X-Service-Catalog', - 'X-User-Id', - 'X-Tenant-Id', - 'X-OpenStack-Request-ID'], - expose_headers=['X-Image-Meta-Checksum', - 'X-Auth-Token', - 'X-Subject-Token', - 'X-Service-Token', - 'X-OpenStack-Request-ID'], - allow_methods=['GET', - 'PUT', - 'POST', - 'DELETE', - 'PATCH'] - ) diff --git a/glare/common/utils.py b/glare/common/utils.py index abc3865..8b47f4f 100644 --- a/glare/common/utils.py +++ b/glare/common/utils.py @@ -114,17 +114,17 @@ MAX_COOP_READER_BUFFER_SIZE = 134217728 # 128M seems like a sane buffer limit class CooperativeReader(object): """ - An eventlet thread friendly class for reading in image data. + An eventlet thread friendly class for reading in blob data. When accessing data either through the iterator or the read method we perform a sleep to allow a co-operative yield. When there is more than - one image being uploaded/downloaded this prevents eventlet thread + one blob being uploaded/downloaded this prevents eventlet thread starvation, ie allows all threads to be scheduled periodically rather than having the same thread be continuously active. """ def __init__(self, fd): """ - :param fd: Underlying image file object + :param fd: Underlying blob file object """ self.fd = fd self.iterator = None @@ -177,7 +177,7 @@ class CooperativeReader(object): # This check is here to prevent potential OOM issues if # this code is called with unreasonably high values of read # size. Currently it is only called from the HTTP clients - # of Glance backend stores, which use httplib for data + # of Glare backend stores, which use httplib for data # streaming, which has readsize hardcoded to 8K, so this # check should never fire. Regardless it still worths to # make the check, as the code may be reused somewhere else. @@ -202,12 +202,12 @@ class CooperativeReader(object): class LimitingReader(object): """ - Reader designed to fail when reading image data past the configured + Reader designed to fail when reading blob data past the configured allowable amount. """ def __init__(self, data, limit): """ - :param data: Underlying image data object + :param data: Underlying blob data object :param limit: maximum number of bytes the reader should allow """ self.data = data @@ -230,27 +230,6 @@ class LimitingReader(object): return result -def create_mashup_dict(image_meta): - """ - Returns a dictionary-like mashup of the image core properties - and the image custom properties from given image metadata. - - :param image_meta: metadata of image with core and custom properties - """ - - d = {} - for key, value in six.iteritems(image_meta): - if isinstance(value, dict): - for subkey, subvalue in six.iteritems( - create_mashup_dict(value)): - if subkey not in image_meta: - d[subkey] = subvalue - else: - d[key] = value - - return d - - def safe_mkdirs(path): try: os.makedirs(path) diff --git a/glare/common/wsgi.py b/glare/common/wsgi.py index 8c95f75..c894a8d 100644 --- a/glare/common/wsgi.py +++ b/glare/common/wsgi.py @@ -789,7 +789,7 @@ class Resource(object): except UnicodeDecodeError: msg = _("Error decoding your request. Either the URL or the " "request body contained characters that could not be " - "decoded by Glance") + "decoded by Glare") raise webob.exc.HTTPBadRequest(explanation=msg) except Exception as e: LOG.exception(_LE("Caught error: %s"), diff --git a/glare/db/migration/migration.py b/glare/db/migration/migration.py index 5979c15..6114d7d 100644 --- a/glare/db/migration/migration.py +++ b/glare/db/migration/migration.py @@ -38,8 +38,8 @@ def version(engine=None): def upgrade(revision, config=None): """Used for upgrading database. - :param version: Desired database version - :type version: string + :param revision: Desired database version + :type revision: string """ revision = revision or 'head' config = config or get_alembic_config() @@ -49,8 +49,8 @@ def upgrade(revision, config=None): def downgrade(revision, config=None): """Used for downgrading database. - :param version: Desired database version7 - :type version: string + :param revision: Desired database version7 + :type revision: string """ revision = revision or 'base' config = config or get_alembic_config() diff --git a/glare/engine.py b/glare/engine.py index 3cfda7d..c156313 100644 --- a/glare/engine.py +++ b/glare/engine.py @@ -31,8 +31,7 @@ LOG = logging.getLogger(__name__) class Engine(object): """Engine is responsible for executing different helper operations when - processing incoming requests from Glare API. For Glance developers it is - like Domain Model layers unified into 1 Layer. + processing incoming requests from Glare API. Engine receives incoming data and does the following: - check basic policy permissions - requests artifact definition from registry diff --git a/glare/objects/base.py b/glare/objects/base.py index 6a28c2b..776f165 100644 --- a/glare/objects/base.py +++ b/glare/objects/base.py @@ -216,7 +216,7 @@ class BaseArtifact(base.VersionedObject): To interact with database each artifact type must provide an api to execute db operations with artifacts. - :return: subtype of glance.db.glare.api.BaseDBAPI + :return: subtype of glare.db.api.BaseDBAPI """ return artifact_api.ArtifactAPI(cls) @@ -586,7 +586,7 @@ class BaseArtifact(base.VersionedObject): :param af: definition of artifact targeted to delete """ if af.visibility == 'public' and not context.is_admin: - msg = _("Only admins are allowed to delete public images") + msg = _("Only admins are allowed to delete public artifacts") raise exception.Forbidden(msg) # marking all blobs as pending delete blobs = {} @@ -829,7 +829,7 @@ class BaseArtifact(base.VersionedObject): msg = _("%s is not a blob") % field_name raise exception.BadRequest(msg) if af.status == cls.STATUS.DEACTIVATED and not context.is_admin: - msg = _("Only admin is allowed to download image data " + msg = _("Only admin is allowed to download artifact data " "when it's deactivated") raise exception.Forbidden(message=msg) blob = getattr(af, field_name) @@ -900,7 +900,7 @@ class BaseArtifact(base.VersionedObject): raise exception.BadRequest(msg) if af.status == cls.STATUS.DEACTIVATED and not context.is_admin: - msg = _("Only admin is allowed to download image data " + msg = _("Only admin is allowed to download artifact data " "when it's deactivated") raise exception.Forbidden(message=msg) try: diff --git a/glare/tests/functional/__init__.py b/glare/tests/functional/__init__.py index faa765d..820dec0 100644 --- a/glare/tests/functional/__init__.py +++ b/glare/tests/functional/__init__.py @@ -203,8 +203,8 @@ class Server(object): conf_filepath = os.path.join(conf_dir, 'glare.conf') with open(conf_filepath, 'w') as conf_file: - conf_file.write('[DEFAULT]\n') - conf_file.write('sql_connection = %s' % self.sql_connection) + conf_file.write('[database]\n') + conf_file.write('connection = %s' % self.sql_connection) conf_file.flush() glare_db_env = 'GLARE_DB_TEST_SQLITE_FILE' @@ -274,13 +274,10 @@ class GlareServer(Server): self.default_store = kwargs.get("default_store", "file") self.key_file = "" self.cert_file = "" - self.metadata_encryption_key = "012345678901234567890123456789ab" - self.image_dir = os.path.join(self.test_dir, "images") + self.blob_dir = os.path.join(self.test_dir, "artifacts") self.pid_file = pid_file or os.path.join(self.test_dir, "glare.pid") self.log_file = os.path.join(self.test_dir, "glare.log") - self.image_size_cap = 1099511627776 self.delayed_delete = delayed_delete - self.owner_is_tenant = True self.workers = 0 self.policy_file = policy_file self.policy_default_rule = 'default' @@ -290,12 +287,8 @@ class GlareServer(Server): default_sql_connection = 'sqlite:////%s/tests.sqlite' % self.test_dir self.sql_connection = os.environ.get('GLARE_TEST_SQL_CONNECTION', default_sql_connection) - self.user_storage_quota = '0' self.lock_path = self.test_dir - self.location_strategy = 'location_order' - self.store_type_location_strategy_preference = "" - self.send_identity_headers = False self.enabled_artifact_types = '' self.custom_artifact_types_modules = '' @@ -307,25 +300,23 @@ bind_host = 127.0.0.1 bind_port = %(bind_port)s key_file = %(key_file)s cert_file = %(cert_file)s -metadata_encryption_key = %(metadata_encryption_key)s log_file = %(log_file)s delayed_delete = %(delayed_delete)s workers = %(workers)s -sql_connection = %(sql_connection)s lock_path = %(lock_path)s [oslo_policy] policy_file = %(policy_file)s policy_default_rule = %(policy_default_rule)s [paste_deploy] flavor = %(deployment_flavor)s -[store_type_location_strategy] -store_type_preference = %(store_type_location_strategy_preference)s [glance_store] -filesystem_store_datadir=%(image_dir)s +filesystem_store_datadir=%(blob_dir)s default_store = %(default_store)s [glare] enabled_artifact_types = %(enabled_artifact_types)s custom_artifact_types_modules = %(custom_artifact_types_modules)s +[database] +connection = %(sql_connection)s """ self.paste_conf_base = """[pipeline:glare-api] pipeline = faultwrapper versionnegotiation unauthenticated-context glarev1api diff --git a/glare/tests/utils.py b/glare/tests/utils.py index c363078..00e8a9c 100644 --- a/glare/tests/utils.py +++ b/glare/tests/utils.py @@ -28,7 +28,6 @@ from oslo_config import fixture as cfg_fixture from oslo_log import log from oslo_middleware import base as base_middleware import six -from six.moves import BaseHTTPServer import testtools import webob @@ -80,14 +79,6 @@ class BaseTestCase(testtools.TestCase): dst_file_name = os.path.join(dst_dir, file_name) return dst_file_name - def set_property_protection_rules(self, rules): - with open(self.property_file, 'w') as f: - for rule_key in rules.keys(): - f.write('[%s]\n' % rule_key) - for operation in rules[rule_key].keys(): - roles_str = ','.join(rules[rule_key][operation]) - f.write('%s = %s\n' % (operation, roles_str)) - def config(self, **kw): """ Override some configuration values. @@ -382,65 +373,6 @@ def xattr_writes_supported(path): return result -def minimal_headers(name, public=True): - headers = { - 'Content-Type': 'application/octet-stream', - 'X-Image-Meta-Name': name, - 'X-Image-Meta-disk_format': 'raw', - 'X-Image-Meta-container_format': 'ovf', - } - if public: - headers['X-Image-Meta-Is-Public'] = 'True' - return headers - - -def minimal_add_command(port, name, suffix='', public=True): - visibility = 'is_public=True' if public else '' - return ("bin/glare --port=%d add %s" - " disk_format=raw container_format=ovf" - " name=%s %s" % (port, visibility, name, suffix)) - - -def start_http_server(image_id, image_data): - def _get_http_handler_class(fixture): - class StaticHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): - def do_GET(self): - self.send_response(200) - self.send_header('Content-Length', str(len(fixture))) - self.end_headers() - self.wfile.write(fixture) - return - - def do_HEAD(self): - # reserve non_existing_image_path for the cases where we expect - # 404 from the server - if 'non_existing_image_path' in self.path: - self.send_response(404) - else: - self.send_response(200) - self.send_header('Content-Length', str(len(fixture))) - self.end_headers() - return - - def log_message(self, *args, **kwargs): - # Override this method to prevent debug output from going - # to stderr during testing - return - - return StaticHTTPRequestHandler - - server_address = ('127.0.0.1', 0) - handler_class = _get_http_handler_class(image_data) - httpd = BaseHTTPServer.HTTPServer(server_address, handler_class) - port = httpd.socket.getsockname()[1] - - pid = os.fork() - if pid == 0: - httpd.serve_forever() - else: - return pid, port - - class FakeAuthMiddleware(base_middleware.ConfigurableMiddleware): @staticmethod