-
Notifications
You must be signed in to change notification settings - Fork 15
Omni Scripting Example Showing Expiration
Tom Mitchell edited this page May 15, 2017
·
3 revisions
Scripting was added to Omni in version 1.3. This script is an example of how to use Omni in a script.
This script generates a list of slices (for PG slices) via a call to listmyslices.
It then iterates over each returned slicename and calls print_slice_expiration.
The script can be found in the examples directory in the file expirationofmyslices.py.
A basic run of the script.
$ ./expirationofmyslices.py
Must provide a username as the first argument of script
$ ./expirationofmyslices.py myuser
INFO:omni:Loading config file /home/myuser/.gcf/omni_config
INFO:omni:Using control framework pgeni_gpo
INFO:omni:User 'myuser' has slices:
urn:publicid:IDN+pgeni.gpolab.bbn.com+slice+myslice
INFO:omni:Loading config file /home/myuser/.gcf/omni_config
INFO:omni:Using control framework pgeni_gpo
INFO:omni:Slice urn:publicid:IDN+pgeni.gpolab.bbn.com+slice+myslice expires on 2011-09-30 00:00:00 UTC
================================================================================
User myuser has 1 slices
Slice urn:publicid:IDN+pgeni.gpolab.bbn.com+slice+myslice expires on 2011-09-30 00:00:00 UTC
================================================================================
A basic run of the script using a built-in Omni command line option to switch frameworks.
$ ./expirationofmyslices.py -f pgeni_utah myuser
INFO:omni:Loading config file /home/myuser/.gcf/omni_config
INFO:omni:Using control framework pgeni_utah
INFO:omni:User 'myuser' has NO slices.
================================================================================
User myuser has NO slices
================================================================================
Get usage.
Notice the default inclusion of Omni options.
Notice the "usage" message customized to this script.
$ ./expirationofmyslices.py -h
Usage: examples/expirationofmyslices.py [options] username
Options:
--version show program's version number and exit
-h, --help show this help message and exit
Basic and Most Used Options:
-a AGGREGATE_URL, --aggregate=AGGREGATE_URL
Communicate with a specific aggregate
--available Only return available resources
-c FILE, --configfile=FILE
Config file name (aka `omni_config`)
-f FRAMEWORK, --framework=FRAMEWORK
Control framework to use for creation/deletion of
slices
-r PROJECT, --project=PROJECT
Name of project. (For use with pgch framework.)
--alap Request slivers be renewed as close to the requested
time as possible, instead of failing if the requested
time is not possible. Default is False.
-t RSPEC-TYPE RSPEC-VERSION, --rspectype=RSPEC-TYPE RSPEC-VERSION
RSpec type and version to return, default 'GENI 3'
-V API_VERSION, --api-version=API_VERSION
Specify version of AM API to use (default 2)
--useSliceAggregates
Perform the slice action at all aggregates the given
slice is known to use according to clearinghouse
records. Default is False.
--useSliceMembers Create accounts and install slice members' SSH keys on
reserved resources in createsliver, provision or
performoperationalaction. Default is False. When true,
adds these users and keys to those read from your
omni_config (unless --ignoreConfigUsers).
--ignoreConfigUsers
Ignore users and SSH keys listed in your omni_config
when installing SSH keys on resources in createsliver
or provision or performoperationalaction. Default is
false - your omni_config users are read and used.
AM API v3+:
Options used in AM API v3 or later
--best-effort Should AMs attempt to complete the operation on only
some slivers, if others fail
--cred=CRED_FILENAME
Send credential in given filename with any call that
takes a list of credentials
--end-time=GENI_END_TIME
Requested end time for any newly allocated or
provisioned slivers - may be ignored by the AM
--optionsfile=JSON_OPTIONS_FILENAME
Send all options defined in named JSON format file to
methods that take options
--speaksfor=USER_URN
Supply given URN as user we are speaking for in Speaks
For option
-u SLIVERS, --sliver-urn=SLIVERS
Sliver URN (not name) on which to act. Supply this
option multiple times for multiple slivers, or not at
all to apply to the entire slice
Logging and Verboseness:
Control the amount of output to the screen and/or to a log
-q, --quiet Turn off verbose command summary for omni commandline
tool
-v, --verbose Turn on verbose command summary for omni commandline
tool
--debug Enable debugging output. If multiple loglevel are set
from commandline (e.g. --debug, --info) the more
verbose one will be preferred.
--info Set logging to INFO.If multiple loglevel are set from
commandline (e.g. --debug, --info) the more verbose
one will be preferred.
--warn Set log level to WARN. This won't print the command
outputs, e.g. manifest rspec, so use the -o or the
--outputfile options to save it to a file. If multiple
loglevel are set from commandline (e.g. --debug,
--info) the more verbose one will be preferred.
--error Set log level to ERROR. This won't print the command
outputs, e.g. manifest rspec, so use the -o or the
--outputfile options to save it to a file.If multiple
loglevel are set from commandline (e.g. --debug,
--info) the more verbose one will be preferred.
--verbosessl Turn on verbose SSL / XMLRPC logging
-l LOGCONFIG, --logconfig=LOGCONFIG
Python logging config file
--logoutput=LOGOUTPUT
Python logging output file [use %(logfilename)s in
logging config file]
--tostdout Print results like rspecs to STDOUT instead of to log
stream
File Output:
Control name of output file and whether to output to a file
-o, --output Write output of many functions (getversion,
listresources, allocate, status, getslicecred,...) ,
to a file (Omni picks the name)
-p FILENAME_PREFIX, --prefix=FILENAME_PREFIX
Filename prefix when saving results (used with -o, not
--usercredfile, --slicecredfile, or --outputfile)
--outputfile=OUTPUT_FILENAME
Name of file to write output to (instead of Omni
picked name). '%a' will be replaced by servername,
'%s' by slicename if any. Implies -o. Note that for
multiple aggregates, without a '%a' in the name, only
the last aggregate output will remain in the file.
Will ignore -p.
--usercredfile=USER_CRED_FILENAME
Name of user credential file to read from if it
exists, or save to when running like '--usercredfile
myUserCred.xml -o getusercred'. Defaults to value of
'GENI_USERCRED' environment variable if defined.
--slicecredfile=SLICE_CRED_FILENAME
Name of slice credential file to read from if it
exists, or save to when running like '--slicecredfile
mySliceCred.xml -o getslicecred mySliceName'. Defaults
to value of 'GENI_SLICECRED' environment variable if
defined.
GetVersion Cache:
Control GetVersion Cache
--NoGetVersionCache
Disable using cached GetVersion results (forces
refresh of cache)
--ForceUseGetVersionCache
Require using the GetVersion cache if possible
(default false)
--GetVersionCacheAge=GETVERSIONCACHEAGE
Age in days of GetVersion cache info before refreshing
(default is 7)
--GetVersionCacheName=GETVERSIONCACHENAME
File where GetVersion info will be cached, default is
~/.gcf/get_version_cache.json
Aggregate Nickname Cache:
Control Aggregate Nickname Cache
--NoAggNickCache Disable using cached AggNick results and force refresh
of cache (default is False)
--ForceUseAggNickCache
Require using the AggNick cache if possible (default
False)
--AggNickCacheAge=AGGNICKCACHEAGE
Age in days of AggNick cache info before refreshing
(default is 1)
--AggNickCacheName=AGGNICKCACHENAME
File where AggNick info will be cached, default is
~/.gcf/agg_nick_cache
--AggNickDefinitiveLocation=AGGNICKDEFINITIVELOCATION
Website with latest agg_nick_cache, default is
https://raw.githubusercontent.com/GENI-NSF/geni-tools/master/agg_nick_cache.base. To force Omni to
read this cache, delete your local AggNickCache or use
--NoAggNickCache.
For Developers:
Features only needed by developers
--abac Use ABAC authorization
--arbitrary-option Add an arbitrary option to ListResources (for testing
purposes)
--devmode Run in developer mode: more verbose, less error
checking of inputs
--no-compress Do not compress returned values
--no-ssl do not use ssl
--no-tz Do not send timezone on RenewSliver
--orca-slice-id=ORCA_SLICE_ID
Use the given Orca slice id
--raise-error-on-v2-amapi-error
In AM API v2, if an AM returns a non-0 (failure)
result code, raise an AMAPIError. Default is False.
For use by scripts.
--ssltimeout=SSLTIMEOUT
Seconds to wait before timing out AM and CH calls.
Default is 360 seconds.
--noExtraCHCalls Disable extra Clearinghouse calls like reporting
slivers. Default is False.
GENI is sponsored by the National Science Foundation.