summaryrefslogtreecommitdiffstats
path: root/sdnvpn/lib/utils.py
diff options
context:
space:
mode:
authorPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>2018-04-30 13:58:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-04-30 13:58:02 +0000
commit23ec5914be722401dcbc2ceb9f4be1491c150776 (patch)
treef4dc4ec138e5cf9cf8f662c87705e180b9396327 /sdnvpn/lib/utils.py
parentbe6cce375c0363f93fa6b1a099eb34fee75a6161 (diff)
parent84f2176cf1aa9d61889ca80aeb25dfd01d25d8a1 (diff)
Merge "Make sdnvpn logging proper" into stable/fraser
Diffstat (limited to 'sdnvpn/lib/utils.py')
-rw-r--r--sdnvpn/lib/utils.py58
1 files changed, 30 insertions, 28 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index ad8215c..aafd69b 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -7,7 +7,6 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
-import logging
import os
import time
import requests
@@ -19,8 +18,9 @@ from opnfv.deployment.factory import Factory as DeploymentFactory
from sdnvpn.lib import config as sdnvpn_config
import sdnvpn.lib.openstack_utils as os_utils
+from sdnvpn.lib import logutil
-logger = logging.getLogger('sdnvpn_test_utils')
+logger = logutil.getLogger('sdnvpn_test_utils')
common_config = sdnvpn_config.CommonConfig()
@@ -34,6 +34,7 @@ class ExtraRoute(object):
"""
Class to represent extra route for a router
"""
+
def __init__(self, destination, nexthop):
self.destination = destination
self.nexthop = nexthop
@@ -43,6 +44,7 @@ class AllowedAddressPair(object):
"""
Class to represent allowed address pair for a neutron port
"""
+
def __init__(self, ipaddress, macaddress):
self.ipaddress = ipaddress
self.macaddress = macaddress
@@ -638,9 +640,9 @@ def cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, interfaces,
if len(floatingip_ids) != 0:
for floatingip_id in floatingip_ids:
if not os_utils.delete_floating_ip(neutron_client, floatingip_id):
- logging.error('Fail to delete all floating ips. '
- 'Floating ip with id {} was not deleted.'.
- format(floatingip_id))
+ logger.error('Fail to delete all floating ips. '
+ 'Floating ip with id {} was not deleted.'.
+ format(floatingip_id))
return False
if len(bgpvpn_ids) != 0:
@@ -651,39 +653,39 @@ def cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, interfaces,
for router_id, subnet_id in interfaces:
if not os_utils.remove_interface_router(neutron_client,
router_id, subnet_id):
- logging.error('Fail to delete all interface routers. '
- 'Interface router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all interface routers. '
+ 'Interface router with id {} was not deleted.'.
+ format(router_id))
if len(router_ids) != 0:
for router_id in router_ids:
if not os_utils.remove_gateway_router(neutron_client, router_id):
- logging.error('Fail to delete all gateway routers. '
- 'Gateway router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all gateway routers. '
+ 'Gateway router with id {} was not deleted.'.
+ format(router_id))
if len(subnet_ids) != 0:
for subnet_id in subnet_ids:
if not os_utils.delete_neutron_subnet(neutron_client, subnet_id):
- logging.error('Fail to delete all subnets. '
- 'Subnet with id {} was not deleted.'.
- format(subnet_id))
+ logger.error('Fail to delete all subnets. '
+ 'Subnet with id {} was not deleted.'.
+ format(subnet_id))
return False
if len(router_ids) != 0:
for router_id in router_ids:
if not os_utils.delete_neutron_router(neutron_client, router_id):
- logging.error('Fail to delete all routers. '
- 'Router with id {} was not deleted.'.
- format(router_id))
+ logger.error('Fail to delete all routers. '
+ 'Router with id {} was not deleted.'.
+ format(router_id))
return False
if len(network_ids) != 0:
for network_id in network_ids:
if not os_utils.delete_neutron_net(neutron_client, network_id):
- logging.error('Fail to delete all networks. '
- 'Network with id {} was not deleted.'.
- format(network_id))
+ logger.error('Fail to delete all networks. '
+ 'Network with id {} was not deleted.'.
+ format(network_id))
return False
return True
@@ -695,9 +697,9 @@ def cleanup_nova(nova_client, instance_ids, flavor_ids=None):
if len(instance_ids) != 0:
for instance_id in instance_ids:
if not os_utils.delete_instance(nova_client, instance_id):
- logging.error('Fail to delete all instances. '
- 'Instance with id {} was not deleted.'.
- format(instance_id))
+ logger.error('Fail to delete all instances. '
+ 'Instance with id {} was not deleted.'.
+ format(instance_id))
return False
return True
@@ -706,9 +708,9 @@ def cleanup_glance(glance_client, image_ids):
if len(image_ids) != 0:
for image_id in image_ids:
if not os_utils.delete_glance_image(glance_client, image_id):
- logging.error('Fail to delete all images. '
- 'Image with id {} was not deleted.'.
- format(image_id))
+ logger.error('Fail to delete all images. '
+ 'Image with id {} was not deleted.'.
+ format(image_id))
return False
return True
@@ -779,8 +781,8 @@ def is_fail_mode_secure():
is_secure[openstack_node.name] = True
else:
# failure
- logging.error('The fail_mode for br-int was not secure '
- 'in {} node'.format(openstack_node.name))
+ logger.error('The fail_mode for br-int was not secure '
+ 'in {} node'.format(openstack_node.name))
is_secure[openstack_node.name] = False
return is_secure