コード例 #1
0
    def mount(self, *, source: str, target: str) -> None:
        """Passthrough for running multipass mount.

        :param str source: path to the local directory to mount.
        :param str target: mountpoint inside the instance in the form of
                           <instance-name>:path.
        :raises errors.ProviderMountError: when the mount operation fails.
        """
        cmd = [self.provider_cmd, "mount", source, target]
        try:
            _run(cmd)
        except subprocess.CalledProcessError as process_error:
            raise errors.ProviderMountError(
                provider_name=self.provider_name,
                exit_code=process_error.returncode) from process_error
コード例 #2
0
 def mount_snaps_directory(self) -> None:
     cmd = [
         "lxc",
         "config",
         "device",
         "add",
         self._instance_name,
         "snapd-snaps",
         "disk",
         "source={}".format(),
         "path={}".format(self._SNAPS_MOUNTPOINT),
     ]
     try:
         _run(cmd)
     except subprocess.CalledProcessError as process_error:
         raise _provider_errors.ProviderMountError(
             provider_name="lxd",
             exit_code=process_error.returncode) from process_error
コード例 #3
0
    def mount(
        self,
        *,
        source: str,
        target: str,
        uid_map: Dict[str, str] = None,
        gid_map: Dict[str, str] = None
    ) -> None:
        """Passthrough for running multipass mount.

        :param str source: path to the local directory to mount.
        :param str target: mountpoint inside the instance in the form of
                           <instance-name>:path.
        :param dict uid_map: A mapping of user IDs for use in the mount of the form
                             <host-id> -> <instance-id>.
                             File and folder ownership will be mapped from
                             <host> to <instance-name> inside the instance.
        :param dict gid_map: A mapping of group IDs for use in the mount of the form
                             <host-id> -> <instance-id>.
                             File and folder ownership will be mapped from
                             <host> to <instance-name> inside the instance.
        :raises errors.ProviderMountError: when the mount operation fails.
        """
        cmd = [self.provider_cmd, "mount", source, target]
        if uid_map is None:
            uid_map = dict()
        for host_map, instance_map in uid_map.items():
            cmd.extend(["--uid-map", "{}:{}".format(host_map, instance_map)])
        if gid_map is None:
            gid_map = dict()
        for host_map, instance_map in gid_map.items():
            cmd.extend(["--gid-map", "{}:{}".format(host_map, instance_map)])
        try:
            _run(cmd)
        except subprocess.CalledProcessError as process_error:
            raise errors.ProviderMountError(
                provider_name=self.provider_name, exit_code=process_error.returncode
            ) from process_error