Search This Blog

Oracle Fusion Middleware Administration Course

Oracle Fusion Middleware Administration Course
OFMW Admin Course

Sunday, June 23, 2013

Socket module using WLST

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.

wls:/offline> import socket
wls:/offline> print(socket.gethostname())

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?


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)
ON', 'DEBUGLEVEL', 'DET', 'DM', 'DO', 'DONT', 'EC', 'ECHO', 'EL', 'ENCRYPT', 'EO
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:

Facebook Blogger Plugin: By

Post a Comment

Please write your comment here

Popular Posts

Oracle WebLogic Administration Course

Oracle WebLogic Administration Course
WebLogic Training