def test_parse_volume_chain_file(self): with self.make_env(DISK_TYPE.FILE) as env: disk_xml = etree.fromstring(""" <disk> <source file='%(top)s'> <seclabel model="dac" relabel="no" type="none" /> </source> <backingStore type='file' index='1'> <source file='%(base)s'/> <backingStore/> </backingStore> </disk>""" % { "top": env.top, "base": env.base }) chain = env.drive.parse_volume_chain(disk_xml) expected = [ storage.VolumeChainEntry( path=env.base, allocation=None, uuid='22222222-2222-2222-2222-222222222222', index=1), storage.VolumeChainEntry( path=env.top, allocation=None, uuid='11111111-1111-1111-1111-111111111111', index=None) ] assert chain == expected
def test_parse_volume_chain_network(self): volume_chain = [{ 'path': 'server:/vol/11111111-1111-1111-1111-111111111111', 'volumeID': '11111111-1111-1111-1111-111111111111' }, { 'path': 'server:/vol/22222222-2222-2222-2222-222222222222', 'volumeID': '22222222-2222-2222-2222-222222222222' }] conf = drive_config(volumeChain=volume_chain) drive = Drive(self.log, diskType=DISK_TYPE.NETWORK, **conf) disk_xml = etree.fromstring(""" <disk> <source name='server:/vol/11111111-1111-1111-1111-111111111111'/> <backingStore type='network' index='1'> <source name='server:/vol/22222222-2222-2222-2222-222222222222'/> <backingStore/> </backingStore> </disk>""") chain = drive.parse_volume_chain(disk_xml) expected = [ storage.VolumeChainEntry( path='server:/vol/22222222-2222-2222-2222-222222222222', allocation=None, uuid='22222222-2222-2222-2222-222222222222', index=1), storage.VolumeChainEntry( path='server:/vol/11111111-1111-1111-1111-111111111111', allocation=None, uuid='11111111-1111-1111-1111-111111111111', index=None) ] self.assertEqual(chain, expected)
def test_parse_volume_chain_block(self): with self.make_env(DISK_TYPE.BLOCK) as env: disk_xml = etree.fromstring(""" <disk> <source dev='%(top)s'/> <backingStore type='block' index='1'> <source dev='%(base)s'/> <backingStore/> </backingStore> </disk>""" % { "top": env.top, "base": env.base }) chain = env.drive.parse_volume_chain(disk_xml) expected = [ storage.VolumeChainEntry( path=env.base, allocation=None, uuid='22222222-2222-2222-2222-222222222222', index=1), storage.VolumeChainEntry( path=env.top, allocation=None, uuid='11111111-1111-1111-1111-111111111111', index=None) ] self.assertEqual(chain, expected)
def test_parse_volume_chain_block(self): with self.make_env(DISK_TYPE.BLOCK) as env: disk = etree.fromstring(""" <disk type='block'> <source dev='%(top)s' index='1'> <seclabel model="dac" relabel="no" type="none" /> </source> <backingStore type='block' index='3'> <source dev='%(base)s'/> <backingStore/> </backingStore> </disk>""" % { "top": env.top, "base": env.base }) chain = env.drive.parse_volume_chain(disk) expected = [ storage.VolumeChainEntry( path=env.base, uuid='22222222-2222-2222-2222-222222222222', index=3), storage.VolumeChainEntry( path=env.top, uuid='11111111-1111-1111-1111-111111111111', index=1) ] assert chain == expected
def setUp(self): volume_chain = [{"path": "/top", "volumeID": "00000000-0000-0000-0000-000000000000"}, {"path": "/base", "volumeID": "11111111-1111-1111-1111-111111111111"}] self.conf = drive_config(volumeChain=volume_chain, alias=0, name="name") self.actual_chain = [ storage.VolumeChainEntry( uuid="11111111-1111-1111-1111-111111111111", index=1, path=None, allocation=None ), storage.VolumeChainEntry( uuid="00000000-0000-0000-0000-000000000000", index=None, path=None, allocation=None ) ]
def test_parse_volume_no_backing(self): with self.make_env(DISK_TYPE.BLOCK) as env: disk_xml = etree.fromstring(""" <disk> <source dev='%s'/> </disk>""" % env.top) chain = env.drive.parse_volume_chain(disk_xml) expected = [ storage.VolumeChainEntry( path=env.top, allocation=None, uuid='11111111-1111-1111-1111-111111111111') ] self.assertEqual(chain, expected)
def test_parse_volume_chain_network(self): volume_chain = [{ 'path': 'server:/vol/11111111-1111-1111-1111-111111111111', 'volumeID': '11111111-1111-1111-1111-111111111111' }, { 'path': 'server:/vol/22222222-2222-2222-2222-222222222222', 'volumeID': '22222222-2222-2222-2222-222222222222' }] conf = drive_config(volumeChain=volume_chain) drive = Drive(self.log, diskType=DISK_TYPE.NETWORK, **conf) disk = etree.fromstring(""" <disk type='network'> <source name='server:/vol/11111111-1111-1111-1111-111111111111' index='1'> <seclabel model="dac" relabel="no" type="none" /> </source> <backingStore type='network' index='3'> <source name='server:/vol/22222222-2222-2222-2222-222222222222'/> <backingStore/> </backingStore> </disk>""") chain = drive.parse_volume_chain(disk) expected = [ storage.VolumeChainEntry( path='server:/vol/22222222-2222-2222-2222-222222222222', uuid='22222222-2222-2222-2222-222222222222', index=3), storage.VolumeChainEntry( path='server:/vol/11111111-1111-1111-1111-111111111111', uuid='11111111-1111-1111-1111-111111111111', index=1) ] assert chain == expected
def test_parse_volume_no_backing(self): with self.make_env(DISK_TYPE.BLOCK) as env: disk_xml = etree.fromstring(""" <disk> <source dev='%s'> <seclabel model="dac" relabel="no" type="none" /> </source> </disk>""" % env.top) chain = env.drive.parse_volume_chain(disk_xml) expected = [ storage.VolumeChainEntry( path=env.top, allocation=None, uuid='11111111-1111-1111-1111-111111111111') ] assert chain == expected