diff --git a/contents/winrm-check.py b/contents/winrm-check.py new file mode 100644 index 0000000..e668f88 --- /dev/null +++ b/contents/winrm-check.py @@ -0,0 +1,49 @@ +import winrm +import os +import sys + + +if "RD_CONFIG_HOSTNAME" in os.environ: + hostname = os.getenv("RD_CONFIG_HOSTNAME") + +if "RD_CONFIG_USERNAME" in os.environ: + username = os.getenv("RD_CONFIG_USERNAME") + +if "RD_CONFIG_PASSWORD_STORAGE_PATH" in os.environ: + password = os.getenv("RD_CONFIG_PASSWORD_STORAGE_PATH") + +if "RD_CONFIG_AUTHTYPE" in os.environ: + authentication = os.getenv("RD_CONFIG_AUTHTYPE") + +if "RD_CONFIG_WINRMTRANSPORT" in os.environ: + transport = os.getenv("RD_CONFIG_WINRMTRANSPORT") + +if "RD_CONFIG_WINRMPORT" in os.environ: + port = os.getenv("RD_CONFIG_WINRMPORT") + +if "RD_CONFIG_NOSSL" in os.environ: + nossl = os.getenv("RD_CONFIG_NOSSL") + + +if os.getenv("RD_JOB_LOGLEVEL") == "DEBUG": + debug = True + +endpoint=transport+'://'+hostname+':'+port + + +if(nossl): + session = winrm.Session(endpoint, auth=(username, password), + transport=authentication, + server_cert_validation='ignore') +else: + session = winrm.Session(endpoint, auth=(username, password), + transport=authentication) + +exec_command = "ipconfig" +result = session.run_cmd(exec_command) + +if(result.std_err): + print "Connection with host %s fail" % hostname + sys.exit(1) +else: + print "Connection with host %s successfull" % hostname diff --git a/plugin.yaml b/plugin.yaml index af43a79..dc10a97 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -143,5 +143,58 @@ providers: valueConversion: "STORAGE_PATH_AUTOMATIC_READ" storage-path-root: "keys" instance-scope-node-attribute: "winrm-password-storage-path" - - \ No newline at end of file + - name: WinRMCheck + title: WinRM Check Step + description: Check the connection with a remote node using winrm-python + service: WorkflowStep + plugin-type: script + script-interpreter: python -u + script-file: winrm-check.py + config: + - name: hostname + title: Hostname + description: "Window's Hostname" + type: String + required: true + - name: authtype + title: Authentication Type + description: "Authentication Type" + type: Select + values: "basic,credssp,ntlm,kerberos,ssl" + default: "basic" + required: true + - name: winrmtransport + title: WinRM Transport Protocol + description: "WinRM transport protocol (http or https)" + type: Select + default: "http" + values: "http, https" + required: true + scope: Instance + - name: nossl + title: No SSL Verification + description: "When set to true ssl certificate validation is not performed" + type: Select + values: "true, false" + default: "false" + required: true + - name: winrmport + title: WinRM Port + description: "WinRM port (Default: 5985/5986 for http/https)" + type: String + default: "5985" + required: true + - name: username + title: Username + description: "Username from window box" + type: String + required: true + - name: password_storage_path + title: Password Storage Path + type: String + required: true + description: "Password storage password path." + renderingOptions: + selectionAccessor: "STORAGE_PATH" + valueConversion: "STORAGE_PATH_AUTOMATIC_READ" + storage-path-root: "keys"