diff --git a/contents/winrm-filecopier.py b/contents/winrm-filecopier.py index 40eba4d..9fd4139 100644 --- a/contents/winrm-filecopier.py +++ b/contents/winrm-filecopier.py @@ -174,7 +174,8 @@ def winrm_upload(self, remote_filename, local_path, step=2048, - quiet=True): + quiet=True, + override=False): if remote_path.endswith('/') or remote_path.endswith('\\'): full_path = remote_path + remote_filename @@ -185,6 +186,9 @@ def winrm_upload(self, self.session.run_ps('if (!(Test-Path {0})) {{ New-Item -ItemType directory -Path {0} }}'.format(remote_path)) + if(override): + self.session.run_ps('if ((Test-Path {0} -PathType Leaf)) {{ rm {0} }}'.format(full_path)) + size = os.stat(local_path).st_size with open(local_path, 'rb') as f: for i in range(0, size, step): @@ -245,6 +249,10 @@ def winrm_upload(self, krb5config = None krbdelegation = False forceTicket = False +override=False + +if os.environ.get('RD_CONFIG_OVERRIDE') == 'true': + override = True if "RD_CONFIG_AUTHTYPE" in os.environ: authentication = os.getenv("RD_CONFIG_AUTHTYPE") @@ -377,7 +385,8 @@ def winrm_upload(self, copy.winrm_upload(remote_path=destination, remote_filename=filename, local_path=args.source, - quiet=quiet) + quiet=quiet, + override=override) else: log.warn("The source is a directory, skipping copy") diff --git a/plugin.yaml b/plugin.yaml index 6dc15c4..89c245f 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -284,6 +284,10 @@ providers: name: debug title: Debug? description: 'Write debug messages' + - type: Boolean + name: override + title: Override? + description: 'Overrides the file on the remote server if it already exists' - name: krb5config title: krb5 Config File description: "Path of krb5.conf file" @@ -409,5 +413,4 @@ providers: default: "false" required: false renderingOptions: - groupName: Kerberos - + groupName: Kerberos \ No newline at end of file