Skip to content

Commit

Permalink
Adding check step
Browse files Browse the repository at this point in the history
  • Loading branch information
ltamaster committed Apr 25, 2018
1 parent a8c9a5f commit 79b9c01
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
49 changes: 49 additions & 0 deletions contents/winrm-check.py
Original file line number Diff line number Diff line change
@@ -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
57 changes: 55 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,58 @@ providers:
valueConversion: "STORAGE_PATH_AUTOMATIC_READ"
storage-path-root: "keys"
instance-scope-node-attribute: "winrm-password-storage-path"


- 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"

0 comments on commit 79b9c01

Please sign in to comment.