예제 #1
0
    def test_init_muliple_disks(self):
        i = virt.Instance({
            'uuid':
            'fakeuuid',
            'name':
            'cirros',
            'disk_spec': [{
                'base': 'cirros',
                'size': 8
            }, {
                'size': 16
            }, {
                'size': 24
            }],
            'block_devices':
            None
        })

        self.assertEqual('/a/b/c/instances/fakeuuid', i.instance_path)
        self.assertEqual('/a/b/c/snapshots', i.snapshot_path)
        self.assertEqual('/a/b/c/instances/fakeuuid/libvirt.xml', i.xml_file)
        self.assertEqual([{
            'base': 'cirros',
            'device': 'vda',
            'bus': 'virtio',
            'path': '/a/b/c/instances/fakeuuid/vda',
            'size': 8,
            'type': 'qcow2',
            'present_as': 'disk',
            'snapshot_ignores': False
        }, {
            'device': 'vdb',
            'bus': 'virtio',
            'path': '/a/b/c/instances/fakeuuid/vdb',
            'type': 'raw',
            'present_as': 'disk',
            'snapshot_ignores': True
        }, {
            'base': None,
            'device': 'vdc',
            'bus': 'virtio',
            'path': '/a/b/c/instances/fakeuuid/vdc',
            'size': 16,
            'type': 'qcow2',
            'present_as': 'disk',
            'snapshot_ignores': False
        }, {
            'base': None,
            'device': 'vdd',
            'bus': 'virtio',
            'path': '/a/b/c/instances/fakeuuid/vdd',
            'size': 24,
            'type': 'qcow2',
            'present_as': 'disk',
            'snapshot_ignores': False
        }], i.db_entry['block_devices']['devices'])
예제 #2
0
 def _make_instance(self):
     return virt.Instance({
         'uuid': 'fakeuuid',
         'name': 'cirros',
         'disk_spec': [{
             'base': 'cirros',
             'size': 8
         }],
         'ssh_key': 'thisisasshkey',
         'user_data': str(base64.b64encode(
             'thisisuserdata'.encode('utf-8')), 'utf-8'),
         'block_devices': None
     })