Exemplo n.º 1
0
    def test_incorrect_protocol(self):
        drive = Drive(self.log,
                      diskType=DISK_TYPE.NETWORK,
                      protocol='gluster',
                      **self.conf)

        with pytest.raises(exception.UnsupportedOperation):
            drive.get_snapshot_xml({'protocol': 'bad', 'diskType': 'network'})
Exemplo n.º 2
0
    def test_block(self):
        drive = Drive(self.log, diskType=DISK_TYPE.BLOCK, **self.conf)

        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)
Exemplo n.º 3
0
    def test_file(self):
        drive = Drive(self.log, diskType=DISK_TYPE.FILE, **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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def test_block(self):
        drive = Drive(self.log, diskType=DISK_TYPE.BLOCK, **self.conf)

        expected = """
            <disk name='vda' snapshot='external' type='block'>
                <source dev='/dev/dm-1' type='block'>
                    <seclabel model="dac" relabel="no" type="none" />
                </source>
            </disk>
            """
        snap_info = {'path': '/dev/dm-1', 'device': 'disk'}
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(xmlutils.tostring(actual), expected)
Exemplo n.º 7
0
    def test_block(self):
        drive = Drive(self.log, diskType=DISK_TYPE.BLOCK, **self.conf)

        expected = """
            <disk name='vda' snapshot='external' type='block'>
                <source dev='/dev/dm-1' type='block'>
                    <seclabel model="dac" relabel="no" type="none" />
                </source>
            </disk>
            """
        snap_info = {'path': '/dev/dm-1', 'device': 'disk'}
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(xmlutils.tostring(actual), expected)
Exemplo n.º 8
0
    def test_network(self):
        drive = Drive(self.log,
                      diskType=DISK_TYPE.NETWORK,
                      protocol='gluster',
                      **self.conf)

        expected = """
            <disk name='vda' snapshot='external' type='network'>
                <source protocol='gluster'
                        name='volume/11111111-1111-1111-1111-111111111111'
                        type='network'>
                    <host name="brick1.example.com" port="49152"
                        transport="tcp"/>
                    <host name="brick2.example.com" port="49153"
                        transport="tcp"/>
                    <seclabel model="dac" relabel="no" type="none"/>
                </source>
            </disk>
            """
        snap_info = {
            'protocol':
            'gluster',
            'path':
            'volume/11111111-1111-1111-1111-111111111111',
            'diskType':
            'network',
            'device':
            'disk',
            'hosts': [{
                'name': 'brick1.example.com',
                'port': '49152',
                'transport': 'tcp'
            }, {
                'name': 'brick2.example.com',
                'port': '49153',
                'transport': 'tcp'
            }]
        }
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(xmlutils.tostring(actual), expected)
Exemplo n.º 9
0
    def test_network(self):
        drive = Drive(self.log, diskType=DISK_TYPE.NETWORK,
                      protocol='gluster', **self.conf)

        expected = """
            <disk name='vda' snapshot='external' type='network'>
                <source protocol='gluster'
                        name='volume/11111111-1111-1111-1111-111111111111'
                        type='network'>
                    <host name="brick1.example.com" port="49152"
                        transport="tcp"/>
                    <host name="brick2.example.com" port="49153"
                        transport="tcp"/>
                </source>
            </disk>
            """
        snap_info = {
            'protocol': 'gluster',
            'path': 'volume/11111111-1111-1111-1111-111111111111',
            'diskType': 'network',
            'device': 'disk',
            'hosts': [
                {
                    'name': 'brick1.example.com',
                    'port': '49152',
                    'transport': 'tcp'
                },
                {
                    'name': 'brick2.example.com',
                    'port': '49153',
                    'transport': 'tcp'
                }
            ]
        }
        actual = drive.get_snapshot_xml(snap_info)
        self.assertXMLEqual(xmlutils.tostring(actual), expected)
Exemplo n.º 10
0
    def test_incorrect_protocol(self):
        drive = Drive(self.log, diskType=DISK_TYPE.NETWORK,
                      protocol='gluster', **self.conf)

        with self.assertRaises(exception.UnsupportedOperation):
            drive.get_snapshot_xml({'protocol': 'bad', 'diskType': 'network'})
Exemplo n.º 11
0
    def test_incorrect_disk_type(self):
        drive = Drive(self.log, diskType=DISK_TYPE.FILE, **self.conf)

        with self.assertRaises(exception.UnsupportedOperation):
            drive.get_snapshot_xml({"path": "/foo", "diskType": "bad"})
Exemplo n.º 12
0
    def test_incorrect_disk_type(self):
        drive = Drive(self.log, diskType=DISK_TYPE.FILE, **self.conf)

        with pytest.raises(exception.UnsupportedOperation):
            drive.get_snapshot_xml({"path": "/foo", "diskType": "bad"})
Exemplo n.º 13
0
    def test_incorrect_disk_type(self):
        drive = Drive(self.log, **self.conf)

        with self.assertRaises(exception.UnsupportedOperation):
            drive.get_snapshot_xml({"path": "/foo", "diskType": "bad"})