Esempio n. 1
0
    def test_lxc_setup_container(self):
        image = "/tmp/fake-image"
        container_dir = "/mnt/fake_rootfs/"

        def proc_mounts(self, mount_point):
            return None

        def fake_instance_for_format(imgfile, mountdir, partition, imgfmt):
            return FakeMount(imgfile, mountdir, partition)

        self.stubs.Set(os.path, "exists", lambda _: True)
        self.stubs.Set(disk_api._DiskImage, "_device_for_path", proc_mounts)
        self.stubs.Set(mount.Mount, "instance_for_format", staticmethod(fake_instance_for_format))

        self.assertEqual(disk_api.setup_container(image, container_dir), "/dev/fake")
Esempio n. 2
0
    def test_lxc_setup_container(self):
        image = '/tmp/fake-image'
        container_dir = '/mnt/fake_rootfs/'

        def proc_mounts(self, mount_point):
            return None

        def fake_instance_for_format(image, mountdir, partition):
            return FakeMount(image, mountdir, partition)

        self.stubs.Set(os.path, 'exists', lambda _: True)
        self.stubs.Set(disk_api._DiskImage, '_device_for_path', proc_mounts)
        self.stubs.Set(mount.Mount, 'instance_for_format',
                       staticmethod(fake_instance_for_format))

        self.assertEqual(disk_api.setup_container(image, container_dir),
                         '/dev/fake')
Esempio n. 3
0
    def test_lxc_setup_container(self):
        image = '/tmp/fake-image'
        container_dir = '/mnt/fake_rootfs/'

        def proc_mounts(self, mount_point):
            return None

        def fake_instance_for_format(imgfile, mountdir, partition, imgfmt):
            return FakeMount(imgfile, mountdir, partition)

        self.stubs.Set(os.path, 'exists', lambda _: True)
        self.stubs.Set(disk_api._DiskImage, '_device_for_path', proc_mounts)
        self.stubs.Set(mount.Mount, 'instance_for_format',
                       staticmethod(fake_instance_for_format))

        self.assertEqual(disk_api.setup_container(image, container_dir),
                         '/dev/fake')
Esempio n. 4
0
    def test_lxc_setup_container(self):
        image = '/tmp/fake-image'
        container_dir = '/mnt/fake_rootfs/'

        def proc_mounts(mount_point):
            return None

        def fake_instance_for_format(image, mountdir, partition):
            return FakeMount(image, mountdir, partition)

        self.stub_out('os.path.exists', lambda _: True)
        self.stub_out('nova.virt.disk.api._DiskImage._device_for_path',
                      proc_mounts)
        self.stub_out('nova.virt.disk.mount.api.Mount.instance_for_format',
                      staticmethod(fake_instance_for_format))

        self.assertEqual(disk_api.setup_container(image, container_dir),
                         '/dev/fake')