Getting Started Commands
This page includes the following:
change_password()
Change the current user's password.
Parameters:
old_password
- the password that was used to log innew_password
- the new password, which must be at least 6 characters, including a non-alpha character
Dependencies:
- Must be logged in
Result:
- Old password changed to new password for the current user
Example change_password() command line usage:
>>> change_password(old_password='password2', new_password='password3')
done
Example change_password() script usage:
import sys from jaws import * login(user='user2', password='password3') print 'begin output' try: change_password(old_password='password3', new_password='password2') print 'end output' finally: logout()
exit()
Exit gracefully.
Parameters:
status
(optional) - system status value (exit code); zero typically signals success and any other value failure; default: 0
Dependencies:
- Can be called before login
Result
- Logged out and disconnected from system
Example exit() command line usage:
>>> exit() Exiting Logged out >>> exit(status=1) >>> exit(1)
Example exit() script usage:
import sys from jaws import * login() print 'begin output' try: print schedulers() print 'end output' finally: logout() exit()
help()
Print some descriptive info about a command and its parameters.
Parameters:
fxn
(optional) - one of the public functions of this module; default: None (show all)details
(optional) - if False, show the name of each function and a brief description only; default: True
Dependencies:
- Can be called before login
Result:
- If fxn parameter is included, description and parameters of the given function is printed. Otherwise, the entire list of possible functions, complete with description and parameters of each function, is printed.
Example help() command line usage:
>>> help(fxn=help, details=False) help() Print some descriptive info about a command and its parameters. >>> help(help) >>> help(fxn=help) >>> help(details=False) >>> help()
Example help() script usage:
import sys from jaws import * login() print 'begin output' try: print help(login, False) print help(logout, False) print 'end output' finally: logout()
login()
Establish a connection to the AAI server.
After a logout() call, this function may be called again with different User Parameters to connect to the same server as a different user. The Connection Parameters will only be honored on the first call to login(). Connection Parameters will be ignored on subsequent calls.
The User Parameters are used to identify and login a particular AAI user to the AAI server.
Parameters:
-
user
(optional) - AAI user to login withDefault: 'admin'
-
domain
(optional) - user domain in which the login user is definedDefault: ‘JAWS’
-
password
(optional) - password for the AAI userDefault: 'password'
-
user_admin
(optional) - whether to use a login restricted to session administrationDefault: False
The Connection Parameters are used to identify the AAI server, connect to the server to verify it is up and check the CLI version against the server version. These parameters are only needed if the server is not at http://localhost:8080.
Connection Parameters:
-
host
(optional) - hostname of the AAI serverDefault: 'localhost'
-
http_port
(optional) - used to make initial contact with the AAI serverDefault: 8080
-
http_protocol
(optional) - 'http' or 'https' (secure http)Default: 'http'
-
disable_cert
(optional) - if True, then https certificate authentication is disabledDefault: False
-
skip_server_contact
(optional) - if True, then the parameters are accepted without contacting the serverDefault: False
-
skip_version_check
(optional) - if True, then the parameters are accepted without verifying the versionDefault: False
Dependencies:
- This call must succeed before any other request is made (except help(), login_domains(), and Date/Time methods)
Result:
- Connected to AAI server and logged in as a specified user
Example login() command line usage:
>>> login(host='localhost', http_port=8443, http_protocol='https',
user='admin', domain='jaws', password='password', user_admin=True)
Connected to PROD (6.0.0)
Message: AAI Server
Eval license, 28089 days remaining
login as "admin"
done (0.0s elapsed)
>>> login(user='user2', password='password2')
Example login() script usage:
import sys from jaws import * try: login() print 'begin output' print schedulers() print 'end output' finally: logout()
login_domains()
Get a list of domains which allow login with password.
Parameters:
- None
Dependencies:
- Must be logged in
Result:
- A list of names of login domains
Example login_domains() command line usage:
>>> login_domains() [u'ldapdomain', u'QAtest']
Example login_domains() script usage:
import sys from jaws import * login() print 'begin output' try: log = login_domains() for l in log: print l print 'end output' finally: logout()
logout()
Close the connection to the server, possibly allowing another user to connect. This should be called before the script exits.
Parameters:
- None
Dependencies:
- Must be logged in
Result:
- Current user disconnected from AAI server
Example logout() command line usage:
>>> logout() done
Example logout() script usage:
import sys from jaws import * login() print 'begin output' try: print schedulers() print 'end output' finally: logout()
params.login_with_params()
Login to the AAI server with parameters passed into the script on the command line.
login_with_params()
is a convenience function in the params.py module which parses the command line parameters and then calls login(), passing the parsed parameters to login()
. For more information, see Parameter Parsing.
Any additional parameters on the command line can be retrieved with params.get_params()
.
Command line parameters:
The following parameters are all optional and must be specified on the command line to specify a non- default value. All command line parameters must be followed by the desired value.
-
-user (optional) - AAI user to login with
Default: 'admin'
-
-password (optional) - password for the AAI user
Default: 'password'
-
-domain (optional) - user domain in which the login user is defined
Default: 'JAWS'
-
-user_admin (optional) - whether to use a login restricted to session administration
Default: False
-
-server (optional) - hostname of the AAI server
Default: 'localhost'
-
-port (optional) - HTTP port for the AAI server
Default: 8080
-
-protocol (optional) - 'http' or 'https'
Default: 'http'
-
-disable_cert (optional) - whether to disable https certificate authentication
Default: False
-
-http_tunnel (ignored) - this parameter is no longer used
Dependencies:
To call this function, include import params in the import preable to the script.
Example params.login_with_params() script usage:
import jaws import params try: params.login_with_params() # do things here finally: jaws.logout()
Example Executing a Script that Uses params.login_with_params():
> ./run.bat login_with_params.py -server myhostname -user myuser \ -password mypassword AAI Command Line Interface (6.0.0) Connected to AAI server: PROD (6.0.0) Message: AAI Server Eval license, 28089 days remaining login as "admin" done (0.3s elapsed) done >
params.get_params()
Retrieve command line parameters, excluding the ones consumed by params.login_with_params()
.
params.login_with_params()
is a convenience function in the params.py module which parses the command line parameters and returns the parameters from the command line which are not used by params.login_with_params()
. For more information, see Parameter Parsing.
There are two type of parameters: unnamed arguments and keyword arguments. Unnamed arguments are single entries on the command line. Keyword arguments are pairs of entries on the command line, keyword followed by value, space separated with a hyphen preceding the keyword.
The result is a tuple of (sequence of un-named args, dictionary of keyword args).
For example, if the command line was "run.pl myscript.py -server prod_01 -file out.txt a b c", then the result of this function would be ( ['a', 'b', 'c'], {'file': 'out,txt'} ).
Dependencies:
- To call this function, include
import params
in the import preable to the script.
Example Using params.get_params() script usage:
import jaws import params try: params.login_with_params() args, kw = params.get_params() for arg in args: print 'arg:', arg for param, val in kw.iteritems(): print 'param:', param, 'value:', val finally: jaws.logout()
Example Executing a Script that Uses params.get_params():
> ./run.pl handy/testParams.py -server prod_01 -user admin \ -password password -infile myfile.txt aa -outfile results.tx bb AAI Command Line Interface (6.0.0) Connected to AAI server: PROD (6.0.0) Message: AAI Sever Eval license, 28089 days remaining login as "admin" done (0.1s elapsed) arg: aa arg: bb param: outfile value: results.tx param: infile value: myfile.txt done >
select_server()
This function has been deprecated and may be removed in a future release. The functionality has been moved to the login() function which should be used instead.
Identify the AAI server, connect to the server to verify it is up, and check the CLI version against the server version.
Parameters:
-
host
(optional) - hostname of the AAI serverDefault: 'localhost'
-
http_port
(optional) - used to make initial contact with the AAI serverDefault: 8080
-
http_protocol
(optional) - http or https (secure http)Default: http
-
disable_cert
(optional) - if True, then https certificate authentication is disabledDefault: False
-
skip_server_contact
(optional) - if True, then the parameters are accepted without contacting the serverDefault: False
-
skip_version_check
(optional) - if True, then the parameters are accepted without verifying the versionDefault: False
-
port
(ignored) - this parameter is no longer used -
http_tunnel
(ignored) - this parameter is no longer used
Dependencies:
- Can be called before login
Result:
- Connected to AAI server
Example select_server() command line usage:
>>> select_server(host='localhost', http_tunnel=False, http_port=8080, http_protocol='http', skip_server_contact=False, skip_version_check=False) Connected to AAI server: PROD (6.0.0) Message: AAI Server >>> select_server()
Example select_server() script usage:
import sys from jaws import * try: select_server(host='localhost', http_tunnel=False, http_port=8080, http_protocol='http', skip_server_contact=False, skip_version_check=False) login() print 'begin output' print schedulers() print 'end output' finally: logout()