Follow up fixes to network services pollsters
This is a follow up commit addressing comments around minor clean up, fix resources variable to set to empty list instead of None and others. Change-Id: Ied9edd356d59f0cdccde45040897018228df2d20
This commit is contained in:
parent
daf92b6bf4
commit
2630e7a7eb
@ -46,6 +46,4 @@ class BaseServicesPollster(plugin.PollsterBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_status_id(value):
|
def get_status_id(value):
|
||||||
status = value.lower()
|
status = value.lower()
|
||||||
if status not in STATUS:
|
return STATUS.get(status, -1)
|
||||||
return -1
|
|
||||||
return STATUS[status]
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright © 2014 Cisco Systems, Inc
|
# Copyright (c) 2014 Cisco Systems, Inc
|
||||||
#
|
#
|
||||||
# Author:Pradeep Kilambi <pkilambi@cisco.com>
|
# Author:Pradeep Kilambi <pkilambi@cisco.com>
|
||||||
#
|
#
|
||||||
@ -29,9 +28,6 @@ class _BaseServicesDiscovery(plugin.DiscoveryBase):
|
|||||||
|
|
||||||
class LBPoolsDiscovery(_BaseServicesDiscovery):
|
class LBPoolsDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(LBPoolsDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -42,9 +38,6 @@ class LBPoolsDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class LBVipsDiscovery(_BaseServicesDiscovery):
|
class LBVipsDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(LBVipsDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -55,9 +48,6 @@ class LBVipsDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class LBMembersDiscovery(_BaseServicesDiscovery):
|
class LBMembersDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(LBMembersDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -68,9 +58,6 @@ class LBMembersDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
|
class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(LBHealthMonitorsDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -80,9 +67,6 @@ class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class VPNServicesDiscovery(_BaseServicesDiscovery):
|
class VPNServicesDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(VPNServicesDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -93,9 +77,6 @@ class VPNServicesDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
|
class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(IPSecConnectionsDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -105,9 +86,6 @@ class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class FirewallDiscovery(_BaseServicesDiscovery):
|
class FirewallDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(FirewallDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
@ -118,9 +96,6 @@ class FirewallDiscovery(_BaseServicesDiscovery):
|
|||||||
|
|
||||||
class FirewallPolicyDiscovery(_BaseServicesDiscovery):
|
class FirewallPolicyDiscovery(_BaseServicesDiscovery):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(FirewallPolicyDiscovery, self).__init__()
|
|
||||||
|
|
||||||
def discover(self, param=None):
|
def discover(self, param=None):
|
||||||
"""Discover resources to monitor."""
|
"""Discover resources to monitor."""
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from ceilometer.network.services import base
|
from ceilometer.network.services import base
|
||||||
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
from ceilometer import sample
|
from ceilometer import sample
|
||||||
@ -34,13 +35,16 @@ class FirewallPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for fw in resources:
|
for fw in resources:
|
||||||
LOG.debug("Firewall : %s" % fw)
|
LOG.debug("Firewall : %s" % fw)
|
||||||
status = self.get_status_id(fw['status'])
|
status = self.get_status_id(fw['status'])
|
||||||
if status == -1:
|
if status == -1:
|
||||||
# unknown status, skip this sample
|
# unknown status, skip this sample
|
||||||
LOG.warn("Unknown status %s received on firewall %s, "
|
LOG.warn(_("Unknown status %(stat)s received on fw %(id)s,"
|
||||||
"skipping sample" % (fw['status'], fw['id']))
|
"skipping sample") % {'stat': fw['status'],
|
||||||
|
'id': fw['id']})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
yield sample.Sample(
|
yield sample.Sample(
|
||||||
@ -57,7 +61,7 @@ class FirewallPollster(base.BaseServicesPollster):
|
|||||||
|
|
||||||
|
|
||||||
class FirewallPolicyPollster(base.BaseServicesPollster):
|
class FirewallPolicyPollster(base.BaseServicesPollster):
|
||||||
"""Pollster to capture firewalls status samples."""
|
"""Pollster to capture firewall policy samples."""
|
||||||
|
|
||||||
FIELDS = ['name',
|
FIELDS = ['name',
|
||||||
'description',
|
'description',
|
||||||
@ -68,6 +72,8 @@ class FirewallPolicyPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for fw in resources:
|
for fw in resources:
|
||||||
LOG.debug("Firewall Policy: %s" % fw)
|
LOG.debug("Firewall Policy: %s" % fw)
|
||||||
|
|
||||||
|
@ -49,13 +49,16 @@ class LBPoolPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for pool in resources:
|
for pool in resources:
|
||||||
LOG.debug("Load Balancer Pool : %s" % pool)
|
LOG.debug("Load Balancer Pool : %s" % pool)
|
||||||
status = self.get_status_id(pool['status'])
|
status = self.get_status_id(pool['status'])
|
||||||
if status == -1:
|
if status == -1:
|
||||||
# unknown status, skip this sample
|
# unknown status, skip this sample
|
||||||
LOG.warn("Unknown status %s received on pool %s, "
|
LOG.warn(_("Unknown status %(stat)s received on pool %(id)s, "
|
||||||
"skipping sample" % (pool['status'], pool['id']))
|
"skipping sample") % {'stat': pool['status'],
|
||||||
|
'id': pool['id']})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
yield sample.Sample(
|
yield sample.Sample(
|
||||||
@ -90,13 +93,16 @@ class LBVipPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for vip in resources:
|
for vip in resources:
|
||||||
LOG.debug("Load Balancer Vip : %s" % vip)
|
LOG.debug("Load Balancer Vip : %s" % vip)
|
||||||
status = self.get_status_id(vip['status'])
|
status = self.get_status_id(vip['status'])
|
||||||
if status == -1:
|
if status == -1:
|
||||||
# unknown status, skip this sample
|
# unknown status, skip this sample
|
||||||
LOG.warn("Unknown status %s received on vip %s, "
|
LOG.warn(_("Unknown status %(stat)s received on vip %(id)s, "
|
||||||
"skipping sample" % (vip['status'], vip['id']))
|
"skipping sample") % {'stat': vip['status'],
|
||||||
|
'id': vip['id']})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
yield sample.Sample(
|
yield sample.Sample(
|
||||||
@ -125,12 +131,15 @@ class LBMemberPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for member in resources:
|
for member in resources:
|
||||||
LOG.debug("Load Balancer Member : %s" % member)
|
LOG.debug("Load Balancer Member : %s" % member)
|
||||||
status = self.get_status_id(member['status'])
|
status = self.get_status_id(member['status'])
|
||||||
if status == -1:
|
if status == -1:
|
||||||
LOG.warn("Unknown status %s received on member %s, "
|
LOG.warn(_("Unknown status %(stat)s received on member %(id)s,"
|
||||||
"skipping sample" % (member['status'], member['id']))
|
"skipping sample") % {'stat': member['status'],
|
||||||
|
'id': member['id']})
|
||||||
continue
|
continue
|
||||||
yield sample.Sample(
|
yield sample.Sample(
|
||||||
name='network.services.lb.member',
|
name='network.services.lb.member',
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from ceilometer.network.services import base
|
from ceilometer.network.services import base
|
||||||
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
from ceilometer import sample
|
from ceilometer import sample
|
||||||
@ -35,13 +36,16 @@ class VPNServicesPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for vpn in resources:
|
for vpn in resources:
|
||||||
LOG.debug("VPN : %s" % vpn)
|
LOG.debug("VPN : %s" % vpn)
|
||||||
status = self.get_status_id(vpn['status'])
|
status = self.get_status_id(vpn['status'])
|
||||||
if status == -1:
|
if status == -1:
|
||||||
# unknown status, skip this sample
|
# unknown status, skip this sample
|
||||||
LOG.warn("Unknown status %s received on vpn %s, "
|
LOG.warn(_("Unknown status %(stat)s received on vpn %(id)s,"
|
||||||
"skipping sample" % (vpn['status'], vpn['id']))
|
"skipping sample") % {'stat': vpn['status'],
|
||||||
|
'id': vpn['id']})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
yield sample.Sample(
|
yield sample.Sample(
|
||||||
@ -58,7 +62,7 @@ class VPNServicesPollster(base.BaseServicesPollster):
|
|||||||
|
|
||||||
|
|
||||||
class IPSecConnectionsPollster(base.BaseServicesPollster):
|
class IPSecConnectionsPollster(base.BaseServicesPollster):
|
||||||
"""Pollster to capture VPN status samples."""
|
"""Pollster to capture vpn ipsec connections status samples."""
|
||||||
|
|
||||||
FIELDS = ['name',
|
FIELDS = ['name',
|
||||||
'description',
|
'description',
|
||||||
@ -77,6 +81,8 @@ class IPSecConnectionsPollster(base.BaseServicesPollster):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_samples(self, manager, cache, resources=None):
|
def get_samples(self, manager, cache, resources=None):
|
||||||
|
resources = resources or []
|
||||||
|
|
||||||
for conn in resources:
|
for conn in resources:
|
||||||
LOG.debug("IPSec Connection Info: %s" % conn)
|
LOG.debug("IPSec Connection Info: %s" % conn)
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ class Client(object):
|
|||||||
|
|
||||||
@logged
|
@logged
|
||||||
def pool_get_all(self):
|
def pool_get_all(self):
|
||||||
LOG.debug("NEUTRON POOL GET")
|
|
||||||
resp = self.client.list_pools()
|
resp = self.client.list_pools()
|
||||||
return resp.get('pools')
|
return resp.get('pools')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user