Merge "Fix pep8 errors in tacker code"

This commit is contained in:
Jenkins 2016-02-10 23:04:33 +00:00 committed by Gerrit Code Review
commit 814c9509e6
24 changed files with 90 additions and 89 deletions

View File

@ -92,7 +92,7 @@ def get_limit_and_marker(request):
def _get_pagination_max_limit(): def _get_pagination_max_limit():
max_limit = -1 max_limit = -1
if (cfg.CONF.pagination_max_limit.lower() != if (cfg.CONF.pagination_max_limit.lower() !=
constants.PAGINATION_INFINITE): constants.PAGINATION_INFINITE):
try: try:
max_limit = int(cfg.CONF.pagination_max_limit) max_limit = int(cfg.CONF.pagination_max_limit)
if max_limit == 0: if max_limit == 0:

View File

@ -127,9 +127,9 @@ class Controller(object):
context, context,
'%s:%s' % (self._plugin_handlers[self.SHOW], attr_name), '%s:%s' % (self._plugin_handlers[self.SHOW], attr_name),
data, data,
might_not_exist=True): might_not_exist=True):
# this attribute is visible, check next one # this attribute is visible, check next one
continue continue
# if the code reaches this point then either the policy check # if the code reaches this point then either the policy check
# failed or the attribute was not visible in the first place # failed or the attribute was not visible in the first place
attributes_to_exclude.append(attr_name) attributes_to_exclude.append(attr_name)
@ -535,10 +535,10 @@ class Controller(object):
for attr, attr_vals in attr_info.iteritems(): for attr, attr_vals in attr_info.iteritems():
if attr_vals['allow_post']: if attr_vals['allow_post']:
if ('default' not in attr_vals and if ('default' not in attr_vals and
attr not in res_dict): attr not in res_dict):
msg = _("Failed to parse request. Required " msg = _("Failed to parse request. Required "
"attribute '%s' not specified") % attr "attribute '%s' not specified") % attr
raise webob.exc.HTTPBadRequest(msg) raise webob.exc.HTTPBadRequest(msg)
res_dict[attr] = res_dict.get(attr, res_dict[attr] = res_dict.get(attr,
attr_vals.get('default')) attr_vals.get('default'))
else: else:
@ -553,7 +553,7 @@ class Controller(object):
for attr, attr_vals in attr_info.iteritems(): for attr, attr_vals in attr_info.iteritems():
if (attr not in res_dict or if (attr not in res_dict or
res_dict[attr] is attributes.ATTR_NOT_SPECIFIED): res_dict[attr] is attributes.ATTR_NOT_SPECIFIED):
continue continue
# Convert values if necessary # Convert values if necessary
if 'convert_to' in attr_vals: if 'convert_to' in attr_vals:

View File

@ -18,9 +18,9 @@ CONF = cfg.CONF
OPTS = [ OPTS = [
cfg.StrOpt('heat_uri', cfg.StrOpt('heat_uri',
default='http://localhost:8004/v1', default='http://localhost:8004/v1',
help=_("Heat service URI to create VNF resources" help=_("Heat service URI to create VNF resources"
"specified in the VNFD templates")), "specified in the VNFD templates")),
] ]
CONF.register_opts(OPTS, group='tacker_heat') CONF.register_opts(OPTS, group='tacker_heat')
@ -39,10 +39,10 @@ class OpenstackClients(object):
def _keystone_client(self): def _keystone_client(self):
return ks_client.Client( return ks_client.Client(
tenant_name=self.auth_tenant_name, tenant_name=self.auth_tenant_name,
username=self.auth_username, username=self.auth_username,
password=self.auth_password, password=self.auth_password,
auth_url=self.auth_url) auth_url=self.auth_url)
def _heat_client(self): def _heat_client(self):
tenant_id = self.auth_token['tenant_id'] tenant_id = self.auth_token['tenant_id']

View File

@ -52,8 +52,8 @@ def init(conf):
global TRANSPORT, NOTIFIER global TRANSPORT, NOTIFIER
exmods = get_allowed_exmods() exmods = get_allowed_exmods()
TRANSPORT = oslo_messaging.get_transport(conf, TRANSPORT = oslo_messaging.get_transport(conf,
allowed_remote_exmods=exmods, allowed_remote_exmods=exmods,
aliases=TRANSPORT_ALIASES) aliases=TRANSPORT_ALIASES)
NOTIFIER = oslo_messaging.Notifier(TRANSPORT) NOTIFIER = oslo_messaging.Notifier(TRANSPORT)

View File

@ -147,7 +147,7 @@ class CommonDbMixin(object):
def _apply_dict_extend_functions(self, resource_type, def _apply_dict_extend_functions(self, resource_type,
response, db_object): response, db_object):
for func in self._dict_extend_functions.get( for func in self._dict_extend_functions.get(
resource_type, []): resource_type, []):
args = (response, db_object) args = (response, db_object)
if isinstance(func, basestring): if isinstance(func, basestring):
func = getattr(self, func, None) func = getattr(self, func, None)

View File

@ -31,4 +31,4 @@ import sqlalchemy as sa
def upgrade(active_plugins=None, options=None): def upgrade(active_plugins=None, options=None):
op.alter_column('devicetemplateattributes', op.alter_column('devicetemplateattributes',
'value', type_=sa.TEXT(65535), nullable=True) 'value', type_=sa.TEXT(65535), nullable=True)

View File

@ -88,7 +88,7 @@ def validate_head_file(config):
head_path = os.path.join(script.versions, HEAD_FILENAME) head_path = os.path.join(script.versions, HEAD_FILENAME)
if (os.path.isfile(head_path) and if (os.path.isfile(head_path) and
open(head_path).read().strip() == script.get_current_head()): open(head_path).read().strip() == script.get_current_head()):
return return
else: else:
alembic_util.err(_('HEAD file does not match migration timeline head')) alembic_util.err(_('HEAD file does not match migration timeline head'))

View File

@ -323,8 +323,8 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
def _device_attribute_update_or_create( def _device_attribute_update_or_create(
self, context, device_id, key, value): self, context, device_id, key, value):
arg = (self._model_query(context, DeviceAttribute). arg = (self._model_query(context, DeviceAttribute).
filter(DeviceAttribute.device_id == device_id). filter(DeviceAttribute.device_id == device_id).
filter(DeviceAttribute.key == key).first()) filter(DeviceAttribute.key == key).first())
if arg: if arg:
arg.value = value arg.value = value
else: else:
@ -482,7 +482,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
def get_devices(self, context, filters=None, fields=None): def get_devices(self, context, filters=None, fields=None):
devices = self._get_collection(context, Device, self._make_device_dict, devices = self._get_collection(context, Device, self._make_device_dict,
filters=filters, fields=fields) filters=filters, fields=fields)
# Ugly hack to mask internaly used record # Ugly hack to mask internaly used record
return [device for device in devices return [device for device in devices
if uuidutils.is_uuid_like(device['id'])] if uuidutils.is_uuid_like(device['id'])]

View File

@ -62,8 +62,8 @@ class BaseTackerTest(base.TestCase):
tenant_name = cfg.CONF.keystone_authtoken.project_name tenant_name = cfg.CONF.keystone_authtoken.project_name
auth_uri = cfg.CONF.keystone_authtoken.auth_uri + '/v2.0' auth_uri = cfg.CONF.keystone_authtoken.auth_uri + '/v2.0'
return tacker_client.Client(username=username, password=password, return tacker_client.Client(username=username, password=password,
tenant_name=tenant_name, tenant_name=tenant_name,
auth_url=auth_uri) auth_url=auth_uri)
@classmethod @classmethod
def wait_until_vnf_status(cls, vnf_id, target_status, timeout, def wait_until_vnf_status(cls, vnf_id, target_status, timeout,
@ -72,8 +72,8 @@ class BaseTackerTest(base.TestCase):
while True: while True:
vnf_result = cls.client.show_vnf(vnf_id) vnf_result = cls.client.show_vnf(vnf_id)
status = vnf_result['vnf']['status'] status = vnf_result['vnf']['status']
if (status == target_status) or ((int(time.time()) - if (status == target_status) or (
start_time) > timeout): (int(time.time()) - start_time) > timeout):
break break
time.sleep(sleep_interval) time.sleep(sleep_interval)
@ -99,19 +99,22 @@ class BaseTackerTest(base.TestCase):
def verify_vnf_restart(self, vnfd_instance, vnf_instance): def verify_vnf_restart(self, vnfd_instance, vnf_instance):
vnf_id = vnf_instance['vnf']['id'] vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(vnf_id, vnf_current_status = self.wait_until_vnf_active(
constants.VNF_CIRROS_CREATE_TIMEOUT, vnf_id,
constants.ACTIVE_SLEEP_TIME) constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE') self.assertEqual(vnf_current_status, 'ACTIVE')
self.validate_vnf_instance(vnfd_instance, vnf_instance) self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url']) self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
vnf_current_status = self.wait_until_vnf_dead(vnf_id, vnf_current_status = self.wait_until_vnf_dead(
constants.VNF_CIRROS_DEAD_TIMEOUT, vnf_id,
constants.DEAD_SLEEP_TIME) constants.VNF_CIRROS_DEAD_TIMEOUT,
constants.DEAD_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'DEAD') self.assertEqual(vnf_current_status, 'DEAD')
vnf_current_status = self.wait_until_vnf_active(vnf_id, vnf_current_status = self.wait_until_vnf_active(
constants.VNF_CIRROS_CREATE_TIMEOUT, vnf_id,
constants.ACTIVE_SLEEP_TIME) constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE') self.assertEqual(vnf_current_status, 'ACTIVE')
self.validate_vnf_instance(vnfd_instance, vnf_instance) self.validate_vnf_instance(vnfd_instance, vnf_instance)

View File

@ -43,9 +43,10 @@ class VnfTestCreate(base.BaseTackerTest):
self.validate_vnf_instance(vnfd_instance, vnf_instance) self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id'] vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(vnf_id, vnf_current_status = self.wait_until_vnf_active(
constants.VNF_CIRROS_CREATE_TIMEOUT, vnf_id,
constants.ACTIVE_SLEEP_TIME) constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE') self.assertEqual(vnf_current_status, 'ACTIVE')
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url']) self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])

View File

@ -38,7 +38,7 @@ class VnfTestMultipleVDU(base.BaseTackerTest):
# Create vnf with vnfd_id # Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id'] vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
"test_vnf_with_multiple_vdus"}} "test_vnf_with_multiple_vdus"}}
vnf_instance = self.client.create_vnf(body=vnf_arg) vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance['vnf']['id'] vnf_id = vnf_instance['vnf']['id']

View File

@ -59,9 +59,10 @@ class VnfmTestParam(base.BaseTackerTest):
self.validate_vnf_instance(vnfd_instance, vnf_instance) self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id'] vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(vnf_id, vnf_current_status = self.wait_until_vnf_active(
constants.VNF_CIRROS_CREATE_TIMEOUT, vnf_id,
constants.ACTIVE_SLEEP_TIME) constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual('ACTIVE', vnf_current_status) self.assertEqual('ACTIVE', vnf_current_status)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url']) self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
vnf_instance = self.client.show_vnf(vnf_id) vnf_instance = self.client.show_vnf(vnf_id)
@ -93,7 +94,7 @@ class VnfmTestParam(base.BaseTackerTest):
def test_vnf_param(self): def test_vnf_param(self):
vnfd_instance = self._test_vnfd_create('sample_cirros_vnf_param.yaml') vnfd_instance = self._test_vnfd_create('sample_cirros_vnf_param.yaml')
vnf_instance = self._test_vnf_create(vnfd_instance, vnf_instance = self._test_vnf_create(vnfd_instance,
'test_vnf_with_parameters', 'test_vnf_with_parameters',
'sample_cirros_vnf_values.yaml') 'sample_cirros_vnf_values.yaml')
self._test_vnf_delete(vnf_instance) self._test_vnf_delete(vnf_instance)
self._test_vnfd_delete(vnfd_instance) self._test_vnfd_delete(vnfd_instance)

View File

@ -340,7 +340,7 @@ class RequestDeserializerTest(testtools.TestCase):
def test_deserialize(self): def test_deserialize(self):
"""Test RequestDeserializer.deserialize.""" """Test RequestDeserializer.deserialize."""
with mock.patch.object( with mock.patch.object(
self.deserializer, 'get_action_args') as mock_method: self.deserializer, 'get_action_args') as mock_method:
mock_method.return_value = {'action': 'create'} mock_method.return_value = {'action': 'create'}
request = wsgi.Request.blank('/') request = wsgi.Request.blank('/')
request.headers['Accept'] = 'application/xml' request.headers['Accept'] = 'application/xml'

View File

@ -44,7 +44,7 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
'mgmt_ip': 'a.b.c.d' 'mgmt_ip': 'a.b.c.d'
} }
monitor_return = self.monitor_http_ping.monitor_call(test_device, monitor_return = self.monitor_http_ping.monitor_call(test_device,
test_kwargs) test_kwargs)
self.assertEqual(monitor_return, 'failure') self.assertEqual(monitor_return, 'failure')
def test_monitor_url(self): def test_monitor_url(self):

View File

@ -31,10 +31,10 @@ class TestVNFMonitorPing(testtools.TestCase):
'mgmt_ip': 'a.b.c.d' 'mgmt_ip': 'a.b.c.d'
} }
mock_ping_cmd = ['ping', mock_ping_cmd = ['ping',
'-c', 5, '-c', 5,
'-W', 1, '-W', 1,
'-i', '0.2', '-i', '0.2',
'a.b.c.d'] 'a.b.c.d']
self.monitor_ping.monitor_call(test_device, self.monitor_ping.monitor_call(test_device,
test_kwargs) test_kwargs)
mock_utils_execute.assert_called_once_with(mock_ping_cmd, mock_utils_execute.assert_called_once_with(mock_ping_cmd,
@ -48,7 +48,7 @@ class TestVNFMonitorPing(testtools.TestCase):
'mgmt_ip': 'a.b.c.d' 'mgmt_ip': 'a.b.c.d'
} }
monitor_return = self.monitor_ping.monitor_call(test_device, monitor_return = self.monitor_ping.monitor_call(test_device,
test_kwargs) test_kwargs)
self.assertEqual(monitor_return, 'failure') self.assertEqual(monitor_return, 'failure')
def test_monitor_url(self): def test_monitor_url(self):

View File

@ -62,7 +62,7 @@ class TestVNFMonitor(testtools.TestCase):
'mgmt_url': '{"vdu1": "a.b.c.d"}', 'mgmt_url': '{"vdu1": "a.b.c.d"}',
'attributes': { 'attributes': {
'monitoring_policy': json.dumps( 'monitoring_policy': json.dumps(
MOCK_VNF_DEVICE['monitoring_policy']) MOCK_VNF_DEVICE['monitoring_policy'])
} }
} }
action_cb = mock.MagicMock() action_cb = mock.MagicMock()

View File

@ -259,7 +259,7 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
elif 'user_data' in vdu_dict or 'user_data_format' in vdu_dict: elif 'user_data' in vdu_dict or 'user_data_format' in vdu_dict:
raise vnfm.UserDataFormatNotFound() raise vnfm.UserDataFormatNotFound()
if ('placement_policy' in vdu_dict and if ('placement_policy' in vdu_dict and
'availability_zone' in vdu_dict['placement_policy']): 'availability_zone' in vdu_dict['placement_policy']):
properties['availability_zone'] = vdu_dict[ properties['availability_zone'] = vdu_dict[
'placement_policy']['availability_zone'] 'placement_policy']['availability_zone']
if 'config' in vdu_dict: if 'config' in vdu_dict:
@ -276,9 +276,10 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
# This should be removed after Mitaka # This should be removed after Mitaka
if monitoring_policy == 'ping' and failure_policy == 'respawn': if monitoring_policy == 'ping' and failure_policy == 'respawn':
vdu_dict['monitoring_policy'] = {'ping': { vdu_dict['monitoring_policy'] = {'ping': {
'actions': { 'actions':
'failure': 'respawn' {
}}} 'failure': 'respawn'
}}}
vdu_dict.pop('failure_policy') vdu_dict.pop('failure_policy')
if monitoring_policy != 'noop': if monitoring_policy != 'noop':
@ -294,7 +295,7 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
if monitoring_dict.keys(): if monitoring_dict.keys():
device['attributes']['monitoring_policy'] = jsonutils.dumps( device['attributes']['monitoring_policy'] = jsonutils.dumps(
monitoring_dict) monitoring_dict)
heat_template_yaml = yaml.dump(template_dict) heat_template_yaml = yaml.dump(template_dict)
fields['template'] = heat_template_yaml fields['template'] = heat_template_yaml

View File

@ -254,7 +254,7 @@ class DeviceNova(abstract_driver.DeviceAbstractDriver):
instance = nova.servers.get(device_id) instance = nova.servers.get(device_id)
except self._novaclient.exceptions.NotFound: except self._novaclient.exceptions.NotFound:
LOG.error(_LE("server %s is not found") % LOG.error(_LE("server %s is not found") %
device_id) device_id)
return return
instance.delete() instance.delete()
@ -280,7 +280,7 @@ class DeviceNova(abstract_driver.DeviceAbstractDriver):
instance = nova.servers.get(device_id) instance = nova.servers.get(device_id)
except self._novaclient.exceptions.NotFound: except self._novaclient.exceptions.NotFound:
LOG.error(_LE("server %s is not found") % LOG.error(_LE("server %s is not found") %
device_id) device_id)
return return
instance.interface_attach(port_id, None, None) instance.interface_attach(port_id, None, None)
@ -292,6 +292,6 @@ class DeviceNova(abstract_driver.DeviceAbstractDriver):
instance = nova.servers.get(device_id) instance = nova.servers.get(device_id)
except self._novaclient.exceptions.NotFound: except self._novaclient.exceptions.NotFound:
LOG.error(_LE("server %s is not found") % LOG.error(_LE("server %s is not found") %
device_id) device_id)
return return
instance.interface_detach(port_id) instance.interface_detach(port_id)

View File

@ -62,7 +62,7 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver):
@log.log @log.log
def mgmt_call(self, plugin, context, device, kwargs): def mgmt_call(self, plugin, context, device, kwargs):
if (kwargs[mgmt_constants.KEY_ACTION] != if (kwargs[mgmt_constants.KEY_ACTION] !=
mgmt_constants.ACTION_UPDATE_DEVICE): mgmt_constants.ACTION_UPDATE_DEVICE):
return return
dev_attrs = device.get('attributes', {}) dev_attrs = device.get('attributes', {})

View File

@ -114,15 +114,15 @@ class VNFMonitor(object):
hosting_vnf = self._hosting_vnfs.pop(device_id, None) hosting_vnf = self._hosting_vnfs.pop(device_id, None)
if hosting_vnf: if hosting_vnf:
LOG.debug('deleting device_id %(device_id)s, Mgmt IP %(ips)s', LOG.debug('deleting device_id %(device_id)s, Mgmt IP %(ips)s',
{'device_id': device_id, {'device_id': device_id,
'ips': hosting_vnf['management_ip_addresses']}) 'ips': hosting_vnf['management_ip_addresses']})
def run_monitor(self, hosting_vnf): def run_monitor(self, hosting_vnf):
mgmt_ips = hosting_vnf['management_ip_addresses'] mgmt_ips = hosting_vnf['management_ip_addresses']
vdupolicies = hosting_vnf['monitoring_policy']['vdus'] vdupolicies = hosting_vnf['monitoring_policy']['vdus']
vnf_delay = hosting_vnf['monitoring_policy'].get( vnf_delay = hosting_vnf['monitoring_policy'].get(
'monitoring_delay', self.boot_wait) 'monitoring_delay', self.boot_wait)
for vdu in vdupolicies.keys(): for vdu in vdupolicies.keys():
if hosting_vnf.get('dead'): if hosting_vnf.get('dead'):
@ -135,8 +135,8 @@ class VNFMonitor(object):
vdu_delay = params.get('monitoring_delay', vnf_delay) vdu_delay = params.get('monitoring_delay', vnf_delay)
if not timeutils.is_older_than( if not timeutils.is_older_than(
hosting_vnf['boot_at'], hosting_vnf['boot_at'],
vdu_delay): vdu_delay):
continue continue
actions = policy[driver].get('actions', {}) actions = policy[driver].get('actions', {})
@ -171,7 +171,7 @@ class VNFMonitor(object):
def monitor_call(self, driver, device_dict, kwargs): def monitor_call(self, driver, device_dict, kwargs):
return self._invoke(driver, return self._invoke(driver,
device=device_dict, kwargs=kwargs) device=device_dict, kwargs=kwargs)
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
@ -293,9 +293,9 @@ class ActionRespawnHeat(ActionPolicy):
# ungly hack to keep id unchanged # ungly hack to keep id unchanged
dead_device_id = device_id + '-DEAD-' + failure_count_str dead_device_id = device_id + '-DEAD-' + failure_count_str
LOG.debug(_('%(dead)s %(new)s %(cur)s'), LOG.debug(_('%(dead)s %(new)s %(cur)s'),
{'dead': dead_device_id, {'dead': dead_device_id,
'new': new_device_id, 'new': new_device_id,
'cur': device_id}) 'cur': device_id})
plugin.rename_device_id(context, device_id, dead_device_id) plugin.rename_device_id(context, device_id, dead_device_id)
plugin.rename_device_id(context, new_device_id, device_id) plugin.rename_device_id(context, new_device_id, device_id)
LOG.debug('Delete dead device') LOG.debug('Delete dead device')

View File

@ -58,10 +58,10 @@ class VNFMonitorPing(abstract_driver.VNFMonitorAbstractDriver):
:return: bool - True or string 'failure' depending on pingability. :return: bool - True or string 'failure' depending on pingability.
""" """
ping_cmd = ['ping', ping_cmd = ['ping',
'-c', count, '-c', count,
'-W', timeout, '-W', timeout,
'-i', interval, '-i', interval,
mgmt_ip] mgmt_ip]
try: try:
linux_utils.execute(ping_cmd, check_exit_code=True) linux_utils.execute(ping_cmd, check_exit_code=True)

View File

@ -47,7 +47,7 @@ class VNFMMgmtMixin(object):
'Hosting Device/logical service ' 'Hosting Device/logical service '
'instance tacker plugin will use')), 'instance tacker plugin will use')),
cfg.IntOpt('boot_wait', default=30, cfg.IntOpt('boot_wait', default=30,
help=_('Time interval to wait for VM to boot')), help=_('Time interval to wait for VM to boot')),
] ]
cfg.CONF.register_opts(OPTS, 'tacker') cfg.CONF.register_opts(OPTS, 'tacker')
@ -167,7 +167,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
if 'monitoring_policy' in dev_attrs and mgmt_url: if 'monitoring_policy' in dev_attrs and mgmt_url:
def action_cb(hosting_vnf_, action): def action_cb(hosting_vnf_, action):
action_cls = monitor.ActionPolicy.get_policy(action, action_cls = monitor.ActionPolicy.get_policy(action,
device_dict) device_dict)
if action_cls: if action_cls:
action_cls.execute_action(self, hosting_vnf['device']) action_cls.execute_action(self, hosting_vnf['device'])
@ -250,7 +250,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
if instance_id is None: if instance_id is None:
self._create_device_post(context, device_id, None, None, self._create_device_post(context, device_id, None, None,
device_dict) device_dict)
return return
device_dict['instance_id'] = instance_id device_dict['instance_id'] = instance_id

View File

@ -705,7 +705,7 @@ class XMLDeserializer(TextDeserializer):
parseError = False parseError = False
# Python2.7 # Python2.7
if (hasattr(etree, 'ParseError') and if (hasattr(etree, 'ParseError') and
isinstance(e, getattr(etree, 'ParseError'))): isinstance(e, getattr(etree, 'ParseError'))):
parseError = True parseError = True
# Python2.6 # Python2.6
elif isinstance(e, expat.ExpatError): elif isinstance(e, expat.ExpatError):
@ -752,9 +752,9 @@ class XMLDeserializer(TextDeserializer):
result = dict() result = dict()
for attr in node.keys(): for attr in node.keys():
if (attr == 'xmlns' or if (attr == 'xmlns' or
attr.startswith('xmlns:') or attr.startswith('xmlns:') or
attr == constants.XSI_ATTR or attr == constants.XSI_ATTR or
attr == constants.TYPE_ATTR): attr == constants.TYPE_ATTR):
continue continue
result[self._get_key(attr)] = node.get(attr) result[self._get_key(attr)] = node.get(attr)
children = list(node) children = list(node)

View File

@ -55,13 +55,8 @@ commands =
commands = {posargs} commands = {posargs}
[flake8] [flake8]
# E125 continuation line does not distinguish itself from next logical line
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent # E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line ignore = E128
# H302 import only modules
# H904 Wrap long lines in parentheses instead of a backslash
ignore = E125,E126,E128,E129,H302,H904
show-source = true show-source = true
builtins = _ builtins = _
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,.ropeproject exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,.ropeproject