Dell FORCE10 Open Automation Instrukcja Użytkownika Strona 28

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 98
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 27
28 | Smart Scripting
www.dell.com | support.dell.com
Figure 3-4. Python Script with API function call: Example
#!/usr/pkg/bin/python
import sys
sys.path.append('/usr/pkg/scripts/smartutils') <--------------- Load the Python API
import F10SmartUtils
def create_vlans(startId,endId):
for vlanId in range(startId,endId+1):
result = F10SmartUtils.F10CreateVlanId(vlanId) <------- Invoke a Python API function
print result
def main(args):
try:
startId = int(args[0])
endId = int(args[1])
if(startId<=endId):
create_vlans(startId, endId)
else :
print "Invalid range: startId cannot be larger than endId",startId,endId
except ValueError:
print "Invalid arguments",args
if __name__=="__main__":
if len(sys.argv)>2:
main(sys.argv[1:])
else:
print "Please supply valid arguments"
print "createVlans.py <startId> <endId>"
Table 3-4 describes the supported functions and required arguments that you can use
in Python scripts run on a Dell Force10 switch to connect through a telnet session and
gather information or configure parameters through the CLI.
Table 3-4. Supported FTOS API Functions in Python Scripts
Python API Function Arguments Description
F10AddLagInttoVlan (lagId, vlanId, tagFlag) Adds a LAG interface to a VLAN as either tagged or untagged.
tagFlag values: 1 (tagged) or 0 (untagged).
F10AddPhyInttoVlan (stackUnitNum, portId,
vlanId, tagFlag)
Adds a physical interface to a VLAN as either tagged or untagged.
tagFlag values: 1 (tagged) or 0 (untagged).
F10CreateVlanId (vlanId) Creates a VLAN on the switch.
F10DeleteVlanId (vlanId) Deletes a VLAN on the switch.
F10ExecShowCmd (command) Executes a specified show command.
F10MakeLagIntNoShutdown (lagId) Enables the specified port channel.
F10MakeLagIntShutdown (lagId) Disables the specified port channel.
F10MakeLagIntSwitch (lagId) Configures the specified port channel (LAG) as a Layer 2
switchport.
F10MakePhyIntNoShutdown (stackUnitNum, portId) Enables the specified port.
F10MakePhyIntShutdown (stackUnitNum, portId) Disables the specified port.
F10MakePhyIntSwitch (stackUnitNum, portId) Configures the specified port as a Layer 2 switchport.
Przeglądanie stron 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 97 98

Komentarze do niniejszej Instrukcji

Brak uwag