White Paper

12 Scripting WSMAN Operating System Deployment Boot Network ISO
else:
wsman_command = 'wsman invoke -a "%s"
http://schemas.dell.com/wbem/wscim/1/cim-schema/2/%s?%s -N %s -u %s -p %s -h %s -P
443 -v -j utf-8 -y basic -o -m 256 -c %s -V -J "%s"'
wsman_command = wsman_command % (methodname, classname, key_str,
namespace, username, password, ipaddress, cert, filename)
return wsman_command
Launch WSMAN CLI command
After the relevant WSMAN CLI command is constructed, it must be launched on the command line or
shell. This must be done to communicate with the remote WSMAN service. The subprocess python
module is used to achieve this. The response from the remote WSMAN service is stored in two strings
stdout and stderr. After returned from the API, stdout must be checked to use the output data. If it
is empty, then an error occurred. The stderr string must be used to print out the error.
# launch the constructed WSMAN CLI command
def wsman_command_launch(wsman_command):
"""
Executes the WSMan command on the shell (OS agnostic) and
returns the standard out and error values.
"""
import subprocess
proc = subprocess.Popen(wsman_command,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout_value,stderr_value = proc.communicate()
return stdout_value,stderr_value
Ping test
The ping API is used to test the network connectivity with the remote controller or device. This is a
useful pre-step before launching WSMAN CLI commands to communicate with the remote WSMAN
service. The implementation below detects the host OS and conducts the ping test. Based on the
connectivity, the appropriate message will be displayed.
# Ping test
def ping(ipaddress):