BDB Scripts (BDB)
RADKit allows a user to execute BDB scripts through the API or in the REPL.
Note
BDB is a Cisco internal tool that is used for support automation. If you are not a Cisco internal user, you do not have access to BDB and the information contained in this document does not apply to you.
The bdb
function
The RADKit Client provides a radkit_client.sync.bdb.BDB
instance that allows the
user to interact with BDB. The function that creates the object is called bdb
and is part of the global context in the REPL.
# In radkit-client (REPL)
>>> client.sso_login("user@domain")
>>> bdb_client = client.integrations.bdb
>>> type(bdb_client)
<class 'radkit_client.sync.integrations.bdb.BDB'>
# In Python
>>> from radkit_client import bdb
>>> client.sso_login("user@domain")
>>> bdb_client = client.integrations.bdb
>>> type(bdb_client)
<class 'radkit_client.sync.integrations.bcb.BDB'>
Get BDB tasks
Examples:
>>> bdb_client.get_tasks()
BDB Tasks
task description labels service internal external blocked
-------- --------------- -------- --------- ---------- ---------- ---------
task 1 description 1 (none) radkit3.9 False False False
task 2 description 2 (none) radkit3.9 False False False
task 3 description 3 (none) radkit3.9 False False False
Run BDB task in BDB
This can be useful when some BDB task can’t be imported to run locally into the radkit-client: any task that requires the BDB env like a BORG gateway for instance. The first parameter is the name of the BDB script to run and the 2nd parameter is a dict with the parameters of the BDB script. Third parameter (optional) is a request’s timeout, in seconds. By default the timeout is the same as the BDB’s global timeout setting which is 60 seconds. To disable the timeout, you need to provide None.
Examples:
>>> result = bdb_client.run_script("sleep", input={"duration":2, "size":10}, timeout=10)
>>> result
{
"code": 200,
"data": {
"printables": [{"type": "pre", "key": "result"}],
"variables": {"result": "xxxxxxxxxx", "_out_automation": None},
"result": {"key": "_out_automation", "type": "null"},
},
"worker_duration": 2.033135175704956,
}
Upload a local file to your BDB sandbox
Note that you can specify a file path, that path will be reflected in the BDB sandbox and directories will be created.
Examples:
>>> bdb_client.upload_file("example.txt")
Upload a string to a file in your BDB sandbox
Examples:
>>> bdb_client.upload_string_as_file("Some device output", "device_output.txt")
Import a Connected Diagnostic IC task stored in BDB into your local radkit-client
This follows the same convention as in BDB tasks where you can import other tasks with “import task_<bdb_task_name>”. If the task is not found in your venv (you can pip install tasks if you are working outside internal network and don’t have access to BDB), it will perform an “over the air” import of the task for you by calling the BDB API and loading the needed modules from your task. If you respected the template provided during creation of the radkit BDB task, your entry point is now the main() function of your task, and you can pass it your service to execute your awesome script.
Examples:
>>> bdb.install_importhook()
>>> import task_test_radkit_service
>>> task_test_radkit_service.main(service)
"Something awesome"