コード例 #1
0
 def _insert_file_in_volume_mount(self, volume_name, host_src_file,
                                  volume_dest_file_name):
     """
     Use volume introspection to place files into the host mountpoint in order
     to work around issues with Docker filesystem operations on Windows
     Hyper-V containers and container mountpoints
     """
     try:
         volume_name = (volume_name.split('/'))[-1]
         volume_info = self._client.api.inspect_volume(volume_name)
         EdgeUtils.copy_files(
             host_src_file.replace('\\\\', '\\'),
             os.path.join(volume_info['Mountpoint'].replace('\\\\', '\\'),
                          volume_dest_file_name))
     except docker.errors.APIError as docker_ex:
         msg = 'Docker volume inspect failed for: {0}'.format(volume_name)
         logging.error(msg)
         print(docker_ex)
         raise edgectl.errors.EdgeDeploymentError(msg, docker_ex)
     except (OSError, IOError) as ex_os:
         msg = 'File IO error seen copying files to volume: {0}. ' \
               'Errno: {1}, Error {2}'.format(volume_name, str(ex_os.errno), ex_os.strerror)
         logging.error(msg)
         print(ex_os)
         raise edgectl.errors.EdgeDeploymentError(msg, ex_os)
コード例 #2
0
ファイル: test_edgeutils.py プロジェクト: darobs/iotedge-HA
    def test_copy_files_raises_oserror_when_cop2_raises_oserror(
            self, mock_copy):
        """ Tests invocation of API copy_files raises OSError when copy2 raises OSError"""
        # arrange
        src_path = 'src'
        dest_path = 'dest'
        mock_copy.side_effect = OSError('copy2 OS error')

        # act, assert
        with self.assertRaises(OSError):
            EdgeUtils.copy_files(src_path, dest_path)
コード例 #3
0
ファイル: test_edgeutils.py プロジェクト: darobs/iotedge-HA
    def test_copy_files_valid(self, mock_copy):
        """ Test a valid invocation of API copy_files """
        # arrange
        src_path = 'src'
        dest_path = 'dest'

        # act
        EdgeUtils.copy_files(src_path, dest_path)

        # assert
        mock_copy.assert_called_with(src_path, dest_path)