Fix flake8 warning and error report
All the flake8 issues have been resolved with this commit. Change-Id: I637f82c484b3dbecc4827731a13f79c2ba2b9240 Closes-Bug: #1346759
This commit is contained in:
parent
229f843fbb
commit
8f6cb9fd23
@ -214,4 +214,4 @@ class PowerVCDriverTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected_ret_dic,
|
self.assertEqual(expected_ret_dic,
|
||||||
ret_dic,
|
ret_dic,
|
||||||
"return stats should be matched")
|
'return stats should be matched')
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
import urllib
|
import urllib
|
||||||
import base64
|
|
||||||
from novaclient import base as client_base
|
from novaclient import base as client_base
|
||||||
from novaclient.v1_1 import servers
|
from novaclient.v1_1 import servers
|
||||||
from novaclient.v1_1 import hypervisors
|
from novaclient.v1_1 import hypervisors
|
||||||
@ -10,7 +9,6 @@ from novaclient.v1_1 import images
|
|||||||
from novaclient.v1_1 import flavors
|
from novaclient.v1_1 import flavors
|
||||||
from novaclient.v1_1 import volumes
|
from novaclient.v1_1 import volumes
|
||||||
from novaclient.v1_1.volume_types import VolumeType
|
from novaclient.v1_1.volume_types import VolumeType
|
||||||
from novaclient.openstack.common import strutils
|
|
||||||
from powervc.common.client.extensions import base
|
from powervc.common.client.extensions import base
|
||||||
from powervc.common import utils
|
from powervc.common import utils
|
||||||
import logging
|
import logging
|
||||||
@ -92,7 +90,6 @@ class PVCServerManager(servers.ServerManager):
|
|||||||
detail = "/detail"
|
detail = "/detail"
|
||||||
return self._list("/servers%s%s" % (detail, query_string), "servers")
|
return self._list("/servers%s%s" % (detail, query_string), "servers")
|
||||||
|
|
||||||
|
|
||||||
# This function was copied from (/usr/lib/python2.6/site-packages/
|
# This function was copied from (/usr/lib/python2.6/site-packages/
|
||||||
# novaclient/v1_1/servers.py) before, but changes needed when activation
|
# novaclient/v1_1/servers.py) before, but changes needed when activation
|
||||||
# data contains userdata and files, because in a boot action, local OS
|
# data contains userdata and files, because in a boot action, local OS
|
||||||
|
@ -7,6 +7,7 @@ from powervc.common.client.config import CONF as CONF
|
|||||||
from powervc.common.client.config import OS_OPTS as OS_OPTS
|
from powervc.common.client.config import OS_OPTS as OS_OPTS
|
||||||
from powervc.common.client.config import PVC_OPTS as PVC_OPTS
|
from powervc.common.client.config import PVC_OPTS as PVC_OPTS
|
||||||
from powervc.common.constants import SERVICE_TYPES as SERVICE_TYPES
|
from powervc.common.constants import SERVICE_TYPES as SERVICE_TYPES
|
||||||
|
from powervc.common.gettextutils import _
|
||||||
|
|
||||||
"""sample useage
|
"""sample useage
|
||||||
|
|
||||||
@ -47,14 +48,14 @@ def initialize_local_servicecatalog():
|
|||||||
return
|
return
|
||||||
|
|
||||||
def new_local_servicecatalog():
|
def new_local_servicecatalog():
|
||||||
LOG.info(_("start to new local keystone client"))
|
LOG.info(_('start to new local keystone client'))
|
||||||
keystone_version = CONF['openstack']['keystone_version']
|
keystone_version = CONF['openstack']['keystone_version']
|
||||||
keystone = service.KeystoneService(str(SERVICE_TYPES.identity),
|
keystone = service.KeystoneService(str(SERVICE_TYPES.identity),
|
||||||
keystone_version,
|
keystone_version,
|
||||||
OS_OPTS['auth_url'], OS_OPTS,
|
OS_OPTS['auth_url'], OS_OPTS,
|
||||||
None).new_client()
|
None).new_client()
|
||||||
servicecatalog = service.ClientServiceCatalog(OS_OPTS, keystone)
|
servicecatalog = service.ClientServiceCatalog(OS_OPTS, keystone)
|
||||||
LOG.info(_("finish to new local keystone client"))
|
LOG.info(_('finish to new local keystone client'))
|
||||||
return servicecatalog
|
return servicecatalog
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
@ -65,11 +66,11 @@ def initialize_local_servicecatalog():
|
|||||||
LOCAL = new_local_servicecatalog()
|
LOCAL = new_local_servicecatalog()
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.info(_("Keystone service is not ready. " + str(e)))
|
LOG.info(_('Keystone service is not ready. ' + str(e)))
|
||||||
count += 1
|
count += 1
|
||||||
if count == CONF['openstack']['keystone_max_try_times']:
|
if count == CONF['openstack']['keystone_max_try_times']:
|
||||||
LOG.error(_("Keystone service is not ready eventually after"
|
LOG.error(_('Keystone service is not ready eventually after'
|
||||||
" retries!"))
|
' retries!'))
|
||||||
raise e
|
raise e
|
||||||
time.sleep(CONF['openstack']['keystone_retry_interval'])
|
time.sleep(CONF['openstack']['keystone_retry_interval'])
|
||||||
|
|
||||||
|
@ -361,11 +361,13 @@ class Utils(object):
|
|||||||
if not scg:
|
if not scg:
|
||||||
# If no scg, then it's a IVM based PowerVC,
|
# If no scg, then it's a IVM based PowerVC,
|
||||||
# return all servers
|
# return all servers
|
||||||
return self._novaclient.manager.list_all_servers(detailed, search_opts)
|
return self._novaclient.manager.list_all_servers(
|
||||||
|
detailed, search_opts)
|
||||||
|
|
||||||
# accessible_storage_servers to return
|
# accessible_storage_servers to return
|
||||||
accessible_storage_servers = []
|
accessible_storage_servers = []
|
||||||
all_servers = self._novaclient.manager.list_all_servers(detailed, search_opts)
|
all_servers = self._novaclient.manager.list_all_servers(
|
||||||
|
detailed, search_opts)
|
||||||
|
|
||||||
# Filter the servers for the SCG
|
# Filter the servers for the SCG
|
||||||
for server in all_servers:
|
for server in all_servers:
|
||||||
|
@ -18,11 +18,14 @@ class PVCConfigTest(testtools.TestCase):
|
|||||||
del config.parse_power_config.power_config_loaded
|
del config.parse_power_config.power_config_loaded
|
||||||
|
|
||||||
def test_parse_config_1(self):
|
def test_parse_config_1(self):
|
||||||
p1 = mock.patch('oslo.config.cfg.find_config_files',
|
p1 = mock.patch(
|
||||||
new=mock.MagicMock(return_value=["%s%s%s" %
|
'oslo.config.cfg.find_config_files',
|
||||||
(os.path.dirname(__file__),
|
new=mock.MagicMock(
|
||||||
|
return_value=["%s%s%s" % (os.path.dirname(__file__),
|
||||||
os.sep,
|
os.sep,
|
||||||
"powervc_test_1.conf")]))
|
"powervc_test_1.conf")]
|
||||||
|
)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
p1.start()
|
p1.start()
|
||||||
config.parse_power_config([], "powervc-baseproject", None)
|
config.parse_power_config([], "powervc-baseproject", None)
|
||||||
@ -35,15 +38,17 @@ class PVCConfigTest(testtools.TestCase):
|
|||||||
p1.stop()
|
p1.stop()
|
||||||
|
|
||||||
def test_parse_config_2(self):
|
def test_parse_config_2(self):
|
||||||
p2 = mock.patch('oslo.config.cfg.find_config_files',
|
p2 = mock.patch(
|
||||||
new=mock.MagicMock(side_effect=[["%s%s%s" %
|
'oslo.config.cfg.find_config_files',
|
||||||
(os.path.dirname(__file__),
|
new=mock.MagicMock(
|
||||||
|
side_effect=[["%s%s%s" % (os.path.dirname(__file__),
|
||||||
os.sep,
|
os.sep,
|
||||||
"powervc_test_1.conf")],
|
"powervc_test_1.conf")],
|
||||||
["%s%s%s" %
|
["%s%s%s" % (os.path.dirname(__file__),
|
||||||
(os.path.dirname(__file__),
|
|
||||||
os.sep,
|
os.sep,
|
||||||
"powervc_test_2.conf")]]))
|
"powervc_test_2.conf")]]
|
||||||
|
)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
p2.start()
|
p2.start()
|
||||||
config.parse_power_config([], "baseproject", None)
|
config.parse_power_config([], "baseproject", None)
|
||||||
|
@ -6,6 +6,7 @@ PowerVC Driver ImageManager Configuration
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import powervc.common.config as common_config
|
import powervc.common.config as common_config
|
||||||
|
from powervc.common.gettextutils import _
|
||||||
from powervc.glance.common import constants
|
from powervc.glance.common import constants
|
||||||
|
|
||||||
CONF = common_config.CONF
|
CONF = common_config.CONF
|
||||||
@ -33,7 +34,8 @@ CONF.register_opts(image_opts, group='powervc')
|
|||||||
Refer to the file glance/api/middleware/context.py , register the config
|
Refer to the file glance/api/middleware/context.py , register the config
|
||||||
option named 'owner_is_tenant' to default group.
|
option named 'owner_is_tenant' to default group.
|
||||||
"""
|
"""
|
||||||
CONF.register_opt(cfg.BoolOpt('owner_is_tenant', default=True,
|
CONF.register_opt(
|
||||||
|
cfg.BoolOpt('owner_is_tenant', default=True,
|
||||||
help=_('When true, this option sets the owner of '
|
help=_('When true, this option sets the owner of '
|
||||||
'an image to be the tenant. Otherwise, the'
|
'an image to be the tenant. Otherwise, the'
|
||||||
' owner of the image will be the '
|
' owner of the image will be the '
|
||||||
|
@ -39,7 +39,9 @@ IMAGE_UPDATE_PARAMS_FILTER = ['owner', 'location']
|
|||||||
IMAGE_UNESCAPE_PROPERTIES = ['configuration_strategy']
|
IMAGE_UNESCAPE_PROPERTIES = ['configuration_strategy']
|
||||||
|
|
||||||
# List of v2image update parameters to filter out
|
# List of v2image update parameters to filter out
|
||||||
v2IMAGE_UPDATE_PARAMS_FILTER = IMAGE_UPDATE_PARAMS_FILTER + ['deleted', 'size', 'checksum']
|
v2IMAGE_UPDATE_PARAMS_FILTER = IMAGE_UPDATE_PARAMS_FILTER + ['deleted',
|
||||||
|
'size',
|
||||||
|
'checksum']
|
||||||
|
|
||||||
# List of image properties to filter out during an update
|
# List of image properties to filter out during an update
|
||||||
IMAGE_UPDATE_PROPERTIES_FILTER = [consts.POWERVC_UUID_KEY,
|
IMAGE_UPDATE_PROPERTIES_FILTER = [consts.POWERVC_UUID_KEY,
|
||||||
|
@ -1403,7 +1403,8 @@ class PowerVCImageManager(service.Service):
|
|||||||
field_dict, update_field_dict = self._get_v1image_create_fields(
|
field_dict, update_field_dict = self._get_v1image_create_fields(
|
||||||
src_image, image_owner, image_endpoint)
|
src_image, image_owner, image_endpoint)
|
||||||
# Community fix needs the property 'checksum' must be set
|
# Community fix needs the property 'checksum' must be set
|
||||||
field_dict['checksum'] = self._get_image_checksum(src_image.to_dict())
|
field_dict['checksum'] = self._get_image_checksum(
|
||||||
|
src_image.to_dict())
|
||||||
new_image = v1images.create(**field_dict)
|
new_image = v1images.create(**field_dict)
|
||||||
updated_image = None
|
updated_image = None
|
||||||
if len(update_field_dict) > 0:
|
if len(update_field_dict) > 0:
|
||||||
|
@ -93,8 +93,7 @@ class TestPowerVCNeutronAgent(unittest.TestCase):
|
|||||||
|
|
||||||
local_port = mock.MagicMock()
|
local_port = mock.MagicMock()
|
||||||
local_port.get = mock.MagicMock(
|
local_port.get = mock.MagicMock(
|
||||||
side_effect=[constants.STATUS_CREATING,
|
side_effect=[constants.STATUS_CREATING, constants.STATUS_ACTIVE])
|
||||||
constants.STATUS_ACTIVE])
|
|
||||||
self.powervc_neutron_agent.db = mock.MagicMock()
|
self.powervc_neutron_agent.db = mock.MagicMock()
|
||||||
self.powervc_neutron_agent.db.get_port = mock.MagicMock(
|
self.powervc_neutron_agent.db.get_port = mock.MagicMock(
|
||||||
return_value=local_port)
|
return_value=local_port)
|
||||||
@ -112,8 +111,7 @@ class TestPowerVCNeutronAgent(unittest.TestCase):
|
|||||||
|
|
||||||
local_port = mock.MagicMock()
|
local_port = mock.MagicMock()
|
||||||
local_port.get = mock.MagicMock(
|
local_port.get = mock.MagicMock(
|
||||||
side_effect=[constants.STATUS_CREATING,
|
side_effect=[constants.STATUS_CREATING, constants.STATUS_CREATING])
|
||||||
constants.STATUS_CREATING])
|
|
||||||
self.powervc_neutron_agent.db = mock.MagicMock()
|
self.powervc_neutron_agent.db = mock.MagicMock()
|
||||||
self.powervc_neutron_agent.db.get_port = mock.MagicMock(
|
self.powervc_neutron_agent.db.get_port = mock.MagicMock(
|
||||||
return_value=local_port)
|
return_value=local_port)
|
||||||
|
@ -175,7 +175,7 @@ class PowerVCService(object):
|
|||||||
else:
|
else:
|
||||||
vm_status_dict = {'vm_id': server.id,
|
vm_status_dict = {'vm_id': server.id,
|
||||||
'state': pvc_vm_states.ACTIVE}
|
'state': pvc_vm_states.ACTIVE}
|
||||||
LOG.debug("Service: VM %(vm_id)s successfully rebooted. " \
|
LOG.debug("Service: VM %(vm_id)s successfully rebooted. "
|
||||||
"Current status: %(state)s" % vm_status_dict)
|
"Current status: %(state)s" % vm_status_dict)
|
||||||
raise loopingcall.LoopingCallDone(True)
|
raise loopingcall.LoopingCallDone(True)
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ class PowerVCService(object):
|
|||||||
if (task_state == task_states.ACTIVATING):
|
if (task_state == task_states.ACTIVATING):
|
||||||
LOG.debug("The task status of the instance: %s"
|
LOG.debug("The task status of the instance: %s"
|
||||||
% task_state)
|
% task_state)
|
||||||
reason = _("The instance in the task status: %s can not" \
|
reason = _("The instance in the task status: %s can not"
|
||||||
" be stopped."
|
" be stopped."
|
||||||
% task_state)
|
% task_state)
|
||||||
raise exception.InstanceUnacceptable(instance_id=server.id,
|
raise exception.InstanceUnacceptable(instance_id=server.id,
|
||||||
|
@ -4,6 +4,7 @@ import re
|
|||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
|
|
||||||
import powervc.common.config as cfg
|
import powervc.common.config as cfg
|
||||||
|
from powervc.common.gettextutils import _
|
||||||
from nova.compute import flavors
|
from nova.compute import flavors
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova import db
|
from nova import db
|
||||||
|
Loading…
x
Reference in New Issue
Block a user