¡@

Home 

OpenStack Study: extension_stubs.py

OpenStack Index

**** CubicPower OpenStack Study ****

# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2011 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.

from abc import abstractmethod

from neutron.api import extensions

from neutron import wsgi

**** CubicPower OpenStack Study ****

class StubExtension(object):

**** CubicPower OpenStack Study ****

    def __init__(self, alias="stub_extension"):

        self.alias = alias

**** CubicPower OpenStack Study ****

    def get_name(self):

        return "Stub Extension"

**** CubicPower OpenStack Study ****

    def get_alias(self):

        return self.alias

**** CubicPower OpenStack Study ****

    def get_description(self):

        return ""

**** CubicPower OpenStack Study ****

    def get_namespace(self):

        return ""

**** CubicPower OpenStack Study ****

    def get_updated(self):

        return ""

**** CubicPower OpenStack Study ****

class StubPlugin(object):

**** CubicPower OpenStack Study ****

    def __init__(self, supported_extensions=[]):

        self.supported_extension_aliases = supported_extensions

**** CubicPower OpenStack Study ****

class ExtensionExpectingPluginInterface(StubExtension):

"""Expect plugin to implement all methods in StubPluginInterface.

This extension expects plugin to implement all the methods

**** CubicPower OpenStack Study ****

    def get_plugin_interface(self):

        return StubPluginInterface

**** CubicPower OpenStack Study ****

class StubPluginInterface(extensions.PluginInterface):

@abstractmethod

**** CubicPower OpenStack Study ****

    def get_foo(self, bar=None):

        pass

**** CubicPower OpenStack Study ****

class StubBaseAppController(wsgi.Controller):

**** CubicPower OpenStack Study ****

    def index(self, request):

        return "base app index"

**** CubicPower OpenStack Study ****

    def show(self, request, id):

        return {'fort': 'knox'}

**** CubicPower OpenStack Study ****

    def update(self, request, id):

        return {'uneditable': 'original_value'}