Beispiel #1
0
    def unmount_special(self, params):
        """Unmount a special-purpose filesystem, like tmpfs.

        :param mount_point: Path on the filesystem to unmount.

        :attention: This is more or less a copy of `unmount_special` from
            `m.api.machines`.
        """
        machine = self.get_object(params)
        if machine.locked:
            raise HandlerPermissionError()
        self._preflight_special_filesystem_modifications("unmount", machine)
        form = UnmountNonStorageFilesystemForm(machine, data=params)
        if form.is_valid():
            form.save()
        else:
            raise HandlerValidationError(form.errors)
Beispiel #2
0
 def test_will_not_unmount_filesystem_on_block_device(self):
     node = factory.make_Node()
     block_device = factory.make_BlockDevice(node=node)
     filesystem = factory.make_Filesystem(
         mount_point=factory.make_absolute_path(),
         block_device=block_device)
     form = UnmountNonStorageFilesystemForm(
         node, data={"mount_point": filesystem.mount_point})
     self.assertFalse(form.is_valid())
     self.assertThat(
         form.errors,
         Equals({
             "mount_point":
             ["No special filesystem is "
              "mounted at this path."]
         }),
     )
Beispiel #3
0
 def test_will_not_unmount_filesystem_on_partition(self):
     node = factory.make_Node()
     partition = factory.make_Partition(node=node)
     filesystem = factory.make_Filesystem(
         mount_point=factory.make_absolute_path(), partition=partition
     )
     form = UnmountNonStorageFilesystemForm(
         node, data={"mount_point": filesystem.mount_point}
     )
     self.assertFalse(form.is_valid())
     self.assertThat(
         form.errors,
         Equals(
             {
                 "mount_point": [
                     "No special filesystem is mounted at this path."
                 ]
             }
         ),
     )
Beispiel #4
0
 def test_requires_mount_point(self):
     node = factory.make_Node()
     form = UnmountNonStorageFilesystemForm(node, data={})
     self.assertFalse(form.is_valid())
     self.assertThat(form.errors,
                     Equals({"mount_point": ["This field is required."]}))