Merge "Renamed Portas to API"

This commit is contained in:
Timur Nurlygayanov 2013-04-05 17:21:45 +04:00 committed by Gerrit Code Review
commit 80b2be6d8f
102 changed files with 630 additions and 527 deletions

View File

7
api/README.rst Normal file
View File

@ -0,0 +1,7 @@
Glazier API README
=====================
Glazier API is a project that provides access to engine via API.
SEE ALSO
--------
* `Glazier <http://glazier.mirantis.com>`__

View File

@ -1,8 +1,6 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -14,14 +12,15 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# under the License.from oslo.config import cfg
import gettext
import os
import sys
# If ../portas/__init__.py exists, add ../ to Python search path, so that
# If ../glazierapi/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
from portas.common.service import TaskResultHandlerService
from glazierapi.common.service import TaskResultHandlerService
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
@ -29,17 +28,17 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'portas', '__init__.py')):
sys.path.insert(0, possible_topdir)
from portas.common import config
from portas.openstack.common import log
from portas.openstack.common import wsgi
from portas.openstack.common import service
from glazierapi.common import config
from glazierapi.openstack.common import log
from glazierapi.openstack.common import wsgi
from glazierapi.openstack.common import service
gettext.install('portas', './portas/locale', unicode=1)
gettext.install('glazierapi', './glazierapi/locale', unicode=1)
if __name__ == '__main__':
try:
config.parse_args()
log.setup('portas')
log.setup('glazierapi')
launcher = service.ServiceLauncher()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2010 OpenStack Foundation.
#
@ -34,10 +33,9 @@ import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path = [os.path.abspath('../../portas'),
os.path.abspath('../..'),
os.path.abspath('../../bin')
] + sys.path
sys.path = [os.path.abspath('../../glazierapi'),
os.path.abspath('../..'),
os.path.abspath('../../bin')] + sys.path
# -- General configuration ---------------------------------------------------
@ -67,7 +65,7 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Portas'
project = u'Glazier APIs'
copyright = u'2013, Mirantis, Inc'
# The version info for the project you're documenting, acts as replacement for
@ -75,7 +73,7 @@ copyright = u'2013, Mirantis, Inc'
# built documents.
#
# The short X.Y version.
from portas.version import version_info as portas_version
from glazierapi.version import version_info as portas_version
# The full version, including alpha/beta/rc tags.
release = portas_version.version_string_with_vcs()
# The short X.Y version.
@ -116,7 +114,7 @@ show_authors = True
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['portas.']
modindex_common_prefix = ['glazierapi.']
# -- Options for man page output --------------------------------------------
@ -124,7 +122,7 @@ modindex_common_prefix = ['portas.']
# List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual'
man_pages = [
('man/portasapi', 'portas-api', u'Portas API Server',
('man/glazierapi', 'glazier-api', u'Glazier API Server',
[u'Mirantis, Inc'], 1)
]
@ -203,7 +201,7 @@ html_use_index = False
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'portasdoc'
htmlhelp_basename = 'glazierapidoc'
# -- Options for LaTeX output ------------------------------------------------
@ -218,8 +216,8 @@ htmlhelp_basename = 'portasdoc'
# (source start file, target name, title, author,
# documentclass [howto/manual]).
latex_documents = [
('index', 'Portas.tex', u'Portas Documentation',
u'Keero Team', 'manual'),
('index', 'Glazier.tex', u'Glazier Documentation',
u'Mirantis, Inc', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of

View File

@ -1,12 +1,11 @@
..
Copyright 2010 OpenStack Foundation
All Rights Reserved.
Copyright (c) 2013 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

View File

@ -1,11 +1,11 @@
[pipeline:portas-api]
[pipeline:glazier-api]
pipeline = authtoken context apiv1app
[app:apiv1app]
paste.app_factory = portas.api.v1.router:API.factory
paste.app_factory = glazierapi.api.v1.router:API.factory
[filter:context]
paste.filter_factory = portas.api.middleware.context:ContextMiddleware.factory
paste.filter_factory = glazierapi.api.middleware.context:ContextMiddleware.factory
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory

View File

@ -16,7 +16,7 @@ bind_port = 8082
log_file = /tmp/portas-api.log
#A valid SQLAlchemy connection string for the metadata database
sql_connection = sqlite:///portas.sqlite
sql_connection = sqlite:///glazier.sqlite
[reports]
results_exchange = task-results

View File

@ -0,0 +1,13 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -0,0 +1,14 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg

View File

@ -0,0 +1,14 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg

View File

@ -1,7 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011-2012 OpenStack LLC.
# All Rights Reserved.
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -13,16 +10,17 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# under the License.from oslo.config import cfg
import json
from oslo.config import cfg
import webob.exc
from portas.openstack.common import wsgi
import portas.context
import portas.openstack.common.log as logging
from glazierapi.openstack.common import wsgi
import glazierapi.context
import glazierapi.openstack.common.log as logging
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -43,7 +41,7 @@ class ContextMiddleware(BaseContextMiddleware):
def process_request(self, req):
"""Convert authentication information into a request context
Generate a portas.context.RequestContext object from the available
Generate a glazierapi.context.RequestContext object from the available
authentication headers and store on the 'context' attribute
of the req object.
@ -77,7 +75,7 @@ class ContextMiddleware(BaseContextMiddleware):
'service_catalog': service_catalog,
'session': req.headers.get('X-Configuration-Session')
}
req.context = portas.context.RequestContext(**kwargs)
req.context = glazierapi.context.RequestContext(**kwargs)
else:
raise webob.exc.HTTPUnauthorized()

View File

@ -1,5 +1,19 @@
from portas.db.models import Session, Environment, Status
from portas.db.session import get_session
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from glazierapi.db.models import Session, Environment, Status
from glazierapi.db.session import get_session
def get_draft(environment_id=None, session_id=None):

View File

@ -1,8 +1,22 @@
from portas import utils
from portas.api.v1 import save_draft, get_draft, get_service_status
from portas.common import uuidutils
from portas.openstack.common import wsgi, timeutils
from portas.openstack.common import log as logging
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from glazierapi import utils
from glazierapi.api.v1 import save_draft, get_draft, get_service_status
from glazierapi.common import uuidutils
from glazierapi.openstack.common import wsgi, timeutils
from glazierapi.openstack.common import log as logging
log = logging.getLogger(__name__)

View File

@ -1,13 +1,27 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from amqplib.client_0_8 import Message
import anyjson
import eventlet
from webob import exc
from portas.common import config
from portas.api.v1 import get_env_status
from portas.db.session import get_session
from portas.db.models import Environment
from portas.openstack.common import wsgi
from portas.openstack.common import log as logging
from glazierapi.common import config
from glazierapi.api.v1 import get_env_status
from glazierapi.db.session import get_session
from glazierapi.db.models import Environment
from glazierapi.openstack.common import wsgi
from glazierapi.openstack.common import log as logging
amqp = eventlet.patcher.import_patched('amqplib.client_0_8')
rabbitmq = config.CONF.rabbitmq

View File

@ -1,7 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -13,10 +10,11 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# under the License.from oslo.config import cfg
import routes
from portas.openstack.common import wsgi
from portas.api.v1 import (environments, sessions,
from glazierapi.openstack.common import wsgi
from glazierapi.api.v1 import (environments, sessions,
active_directories, webservers)

View File

@ -1,12 +1,26 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from amqplib.client_0_8 import Message
import anyjson
import eventlet
from webob import exc
from portas.common import config
from portas.db.models import Session, Status, Environment
from portas.db.session import get_session
from portas.openstack.common import wsgi
from portas.openstack.common import log as logging
from glazierapi.common import config
from glazierapi.db.models import Session, Status, Environment
from glazierapi.db.session import get_session
from glazierapi.openstack.common import wsgi
from glazierapi.openstack.common import log as logging
amqp = eventlet.patcher.import_patched('amqplib.client_0_8')
rabbitmq = config.CONF.rabbitmq

View File

@ -1,8 +1,22 @@
from portas import utils
from portas.api.v1 import save_draft, get_draft, get_service_status
from portas.common import uuidutils
from portas.openstack.common import wsgi, timeutils
from portas.openstack.common import log as logging
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from glazierapi import utils
from glazierapi.api.v1 import save_draft, get_draft, get_service_status
from glazierapi.common import uuidutils
from glazierapi.openstack.common import wsgi, timeutils
from glazierapi.openstack.common import log as logging
log = logging.getLogger(__name__)

View File

@ -0,0 +1,14 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg

View File

@ -29,7 +29,7 @@ import sys
from oslo.config import cfg
from paste import deploy
from portas.version import version_info as version
from glazierapi.version import version_info as version
paste_deploy_opts = [
cfg.StrOpt('flavor'),
@ -65,20 +65,20 @@ CONF.register_opts(reports_opts, group='reports')
CONF.register_opts(rabbit_opts, group='rabbitmq')
CONF.import_opt('verbose', 'portas.openstack.common.log')
CONF.import_opt('debug', 'portas.openstack.common.log')
CONF.import_opt('log_dir', 'portas.openstack.common.log')
CONF.import_opt('log_file', 'portas.openstack.common.log')
CONF.import_opt('log_config', 'portas.openstack.common.log')
CONF.import_opt('log_format', 'portas.openstack.common.log')
CONF.import_opt('log_date_format', 'portas.openstack.common.log')
CONF.import_opt('use_syslog', 'portas.openstack.common.log')
CONF.import_opt('syslog_log_facility', 'portas.openstack.common.log')
CONF.import_opt('verbose', 'glazierapi.openstack.common.log')
CONF.import_opt('debug', 'glazierapi.openstack.common.log')
CONF.import_opt('log_dir', 'glazierapi.openstack.common.log')
CONF.import_opt('log_file', 'glazierapi.openstack.common.log')
CONF.import_opt('log_config', 'glazierapi.openstack.common.log')
CONF.import_opt('log_format', 'glazierapi.openstack.common.log')
CONF.import_opt('log_date_format', 'glazierapi.openstack.common.log')
CONF.import_opt('use_syslog', 'glazierapi.openstack.common.log')
CONF.import_opt('syslog_log_facility', 'glazierapi.openstack.common.log')
def parse_args(args=None, usage=None, default_config_files=None):
CONF(args=args,
project='portas',
project='glazierapi',
version=version.cached_version_string(),
usage=usage,
default_config_files=default_config_files)

View File

@ -1,13 +1,27 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
import anyjson
from eventlet import patcher
from portas.db.models import Status, Session, Environment
from portas.db.session import get_session
from glazierapi.db.models import Status, Session, Environment
from glazierapi.db.session import get_session
amqp = patcher.import_patched('amqplib.client_0_8')
from portas.openstack.common import service
from portas.openstack.common import log as logging
from portas.common import config
from glazierapi.openstack.common import service
from glazierapi.openstack.common import log as logging
from glazierapi.common import config
conf = config.CONF.reports
rabbitmq = config.CONF.rabbitmq

View File

@ -0,0 +1,19 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
import uuid
def generate_uuid():
return str(uuid.uuid4()).replace('-', '')

View File

@ -1,7 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011-2012 OpenStack LLC.
# All Rights Reserved.
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -15,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from portas.openstack.common import uuidutils
from glazierapi.openstack.common import uuidutils
class RequestContext(object):

View File

@ -0,0 +1,26 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from oslo.config import cfg
sql_connection_opt = cfg.StrOpt('sql_connection',
default='sqlite:///glazierapi.sqlite',
secret=True,
metavar='CONNECTION',
help='A valid SQLAlchemy connection '
'string for the metadata database. '
'Default: %(default)s')
CONF = cfg.CONF
CONF.register_opt(sql_connection_opt)

View File

@ -0,0 +1,20 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from migrate.versioning.shell import main
# This should probably be a console script entry point.
if __name__ == '__main__':
main(debug='False', repository='.')

View File

@ -1,7 +1,7 @@
[db_settings]
# Used to identify which repository this database is versioned under.
# You can use the name of your project.
repository_id=Portas Migrations
repository_id=Glazier Migrations
# The name of the database table used to track the schema version.
# This name shouldn't already be used by your project.
@ -16,5 +16,5 @@ version_table=migrate_version
# Databases in this list MUST compile successfully during a commit, or the
# entire commit will fail. List the databases your application will actually
# be using to ensure your updates to that database work properly.
# This must be a list; example: ['postgres','sqlite']
# This must be a list; example: ['glazier','sqlite']
required_dbs=[]

View File

@ -1,3 +1,17 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.types import String, Text, DateTime

View File

@ -1,3 +1,17 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.types import String, Text, DateTime

View File

@ -1,3 +1,17 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.types import String, Text, DateTime

View File

@ -0,0 +1,31 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import Text
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
session = Table('session', meta, autoload=True)
description = Column('description', Text(), nullable=True, default='{}')
description.create(session)
def downgrade(migrate_engine):
meta.bind = migrate_engine
session = Table('session', meta, autoload=True)
session.c.description.drop()

View File

@ -1,3 +1,17 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column, ForeignKey
from sqlalchemy.types import String, Text, DateTime

View File

@ -0,0 +1,31 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.from oslo.config import cfg
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import String
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
status = Table('status', meta, autoload=True)
entity_id = Column('entity_id', String(32), nullable=True)
entity_id.create(status)
def downgrade(migrate_engine):
meta.bind = migrate_engine
status = Table('status', meta, autoload=True)
status.c.entity_id.drop()

View File

@ -1,8 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -17,7 +13,7 @@
# under the License.
"""
SQLAlchemy models for portas data
SQLAlchemy models for glazierapi data
"""
import anyjson
@ -26,10 +22,10 @@ from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import DateTime, Text
from sqlalchemy.orm import relationship, backref, object_mapper
from portas.common import uuidutils
from glazierapi.common import uuidutils
from portas.openstack.common import timeutils
from portas.db.session import get_session
from glazierapi.openstack.common import timeutils
from glazierapi.db.session import get_session
BASE = declarative_base()

View File

@ -30,9 +30,9 @@ from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import NullPool
from sqlalchemy.exc import DisconnectionError
from portas.common.config import CONF as conf
from glazierapi.common.config import CONF as conf
from portas.db import migrate_repo
from glazierapi.db import migrate_repo
MAKER = None

View File

@ -21,7 +21,7 @@ Exceptions common to OpenStack projects
import logging
from portas.openstack.common.gettextutils import _
from glazierapi.openstack.common.gettextutils import _
_FATAL_EXCEPTION_FORMAT_ERRORS = False

View File

@ -20,7 +20,7 @@ gettext for openstack-common modules.
Usual usage in an openstack.common module:
from portas.openstack.common.gettextutils import _
from glazierapi.openstack.common.gettextutils import _
"""
import gettext

View File

@ -41,8 +41,8 @@ import json
import logging
import xmlrpclib
from portas.openstack.common.gettextutils import _
from portas.openstack.common import timeutils
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import timeutils
LOG = logging.getLogger(__name__)

View File

@ -42,10 +42,10 @@ import traceback
from oslo.config import cfg
from portas.openstack.common.gettextutils import _
from portas.openstack.common import jsonutils
from portas.openstack.common import local
from portas.openstack.common import notifier
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import jsonutils
from glazierapi.openstack.common import local
from glazierapi.openstack.common import notifier
_DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
@ -305,7 +305,7 @@ class JSONFormatter(logging.Formatter):
class PublishErrorsHandler(logging.Handler):
def emit(self, record):
if ('portas.openstack.common.notifier.log_notifier' in
if ('glazierapi.openstack.common.notifier.log_notifier' in
CONF.notification_driver):
return
notifier.api.notify(None, 'error.publisher',

View File

@ -22,9 +22,9 @@ import sys
from eventlet import event
from eventlet import greenthread
from portas.openstack.common.gettextutils import _
from portas.openstack.common import log as logging
from portas.openstack.common import timeutils
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import timeutils
LOG = logging.getLogger(__name__)

View File

@ -17,12 +17,12 @@ import uuid
from oslo.config import cfg
from portas.openstack.common import context
from portas.openstack.common.gettextutils import _
from portas.openstack.common import importutils
from portas.openstack.common import jsonutils
from portas.openstack.common import log as logging
from portas.openstack.common import timeutils
from glazierapi.openstack.common import context
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import importutils
from glazierapi.openstack.common import jsonutils
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import timeutils
LOG = logging.getLogger(__name__)

View File

@ -15,8 +15,8 @@
from oslo.config import cfg
from portas.openstack.common import jsonutils
from portas.openstack.common import log as logging
from glazierapi.openstack.common import jsonutils
from glazierapi.openstack.common import log as logging
CONF = cfg.CONF
@ -30,6 +30,6 @@ def notify(_context, message):
CONF.default_notification_level)
priority = priority.lower()
logger = logging.getLogger(
'portas.openstack.common.notification.%s' %
'glazierapi.openstack.common.notification.%s' %
message['event_type'])
getattr(logger, priority)(jsonutils.dumps(message))

View File

@ -14,9 +14,9 @@
# under the License.
from portas.openstack.common.gettextutils import _
from portas.openstack.common import log as logging
from portas.openstack.common.notifier import rpc_notifier
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common.notifier import rpc_notifier
LOG = logging.getLogger(__name__)

View File

@ -15,10 +15,10 @@
from oslo.config import cfg
from portas.openstack.common import context as req_context
from portas.openstack.common.gettextutils import _
from portas.openstack.common import log as logging
from portas.openstack.common import rpc
from glazierapi.openstack.common import context as req_context
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import rpc
LOG = logging.getLogger(__name__)

View File

@ -17,10 +17,10 @@
from oslo.config import cfg
from portas.openstack.common import context as req_context
from portas.openstack.common.gettextutils import _
from portas.openstack.common import log as logging
from portas.openstack.common import rpc
from glazierapi.openstack.common import context as req_context
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import rpc
LOG = logging.getLogger(__name__)

View File

@ -30,14 +30,14 @@ import eventlet
import logging as std_logging
from oslo.config import cfg
from portas.openstack.common import eventlet_backdoor
from portas.openstack.common.gettextutils import _
from portas.openstack.common import importutils
from portas.openstack.common import log as logging
from portas.openstack.common import threadgroup
from glazierapi.openstack.common import eventlet_backdoor
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import importutils
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import threadgroup
rpc = importutils.try_import('portas.openstack.common.rpc')
rpc = importutils.try_import('glazierapi.openstack.common.rpc')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import ssl
from oslo.config import cfg
from portas.openstack.common.gettextutils import _
from glazierapi.openstack.common.gettextutils import _
ssl_opts = [

View File

@ -18,8 +18,8 @@ from eventlet import greenlet
from eventlet import greenpool
from eventlet import greenthread
from portas.openstack.common import log as logging
from portas.openstack.common import loopingcall
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import loopingcall
LOG = logging.getLogger(__name__)

View File

@ -52,7 +52,7 @@ class VersionInfo(object):
# The most likely cause for this is running tests in a tree
# produced from a tarball where the package itself has not been
# installed into anything. Revert to setup-time logic.
from portas.openstack.common import setup
from glazierapi.openstack.common import setup
return setup.get_version(self.package)
def release_string(self):

View File

@ -35,13 +35,13 @@ import webob.exc
from xml.dom import minidom
from xml.parsers import expat
from portas.openstack.common import exception
from portas.openstack.common.gettextutils import _
from portas.openstack.common import jsonutils
from portas.openstack.common import log as logging
from portas.openstack.common import service
from portas.openstack.common import sslutils
from portas.openstack.common import xmlutils
from glazierapi.openstack.common import exception
from glazierapi.openstack.common.gettextutils import _
from glazierapi.openstack.common import jsonutils
from glazierapi.openstack.common import log as logging
from glazierapi.openstack.common import service
from glazierapi.openstack.common import sslutils
from glazierapi.openstack.common import xmlutils
socket_opts = [
cfg.IntOpt('backlog',

View File

@ -0,0 +1,13 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -0,0 +1,13 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -1,6 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack Foundation
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -14,7 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import unittest
from portas.openstack.common import version as common_version
version_info = common_version.VersionInfo('portas')
class Test(unittest.TestCase):
def test(self):
assert True

View File

@ -1,22 +1,21 @@
# Copyright (c) 2013 Mirantis Inc.
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest2
from mock import MagicMock
import portas.api.v1.router as router
import glazierapi.api.v1.router as router
def my_mock(link, controller, action, conditions):

38
api/glazierapi/utils.py Normal file
View File

@ -0,0 +1,38 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import functools
import logging
from webob import exc
from glazierapi.db.models import Session
from glazierapi.db.session import get_session
log = logging.getLogger(__name__)
def verify_session(func):
@functools.wraps(func)
def __inner(self, request, *args, **kwargs):
if hasattr(request, 'context') and request.context.session:
uw = get_session().query(Session)
configuration_session = uw.get(request.context.session)
if configuration_session.state != 'open':
log.info('Session is already deployed')
raise exc.HTTPUnauthorized
else:
log.info('No session is supplied')
raise exc.HTTPUnauthorized
return func(self, request, *args, **kwargs)
return __inner

17
api/glazierapi/version.py Normal file
View File

@ -0,0 +1,17 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from glazierapi.openstack.common import version as common_version
version_info = common_version.VersionInfo('glazierapi')

View File

@ -4,4 +4,4 @@
modules=setup,wsgi,config,exception,gettextutils,importutils,jsonutils,log,xmlutils,sslutils,service,notifier,local,install_venv_common,version,timeutils,eventlet_backdoor,threadgroup,loopingcall,uuidutils
# The base module to hold the copy of openstack.common
base=portas
base=glazierapi

View File

@ -2,7 +2,7 @@
function usage {
echo "Usage: $0 [OPTION]..."
echo "Run Portas's test suite(s)"
echo "Run Glazier API's test suite(s)"
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"

View File

@ -9,18 +9,18 @@ tag_date = 0
tag_svn_revision = 0
[compile_catalog]
directory = portas/locale
domain = portas
directory = glazierapi/locale
domain = glazierapi
[update_catalog]
domain = portas
output_dir = portas/locale
input_file = portas/locale/portas.pot
domain = glazierapi
output_dir = glazierapi/locale
input_file = glazierapi/locale/glazierapi.pot
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg
output_file = portas/locale/portas.pot
output_file = glazierapi/locale/glazierapi.pot
[nosetests]
# NOTE(jkoelker) To run the test suite under nose install the following

49
api/setup.py Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/python
#
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import setuptools
from glazierapi.openstack.common import setup
requires = setup.parse_requirements()
depend_links = setup.parse_dependency_links()
project = 'glazierapi'
setuptools.setup(
name=project,
version=setup.get_version(project, '2013.1'),
description='The Glazier Project API',
license='Apache License (2.0)',
author='Mirantis, Inc',
author_email='smelikyan@mirantis.com',
url='http://glazierapi.mirantis.com/',
packages=setuptools.find_packages(exclude=['bin']),
test_suite='nose.collector',
cmdclass=setup.get_cmdclass(),
include_package_data=True,
install_requires=requires,
dependency_links=depend_links,
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Environment :: No Input/Output (Daemon)',
'Environment :: OpenStack',
],
scripts=['bin/glazierapi-api'],
py_modules=[]
)

View File

@ -32,12 +32,12 @@ import install_venv_common as install_venv
def print_help():
help = """
Portas development environment setup is complete.
Glazier API development environment setup is complete.
Portas development uses virtualenv to track and manage Python dependencies
Glazier API development uses virtualenv to track and manage Python dependencies
while in development and testing.
To activate the Portas virtualenv for the extent of your current shell session
To activate the Glazier API virtualenv for the extent of your current shell session
you can run:
$ source .venv/bin/activate
@ -58,7 +58,7 @@ def main(argv):
pip_requires = os.path.join(root, 'tools', 'pip-requires')
test_requires = os.path.join(root, 'tools', 'test-requires')
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
project = 'Portas'
project = 'glazierapi'
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
py_version, project)
options = install.parse_args(argv)

View File

@ -14,13 +14,13 @@ commands = nosetests
[testenv:pep8]
deps = pep8==1.3.3
commands = pep8 --repeat --show-source portas setup.py
commands = pep8 --repeat --show-source glazierapi setup.py
[testenv:venv]
commands = {posargs}
[testenv:cover]
commands = nosetests --cover-erase --cover-package=portas --with-xcoverage
commands = nosetests --cover-erase --cover-package=glazierapi --with-xcoverage
[tox:jenkins]
downloadcache = ~/cache/pip
@ -38,7 +38,7 @@ deps = file://{toxinidir}/.cache.bundle
[testenv:jenkinscover]
deps = file://{toxinidir}/.cache.bundle
setenv = NOSE_WITH_XUNIT=1
commands = nosetests --cover-erase --cover-package=portas --with-xcoverage
commands = nosetests --cover-erase --cover-package=glazierapi --with-xcoverage
[testenv:jenkinsvenv]
deps = file://{toxinidir}/.cache.bundle

View File

@ -1,7 +0,0 @@
Keero Portas README
=====================
Portas is a project that provides access to engine via API.
SEE ALSO
--------
* `Keero <http://keero.mirantis.com>`__

View File

@ -1,55 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Portas exception subclasses"""
_FATAL_EXCEPTION_FORMAT_ERRORS = False
class PortasException(Exception):
"""
Base Portas Exception
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd
with the keyword arguments provided to the constructor.
"""
message = _("An unknown exception occurred")
def __init__(self, message=None, *args, **kwargs):
if not message:
message = self.message
try:
message = message % kwargs
except Exception as e:
if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise e
else:
# at least get the core message out if something happened
pass
super(PortasException, self).__init__(message)
class SchemaLoadError(PortasException):
message = _("Unable to load schema: %(reason)s")
class InvalidObject(PortasException):
message = _("Provided object does not match schema "
"'%(schema)s': %(reason)s")

View File

@ -1,5 +0,0 @@
import uuid
def generate_uuid():
return str(uuid.uuid4()).replace('-', '')

View File

@ -1,12 +0,0 @@
from oslo.config import cfg
sql_connection_opt = cfg.StrOpt('sql_connection',
default='sqlite:///portas.sqlite',
secret=True,
metavar='CONNECTION',
help='A valid SQLAlchemy connection '
'string for the metadata database. '
'Default: %(default)s')
CONF = cfg.CONF
CONF.register_opt(sql_connection_opt)

View File

@ -1,21 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2012 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from migrate.versioning.shell import main
# This should probably be a console script entry point.
if __name__ == '__main__':
main(debug='False', repository='.')

View File

@ -1,17 +0,0 @@
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import Text
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
session = Table('session', meta, autoload=True)
description = Column('description', Text(), nullable=True, default='{}')
description.create(session)
def downgrade(migrate_engine):
meta.bind = migrate_engine
session = Table('session', meta, autoload=True)
session.c.description.drop()

View File

@ -1,17 +0,0 @@
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import String
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
status = Table('status', meta, autoload=True)
entity_id = Column('entity_id', String(32), nullable=True)
entity_id.create(status)
def downgrade(migrate_engine):
meta.bind = migrate_engine
status = Table('status', meta, autoload=True)
status.c.entity_id.drop()

View File

@ -1,81 +0,0 @@
# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import jsonschema
from portas.common import exception
class Schema(object):
def __init__(self, name, properties=None, links=None):
self.name = name
if properties is None:
properties = {}
self.properties = properties
self.links = links
def validate(self, obj):
try:
jsonschema.validate(obj, self.raw())
except jsonschema.ValidationError as e:
raise exception.InvalidObject(schema=self.name, reason=str(e))
def filter(self, obj):
filtered = {}
for key, value in obj.iteritems():
if self._filter_func(self.properties, key) and value is not None:
filtered[key] = value
return filtered
@staticmethod
def _filter_func(properties, key):
return key in properties
def raw(self):
raw = {
'name': self.name,
'properties': self.properties,
'additionalProperties': False,
}
if self.links:
raw['links'] = self.links
return raw
class CollectionSchema(object):
def __init__(self, name, item_schema):
self.name = name
self.item_schema = item_schema
def raw(self):
return {
'name': self.name,
'properties': {
self.name: {
'type': 'array',
'items': self.item_schema.raw(),
},
'first': {'type': 'string'},
'next': {'type': 'string'},
'schema': {'type': 'string'},
},
'links': [
{'rel': 'first', 'href': '{first}'},
{'rel': 'next', 'href': '{next}'},
{'rel': 'describedby', 'href': '{schema}'},
],
}

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -1,15 +0,0 @@
# Copyright (c) 2013 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__ = 'Mirantis'

View File

@ -1,22 +0,0 @@
# Copyright (c) 2013 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import portas.api.v1 as api
class Test(unittest.TestCase):
def test(self):
assert True

Some files were not shown because too many files have changed in this diff Show More