Пример #1
0
    def test_registry(self):
        """ Verify registration and autodiscovery work correctly.

        Please note that this implicitly tests that autodiscovery works
        by virtue of the fact that the dashboards listed in
        ``settings.INSTALLED_APPS`` are loaded from the start.
        """

        # Registration
        self.assertEqual(len(Steer._registry), 3)
        steer.register(MyDash)
        self.assertEqual(len(Steer._registry), 4)
        with self.assertRaises(ValueError):
            steer.register(MyPanel)
        with self.assertRaises(ValueError):
            steer.register("MyPanel")

        # Retrieval
        my_dash_instance_by_name = steer.get_dashboard("mydash")
        self.assertTrue(isinstance(my_dash_instance_by_name, MyDash))
        my_dash_instance_by_class = steer.get_dashboard(MyDash)
        self.assertEqual(my_dash_instance_by_name, my_dash_instance_by_class)
        with self.assertRaises(base.NotRegistered):
            steer.get_dashboard("fake")
        self.assertQuerysetEqual(steer.get_dashboards(), [
            '<Dashboard: Project>', '<Dashboard: Admin>',
            '<Dashboard: Settings>', '<Dashboard: My Dashboard>'
        ])

        # Removal
        self.assertEqual(len(Steer._registry), 4)
        steer.unregister(MyDash)
        self.assertEqual(len(Steer._registry), 3)
        with self.assertRaises(base.NotRegistered):
            steer.get_dashboard(MyDash)
Пример #2
0
    def test_registry(self):
        """ Verify registration and autodiscovery work correctly.

        Please note that this implicitly tests that autodiscovery works
        by virtue of the fact that the dashboards listed in
        ``settings.INSTALLED_APPS`` are loaded from the start.
        """

        # Registration
        self.assertEqual(len(Steer._registry), 3)
        steer.register(MyDash)
        self.assertEqual(len(Steer._registry), 4)
        with self.assertRaises(ValueError):
            steer.register(MyPanel)
        with self.assertRaises(ValueError):
            steer.register("MyPanel")

        # Retrieval
        my_dash_instance_by_name = steer.get_dashboard("mydash")
        self.assertTrue(isinstance(my_dash_instance_by_name, MyDash))
        my_dash_instance_by_class = steer.get_dashboard(MyDash)
        self.assertEqual(my_dash_instance_by_name, my_dash_instance_by_class)
        with self.assertRaises(base.NotRegistered):
            steer.get_dashboard("fake")
        self.assertQuerysetEqual(steer.get_dashboards(),
                                 ['<Dashboard: Project>',
                                  '<Dashboard: Admin>',
                                  '<Dashboard: Settings>',
                                  '<Dashboard: My Dashboard>'])

        # Removal
        self.assertEqual(len(Steer._registry), 4)
        steer.unregister(MyDash)
        self.assertEqual(len(Steer._registry), 3)
        with self.assertRaises(base.NotRegistered):
            steer.get_dashboard(MyDash)
Пример #3
0
# Copyright 2011 Nebula, 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 django.utils.translation import ugettext as _

import steer

import logging
LOG = logging.getLogger(__name__)

class VmsManage(steer.Dashboard):
    name = "VmsManage"
    slug = "vmsmanage"
    panels = {_("VmsManage"): ('migrate', 'state',),
    }
    default_panel = 'migrate'
    roles = ('admin',)
LOG.debug("reg")
steer.register(VmsManage)
Пример #4
0
#    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 django.utils.translation import ugettext as _

import steer


class Engine(steer.Dashboard):
    name = "Project"
    slug = "engine"
    panels = {_("Manage Compute"): ('overview',
                                    'instances_and_volumes',
                                    'access_and_security',
                                    'images_and_snapshots'),
              _("Network"): ('networks',),
              _("Object Store"): ('containers',)}
    default_panel = 'overview'
    supports_tenants = True


steer.register(Engine)
Пример #5
0
# Copyright 2011 Nebula, 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 django.utils.translation import ugettext as _

import steer


class Syspanel(steer.Dashboard):
    name = "Admin"  # Appears in navigation
    slug = "syspanel"
    panels = {_("System Panel"): ('overview', 'instances', 'services',
                                  'flavors', 'images', 'tenants', 'users',
                                  'quotas',)}
    default_panel = 'overview'
    roles = ('admin',)


steer.register(Syspanel)
Пример #6
0
#    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 django.utils.translation import ugettext as _

import steer


class Engine(steer.Dashboard):
    name = "Project"
    slug = "engine"
    panels = {
        _("Manage Compute"): ('overview', 'instances_and_volumes',
                              'access_and_security', 'images_and_snapshots'),
        _("Network"): ('networks', ),
        _("Object Store"): ('containers', )
    }
    default_panel = 'overview'
    supports_tenants = True


steer.register(Engine)
Пример #7
0
#    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 django.utils.translation import ugettext as _

import steer


class Syspanel(steer.Dashboard):
    name = "Admin"  # Appears in navigation
    slug = "syspanel"
    panels = {
        _("System Panel"): (
            'overview',
            'instances',
            'services',
            'flavors',
            'images',
            'tenants',
            'users',
            'quotas',
        )
    }
    default_panel = 'overview'
    roles = ('admin', )


steer.register(Syspanel)
Пример #8
0
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2011 Nebula, 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 django.utils.translation import ugettext as _

import steer


class Settings(steer.Dashboard):
    name = "Settings"
    slug = "settings"
    panels = ('user', 'tenant')
    default_panel = 'user'
    nav = False


steer.register(Settings)