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:
Pradeep Kilambi 2014-07-22 09:30:39 -07:00
parent daf92b6bf4
commit 2630e7a7eb
6 changed files with 35 additions and 42 deletions

View File

@ -46,6 +46,4 @@ class BaseServicesPollster(plugin.PollsterBase):
@staticmethod
def get_status_id(value):
status = value.lower()
if status not in STATUS:
return -1
return STATUS[status]
return STATUS.get(status, -1)

View File

@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2014 Cisco Systems, Inc
# Copyright (c) 2014 Cisco Systems, Inc
#
# Author:Pradeep Kilambi <pkilambi@cisco.com>
#
@ -29,9 +28,6 @@ class _BaseServicesDiscovery(plugin.DiscoveryBase):
class LBPoolsDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(LBPoolsDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -42,9 +38,6 @@ class LBPoolsDiscovery(_BaseServicesDiscovery):
class LBVipsDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(LBVipsDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -55,9 +48,6 @@ class LBVipsDiscovery(_BaseServicesDiscovery):
class LBMembersDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(LBMembersDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -68,9 +58,6 @@ class LBMembersDiscovery(_BaseServicesDiscovery):
class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(LBHealthMonitorsDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -80,9 +67,6 @@ class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
class VPNServicesDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(VPNServicesDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -93,9 +77,6 @@ class VPNServicesDiscovery(_BaseServicesDiscovery):
class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(IPSecConnectionsDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -105,9 +86,6 @@ class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
class FirewallDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(FirewallDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""
@ -118,9 +96,6 @@ class FirewallDiscovery(_BaseServicesDiscovery):
class FirewallPolicyDiscovery(_BaseServicesDiscovery):
def __init__(self):
super(FirewallPolicyDiscovery, self).__init__()
def discover(self, param=None):
"""Discover resources to monitor."""

View File

@ -16,6 +16,7 @@
# under the License.
from ceilometer.network.services import base
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
@ -34,13 +35,16 @@ class FirewallPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for fw in resources:
LOG.debug("Firewall : %s" % fw)
status = self.get_status_id(fw['status'])
if status == -1:
# unknown status, skip this sample
LOG.warn("Unknown status %s received on firewall %s, "
"skipping sample" % (fw['status'], fw['id']))
LOG.warn(_("Unknown status %(stat)s received on fw %(id)s,"
"skipping sample") % {'stat': fw['status'],
'id': fw['id']})
continue
yield sample.Sample(
@ -57,7 +61,7 @@ class FirewallPollster(base.BaseServicesPollster):
class FirewallPolicyPollster(base.BaseServicesPollster):
"""Pollster to capture firewalls status samples."""
"""Pollster to capture firewall policy samples."""
FIELDS = ['name',
'description',
@ -68,6 +72,8 @@ class FirewallPolicyPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for fw in resources:
LOG.debug("Firewall Policy: %s" % fw)

View File

@ -49,13 +49,16 @@ class LBPoolPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for pool in resources:
LOG.debug("Load Balancer Pool : %s" % pool)
status = self.get_status_id(pool['status'])
if status == -1:
# unknown status, skip this sample
LOG.warn("Unknown status %s received on pool %s, "
"skipping sample" % (pool['status'], pool['id']))
LOG.warn(_("Unknown status %(stat)s received on pool %(id)s, "
"skipping sample") % {'stat': pool['status'],
'id': pool['id']})
continue
yield sample.Sample(
@ -90,13 +93,16 @@ class LBVipPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for vip in resources:
LOG.debug("Load Balancer Vip : %s" % vip)
status = self.get_status_id(vip['status'])
if status == -1:
# unknown status, skip this sample
LOG.warn("Unknown status %s received on vip %s, "
"skipping sample" % (vip['status'], vip['id']))
LOG.warn(_("Unknown status %(stat)s received on vip %(id)s, "
"skipping sample") % {'stat': vip['status'],
'id': vip['id']})
continue
yield sample.Sample(
@ -125,12 +131,15 @@ class LBMemberPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for member in resources:
LOG.debug("Load Balancer Member : %s" % member)
status = self.get_status_id(member['status'])
if status == -1:
LOG.warn("Unknown status %s received on member %s, "
"skipping sample" % (member['status'], member['id']))
LOG.warn(_("Unknown status %(stat)s received on member %(id)s,"
"skipping sample") % {'stat': member['status'],
'id': member['id']})
continue
yield sample.Sample(
name='network.services.lb.member',

View File

@ -16,6 +16,7 @@
# under the License.
from ceilometer.network.services import base
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
from ceilometer import sample
@ -35,13 +36,16 @@ class VPNServicesPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for vpn in resources:
LOG.debug("VPN : %s" % vpn)
status = self.get_status_id(vpn['status'])
if status == -1:
# unknown status, skip this sample
LOG.warn("Unknown status %s received on vpn %s, "
"skipping sample" % (vpn['status'], vpn['id']))
LOG.warn(_("Unknown status %(stat)s received on vpn %(id)s,"
"skipping sample") % {'stat': vpn['status'],
'id': vpn['id']})
continue
yield sample.Sample(
@ -58,7 +62,7 @@ class VPNServicesPollster(base.BaseServicesPollster):
class IPSecConnectionsPollster(base.BaseServicesPollster):
"""Pollster to capture VPN status samples."""
"""Pollster to capture vpn ipsec connections status samples."""
FIELDS = ['name',
'description',
@ -77,6 +81,8 @@ class IPSecConnectionsPollster(base.BaseServicesPollster):
]
def get_samples(self, manager, cache, resources=None):
resources = resources or []
for conn in resources:
LOG.debug("IPSec Connection Info: %s" % conn)

View File

@ -79,7 +79,6 @@ class Client(object):
@logged
def pool_get_all(self):
LOG.debug("NEUTRON POOL GET")
resp = self.client.list_pools()
return resp.get('pools')