Removing files not required in this directory

Change-Id: I91e449849a71ca47841a5e50143dcf0238496e65
This commit is contained in:
Lakshmi N Sampath 2014-03-11 16:20:51 -07:00
parent 85a25f5481
commit a963904484
26 changed files with 12 additions and 533 deletions

View File

@ -16,7 +16,7 @@
from pecan import expose
from webob.exc import status_map
from graffiti.controllers.versions import V1Controller
from graffiti.api.controllers.versions import V1Controller
class RootController(object):

View File

@ -18,7 +18,7 @@ from pecan.rest import RestController
from wsme.api import Response
from wsmeext.pecan import wsexpose
from graffiti.model.v1.resource import Resource
from graffiti.api.model.v1.resource import Resource
import six

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from graffiti.controllers.v1.resource import ResourceController
from graffiti.api.controllers.v1.resource import ResourceController
class V1Controller(object):

View File

@ -16,7 +16,7 @@
import wsme
from wsme import types
from graffiti.model.v1.property import Property
from graffiti.api.model.v1.property import Property
class Capability(types.Base):

View File

@ -16,10 +16,10 @@
import wsme
from wsme import types
from graffiti.model.v1.capability import Capability
from graffiti.model.v1.property import Property
from graffiti.model.v1.provider import Provider
from graffiti.model.v1.requirement import Requirement
from graffiti.api.model.v1.capability import Capability
from graffiti.api.model.v1.property import Property
from graffiti.api.model.v1.provider import Provider
from graffiti.api.model.v1.requirement import Requirement
class Resource(types.Base):

View File

@ -20,10 +20,10 @@ test_controller_v1
Tests for `graffiti` module.
"""
from graffiti.tests import base
from graffiti.api.tests import base
from graffiti.controllers.root import RootController
from graffiti.controllers.versions import V1Controller
from graffiti.api.controllers.root import RootController
from graffiti.api.controllers.versions import V1Controller
class TestControllerV1(base.TestCase):

View File

@ -20,7 +20,7 @@ test_graffiti
Tests for `graffiti` module.
"""
from graffiti.tests import base
from graffiti.api.tests import base
class TestGraffiti(base.TestCase):

View File

@ -1,41 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 pecan import make_app
from graffiti import model
from graffiti.service import prepare_service
from graffiti.hooks import CorsHook
from oslo.config import cfg
CONF = cfg.CONF
def setup_app(config):
model.init_model()
app_conf = dict(config.app)
prepare_service()
app_hooks = [CorsHook()]
return make_app(
app_conf.pop('root'),
logging=getattr(config, 'logging', {}),
hooks=app_hooks,
**app_conf
)

View File

@ -1,33 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 pecan import expose
from webob.exc import status_map
from graffiti.controllers.versions import V1Controller
class RootController(object):
v1 = V1Controller()
@expose('error.html')
def error(self, status):
try:
status = int(status)
except ValueError: # pragma: no cover
status = 500
message = getattr(status_map.get(status), 'explanation', '')
return dict(status=status, message=message)

View File

@ -1,59 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 pecan.rest import RestController
from wsme.api import Response
from wsmeext.pecan import wsexpose
from graffiti.model.v1.resource import Resource
import six
resources = []
class ResourceController(RestController):
def __init__(self):
super(ResourceController, self).__init__()
self.status = 200
@wsexpose()
def options():
pass
@wsexpose(Resource, six.text_type)
def get_one(self, id):
global resources
for res in resources:
if res.id.lower() == id.lower():
return res
res = Response(Resource(), status_code=404, error="Resource Not Found")
return res
@wsexpose([Resource])
def get_all(self):
global resources
return resources
@wsexpose(Resource, Resource)
def post(self, resource):
global resources
resources.append(resource)

View File

@ -1,21 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 graffiti.controllers.v1.resource import ResourceController
class V1Controller(object):
resource = ResourceController()

View File

@ -1,36 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 json
from pecan.hooks import PecanHook
class CorsHook(PecanHook):
def after(self, state):
state.response.headers['Access-Control-Allow-Origin'] = '*'
state.response.headers['Access-Control-Allow-Methods'] = \
'GET, PUT, POST, DELETE, OPTIONS'
state.response.headers['Access-Control-Allow-Headers'] = \
'origin, authorization, accept, content-type'
if not state.response.headers['Content-Length']:
state.response.headers['Content-Length'] = \
str(len(state.response.body))
if state.response.headers['Content-Type'].find('json') != -1:
# Sort the Response Body's JSON
json_str = json.loads(state.response.body)
state.response.body = json.dumps(json_str, sort_keys=True)

View File

@ -1,18 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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.
def init_model():
pass

View File

@ -1,31 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 wsme
from wsme import types
from graffiti.model.v1.property import Property
class Capability(types.Base):
properties = wsme.wsattr([Property], mandatory=True)
capability_type = wsme.wsattr(types.text, mandatory=True)
capability_type_namespace = wsme.wsattr(types.text, mandatory=True)
_wsme_attr_order = ('properties', 'capability_type',
'capability_type_namespace')
def __init__(self, **kwargs):
super(Capability, self).__init__(**kwargs)

View File

@ -1,27 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 wsme
from wsme import types
class Property(types.Base):
name = wsme.wsattr(types.text, mandatory=True)
value = wsme.wsattr(types.text, mandatory=True)
_wsme_attr_order = ('name', 'value')
def __init__(self, **kwargs):
super(Property, self).__init__(**kwargs)

View File

@ -1,26 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 wsme
from wsme import types
class Provider(types.Base):
id = wsme.wsattr(types.text, mandatory=True)
_wsme_attr_order = ('id',)
def __init__(self, **kwargs):
super(Provider, self).__init__(**kwargs)

View File

@ -1,29 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 wsme
from wsme import types
class Requirement(types.Base):
criterion = wsme.wsattr(types.text, mandatory=True)
capability_type = wsme.wsattr(types.text, mandatory=True)
capability_type_namespace = wsme.wsattr(types.text, mandatory=True)
_wsme_attr_order = ('criterion', 'capability_type',
'capability_type_namespace')
def __init__(self, **kwargs):
super(Requirement, self).__init__(**kwargs)

View File

@ -1,40 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 wsme
from wsme import types
from graffiti.model.v1.capability import Capability
from graffiti.model.v1.property import Property
from graffiti.model.v1.provider import Provider
from graffiti.model.v1.requirement import Requirement
class Resource(types.Base):
id = wsme.wsattr(types.text, mandatory=True)
type = wsme.wsattr(types.text, mandatory=True)
name = wsme.wsattr(types.text, mandatory=True)
description = wsme.wsattr(types.text, mandatory=False)
provider = wsme.wsattr(Provider, mandatory=True)
properties = wsme.wsattr([Property], mandatory=False)
capabilities = wsme.wsattr([Capability], mandatory=True)
requirements = wsme.wsattr([Requirement], mandatory=True)
_wsme_attr_order = ('id', 'name', 'description', 'type',
'provider', 'properties', 'capabilities',
'requirements')
def __init__(self, **kwargs):
super(Resource, self).__init__(**kwargs)

View File

@ -1,25 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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 sys
from oslo.config import cfg
def prepare_service(argv=None):
if argv is None:
argv = sys.argv
cfg.CONF(argv[3:], project='graffiti')

View File

@ -1,14 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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,53 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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 os
import fixtures
import testtools
_TRUE_VALUES = ('True', 'true', '1', 'yes')
class TestCase(testtools.TestCase):
"""Test case base class for all unit tests."""
def setUp(self):
"""Run before each test method to initialize test environment."""
super(TestCase, self).setUp()
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
try:
test_timeout = int(test_timeout)
except ValueError:
# If timeout value is invalid do not set a timeout.
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
self.log_fixture = self.useFixture(fixtures.FakeLogger())

View File

@ -1,39 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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.
"""
test_controller_v1
----------------------------------
Tests for `graffiti` module.
"""
from graffiti.tests import base
from graffiti.controllers.root import RootController
from graffiti.controllers.versions import V1Controller
class TestControllerV1(base.TestCase):
def test_v1_exists(self):
root = RootController()
self.assertIn(hasattr(root, 'v1'), [True])
pass
def test_v1_resource_exists(self):
v1 = V1Controller()
self.assertIn(hasattr(v1, 'resource'), [True])
pass

View File

@ -1,29 +0,0 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# 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.
"""
test_graffiti
----------------------------------
Tests for `graffiti` module.
"""
from graffiti.tests import base
class TestGraffiti(base.TestCase):
def test_something(self):
pass