summaryrefslogtreecommitdiff
path: root/ceilometer/network/services/discovery.py
blob: 82ebc7ae856b18718364d298b10932b386864a6b (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# Copyright (c) 2014 Cisco Systems, 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 ceilometer import neutron_client
from ceilometer.polling import plugin_base


class _BaseServicesDiscovery(plugin_base.DiscoveryBase):
    KEYSTONE_REQUIRED_FOR_SERVICE = 'neutron'

    def __init__(self, conf):
        super(_BaseServicesDiscovery, self).__init__(conf)
        self.neutron_cli = neutron_client.Client(conf)


class LBPoolsDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        pools = self.neutron_cli.pool_get_all()
        return [i for i in pools
                if i.get('status') != 'error']


class LBVipsDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        vips = self.neutron_cli.vip_get_all()
        return [i for i in vips
                if i.get('status', None) != 'error']


class LBMembersDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        members = self.neutron_cli.member_get_all()
        return [i for i in members
                if i.get('status', None) != 'error']


class LBListenersDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover load balancer listener resources to monitor."""

        listeners = self.neutron_cli.list_listener()
        return [i for i in listeners
                if i.get('operating_status', None) != 'error']


class LBLoadBalancersDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover load balancer resources to monitor."""

        loadbalancers = self.neutron_cli.list_loadbalancer()
        return [i for i in loadbalancers
                if i.get('operating_status', None) != 'error']


class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        probes = self.neutron_cli.health_monitor_get_all()
        return probes


class VPNServicesDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        vpnservices = self.neutron_cli.vpn_get_all()
        return [i for i in vpnservices
                if i.get('status', None) != 'error']


class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        conns = self.neutron_cli.ipsec_site_connections_get_all()
        return conns


class FirewallDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        fw = self.neutron_cli.firewall_get_all()
        return [i for i in fw
                if i.get('status', None) != 'error']


class FirewallPolicyDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover resources to monitor."""

        return self.neutron_cli.fw_policy_get_all()


class FloatingIPDiscovery(_BaseServicesDiscovery):
    def discover(self, manager, param=None):
        """Discover floating IP resources to monitor."""

        return self.neutron_cli.fip_get_all()