aboutsummaryrefslogtreecommitdiffstats
path: root/moon_manager/moon_manager/plugins/moon_nova_plugin.py
blob: 0848152eedce4b8e6042a975eb14024556e8a249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Software Name: MOON

# Version: 5.4

# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0

# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LICENSE" file for more details.

"""
Plugin to request OpenStack infrastructure:
- Nova
"""

from moon_manager.plugins.moon_openstack_plugin import *

LOGGER = logging.getLogger("moon.manager.plugins.moon_nova_plugin")

PLUGIN_TYPE = "information"
_ = str

# Nova exceptions


class NovaError(MoonError):
    description = _("There is an error connecting to Nova.")
    code = 400
    title = 'Nova error'
    logger = "ERROR"


class NovaProjectError(NovaError):
    description = _("There is an error retrieving projects from the Nova service.")
    code = 400
    title = 'Nova project error'
    logger = "ERROR"


class NovaUserError(NovaError):
    description = _("There is an error retrieving users from the Nova service.")
    code = 400
    title = 'Nova user error'
    logger = "ERROR"


class NovaUserConflict(NovaUserError):
    description = _("A user with that name already exist.")
    code = 400
    title = 'Nova user error'
    logger = "ERROR"


class NovaConnector(OpenStackConnector):

    def get_items(self, item_id=None, **kwargs):
        return self._get(endpoint="/servers", _exception=NovaProjectError)

    def add_item(self, object_id=None, **kwargs):
        raise NotImplementedError()  # pragma: no cover

    def update_item(self, item_id, **kwargs):
        raise NotImplementedError()  # pragma: no cover

    def delete_item(self, item_id, **kwargs):
        raise NotImplementedError()  # pragma: no cover


class Connector(NovaConnector):
    pass