Python Api  IE10.1
Classes | Functions | Variables
netbrain.sysapi.pluginfw Namespace Reference

Classes

class  PluginError
 plugin error code More...
 
class  Thread
 Wrapper class of threading.Thread for pluginfw If we need use multi-threads in plugin, we need copy the context to new thread. More...
 

Functions

def GetOpUserId ()
 get the operation user id. More...
 
def GetOpUserName ()
 get the operation user name. More...
 
def GetTaskId ()
 get the worker task id. More...
 
def GetAPIContext ()
 Get Context Object Pointer in FW Worker, this Context Object is local in thread. More...
 
def SetAPIContext (contextAddr)
 This method will clone one Context Object in new thread. More...
 
def ReleaseAPIContext ()
 set the plugin API context to null. More...
 
def AddLog (content, logType=INFO)
 Add logs to plugin exction. More...
 
def GetExcutionLogs ()
 get excution log in current task. More...
 
def IsUserStopped ()
 Test if the task has canceled by user. More...
 
def SetError (errorCode, errorMsg)
 Set the error message and error code. More...
 
def GetRunParam ()
 Get the plugin running params. More...
 
def GetXfTaskId ()
 Get the xf task id of plugin schedluler(benchmrak task id,discover task id,schedule plugin task id) More...
 
def GetTaskSourceType ()
 Get the xf task source type. More...
 
def GetTaskSourceId ()
 get the task source id,it is the Id of benchmarkdefine or shceduleplugin More...
 
def GetTaskTargetDevices ()
 Get target devices of current task,work only if current task type is Benchmark,otherwise return empty list. More...
 
def GetTaskAPIServerIDList ()
 Get sdn scope range of current task,work only if current task type is Benchmark,otherwise return empty list. More...
 
def GetQualifyDeviceIds ()
 

Variables

int DEBUG = 0
 debug log level More...
 
int INFO = 1
 info log level More...
 
int WARNING = 2
 waring log level More...
 
int ERROR = 3
 error log level More...
 

Function Documentation

◆ AddLog()

def netbrain.sysapi.pluginfw.AddLog (   content,
  logType = INFO 
)

Add logs to plugin exction.

Parameters
content(string) content of log.
logType(string) log level.
See also
PluginLogLevel

◆ GetAPIContext()

def netbrain.sysapi.pluginfw.GetAPIContext ( )

Get Context Object Pointer in FW Worker, this Context Object is local in thread.

If we need use multi-threads in plugin, we need use this method in C++ Thread and use SetAPIContext in Python Thread before call any C++ API.
sample code:

context = PluginFWWrapper.GetAPIContext()
thread_args = (context, ipsec_intfs, 'peerIP', 'cryptoEndpt')
thread = threading.Thread(target=build_links, args=thread_args)
ret = thread.start()
thread.join
Python Thread function
def build_links(context, vpn_intfs, local_property_name, remote_property_name):
PluginFWWrapper.SetAPIContext(context)
Returns
(C++ pointer)plugin API context.

◆ GetExcutionLogs()

def netbrain.sysapi.pluginfw.GetExcutionLogs ( )

get excution log in current task.

◆ GetOpUserId()

def netbrain.sysapi.pluginfw.GetOpUserId ( )

get the operation user id.

Returns
(string)the Id of operation user.

◆ GetOpUserName()

def netbrain.sysapi.pluginfw.GetOpUserName ( )

get the operation user name.

Returns
(string)the string name of operation user.

◆ GetQualifyDeviceIds()

def netbrain.sysapi.pluginfw.GetQualifyDeviceIds ( )

◆ GetRunParam()

def netbrain.sysapi.pluginfw.GetRunParam ( )

Get the plugin running params.

Returns
(PyPluginFW.RunPluginParam)the plugin running params
See also
PyPluginFW.RunPluginParam:
http://confluence.netbraintech.com/confluence/pages/viewpage.action?pageId=76746996
RunPluginParam.sourceType (string)
RunPluginParam.sourceId (string)
RunPluginParam.sourceXfTaskId (string)
RunPluginParam.execPoint (string)
RunPluginParam.path (string)
RunPluginParam.input (string)
RunPluginParam.isDebugMode (string)
RunPluginParam.ToJsonString() (string)
RunPluginParam.GetDomain() (domain)

◆ GetTaskAPIServerIDList()

def netbrain.sysapi.pluginfw.GetTaskAPIServerIDList ( )

Get sdn scope range of current task,work only if current task type is Benchmark,otherwise return empty list.

Returns
(list) sdn scope range list:

◆ GetTaskId()

def netbrain.sysapi.pluginfw.GetTaskId ( )

get the worker task id.

Returns
(string) the task id of running plugin worker.

◆ GetTaskSourceId()

def netbrain.sysapi.pluginfw.GetTaskSourceId ( )

get the task source id,it is the Id of benchmarkdefine or shceduleplugin

◆ GetTaskSourceType()

def netbrain.sysapi.pluginfw.GetTaskSourceType ( )

Get the xf task source type.

Returns
(string) xf task source type -
"ScheduleDiscovery"
"ScheduleBenchmark"
"SchedulePlugin"
"OnDemandDiscovery"
"OnDemandRun"

◆ GetTaskTargetDevices()

def netbrain.sysapi.pluginfw.GetTaskTargetDevices ( )

Get target devices of current task,work only if current task type is Benchmark,otherwise return empty list.

Returns
(list) device name list like: [ "Device1", "Device2" ]

◆ GetXfTaskId()

def netbrain.sysapi.pluginfw.GetXfTaskId ( )

Get the xf task id of plugin schedluler(benchmrak task id,discover task id,schedule plugin task id)

◆ IsUserStopped()

def netbrain.sysapi.pluginfw.IsUserStopped ( )

Test if the task has canceled by user.

if we check it is true in plugin,we should End the script as soon as possible. otherwise,it maybe kill by xfagent.

◆ ReleaseAPIContext()

def netbrain.sysapi.pluginfw.ReleaseAPIContext ( )

set the plugin API context to null.

◆ SetAPIContext()

def netbrain.sysapi.pluginfw.SetAPIContext (   contextAddr)

This method will clone one Context Object in new thread.

Only first call will do clone, more calls will do nothing

Parameters
contextAddr(C++ pointer)address of plugin API context,is get from C++ Api by call GetAPIContext
See also
GetAPIContext

◆ SetError()

def netbrain.sysapi.pluginfw.SetError (   errorCode,
  errorMsg 
)

Set the error message and error code.

Parameters
errorCode(int) error code
errorMsg(string) error message

Variable Documentation

◆ DEBUG

int netbrain.sysapi.pluginfw.DEBUG = 0

debug log level

◆ ERROR

int netbrain.sysapi.pluginfw.ERROR = 3

error log level

◆ INFO

int netbrain.sysapi.pluginfw.INFO = 1

info log level

◆ WARNING

int netbrain.sysapi.pluginfw.WARNING = 2

waring log level