fix pep8 and UT issue

fix latest pep8 and UT issues

Change-Id: I9a3b7f55ec68a9944eb7513fca4c7f521642e49e
changes/68/139568/4
terryyao 8 years ago
parent e506e9a9b4
commit 3699879307

@ -1,5 +1,5 @@
import unittest
import mox
import mock
import neutron.db.api as db_api
from powervc.neutron.api.powervc_rpc import PVCRpcCallbacks
@ -30,17 +30,9 @@ def dummy():
class TestSyncInstance(unittest.TestCase):
def setUp(self):
# Disable DB init.
db_api.get_session = dummy
db_api.configure_db = dummy
self._db = powervc_db_v2.PowerVCAgentDB()
powervc_db_v2.PowerVCAgentDB = mock.MagicMock()
self._callback = PVCRpcCallbacks(self)
# Replace with the dummy DB.
self._callback.db = self._db
self.moxer = mox.Mox()
def get_db_api(self):
return self._db
self._callback.db = mock.MagicMock()
def tearDown(self):
pass
@ -59,15 +51,8 @@ class TestSyncInstance(unittest.TestCase):
context = FakeCTX()
self.moxer.StubOutWithMock(self._db, "get_network")
self._db.get_network(local_id=id_in).AndReturn(id_out)
self.moxer.ReplayAll()
self._callback.db.get_network = mock.MagicMock(return_value=id_out)
rtn = self._callback.get_pvc_network_uuid(context, id_in)
self.moxer.VerifyAll()
self.moxer.UnsetStubs()
print str(rtn)
return rtn

@ -2,8 +2,9 @@
from novaclient import base
from novaclient import exceptions
from powervc.common.gettextutils import _
from novaclient import utils
from novaclient.openstack.common import cliutils
from powervc.common.gettextutils import _
class HostMaintenanceResource(base.Resource):
@ -41,18 +42,18 @@ class HostMaintenanceManager(base.Manager):
return obj
@utils.arg('host',
metavar='<host>',
help='Name of a host.')
@utils.arg('--set-status', choices=["enable", "disable"],
metavar="<enable|disable>",
help='To enable or disable the host maintenance mode.')
@utils.arg('--migrate', choices=["active-only", "all", "none"],
metavar="<all|active-only|none>",
help='Which kinds of instances to migrate.')
@utils.arg('--target-host',
metavar='<target host>',
help='Which service host instances would be migrated to.')
@cliutils.arg('host',
metavar='<host>',
help='Name of a host.')
@cliutils.arg('--set-status', choices=["enable", "disable"],
metavar="<enable|disable>",
help='To enable or disable the host maintenance mode.')
@cliutils.arg('--migrate', choices=["active-only", "all", "none"],
metavar="<all|active-only|none>",
help='Which kinds of instances to migrate.')
@cliutils.arg('--target-host',
metavar='<target host>',
help='Which service host instances would be migrated to.')
def do_host_maintenance(cs, args):
"""Enable maintenance mode for a hypervisor."""
if not args.set_status:

@ -498,6 +498,7 @@ class PowerVCDriverTestCase(test.NoDBTestCase):
def test_detach_interface_with_no_local_id_match(self):
instance = MagicMock()
detach_instance = pvcIns
def detach_response(pvc_id):
if pvc_id == 'powervc-port-id-77774'\
or pvc_id == 'powervc-port-id-77775':

Loading…
Cancel
Save