setup logger name of NeutronCommand automatically

It is a common pattern to add
class XXXCommand(NeutronCommand):
    log = logging.getLogger(__name__ + '.<command name>').
So introduce a metaclass to do that automatically in order to simplify
the code a bit.

Change-Id: I7febdcd806eb2da51781a5866cc5fac5422b1721
This commit is contained in:
Isaku Yamahata 2013-11-26 16:01:29 +09:00
parent 872ab5e336
commit e8debf8d55
31 changed files with 59 additions and 220 deletions

@ -16,6 +16,7 @@
from __future__ import print_function
import abc
import argparse
import logging
import re
@ -23,6 +24,7 @@ import re
from cliff.formatters import table
from cliff import lister
from cliff import show
import six
from neutronclient.common import command
from neutronclient.common import exceptions
@ -335,9 +337,22 @@ class TableFormater(table.TableFormatter):
stdout.write('\n')
# command.OpenStackCommand is abstract class so that metaclass of
# subclass must be subclass of metaclass of all its base.
# otherwise metaclass conflict exception is raised.
class NeutronCommandMeta(abc.ABCMeta):
def __new__(cls, name, bases, cls_dict):
if 'log' not in cls_dict:
cls_dict['log'] = logging.getLogger(
cls_dict['__module__'] + '.' + name)
return super(NeutronCommandMeta, cls).__new__(cls,
name, bases, cls_dict)
@six.add_metaclass(NeutronCommandMeta)
class NeutronCommand(command.OpenStackCommand):
api = 'network'
log = logging.getLogger(__name__ + '.NeutronCommand')
values_specs = []
json_indent = None

@ -14,8 +14,6 @@
# under the License.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
@ -30,7 +28,6 @@ class ListAgent(neutronV20.ListCommand):
"""List agents."""
resource = 'agent'
log = logging.getLogger(__name__ + '.ListAgent')
list_columns = ['id', 'agent_type', 'host', 'alive', 'admin_state_up',
'binary']
_formatters = {'heartbeat_timestamp': _format_timestamp}
@ -46,7 +43,6 @@ class ShowAgent(neutronV20.ShowCommand):
"""Show information of a given agent."""
resource = 'agent'
log = logging.getLogger(__name__ + '.ShowAgent')
allow_names = False
json_indent = 5
@ -54,7 +50,6 @@ class ShowAgent(neutronV20.ShowCommand):
class DeleteAgent(neutronV20.DeleteCommand):
"""Delete a given agent."""
log = logging.getLogger(__name__ + '.DeleteAgent')
resource = 'agent'
allow_names = False
@ -62,6 +57,5 @@ class DeleteAgent(neutronV20.DeleteCommand):
class UpdateAgent(neutronV20.UpdateCommand):
"""Update a given agent."""
log = logging.getLogger(__name__ + '.UpdateAgent')
resource = 'agent'
allow_names = False

@ -16,8 +16,6 @@
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import network
from neutronclient.neutron.v2_0 import router
@ -30,8 +28,6 @@ PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
class AddNetworkToDhcpAgent(neutronV20.NeutronCommand):
"""Add a network to a DHCP agent."""
log = logging.getLogger(__name__ + '.AddNetworkToDhcpAgent')
def get_parser(self, prog_name):
parser = super(AddNetworkToDhcpAgent, self).get_parser(prog_name)
parser.add_argument(
@ -56,7 +52,6 @@ class AddNetworkToDhcpAgent(neutronV20.NeutronCommand):
class RemoveNetworkFromDhcpAgent(neutronV20.NeutronCommand):
"""Remove a network from a DHCP agent."""
log = logging.getLogger(__name__ + '.RemoveNetworkFromDhcpAgent')
def get_parser(self, prog_name):
parser = super(RemoveNetworkFromDhcpAgent, self).get_parser(prog_name)
@ -83,7 +78,6 @@ class RemoveNetworkFromDhcpAgent(neutronV20.NeutronCommand):
class ListNetworksOnDhcpAgent(network.ListNetwork):
"""List the networks on a DHCP agent."""
log = logging.getLogger(__name__ + '.ListNetworksOnDhcpAgent')
unknown_parts_flag = False
def get_parser(self, prog_name):
@ -105,7 +99,6 @@ class ListDhcpAgentsHostingNetwork(neutronV20.ListCommand):
resource = 'agent'
_formatters = {}
log = logging.getLogger(__name__ + '.ListDhcpAgentsHostingNetwork')
list_columns = ['id', 'host', 'admin_state_up', 'alive']
unknown_parts_flag = False
@ -133,8 +126,6 @@ class ListDhcpAgentsHostingNetwork(neutronV20.ListCommand):
class AddRouterToL3Agent(neutronV20.NeutronCommand):
"""Add a router to a L3 agent."""
log = logging.getLogger(__name__ + '.AddRouterToL3Agent')
def get_parser(self, prog_name):
parser = super(AddRouterToL3Agent, self).get_parser(prog_name)
parser.add_argument(
@ -160,8 +151,6 @@ class AddRouterToL3Agent(neutronV20.NeutronCommand):
class RemoveRouterFromL3Agent(neutronV20.NeutronCommand):
"""Remove a router from a L3 agent."""
log = logging.getLogger(__name__ + '.RemoveRouterFromL3Agent')
def get_parser(self, prog_name):
parser = super(RemoveRouterFromL3Agent, self).get_parser(prog_name)
parser.add_argument(
@ -187,7 +176,6 @@ class RemoveRouterFromL3Agent(neutronV20.NeutronCommand):
class ListRoutersOnL3Agent(neutronV20.ListCommand):
"""List the routers on a L3 agent."""
log = logging.getLogger(__name__ + '.ListRoutersOnL3Agent')
_formatters = {'external_gateway_info':
router._format_external_gateway_info}
list_columns = ['id', 'name', 'external_gateway_info']
@ -213,7 +201,6 @@ class ListL3AgentsHostingRouter(neutronV20.ListCommand):
resource = 'agent'
_formatters = {}
log = logging.getLogger(__name__ + '.ListL3AgentsHostingRouter')
list_columns = ['id', 'host', 'admin_state_up', 'alive']
unknown_parts_flag = False
@ -240,7 +227,6 @@ class ListL3AgentsHostingRouter(neutronV20.ListCommand):
class ListPoolsOnLbaasAgent(neutronV20.ListCommand):
"""List the pools on a loadbalancer agent."""
log = logging.getLogger(__name__ + '.ListPoolsOnLbaasAgent')
list_columns = ['id', 'name', 'lb_method', 'protocol',
'admin_state_up', 'status']
resource = 'pool'
@ -267,7 +253,6 @@ class GetLbaasAgentHostingPool(neutronV20.ListCommand):
"""
resource = 'agent'
log = logging.getLogger(__name__ + '.GetLbaasAgentHostingPool')
list_columns = ['id', 'host', 'admin_state_up', 'alive']
unknown_parts_flag = False

@ -11,8 +11,6 @@
# under the License.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -21,7 +19,6 @@ class ListCredential(neutronV20.ListCommand):
"""List credentials that belong to a given tenant."""
resource = 'credential'
log = logging.getLogger(__name__ + '.ListCredential')
_formatters = {}
list_columns = ['credential_id', 'credential_name', 'user_name',
'password', 'type']
@ -31,7 +28,6 @@ class ShowCredential(neutronV20.ShowCommand):
"""Show information of a given credential."""
resource = 'credential'
log = logging.getLogger(__name__ + '.ShowCredential')
allow_names = False
@ -39,7 +35,6 @@ class CreateCredential(neutronV20.CreateCommand):
"""Creates a credential."""
resource = 'credential'
log = logging.getLogger(__name__ + '.CreateCredential')
def add_known_arguments(self, parser):
parser.add_argument(
@ -74,6 +69,5 @@ class CreateCredential(neutronV20.CreateCommand):
class DeleteCredential(neutronV20.DeleteCommand):
"""Delete a given credential."""
log = logging.getLogger(__name__ + '.DeleteCredential')
resource = 'credential'
allow_names = False

@ -14,8 +14,6 @@
# under the License.
#
import logging
from neutronclient.neutron import v2_0 as cmd_base
from neutronclient.openstack.common.gettextutils import _
@ -24,7 +22,6 @@ class ListExt(cmd_base.ListCommand):
"""List all extensions."""
resource = 'extension'
log = logging.getLogger(__name__ + '.ListExt')
list_columns = ['alias', 'name']
@ -32,7 +29,6 @@ class ShowExt(cmd_base.ShowCommand):
"""Show information of a given resource."""
resource = "extension"
log = logging.getLogger(__name__ + '.ShowExt')
allow_names = False
def get_parser(self, prog_name):

@ -17,7 +17,6 @@
from __future__ import print_function
import argparse
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -27,7 +26,6 @@ class ListFloatingIP(neutronV20.ListCommand):
"""List floating ips that belong to a given tenant."""
resource = 'floatingip'
log = logging.getLogger(__name__ + '.ListFloatingIP')
list_columns = ['id', 'fixed_ip_address', 'floating_ip_address',
'port_id']
pagination_support = True
@ -38,7 +36,6 @@ class ShowFloatingIP(neutronV20.ShowCommand):
"""Show information of a given floating ip."""
resource = 'floatingip'
log = logging.getLogger(__name__ + '.ShowFloatingIP')
allow_names = False
@ -46,7 +43,6 @@ class CreateFloatingIP(neutronV20.CreateCommand):
"""Create a floating ip for a given tenant."""
resource = 'floatingip'
log = logging.getLogger(__name__ + '.CreateFloatingIP')
def add_known_arguments(self, parser):
parser.add_argument(
@ -83,7 +79,6 @@ class CreateFloatingIP(neutronV20.CreateCommand):
class DeleteFloatingIP(neutronV20.DeleteCommand):
"""Delete a given floating ip."""
log = logging.getLogger(__name__ + '.DeleteFloatingIP')
resource = 'floatingip'
allow_names = False
@ -92,7 +87,6 @@ class AssociateFloatingIP(neutronV20.NeutronCommand):
"""Create a mapping between a floating ip and a fixed ip."""
api = 'network'
log = logging.getLogger(__name__ + '.AssociateFloatingIP')
resource = 'floatingip'
def get_parser(self, prog_name):
@ -133,7 +127,6 @@ class DisassociateFloatingIP(neutronV20.NeutronCommand):
"""
api = 'network'
log = logging.getLogger(__name__ + '.DisassociateFloatingIP')
resource = 'floatingip'
def get_parser(self, prog_name):

@ -17,7 +17,6 @@
#
import argparse
import logging
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.openstack.common.gettextutils import _
@ -27,7 +26,6 @@ class ListFirewall(neutronv20.ListCommand):
"""List firewalls that belong to a given tenant."""
resource = 'firewall'
log = logging.getLogger(__name__ + '.ListFirewall')
list_columns = ['id', 'name', 'firewall_policy_id']
_formatters = {}
pagination_support = True
@ -38,14 +36,12 @@ class ShowFirewall(neutronv20.ShowCommand):
"""Show information of a given firewall."""
resource = 'firewall'
log = logging.getLogger(__name__ + '.ShowFirewall')
class CreateFirewall(neutronv20.CreateCommand):
"""Create a firewall."""
resource = 'firewall'
log = logging.getLogger(__name__ + '.CreateFirewall')
def add_known_arguments(self, parser):
parser.add_argument(
@ -86,11 +82,9 @@ class UpdateFirewall(neutronv20.UpdateCommand):
"""Update a given firewall."""
resource = 'firewall'
log = logging.getLogger(__name__ + '.UpdateFirewall')
class DeleteFirewall(neutronv20.DeleteCommand):
"""Delete a given firewall."""
resource = 'firewall'
log = logging.getLogger(__name__ + '.DeleteFirewall')

@ -19,7 +19,6 @@
from __future__ import print_function
import argparse
import logging
import string
from neutronclient.neutron import v2_0 as neutronv20
@ -39,7 +38,6 @@ class ListFirewallPolicy(neutronv20.ListCommand):
"""List firewall policies that belong to a given tenant."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.ListFirewallPolicy')
list_columns = ['id', 'name', 'firewall_rules']
_formatters = {'firewall_rules': _format_firewall_rules,
}
@ -51,14 +49,12 @@ class ShowFirewallPolicy(neutronv20.ShowCommand):
"""Show information of a given firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.ShowFirewallPolicy')
class CreateFirewallPolicy(neutronv20.CreateCommand):
"""Create a firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.CreateFirewallPolicy')
def add_known_arguments(self, parser):
parser.add_argument(
@ -107,21 +103,18 @@ class UpdateFirewallPolicy(neutronv20.UpdateCommand):
"""Update a given firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.UpdateFirewallPolicy')
class DeleteFirewallPolicy(neutronv20.DeleteCommand):
"""Delete a given firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.DeleteFirewallPolicy')
class FirewallPolicyInsertRule(neutronv20.UpdateCommand):
"""Insert a rule into a given firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.FirewallPolicyInsertRule')
def call_api(self, neutron_client, firewall_policy_id, body):
return neutron_client.firewall_policy_insert_rule(firewall_policy_id,
@ -184,7 +177,6 @@ class FirewallPolicyRemoveRule(neutronv20.UpdateCommand):
"""Remove a rule from a given firewall policy."""
resource = 'firewall_policy'
log = logging.getLogger(__name__ + '.FirewallPolicyRemoveRule')
def call_api(self, neutron_client, firewall_policy_id, body):
return neutron_client.firewall_policy_remove_rule(firewall_policy_id,

@ -17,7 +17,6 @@
#
import argparse
import logging
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.openstack.common.gettextutils import _
@ -27,7 +26,6 @@ class ListFirewallRule(neutronv20.ListCommand):
"""List firewall rules that belong to a given tenant."""
resource = 'firewall_rule'
log = logging.getLogger(__name__ + '.ListFirewallRule')
list_columns = ['id', 'name', 'firewall_policy_id', 'summary', 'enabled']
pagination_support = True
sorting_support = True
@ -64,14 +62,12 @@ class ShowFirewallRule(neutronv20.ShowCommand):
"""Show information of a given firewall rule."""
resource = 'firewall_rule'
log = logging.getLogger(__name__ + '.ShowFirewallRule')
class CreateFirewallRule(neutronv20.CreateCommand):
"""Create a firewall rule."""
resource = 'firewall_rule'
log = logging.getLogger(__name__ + '.CreateFirewallRule')
def add_known_arguments(self, parser):
parser.add_argument(
@ -134,7 +130,6 @@ class UpdateFirewallRule(neutronv20.UpdateCommand):
"""Update a given firewall rule."""
resource = 'firewall_rule'
log = logging.getLogger(__name__ + '.UpdateFirewallRule')
def add_known_arguments(self, parser):
parser.add_argument(
@ -158,4 +153,3 @@ class DeleteFirewallRule(neutronv20.DeleteCommand):
"""Delete a given firewall rule."""
resource = 'firewall_rule'
log = logging.getLogger(__name__ + '.DeleteFirewallRule')

@ -18,8 +18,6 @@
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -28,7 +26,6 @@ class ListHealthMonitor(neutronV20.ListCommand):
"""List healthmonitors that belong to a given tenant."""
resource = 'health_monitor'
log = logging.getLogger(__name__ + '.ListHealthMonitor')
list_columns = ['id', 'type', 'admin_state_up']
pagination_support = True
sorting_support = True
@ -38,14 +35,12 @@ class ShowHealthMonitor(neutronV20.ShowCommand):
"""Show information of a given healthmonitor."""
resource = 'health_monitor'
log = logging.getLogger(__name__ + '.ShowHealthMonitor')
class CreateHealthMonitor(neutronV20.CreateCommand):
"""Create a healthmonitor."""
resource = 'health_monitor'
log = logging.getLogger(__name__ + '.CreateHealthMonitor')
def add_known_arguments(self, parser):
parser.add_argument(
@ -109,7 +104,6 @@ class UpdateHealthMonitor(neutronV20.UpdateCommand):
"""Update a given healthmonitor."""
resource = 'health_monitor'
log = logging.getLogger(__name__ + '.UpdateHealthMonitor')
allow_names = False
@ -117,13 +111,11 @@ class DeleteHealthMonitor(neutronV20.DeleteCommand):
"""Delete a given healthmonitor."""
resource = 'health_monitor'
log = logging.getLogger(__name__ + '.DeleteHealthMonitor')
class AssociateHealthMonitor(neutronV20.NeutronCommand):
"""Create a mapping between a health monitor and a pool."""
log = logging.getLogger(__name__ + '.AssociateHealthMonitor')
resource = 'health_monitor'
def get_parser(self, prog_name):
@ -151,7 +143,6 @@ class AssociateHealthMonitor(neutronV20.NeutronCommand):
class DisassociateHealthMonitor(neutronV20.NeutronCommand):
"""Remove a mapping from a health monitor to a pool."""
log = logging.getLogger(__name__ + '.DisassociateHealthMonitor')
resource = 'health_monitor'
def get_parser(self, prog_name):

@ -16,8 +16,6 @@
# @author: Ilya Shakhat, Mirantis Inc.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -26,7 +24,6 @@ class ListMember(neutronV20.ListCommand):
"""List members that belong to a given tenant."""
resource = 'member'
log = logging.getLogger(__name__ + '.ListMember')
list_columns = [
'id', 'address', 'protocol_port', 'weight', 'admin_state_up', 'status'
]
@ -38,14 +35,12 @@ class ShowMember(neutronV20.ShowCommand):
"""Show information of a given member."""
resource = 'member'
log = logging.getLogger(__name__ + '.ShowMember')
class CreateMember(neutronV20.CreateCommand):
"""Create a member."""
resource = 'member'
log = logging.getLogger(__name__ + '.CreateMember')
def add_known_arguments(self, parser):
parser.add_argument(
@ -89,11 +84,9 @@ class UpdateMember(neutronV20.UpdateCommand):
"""Update a given member."""
resource = 'member'
log = logging.getLogger(__name__ + '.UpdateMember')
class DeleteMember(neutronV20.DeleteCommand):
"""Delete a given member."""
resource = 'member'
log = logging.getLogger(__name__ + '.DeleteMember')

@ -16,8 +16,6 @@
# @author: Ilya Shakhat, Mirantis Inc.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -30,7 +28,6 @@ class ListPool(neutronV20.ListCommand):
"""List pools that belong to a given tenant."""
resource = 'pool'
log = logging.getLogger(__name__ + '.ListPool')
list_columns = ['id', 'name', 'provider', 'lb_method', 'protocol',
'admin_state_up', 'status']
_formatters = {'provider': _format_provider}
@ -42,14 +39,12 @@ class ShowPool(neutronV20.ShowCommand):
"""Show information of a given pool."""
resource = 'pool'
log = logging.getLogger(__name__ + '.ShowPool')
class CreatePool(neutronV20.CreateCommand):
"""Create a pool."""
resource = 'pool'
log = logging.getLogger(__name__ + '.CreatePool')
def add_known_arguments(self, parser):
parser.add_argument(
@ -102,21 +97,18 @@ class UpdatePool(neutronV20.UpdateCommand):
"""Update a given pool."""
resource = 'pool'
log = logging.getLogger(__name__ + '.UpdatePool')
class DeletePool(neutronV20.DeleteCommand):
"""Delete a given pool."""
resource = 'pool'
log = logging.getLogger(__name__ + '.DeletePool')
class RetrievePoolStats(neutronV20.ShowCommand):
"""Retrieve stats for a given pool."""
resource = 'pool'
log = logging.getLogger(__name__ + '.RetrievePoolStats')
def get_data(self, parsed_args):
self.log.debug('run(%s)' % parsed_args)

@ -16,8 +16,6 @@
# @author: Ilya Shakhat, Mirantis Inc.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -26,7 +24,6 @@ class ListVip(neutronV20.ListCommand):
"""List vips that belong to a given tenant."""
resource = 'vip'
log = logging.getLogger(__name__ + '.ListVip')
list_columns = ['id', 'name', 'algorithm', 'address', 'protocol',
'admin_state_up', 'status']
pagination_support = True
@ -37,14 +34,12 @@ class ShowVip(neutronV20.ShowCommand):
"""Show information of a given vip."""
resource = 'vip'
log = logging.getLogger(__name__ + '.ShowVip')
class CreateVip(neutronV20.CreateCommand):
"""Create a vip."""
resource = 'vip'
log = logging.getLogger(__name__ + '.CreateVip')
def add_known_arguments(self, parser):
parser.add_argument(
@ -106,11 +101,9 @@ class UpdateVip(neutronV20.UpdateCommand):
"""Update a given vip."""
resource = 'vip'
log = logging.getLogger(__name__ + '.UpdateVip')
class DeleteVip(neutronV20.DeleteCommand):
"""Delete a given vip."""
resource = 'vip'
log = logging.getLogger(__name__ + '.DeleteVip')

@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.openstack.common.gettextutils import _
@ -24,7 +22,6 @@ class ListMeteringLabel(neutronv20.ListCommand):
"""List metering labels that belong to a given tenant."""
resource = 'metering_label'
log = logging.getLogger(__name__ + '.ListMeteringLabel')
list_columns = ['id', 'name', 'description', 'shared']
pagination_support = True
sorting_support = True
@ -34,7 +31,6 @@ class ShowMeteringLabel(neutronv20.ShowCommand):
"""Show information of a given metering label."""
resource = 'metering_label'
log = logging.getLogger(__name__ + '.ShowMeteringLabel')
allow_names = True
@ -42,7 +38,6 @@ class CreateMeteringLabel(neutronv20.CreateCommand):
"""Create a metering label for a given tenant."""
resource = 'metering_label'
log = logging.getLogger(__name__ + '.CreateMeteringLabel')
def add_known_arguments(self, parser):
parser.add_argument(
@ -74,7 +69,6 @@ class CreateMeteringLabel(neutronv20.CreateCommand):
class DeleteMeteringLabel(neutronv20.DeleteCommand):
"""Delete a given metering label."""
log = logging.getLogger(__name__ + '.DeleteMeteringLabel')
resource = 'metering_label'
allow_names = True
@ -83,7 +77,6 @@ class ListMeteringLabelRule(neutronv20.ListCommand):
"""List metering labels that belong to a given label."""
resource = 'metering_label_rule'
log = logging.getLogger(__name__ + '.ListMeteringLabelRule')
list_columns = ['id', 'excluded', 'direction', 'remote_ip_prefix']
pagination_support = True
sorting_support = True
@ -93,14 +86,12 @@ class ShowMeteringLabelRule(neutronv20.ShowCommand):
"""Show information of a given metering label rule."""
resource = 'metering_label_rule'
log = logging.getLogger(__name__ + '.ShowMeteringLabelRule')
class CreateMeteringLabelRule(neutronv20.CreateCommand):
"""Create a metering label rule for a given label."""
resource = 'metering_label_rule'
log = logging.getLogger(__name__ + '.CreateMeteringLabelRule')
def add_known_arguments(self, parser):
parser.add_argument(
@ -141,5 +132,4 @@ class CreateMeteringLabelRule(neutronv20.CreateCommand):
class DeleteMeteringLabelRule(neutronv20.DeleteCommand):
"""Delete a given metering label."""
log = logging.getLogger(__name__ + '.DeleteMeteringLabelRule')
resource = 'metering_label_rule'

@ -14,8 +14,6 @@
#
# @author: Ronak Shah, Nuage Networks, Alcatel-Lucent USA Inc.
import logging
from neutronclient.neutron.v2_0 import CreateCommand
from neutronclient.neutron.v2_0 import DeleteCommand
from neutronclient.neutron.v2_0 import ListCommand
@ -25,7 +23,6 @@ from neutronclient.neutron.v2_0 import ShowCommand
class ListNetPartition(ListCommand):
"""List netpartitions that belong to a given tenant."""
resource = 'net_partition'
log = logging.getLogger(__name__ + '.ListNetPartition')
list_columns = ['id', 'name']
@ -33,14 +30,12 @@ class ShowNetPartition(ShowCommand):
"""Show information of a given netpartition."""
resource = 'net_partition'
log = logging.getLogger(__name__ + '.ShowNetPartition')
class CreateNetPartition(CreateCommand):
"""Create a netpartition for a given tenant."""
resource = 'net_partition'
log = logging.getLogger(__name__ + '.CreateNetPartition')
def add_known_arguments(self, parser):
parser.add_argument(
@ -56,4 +51,3 @@ class DeleteNetPartition(DeleteCommand):
"""Delete a given netpartition."""
resource = 'net_partition'
log = logging.getLogger(__name__ + '.DeleteNetPartition')

@ -15,7 +15,6 @@
#
import argparse
import logging
from neutronclient.common import exceptions
from neutronclient.neutron import v2_0 as neutronV20
@ -37,7 +36,6 @@ class ListNetwork(neutronV20.ListCommand):
# id=<uuid>& (with len(uuid)=36)
subnet_id_filter_len = 40
resource = 'network'
log = logging.getLogger(__name__ + '.ListNetwork')
_formatters = {'subnets': _format_subnets, }
list_columns = ['id', 'name', 'subnets']
pagination_support = True
@ -86,7 +84,6 @@ class ListNetwork(neutronV20.ListCommand):
class ListExternalNetwork(ListNetwork):
"""List external networks that belong to a given tenant."""
log = logging.getLogger(__name__ + '.ListExternalNetwork')
pagination_support = True
sorting_support = True
@ -101,14 +98,12 @@ class ShowNetwork(neutronV20.ShowCommand):
"""Show information of a given network."""
resource = 'network'
log = logging.getLogger(__name__ + '.ShowNetwork')
class CreateNetwork(neutronV20.CreateCommand):
"""Create a network for a given tenant."""
resource = 'network'
log = logging.getLogger(__name__ + '.CreateNetwork')
def add_known_arguments(self, parser):
parser.add_argument(
@ -140,12 +135,10 @@ class CreateNetwork(neutronV20.CreateCommand):
class DeleteNetwork(neutronV20.DeleteCommand):
"""Delete a given network."""
log = logging.getLogger(__name__ + '.DeleteNetwork')
resource = 'network'
class UpdateNetwork(neutronV20.UpdateCommand):
"""Update network's information."""
log = logging.getLogger(__name__ + '.UpdateNetwork')
resource = 'network'

@ -16,8 +16,6 @@
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import parse_args_to_dict
from neutronclient.openstack.common.gettextutils import _
@ -30,7 +28,6 @@ class ListNetworkProfile(neutronV20.ListCommand):
"""List network profiles that belong to a given tenant."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.ListNetworkProfile')
_formatters = {}
list_columns = ['id', 'name', 'segment_type', 'sub_type', 'segment_range',
'physical_network', 'multicast_ip_index',
@ -41,7 +38,6 @@ class ShowNetworkProfile(neutronV20.ShowCommand):
"""Show information of a given network profile."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.ShowNetworkProfile')
allow_names = True
@ -49,7 +45,6 @@ class CreateNetworkProfile(neutronV20.CreateCommand):
"""Creates a network profile."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.CreateNetworkProfile')
def add_known_arguments(self, parser):
parser.add_argument('name',
@ -97,7 +92,6 @@ class CreateNetworkProfile(neutronV20.CreateCommand):
class DeleteNetworkProfile(neutronV20.DeleteCommand):
"""Delete a given network profile."""
log = logging.getLogger(__name__ + '.DeleteNetworkProfile')
resource = RESOURCE
allow_names = True
@ -106,13 +100,11 @@ class UpdateNetworkProfile(neutronV20.UpdateCommand):
"""Update network profile's information."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.UpdateNetworkProfile')
class UpdateNetworkProfileV2(neutronV20.NeutronCommand):
api = 'network'
log = logging.getLogger(__name__ + '.UpdateNetworkProfileV2')
resource = RESOURCE
def get_parser(self, prog_name):

@ -16,8 +16,6 @@
from __future__ import print_function
import logging
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -41,7 +39,6 @@ class ListGatewayDevice(neutronV20.ListCommand):
"""List network gateway devices for a given tenant."""
resource = DEV_RESOURCE
log = logging.getLogger(__name__ + '.ListGatewayDevice')
list_columns = ['id', 'name']
@ -49,7 +46,6 @@ class ShowGatewayDevice(neutronV20.ShowCommand):
"""Show information for a given network gateway device."""
resource = DEV_RESOURCE
log = logging.getLogger(__name__ + '.ShowGatewayDevice')
def read_cert_file(cert_file):
@ -80,7 +76,6 @@ class CreateGatewayDevice(neutronV20.CreateCommand):
"""Create a network gateway device."""
resource = DEV_RESOURCE
log = logging.getLogger(__name__ + '.CreateGatewayDevice')
def add_known_arguments(self, parser):
parser.add_argument(
@ -114,7 +109,6 @@ class UpdateGatewayDevice(neutronV20.UpdateCommand):
"""Update a network gateway device."""
resource = DEV_RESOURCE
log = logging.getLogger(__name__ + '.UpdateGatewayDevice')
def add_known_arguments(self, parser):
parser.add_argument(
@ -147,14 +141,12 @@ class DeleteGatewayDevice(neutronV20.DeleteCommand):
"""Delete a given network gateway device."""
resource = DEV_RESOURCE
log = logging.getLogger(__name__ + '.DeleteGatewayDevice')
class ListNetworkGateway(neutronV20.ListCommand):
"""List network gateways for a given tenant."""
resource = GW_RESOURCE
log = logging.getLogger(__name__ + '.ListNetworkGateway')
list_columns = ['id', 'name']
@ -162,14 +154,12 @@ class ShowNetworkGateway(neutronV20.ShowCommand):
"""Show information of a given network gateway."""
resource = GW_RESOURCE
log = logging.getLogger(__name__ + '.ShowNetworkGateway')
class CreateNetworkGateway(neutronV20.CreateCommand):
"""Create a network gateway."""
resource = GW_RESOURCE
log = logging.getLogger(__name__ + '.CreateNetworkGateway')
def add_known_arguments(self, parser):
parser.add_argument(
@ -199,14 +189,12 @@ class DeleteNetworkGateway(neutronV20.DeleteCommand):
"""Delete a given network gateway."""
resource = GW_RESOURCE
log = logging.getLogger(__name__ + '.DeleteNetworkGateway')
class UpdateNetworkGateway(neutronV20.UpdateCommand):
"""Update the name for a network gateway."""
resource = GW_RESOURCE
log = logging.getLogger(__name__ + '.UpdateNetworkGateway')
class NetworkGatewayInterfaceCommand(neutronV20.NeutronCommand):
@ -244,8 +232,6 @@ class NetworkGatewayInterfaceCommand(neutronV20.NeutronCommand):
class ConnectNetworkGateway(NetworkGatewayInterfaceCommand):
"""Add an internal network interface to a router."""
log = logging.getLogger(__name__ + '.ConnectNetworkGateway')
def run(self, parsed_args):
self.log.debug('run(%s)' % parsed_args)
neutron_client = self.get_client()
@ -265,8 +251,6 @@ class ConnectNetworkGateway(NetworkGatewayInterfaceCommand):
class DisconnectNetworkGateway(NetworkGatewayInterfaceCommand):
"""Remove a network from a network gateway."""
log = logging.getLogger(__name__ + '.DisconnectNetworkGateway')
def run(self, parsed_args):
self.log.debug('run(%s)' % parsed_args)
neutron_client = self.get_client()

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -23,7 +21,6 @@ class ListQoSQueue(neutronV20.ListCommand):
"""List queues that belong to a given tenant."""
resource = 'qos_queue'
log = logging.getLogger(__name__ + '.ListQoSQueue')
list_columns = ['id', 'name', 'min', 'max',
'qos_marking', 'dscp', 'default']
@ -32,7 +29,6 @@ class ShowQoSQueue(neutronV20.ShowCommand):
"""Show information of a given queue."""
resource = 'qos_queue'
log = logging.getLogger(__name__ + '.ShowQoSQueue')
allow_names = True
@ -40,7 +36,6 @@ class CreateQoSQueue(neutronV20.CreateCommand):
"""Create a queue."""
resource = 'qos_queue'
log = logging.getLogger(__name__ + '.CreateQoSQueue')
def add_known_arguments(self, parser):
parser.add_argument(
@ -83,6 +78,5 @@ class CreateQoSQueue(neutronV20.CreateCommand):
class DeleteQoSQueue(neutronV20.DeleteCommand):
"""Delete a given queue."""
log = logging.getLogger(__name__ + '.DeleteQoSQueue')
resource = 'qos_queue'
allow_names = True

@ -15,8 +15,6 @@
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import parse_args_to_dict
from neutronclient.openstack.common.gettextutils import _
@ -28,7 +26,6 @@ class ListPolicyProfile(neutronV20.ListCommand):
"""List policy profiles that belong to a given tenant."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.ListProfile')
_formatters = {}
list_columns = ['id', 'name']
@ -37,7 +34,6 @@ class ShowPolicyProfile(neutronV20.ShowCommand):
"""Show information of a given policy profile."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.ShowProfile')
allow_names = True
@ -45,14 +41,12 @@ class UpdatePolicyProfile(neutronV20.UpdateCommand):
"""Update policy profile's information."""
resource = RESOURCE
log = logging.getLogger(__name__ + '.UpdatePolicyProfile')
class UpdatePolicyProfileV2(neutronV20.UpdateCommand):
"""Update policy profile's information."""
api = 'network'
log = logging.getLogger(__name__ + '.UpdatePolicyProfileV2')
resource = RESOURCE
def get_parser(self, prog_name):

@ -15,7 +15,6 @@
#
import argparse
import logging
from neutronclient.common import exceptions
from neutronclient.common import utils
@ -34,7 +33,6 @@ class ListPort(neutronV20.ListCommand):
"""List ports that belong to a given tenant."""
resource = 'port'
log = logging.getLogger(__name__ + '.ListPort')
_formatters = {'fixed_ips': _format_fixed_ips, }
list_columns = ['id', 'name', 'mac_address', 'fixed_ips']
pagination_support = True
@ -45,7 +43,6 @@ class ListRouterPort(neutronV20.ListCommand):
"""List ports that belong to a given tenant, with specified router."""
resource = 'port'
log = logging.getLogger(__name__ + '.ListRouterPort')
_formatters = {'fixed_ips': _format_fixed_ips, }
list_columns = ['id', 'name', 'mac_address', 'fixed_ips']
pagination_support = True
@ -71,7 +68,6 @@ class ShowPort(neutronV20.ShowCommand):
"""Show information of a given port."""
resource = 'port'
log = logging.getLogger(__name__ + '.ShowPort')
class UpdatePortSecGroupMixin(object):
@ -144,7 +140,6 @@ class CreatePort(neutronV20.CreateCommand, UpdatePortSecGroupMixin,
"""Create a port for a given tenant."""
resource = 'port'
log = logging.getLogger(__name__ + '.CreatePort')
def add_known_arguments(self, parser):
parser.add_argument(
@ -224,7 +219,6 @@ class DeletePort(neutronV20.DeleteCommand):
"""Delete a given port."""
resource = 'port'
log = logging.getLogger(__name__ + '.DeletePort')
class UpdatePort(neutronV20.UpdateCommand, UpdatePortSecGroupMixin,
@ -232,7 +226,6 @@ class UpdatePort(neutronV20.UpdateCommand, UpdatePortSecGroupMixin,
"""Update port's information."""
resource = 'port'
log = logging.getLogger(__name__ + '.UpdatePort')
def add_known_arguments(self, parser):
self.add_arguments_secgroup(parser)

@ -17,7 +17,6 @@
from __future__ import print_function
import argparse
import logging
from cliff import lister
from cliff import show
@ -38,7 +37,6 @@ class DeleteQuota(neutronV20.NeutronCommand):
api = 'network'
resource = 'quota'
log = logging.getLogger(__name__ + '.DeleteQuota')
def get_parser(self, prog_name):
parser = super(DeleteQuota, self).get_parser(prog_name)
@ -71,7 +69,6 @@ class ListQuota(neutronV20.NeutronCommand, lister.Lister):
api = 'network'
resource = 'quota'
log = logging.getLogger(__name__ + '.ListQuota')
def get_parser(self, prog_name):
parser = super(ListQuota, self).get_parser(prog_name)
@ -101,7 +98,6 @@ class ShowQuota(neutronV20.NeutronCommand, show.ShowOne):
"""
api = 'network'
resource = "quota"
log = logging.getLogger(__name__ + '.ShowQuota')
def get_parser(self, prog_name):
parser = super(ShowQuota, self).get_parser(prog_name)
@ -146,7 +142,6 @@ class UpdateQuota(neutronV20.NeutronCommand, show.ShowOne):
"""Define tenant's quotas not to use defaults."""
resource = 'quota'
log = logging.getLogger(__name__ + '.UpdateQuota')
def get_parser(self, prog_name):
parser = super(UpdateQuota, self).get_parser(prog_name)

@ -17,7 +17,6 @@
from __future__ import print_function
import argparse
import logging
from neutronclient.common import exceptions
from neutronclient.common import utils
@ -36,7 +35,6 @@ class ListRouter(neutronV20.ListCommand):
"""List routers that belong to a given tenant."""
resource = 'router'
log = logging.getLogger(__name__ + '.ListRouter')
_formatters = {'external_gateway_info': _format_external_gateway_info, }
list_columns = ['id', 'name', 'external_gateway_info']
pagination_support = True
@ -47,14 +45,12 @@ class ShowRouter(neutronV20.ShowCommand):
"""Show information of a given router."""
resource = 'router'
log = logging.getLogger(__name__ + '.ShowRouter')
class CreateRouter(neutronV20.CreateCommand):
"""Create a router for a given tenant."""
resource = 'router'
log = logging.getLogger(__name__ + '.CreateRouter')
_formatters = {'external_gateway_info': _format_external_gateway_info, }
def add_known_arguments(self, parser):
@ -85,14 +81,12 @@ class CreateRouter(neutronV20.CreateCommand):
class DeleteRouter(neutronV20.DeleteCommand):
"""Delete a given router."""
log = logging.getLogger(__name__ + '.DeleteRouter')
resource = 'router'
class UpdateRouter(neutronV20.UpdateCommand):
"""Update router's information."""
log = logging.getLogger(__name__ + '.UpdateRouter')
resource = 'router'
@ -150,8 +144,6 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
class AddInterfaceRouter(RouterInterfaceCommand):
"""Add an internal network interface to a router."""
log = logging.getLogger(__name__ + '.AddInterfaceRouter')
def call_api(self, neutron_client, router_id, body):
return neutron_client.add_interface_router(router_id, body)
@ -163,8 +155,6 @@ class AddInterfaceRouter(RouterInterfaceCommand):
class RemoveInterfaceRouter(RouterInterfaceCommand):
"""Remove an internal network interface from a router."""
log = logging.getLogger(__name__ + '.RemoveInterfaceRouter')
def call_api(self, neutron_client, router_id, body):
return neutron_client.remove_interface_router(router_id, body)
@ -176,7 +166,6 @@ class RemoveInterfaceRouter(RouterInterfaceCommand):
class SetGatewayRouter(neutronV20.NeutronCommand):
"""Set the external network gateway for a router."""
log = logging.getLogger(__name__ + '.SetGatewayRouter')
api = 'network'
resource = 'router'
@ -212,7 +201,6 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
class RemoveGatewayRouter(neutronV20.NeutronCommand):
"""Remove an external network gateway from a router."""
log = logging.getLogger(__name__ + '.RemoveGatewayRouter')
api = 'network'
resource = 'router'

@ -15,7 +15,6 @@
#
import argparse
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.openstack.common.gettextutils import _
@ -25,7 +24,6 @@ class ListSecurityGroup(neutronV20.ListCommand):
"""List security groups that belong to a given tenant."""
resource = 'security_group'
log = logging.getLogger(__name__ + '.ListSecurityGroup')
list_columns = ['id', 'name', 'description']
pagination_support = True
sorting_support = True
@ -35,7 +33,6 @@ class ShowSecurityGroup(neutronV20.ShowCommand):
"""Show information of a given security group."""
resource = 'security_group'
log = logging.getLogger(__name__ + '.ShowSecurityGroup')
allow_names = True
@ -43,7 +40,6 @@ class CreateSecurityGroup(neutronV20.CreateCommand):
"""Create a security group."""
resource = 'security_group'
log = logging.getLogger(__name__ + '.CreateSecurityGroup')
def add_known_arguments(self, parser):
parser.add_argument(
@ -67,7 +63,6 @@ class CreateSecurityGroup(neutronV20.CreateCommand):
class DeleteSecurityGroup(neutronV20.DeleteCommand):
"""Delete a given security group."""
log = logging.getLogger(__name__ + '.DeleteSecurityGroup')
resource = 'security_group'
allow_names = True
@ -75,7 +70,6 @@ class DeleteSecurityGroup(neutronV20.DeleteCommand):
class UpdateSecurityGroup(neutronV20.UpdateCommand):
"""Update a given security group."""
log = logging.getLogger(__name__ + '.UpdateSecurityGroup')
resource = 'security_group'
def add_known_arguments(self, parser):
@ -101,7 +95,6 @@ class ListSecurityGroupRule(neutronV20.ListCommand):
"""List security group rules that belong to a given tenant."""
resource = 'security_group_rule'
log = logging.getLogger(__name__ + '.ListSecurityGroupRule')
list_columns = ['id', 'security_group_id', 'direction', 'protocol',
'remote_ip_prefix', 'remote_group_id']
replace_rules = {'security_group_id': 'security_group',
@ -170,7 +163,6 @@ class ShowSecurityGroupRule(neutronV20.ShowCommand):
"""Show information of a given security group rule."""
resource = 'security_group_rule'
log = logging.getLogger(__name__ + '.ShowSecurityGroupRule')
allow_names = False
@ -178,7 +170,6 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand):
"""Create a security group rule."""
resource = 'security_group_rule'
log = logging.getLogger(__name__ + '.CreateSecurityGroupRule')
def add_known_arguments(self, parser):
parser.add_argument(
@ -254,6 +245,5 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand):
class DeleteSecurityGroupRule(neutronV20.DeleteCommand):
"""Delete a given security group rule."""
log = logging.getLogger(__name__ + '.DeleteSecurityGroupRule')
resource = 'security_group_rule'
allow_names = False

@ -14,8 +14,6 @@
# under the License.
#
import logging
from neutronclient.neutron import v2_0 as neutronV20
@ -23,7 +21,6 @@ class ListServiceProvider(neutronV20.ListCommand):
"""List service providers."""
resource = 'service_provider'
log = logging.getLogger(__name__ + '.ListServiceProviders')
list_columns = ['service_type', 'name', 'default']
_formatters = {}
pagination_support = True

@ -15,7 +15,6 @@
#
import argparse
import logging
from neutronclient.common import exceptions
from neutronclient.common import utils
@ -117,7 +116,6 @@ class ListSubnet(neutronV20.ListCommand):
"""List subnets that belong to a given tenant."""
resource = 'subnet'
log = logging.getLogger(__name__ + '.ListSubnet')
_formatters = {'allocation_pools': _format_allocation_pools,
'dns_nameservers': _format_dns_nameservers,
'host_routes': _format_host_routes, }
@ -130,14 +128,12 @@ class ShowSubnet(neutronV20.ShowCommand):
"""Show information of a given subnet."""
resource = 'subnet'
log = logging.getLogger(__name__ + '.ShowSubnet')
class CreateSubnet(neutronV20.CreateCommand):
"""Create a subnet for a given tenant."""
resource = 'subnet'
log = logging.getLogger(__name__ + '.CreateSubnet')
def add_known_arguments(self, parser):
add_updatable_arguments(parser)
@ -176,14 +172,12 @@ class DeleteSubnet(neutronV20.DeleteCommand):
"""Delete a given subnet."""
resource = 'subnet'
log = logging.getLogger(__name__ + '.DeleteSubnet')
class UpdateSubnet(neutronV20.UpdateCommand):
"""Update subnet's information."""
resource = 'subnet'
log = logging.getLogger(__name__ + '.UpdateSubnet')
def add_known_arguments(self, parser):
add_updatable_arguments(parser)

@ -16,8 +16,6 @@
# @author: Swaminathan Vasudevan, Hewlett-Packard.
#
import logging
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils
@ -28,7 +26,6 @@ class ListIKEPolicy(neutronv20.ListCommand):
"""List IKEPolicies that belong to a tenant."""
resource = 'ikepolicy'
log = logging.getLogger(__name__ + '.ListIKEPolicy')
list_columns = ['id', 'name', 'auth_algorithm',
'encryption_algorithm', 'ike_version', 'pfs']
_formatters = {}
@ -40,14 +37,12 @@ class ShowIKEPolicy(neutronv20.ShowCommand):
"""Show information of a given IKEPolicy."""
resource = 'ikepolicy'
log = logging.getLogger(__name__ + '.ShowIKEPolicy')
class CreateIKEPolicy(neutronv20.CreateCommand):
"""Create an IKEPolicy."""
resource = 'ikepolicy'
log = logging.getLogger(__name__ + '.CreateIKEPolicy')
def add_known_arguments(self, parser):
parser.add_argument(
@ -111,7 +106,6 @@ class UpdateIKEPolicy(neutronv20.UpdateCommand):
"""Update a given IKE Policy."""
resource = 'ikepolicy'
log = logging.getLogger(__name__ + '.UpdateIKEPolicy')
def add_known_arguments(self, parser):
parser.add_argument(
@ -134,4 +128,3 @@ class DeleteIKEPolicy(neutronv20.DeleteCommand):
"""Delete a given IKE Policy."""
resource = 'ikepolicy'
log = logging.getLogger(__name__ + '.DeleteIKEPolicy')

@ -16,8 +16,6 @@
# @author: Swaminathan Vasudevan, Hewlett-Packard.
#
import logging
from neutronclient.common import exceptions
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronv20
@ -37,7 +35,6 @@ class ListIPsecSiteConnection(neutronv20.ListCommand):
"""List IPsecSiteConnections that belong to a given tenant."""
resource = 'ipsec_site_connection'
log = logging.getLogger(__name__ + '.ListIPsecSiteConnection')
_formatters = {'peer_cidrs': _format_peer_cidrs}
list_columns = [
'id', 'name', 'peer_address', 'peer_cidrs', 'route_mode',
@ -50,13 +47,11 @@ class ShowIPsecSiteConnection(neutronv20.ShowCommand):
"""Show information of a given IPsecSiteConnection."""
resource = 'ipsec_site_connection'
log = logging.getLogger(__name__ + '.ShowIPsecSiteConnection')
class CreateIPsecSiteConnection(neutronv20.CreateCommand):
"""Create an IPsecSiteConnection."""
resource = 'ipsec_site_connection'
log = logging.getLogger(__name__ + '.CreateIPsecSiteConnection')
def add_known_arguments(self, parser):
parser.add_argument(
@ -165,7 +160,6 @@ class UpdateIPsecSiteConnection(neutronv20.UpdateCommand):
"""Update a given IPsecSiteConnection."""
resource = 'ipsec_site_connection'
log = logging.getLogger(__name__ + '.UpdateIPsecSiteConnection')
def add_known_arguments(self, parser):
@ -189,4 +183,3 @@ class DeleteIPsecSiteConnection(neutronv20.DeleteCommand):
"""Delete a given IPsecSiteConnection."""
resource = 'ipsec_site_connection'
log = logging.getLogger(__name__ + '.DeleteIPsecSiteConnection')

@ -15,8 +15,6 @@
#
# @author: Swaminathan Vasudevan, Hewlett-Packard.
import logging
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.neutron.v2_0.vpn import utils as vpn_utils
@ -27,7 +25,6 @@ class ListIPsecPolicy(neutronv20.ListCommand):
"""List ipsecpolicies that belongs to a given tenant connection."""
resource = 'ipsecpolicy'
log = logging.getLogger(__name__ + '.ListIPsecPolicy')
list_columns = ['id', 'name', 'auth_algorithm',
'encryption_algorithm', 'pfs']
_formatters = {}
@ -39,14 +36,12 @@ class ShowIPsecPolicy(neutronv20.ShowCommand):
"""Show information of a given ipsecpolicy."""
resource = 'ipsecpolicy'
log = logging.getLogger(__name__ + '.ShowIPsecPolicy')
class CreateIPsecPolicy(neutronv20.CreateCommand):
"""Create an ipsecpolicy."""
resource = 'ipsecpolicy'
log = logging.getLogger(__name__ + '.CreateIPsecPolicy')
def add_known_arguments(self, parser):
parser.add_argument(
@ -111,7 +106,6 @@ class UpdateIPsecPolicy(neutronv20.UpdateCommand):
"""Update a given ipsec policy."""
resource = 'ipsecpolicy'
log = logging.getLogger(__name__ + '.UpdateIPsecPolicy')
def add_known_arguments(self, parser):
parser.add_argument(
@ -134,4 +128,3 @@ class DeleteIPsecPolicy(neutronv20.DeleteCommand):
"""Delete a given ipsecpolicy."""
resource = 'ipsecpolicy'
log = logging.getLogger(__name__ + '.DeleteIPsecPolicy')

@ -16,8 +16,6 @@
# @author: Swaminathan Vasudevan, Hewlett-Packard.
#
import logging
from neutronclient.neutron import v2_0 as neutronv20
from neutronclient.openstack.common.gettextutils import _
@ -26,7 +24,6 @@ class ListVPNService(neutronv20.ListCommand):
"""List VPNService configurations that belong to a given tenant."""
resource = 'vpnservice'
log = logging.getLogger(__name__ + '.ListVPNService')
list_columns = [
'id', 'name', 'router_id', 'status'
]
@ -39,13 +36,11 @@ class ShowVPNService(neutronv20.ShowCommand):
"""Show information of a given VPNService."""
resource = 'vpnservice'
log = logging.getLogger(__name__ + '.ShowVPNService')
class CreateVPNService(neutronv20.CreateCommand):
"""Create a VPNService."""
resource = 'vpnservice'
log = logging.getLogger(__name__ + '.CreateVPNService')
def add_known_arguments(self, parser):
parser.add_argument(
@ -87,11 +82,9 @@ class UpdateVPNService(neutronv20.UpdateCommand):
"""Update a given VPNService."""
resource = 'vpnservice'
log = logging.getLogger(__name__ + '.UpdateVPNService')
class DeleteVPNService(neutronv20.DeleteCommand):
"""Delete a given VPNService."""
resource = 'vpnservice'
log = logging.getLogger(__name__ + '.DeleteVPNService')

@ -0,0 +1,43 @@
# Copyright 2013 Intel
# Copyright 2013 Isaku Yamahata <isaku.yamahata at intel com>
# <isaku.yamahata at gmail com>
# All Rights Reserved.
#
#
# 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.
#
# @author: Isaku Yamahata, Intel
import logging
import testtools
from testtools import helpers
from neutronclient.neutron import v2_0 as neutronV20
class TestCommandMeta(testtools.TestCase):
def test_neutron_command_meta_defines_log(self):
class FakeCommand(neutronV20.NeutronCommand):
pass
self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log'))
self.assertIsInstance(FakeCommand.log, logging.getLoggerClass())
self.assertEqual(FakeCommand.log.name, __name__ + ".FakeCommand")
def test_neutron_command_log_defined_explicitly(self):
class FakeCommand(neutronV20.NeutronCommand):
log = None
self.assertTrue(helpers.safe_hasattr(FakeCommand, 'log'))
self.assertIsNone(FakeCommand.log)