Fix huawei driver test issues

Replace "params[params.index('-lun')]" with
"params[params.index('-lun') + 1]" to get lun ID correctly.
Replace the invalid controller ID "N" with "B".
Dict CLONED_LUN_INFO has no key provider_location, delete it.

Moreover, simplify the "if..., elif..." module with "getattr"
method in fake recv function.

fixes bug 1225884
Change-Id: Ic4cbf8b07321cdecd6290e8cd90bca1b09dca7fd
This commit is contained in:
zhangchao010 2013-09-17 23:53:24 +08:00
parent 1f563d6061
commit 306dc1792d

View File

@ -186,79 +186,9 @@ class FakeChannel():
reset_error_flg(cmd) reset_error_flg(cmd)
out = self.command[:-1] + 'ERROR' + '\nadmin:/>' out = self.command[:-1] + 'ERROR' + '\nadmin:/>'
return out.replace('\n', '\r\n') return out.replace('\n', '\r\n')
func_name = 'cli_' + cmd
if cmd == 'showsys': cli_func = getattr(self.simu, func_name)
out = self.simu.cli_showsys(params) out = cli_func(params)
elif cmd == 'createlun':
out = self.simu.cli_createlun(params)
elif cmd == 'showlun':
out = self.simu.cli_showlun(params)
elif cmd == 'dellun':
out = self.simu.cli_dellun(params)
elif cmd == 'showrg':
out = self.simu.cli_showrg(params)
elif cmd == 'showpool':
out = self.simu.cli_showpool(params)
elif cmd == 'createluncopy':
out = self.simu.cli_createluncopy(params)
elif cmd == 'chgluncopystatus':
out = self.simu.cli_chgluncopystatus(params)
elif cmd == 'showluncopy':
out = self.simu.cli_showluncopy(params)
elif cmd == 'delluncopy':
out = self.simu.cli_delluncopy(params)
elif cmd == 'createsnapshot':
out = self.simu.cli_createsnapshot(params)
elif cmd == 'actvsnapshot':
out = self.simu.cli_activesnapshot(params)
elif cmd == 'showsnapshot':
out = self.simu.cli_showsnapshot(params)
elif cmd == 'disablesnapshot':
out = self.simu.cli_disablesnapshot(params)
elif cmd == 'delsnapshot':
out = self.simu.cli_delsnapshot(params)
elif cmd == 'showrespool':
out = self.simu.cli_showrespool(params)
elif cmd == 'showiscsitgtname':
out = self.simu.cli_showiscsitgtname(params)
elif cmd == 'showiscsiip':
out = self.simu.cli_showiscsiip(params)
elif cmd == 'showhostgroup':
out = self.simu.cli_showhostgroup(params)
elif cmd == 'createhostgroup':
out = self.simu.cli_createhostgroup(params)
elif cmd == 'showhost':
out = self.simu.cli_showhost(params)
elif cmd == 'addhost':
out = self.simu.cli_addhost(params)
elif cmd == 'delhost':
out = self.simu.cli_delhost(params)
elif cmd == 'showiscsiini':
out = self.simu.cli_showiscsiini(params)
elif cmd == 'addiscsiini':
out = self.simu.cli_addiscsiini(params)
elif cmd == 'deliscsiini':
out = self.simu.cli_deliscsiini(params)
elif cmd == 'showhostport':
out = self.simu.cli_showhostport(params)
elif cmd == 'addhostport':
out = self.simu.cli_addhostport(params)
elif cmd == 'delhostport':
out = self.simu.cli_delhostport(params)
elif cmd == 'showhostmap':
out = self.simu.cli_showhostmap(params)
elif cmd == 'addhostmap':
out = self.simu.cli_addhostmap(params)
elif cmd == 'delhostmap':
out = self.simu.cli_delhostmap(params)
elif cmd == 'showfreeport':
out = self.simu.cli_showfreeport(params)
elif cmd == 'showhostpath':
out = self.simu.cli_showhostpath(params)
elif cmd == 'chglun':
out = self.simu.cli_chglun(params)
elif cmd == 'showfcmode':
out = self.simu.cli_showfcmode(params)
out = self.command[:-1] + out + '\nadmin:/>' out = self.command[:-1] + out + '\nadmin:/>'
return out.replace('\n', '\r\n') return out.replace('\n', '\r\n')
@ -421,7 +351,6 @@ class HuaweiTCLIResSimulator():
CLONED_LUN_INFO['Owner Controller'] = 'A' CLONED_LUN_INFO['Owner Controller'] = 'A'
CLONED_LUN_INFO['Worker Controller'] = 'A' CLONED_LUN_INFO['Worker Controller'] = 'A'
CLONED_LUN_INFO['RAID Group ID'] = POOL_SETTING['ID'] CLONED_LUN_INFO['RAID Group ID'] = POOL_SETTING['ID']
CLONED_LUN_INFO['provider_location'] = CLONED_LUN_INFO['ID']
FAKE_CLONED_VOLUME['provider_location'] = CLONED_LUN_INFO['ID'] FAKE_CLONED_VOLUME['provider_location'] = CLONED_LUN_INFO['ID']
out = 'command operates successfully' out = 'command operates successfully'
return out return out
@ -610,7 +539,7 @@ class HuaweiTCLIResSimulator():
""" % (SNAPSHOT_INFO['Name'], SNAPSHOT_INFO['ID'], SNAPSHOT_INFO['Status']) """ % (SNAPSHOT_INFO['Name'], SNAPSHOT_INFO['ID'], SNAPSHOT_INFO['Status'])
return out return out
def cli_activesnapshot(self, params): def cli_actvsnapshot(self, params):
SNAPSHOT_INFO['Status'] = 'Active' SNAPSHOT_INFO['Status'] = 'Active'
FAKE_SNAPSHOT['provider_location'] = SNAPSHOT_INFO['ID'] FAKE_SNAPSHOT['provider_location'] = SNAPSHOT_INFO['ID']
out = 'command operates successfully' out = 'command operates successfully'
@ -663,7 +592,7 @@ class HuaweiTCLIResSimulator():
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
Controller ID Interface Module ID Port ID IP Address Mask Controller ID Interface Module ID Port ID IP Address Mask
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
N 0 P1 %s 255.255.255.0 B 0 P1 %s 255.255.255.0
============================================================================ ============================================================================
-""" % INITIATOR_SETTING['Initiator TargetIP'] -""" % INITIATOR_SETTING['Initiator TargetIP']
return out return out
@ -959,7 +888,7 @@ class HuaweiDorado5100CLIResSimulator(HuaweiTCLIResSimulator):
LUN_INFO['RAID Group ID'], LUN_INFO['Owner Controller'], LUN_INFO['RAID Group ID'], LUN_INFO['Owner Controller'],
LUN_INFO['Worker Controller'], LUN_INFO['Lun Type'], LUN_INFO['Worker Controller'], LUN_INFO['Lun Type'],
LUN_INFO['SnapShot ID'], LUN_INFO['LunCopy ID']) LUN_INFO['SnapShot ID'], LUN_INFO['LunCopy ID'])
if params[params.index('-lun')] == VOLUME_SNAP_ID['vol'] else if params[params.index('-lun') + 1] == VOLUME_SNAP_ID['vol'] else
(CLONED_LUN_INFO['ID'], CLONED_LUN_INFO['Name'], (CLONED_LUN_INFO['ID'], CLONED_LUN_INFO['Name'],
CLONED_LUN_INFO['Visible Capacity'], CLONED_LUN_INFO['RAID Group ID'], CLONED_LUN_INFO['Visible Capacity'], CLONED_LUN_INFO['RAID Group ID'],
CLONED_LUN_INFO['Owner Controller'], CLONED_LUN_INFO['Owner Controller'],