Network Socket with Python/WLST
Internet protocol libraries for Python can be used in WLST. hostname you can use to make most generic for your automation scripts. Use this idea in build and deployment process.![]() |
Python libraries that can be imported to WLST shell |
Let's start exploring the most network related libraries useful for WLST scripts
Benefits of Python network, communication libraries importing in WLST
- Use `socket` to verify if WebLogic servers, admin servers, or managed servers are reachable on specific ports (e.g., 7001 for HTTP, 7002 for HTTPS).
- Automated Alerts: Send email notifications for WebLogic events, such as server crashes, deployment failures, or performance thresholds (e.g., high CPU usage).
- Integration with CI/CD: Include email alerts in deployment scripts to inform teams about successful or failed deployments.
- Enhances communication in automated workflows, reducing manual oversight.
- Supports proactive incident management by notifying teams instantly.
- Customizable for different recipients or conditions (e.g., based on server metrics).
:
There are many socket related modules and built-in functions available to check we can run dir command on each to know wha is inside that package.
Did you ever thought of using FTP from WLST?
wls:/offline> import socket wls:/offline> print(socket.gethostname()) pavanb.wlst.by.examples.com
There are many socket related modules and built-in functions available to check we can run dir command on each to know wha is inside that package.
wls:/offline> import smtplib wls:/offline> dir(smtplib) ['CRLF', 'OLDSTYLE_AUTH', 'SMTP', 'SMTPAuthenticationError', 'SMTPConnectError', 'SMTPDataError', 'SMTPException', 'SMTPHeloError', 'SMTPRecipientsRefused', 'SM TPResponseException', 'SMTPSenderRefused', 'SMTPServerDisconnected', 'SMTP_PORT' , 'SSLFakeFile', 'SSLFakeSocket', '__all__', '__doc__', '__file__', '__name__', 'base64', 'encode_base64', 'hmac', 'quoteaddr', 'quotedata', 're', 'rfc822', 'so cket', 'types']
FTP library in WLST
wls:/offline> import ftplib wls:/offline> dir(ftplib) ['CRLF', 'Error', 'FTP', 'FTP_PORT', 'MSG_OOB', 'Netrc', '_150_re', '_227_re', ' __all__', '__doc__', '__file__', '__name__', 'all_errors', 'error_perm', 'error_ proto', 'error_reply', 'error_temp', 'ftpcp', 'os', 'parse150', 'parse227', 'par se229', 'parse257', 'print_line', 'socket', 'string', 'sys', 'test']
Did you ever thought of using FTP from WLST?
IMAPLIB in WLST
wls:/offline> import imaplib wls:/offline> dir(imaplib) ['AllowedVersions', 'CRLF', 'Commands', 'Continuation', 'Debug', 'Flags', 'IMAP4 ', 'IMAP4_PORT', 'Int2AP', 'InternalDate', 'Internaldate2tuple', 'Literal', 'Mon 2num', 'ParseFlags', 'Response_code', 'Time2Internaldate', 'Untagged_response', 'Untagged_status', '_Authenticator', '__all__', '__doc__', '__file__', '__name__ ', '__version__', '_cmd_log', '_cmd_log_len', '_dump_ur', '_log', '_mesg', 'bina scii', 'print_log', 'random', 're', 'socket', 'sys', 'time']This is implib
telnet Library in WLST
Just for connectivity before create your database connection pools.wls:/offline> import telnetlib wls:/offline> dir(telnetlib) ['AO', 'AUTHENTICATION', 'AYT', 'BINARY', 'BM', 'BRK', 'CHARSET', 'COM_PORT_OPTI ON', 'DEBUGLEVEL', 'DET', 'DM', 'DO', 'DONT', 'EC', 'ECHO', 'EL', 'ENCRYPT', 'EO R', 'EXOPL', 'FORWARD_X', 'GA', 'IAC', 'IP', 'KERMIT', 'LFLOW', 'LINEMODE', 'LOG OUT', 'NAMS', 'NAOCRD', 'NAOFFD', 'NAOHTD', 'NAOHTS', 'NAOL', 'NAOLFD', 'NAOP', 'NAOVTD', 'NAOVTS', 'NAWS', 'NEW_ENVIRON', 'NOOPT', 'NOP', 'OLD_ENVIRON', 'OUTMR K', 'PRAGMA_HEARTBEAT', 'PRAGMA_LOGON', 'RCP', 'RCTE', 'RSP', 'SB', 'SE', 'SEND_ URL', 'SGA', 'SNDLOC', 'SSPI_LOGON', 'STATUS', 'SUPDUP', 'SUPDUPOUTPUT', 'SUPPRE SS_LOCAL_ECHO', 'TELNET_PORT', 'TLS', 'TM', 'TN3270E', 'TSPEED', 'TTYLOC', 'TTYP E', 'TUID', 'Telnet', 'VT3270REGIME', 'WILL', 'WONT', 'X3PAD', 'XASCII', 'XAUTH' , 'XDISPLOC', '__all__', '__doc__', '__file__', '__name__', 'select', 'socket', 'sys', 'test', 'theNULL']This is having more functions and variables check it...
httplib in WLST for Sanity check
You can use 'httplib' for checking sanity of an application after deployment.wls:/offline> import httplib wls:/offline> dir(httplib) ['BadStatusLine', 'CannotSendHeader', 'CannotSendRequest', 'FakeSocket', 'HTTP', 'HTTPConnection', 'HTTPException', 'HTTPMessage', 'HTTPResponse', 'HTTPS', 'HTTPSConnection', 'HTTPS_PORT', 'HTTP_PORT', 'ImproperConnectionState', 'IncompleteRead', 'InvalidURL', 'LineAndFileWrapper', 'NotConnected', 'ResponseNotReady', 'SSLFile', 'SharedSocket', 'SharedSocketClient', 'StringIO', 'UnimplementedFileMode', 'UnknownProtocol', 'UnknownTransferEncoding', '_CS_IDLE', '_CS_REQ_SENT', '_CS_REQ_STARTED', '_UNKNOWN', '__all__', '__doc__', '__file__', '__name__', 'errno', 'error', 'mimetools', 'socket', 'test', 'urlsplit']Here, I fond the HTTPLIB example given by Valdmir blog post->Python: HTTP Basic authentication with httplib. Where in the Python script used to do the Sanity test for a provided application URL, which uses the authentication provided using base64 module.
The xmlrpclib library for WLST
This is xmrpclib can be used while interacting with config.xml file. have a look and decide :)wls:/offline> import xmlrpclib wls:/offline> dir(xmlrpclib) ['ArrayType', 'Binary', 'Boolean', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DateTime', 'DictProxyType', 'DictType','DictionaryType', 'EllipsisType', 'Error', 'ExpatParser', 'False', 'FastParser', 'FastUnmarshaller', 'Fault', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MAXINT', 'MININT', 'Marshaller', 'MethodType', 'ModuleType', 'NoneType', 'ObjectType', 'ProtocolError', 'ResponseError', 'SafeTransport', 'Server', 'ServerProxy', 'SgmlopParser', 'SliceType', 'SlowParser', 'StringType', 'StringTypes', 'TracebackType', 'Transport', 'True', 'TupleType', 'TypeType', 'UnboundMethodT ype', 'UnicodeType', 'Unmarshaller', 'WRAPPERS', 'XRangeType', '_Method', '__doc__', '__file__', '__name__', '__version__', '_decode', '_stringify', 'binary', 'boolean', 'classDictInit', 'datetime', 'dumps', 'escape', 'getparser', 'loads','operator', 're', 'string', 'time']
No comments:
Post a Comment
Please write your comment here