dabla commented on code in PR #60651:
URL: https://github.com/apache/airflow/pull/60651#discussion_r2783601875
##########
providers/microsoft/winrm/src/airflow/providers/microsoft/winrm/hooks/winrm.py:
##########
@@ -191,47 +192,74 @@ def get_conn(self):
if not self.endpoint:
self.endpoint =
f"http://{self.remote_host}:{self.remote_port}/wsman"
+ if not self.password or not self.password.strip():
+ raise AirflowException(f"Missing password for WinRM connection to
host: {self.remote_host}")
+
try:
- if self.password and self.password.strip():
- self.winrm_protocol = Protocol(
- endpoint=self.endpoint,
- transport=self.transport,
- username=self.username,
- password=self.password,
- service=self.service,
- keytab=self.keytab,
- ca_trust_path=self.ca_trust_path,
- cert_pem=self.cert_pem,
- cert_key_pem=self.cert_key_pem,
- server_cert_validation=self.server_cert_validation,
- kerberos_delegation=self.kerberos_delegation,
- read_timeout_sec=self.read_timeout_sec,
- operation_timeout_sec=self.operation_timeout_sec,
- kerberos_hostname_override=self.kerberos_hostname_override,
- message_encryption=self.message_encryption,
- credssp_disable_tlsv1_2=self.credssp_disable_tlsv1_2,
- send_cbt=self.send_cbt,
+ winrm_protocol = Protocol(
+ endpoint=self.endpoint,
+ transport=cast(
+ "Literal['auto', 'basic', 'certificate', 'ntlm',
'kerberos', 'credssp', 'plaintext', 'ssl']",
+ self.transport,
+ ),
+ username=self.username,
+ password=self.password,
+ service=self.service,
+ keytab=cast("Any", self.keytab),
+ ca_trust_path=cast("str | Literal['legacy_requests']",
self.ca_trust_path),
+ cert_pem=self.cert_pem,
+ cert_key_pem=self.cert_key_pem,
+ server_cert_validation=cast(
+ "Literal['validate', 'ignore'] | None",
self.server_cert_validation
+ ),
+ kerberos_delegation=self.kerberos_delegation,
+ read_timeout_sec=self.read_timeout_sec,
+ operation_timeout_sec=self.operation_timeout_sec,
+ kerberos_hostname_override=self.kerberos_hostname_override,
+ message_encryption=cast("Literal['auto', 'always', 'never']",
self.message_encryption),
+ credssp_disable_tlsv1_2=self.credssp_disable_tlsv1_2,
+ send_cbt=self.send_cbt,
+ )
+
+ if not hasattr(winrm_protocol, "get_command_output_raw"):
+ # since pywinrm>=0.5 get_command_output_raw replace
_raw_get_command_output
+ winrm_protocol.get_command_output_raw = ( # type:
ignore[method-assign]
+ winrm_protocol._raw_get_command_output
)
+ if winrm_protocol is None:
+ raise AirflowException("WinRM protocol was not initialized")
Review Comment:
I think this is a remainder of the original code, we can indeed remove it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]