Ejemplo n.º 1
0
 def test_creates_filesystem_with_mount_point_and_options(self):
     owner = None
     if self.acquired:
         owner = factory.make_User()
     node = factory.make_Node(owner=owner)
     mount_point = factory.make_absolute_path()
     mount_options = factory.make_name("options")
     form = MountNonStorageFilesystemForm(
         node,
         data={
             "fstype": self.fstype,
             "mount_point": mount_point,
             # Whitespace is stripped by form validation.
             'mount_options': "  " + mount_options + "\t\n",
         })
     self.assertTrue(form.is_valid(), form.errors)
     filesystem = form.save()
     self.assertThat(
         filesystem,
         MatchesStructure.byEquality(node=node,
                                     fstype=self.fstype,
                                     mount_point=mount_point,
                                     mount_options=mount_options,
                                     is_mounted=True,
                                     acquired=self.acquired))
Ejemplo n.º 2
0
    def mount_special(self, params):
        """Mount a special-purpose filesystem, like tmpfs.

        :param fstype: The filesystem type. This must be a filesystem that
            does not require a block special device.
        :param mount_point: Path on the filesystem to mount.
        :param mount_option: Options to pass to mount(8).

        :attention: This is more or less a copy of `mount_special` from
            `m.api.machines`.
        """
        machine = self.get_object(params)
        self._preflight_special_filesystem_modifications("mount", machine)
        form = MountNonStorageFilesystemForm(machine, data=params)
        if form.is_valid():
            form.save()
        else:
            raise HandlerValidationError(form.errors)