|
| 1 | +Commands |
| 2 | +======== |
| 3 | + |
| 4 | +The |exec_cmd| method is the way to run tmsh commands like run, load, and save via the SDK. It is almost always used in conjunction with an |unnamed resource|. |
| 5 | + |
| 6 | +.. topic:: Example: Save the BIG-IP configuration |
| 7 | + |
| 8 | + .. code-block:: python |
| 9 | +
|
| 10 | + >>> from f5.bigip import ManagementRoot |
| 11 | + >>> mgmt = ManagementRoot('192.168.1.1.', 'user', 'pass') |
| 12 | + >>> mgmt.tm.sys.config.exec_cmd('save') |
| 13 | +
|
| 14 | +.. topic:: Example: Merge a file into the BIG-IP configuration |
| 15 | + |
| 16 | + .. code-block:: python |
| 17 | +
|
| 18 | + >>> from f5.bigip import ManagementRoot |
| 19 | + >>> mgmt = ManagementRoot('192.168.1.1', 'user', 'pass') |
| 20 | + >>> options = {} |
| 21 | + >>> options['file'] = '/var/config/rest/downloads/myfile.txt' |
| 22 | + >>> options['merge'] = True |
| 23 | + >>> mgmt.tm.sys.config.exec_cmd('load', options=[options]) |
| 24 | +
|
| 25 | +In the example above, you need to upload the file you wish to merge prior to executing this command. Also note that in version 12.1+, you will need to update the fileWhitelistPathPrefix attribute in global settings to merge files from this location. |
| 26 | + |
| 27 | +.. topic:: Example: Generate a qkview file without core dumps or log files |
| 28 | + |
| 29 | + .. code-block:: python |
| 30 | +
|
| 31 | + >>> from f5.bigip import ManagementRoot |
| 32 | + >>> mgmt = ManagementRoot('192.168.1.1', 'user', 'pass') |
| 33 | + >>> mgmt.tm.util.qkview.exec_cmd('run', utilCmdArgs='-C --exclude all') |
| 34 | +
|
| 35 | +.. topic:: Example: Use the bash utility to print the host routing table |
| 36 | + |
| 37 | + .. code-block:: python |
| 38 | +
|
| 39 | + >>> from f5.bigip import ManagementRoot |
| 40 | + >>> mgmt = ManagementRoot('192.168.1.1', 'user', 'pass') |
| 41 | + >>> rt_table = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='')rt = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "netstat -rn"') |
| 42 | + >>> print rt.commandResult |
| 43 | + Kernel IP routing table |
| 44 | + Destination Gateway Genmask Flags MSS Window irtt Iface |
| 45 | + 0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 vlan10 |
| 46 | + 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 mgmt |
| 47 | + 10.10.10.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan10 |
| 48 | + 127.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tmm |
| 49 | + 127.7.0.0 127.1.1.253 255.255.0.0 UG 0 0 0 tmm |
| 50 | + 127.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 tmm_bp |
| 51 | + 192.168.102.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan102 |
| 52 | + 192.168.103.0 0.0.0.0 255.255.255.0 U 0 0 0 vlan103 |
0 commit comments