當前位置: 首頁>>代碼示例>>Python>>正文


Python storage.Drive類代碼示例

本文整理匯總了Python中vdsm.virt.vmdevices.storage.Drive的典型用法代碼示例。如果您正苦於以下問題:Python Drive類的具體用法?Python Drive怎麽用?Python Drive使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Drive類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_migrate_network_to_block

 def test_migrate_network_to_block(self):
     conf = drive_config(diskType=DISK_TYPE.NETWORK, path='pool/volume')
     drive = Drive(self.log, **conf)
     # Migrate drive to block domain...
     drive.path = '/blockdomain/volume'
     drive.diskType = DISK_TYPE.BLOCK
     self.assertEqual(DISK_TYPE.BLOCK, drive.diskType)
開發者ID:nirs,項目名稱:vdsm,代碼行數:7,代碼來源:vmstorage_test.py

示例2: test_parse_volume_chain_network

    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)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:34,代碼來源:vmstorage_test.py

示例3: test_migrate_from_block_to_file

 def test_migrate_from_block_to_file(self):
     conf = drive_config(path='/blockdomain/volume')
     drive = Drive(self.log, diskType=DISK_TYPE.BLOCK, **conf)
     # Migrate drive to file domain...
     drive.diskType = DISK_TYPE.FILE
     drive.path = "/filedomain/volume"
     self.assertEqual(DISK_TYPE.FILE, drive.diskType)
開發者ID:nirs,項目名稱:vdsm,代碼行數:7,代碼來源:vmstorage_test.py

示例4: test_block_threshold_stale_path

    def test_block_threshold_stale_path(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/new/path')
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold('/old/path')
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.SET)
開發者ID:nirs,項目名稱:vdsm,代碼行數:7,代碼來源:vmstorage_test.py

示例5: test_migrate_from_block_to_network

 def test_migrate_from_block_to_network(self):
     conf = drive_config(path='/blockdomain/volume')
     drive = Drive(self.log, diskType=DISK_TYPE.BLOCK, **conf)
     # Migrate drive to network disk...
     drive.path = "pool/volume"
     drive.diskType = DISK_TYPE.NETWORK
     self.assertEqual(DISK_TYPE.NETWORK, drive.diskType)
開發者ID:nirs,項目名稱:vdsm,代碼行數:7,代碼來源:vmstorage_test.py

示例6: test_set_iotune

    def test_set_iotune(self, iotune):
        conf = drive_config(
            serial='54-a672-23e5b495a9ea',
        )
        drive = Drive(self.log, **conf)

        with self.assertRaises(Exception):
            drive.iotune = iotune
開發者ID:EdDev,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例7: test_path_change_reset_threshold_state

    def test_path_change_reset_threshold_state(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/old/path')
        drive = Drive(self.log, **conf)
        # Simulating drive in SET state
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.path = '/new/path'
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.UNSET)
開發者ID:nirs,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例8: test_block_threshold_set_state

    def test_block_threshold_set_state(self):
        path = '/old/path'
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path=path)
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold(path)
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.EXCEEDED)
開發者ID:nirs,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例9: test_migrate_network_to_block

 def test_migrate_network_to_block(self):
     conf = drive_config(diskType=DISK_TYPE.NETWORK, path='pool/volume')
     drive = Drive(self.log, **conf)
     self.assertTrue(drive.networkDev)
     # Migrate drive to block domain...
     drive.path = '/blockdomain/volume'
     drive.diskType = None
     self.assertTrue(drive.blockDev)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例10: test_migrate_from_block_to_network

 def test_migrate_from_block_to_network(self):
     conf = drive_config(path='/blockdomain/volume')
     drive = Drive(self.log, **conf)
     self.assertTrue(drive.blockDev)
     # Migrate drive to network disk...
     drive.path = "pool/volume"
     drive.diskType = DISK_TYPE.NETWORK
     self.assertFalse(drive.blockDev)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例11: test_migrate_from_block_to_file

 def test_migrate_from_block_to_file(self):
     conf = drive_config(path='/blockdomain/volume')
     drive = Drive(self.log, **conf)
     self.assertTrue(drive.blockDev)
     # Migrate drive to file domain...
     utils.isBlockDevice = lambda path: False
     drive.path = "/filedomain/volume"
     self.assertFalse(drive.blockDev)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:8,代碼來源:vmstorage_test.py

示例12: test_file

    def test_file(self):
        drive = Drive(self.log, **self.conf)

        expected = """
            <disk name='vda' snapshot='external' type='file'>
                <source file='/image' type='file'/>
            </disk>
            """
        snap_info = {'path': '/image', 'device': 'disk'}
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(vmxml.format_xml(actual), expected)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:11,代碼來源:vmstorage_test.py

示例13: check_leases

 def check_leases(self, conf):
     drive = Drive(self.log, **conf)
     leases = list(drive.getLeasesXML())
     self.assertEqual(1, len(leases))
     xml = """
     <lease>
         <key>vol_id</key>
         <lockspace>dom_id</lockspace>
         <target offset="0" path="path" />
     </lease>
     """
     self.assertXMLEqual(vmxml.format_xml(leases[0]), xml)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:12,代碼來源:vmstorage_test.py

示例14: test_block

    def test_block(self):
        drive = Drive(self.log, **self.conf)
        drive._blockDev = True

        expected = """
            <disk name='vda' snapshot='external' type='block'>
                <source dev='/dev/dm-1' type='block'/>
            </disk>
            """
        snap_info = {'path': '/dev/dm-1', 'device': 'disk'}
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(vmxml.format_xml(actual), expected)
開發者ID:EdDev,項目名稱:vdsm,代碼行數:12,代碼來源:vmstorage_test.py

示例15: check_leases

 def check_leases(self, conf):
     drive = Drive(self.log, diskType=DISK_TYPE.FILE, **conf)
     leases = list(drive.getLeasesXML())
     self.assertEqual(1, len(leases))
     xml = """
     <lease>
         <key>vol_id</key>
         <lockspace>dom_id</lockspace>
         <target offset="0" path="path" />
     </lease>
     """
     self.assertXMLEqual(xmlutils.tostring(leases[0]), xml)
開發者ID:nirs,項目名稱:vdsm,代碼行數:12,代碼來源:vmstorage_test.py


注:本文中的vdsm.virt.vmdevices.storage.Drive類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。