Brocade Virtual Traffic Manager: Trafficscript Guide
Total Page:16
File Type:pdf, Size:1020Kb
53-1005270-01 3 July 2017 Brocade Virtual Traffic Manager: TrafficScript Guide Supporting 17.3 Copyright © 2017 Brocade Communications Systems, Inc. All Rights Reserved. ADX, Brocade, Brocade Assurance, the B-wing symbol, DCX, Fabric OS, HyperEdge, ICX, MLX, MyBrocade, OpenScript, The Effortless Network, VCS, VDX, Vplane, and Vyatta are registered trademarks, and Fabric Vision and vADX are trademarks of Brocade Communications Systems, Inc., in the United States and/or in other countries. Other brands, products, or service names mentioned may be trademarks of others. Notice: This document is for informational purposes only and does not set forth any warranty, expressed or implied, concerning any equipment, equipment feature, or service offered or to be offered by Brocade. Brocade reserves the right to make changes to this document at any time, without notice, and assumes no responsibility for its use. This informational document describes features that may not be currently available. Contact a Brocade sales office for information on feature and product availability. Export of technical data contained in this document may require an export license from the United States government. .The authors and Brocade Communications Systems, Inc. assume no liability or responsibility to any person or entity with respect to the accuracy of this document or any loss, cost, liability, or damages arising from the information contained herein or the computer programs that accompany it. The product described by this document may contain “open source” software covered by the GNU General Public License or other open source license agreements. To find out which open source software is included in Brocade products, view the licensing terms applicable to the open source software, and obtain a copy of the programming source code, please visit http://www.brocade.com/en/support/support-tools/oscd.html. Brocade Communications Systems, Incorporated Corporate and Latin American Headquarters Asia-Pacific Headquarters Brocade Communications Systems, Inc. Brocade Communications Systems China HK, Ltd. 130 Holger Way No. 1 Guanghua Road San Jose, CA 95134 Chao Yang District Tel: 1-408-333-8000 Units 2718 and 2818 Fax: 1-408-333-8101 Beijing 100020, China E-mail: [email protected] Tel: +8610 6588 8888 Fax: +8610 6588 9999 E-mail: [email protected] European Headquarters Asia-Pacific Headquarters Brocade Communications Switzerland Sàrl Brocade Communications Systems Co., Ltd. (Shenzhen WFOE) Centre Swissair Citic Plaza Tour B - 4ème étage No. 233 Tian He Road North 29, Route de l'Aéroport Unit 1308 – 13th Floor Case Postale 105 Guangzhou, China CH-1215 Genève 15 Tel: +8620 3891 2000 Switzerland Fax: +8620 3891 2111 Tel: +41 22 799 5640 E-mail: [email protected] Fax: +41 22 799 5641 E-mail: [email protected] Contents Preface.........................................................................................................................................................1 Document Conventions ................................................................................................................................1 Notes and Warnings...............................................................................................................................1 Text Formatting Conventions ...............................................................................................................2 Command Syntax Conventions............................................................................................................2 Brocade Resources .........................................................................................................................................3 Document Feedback ......................................................................................................................................3 Contacting Brocade Technical Support.......................................................................................................3 Brocade Customers.................................................................................................................................3 Brocade OEM Customers ......................................................................................................................4 Chapter 1 - Introduction.............................................................................................................................5 About This Guide ..........................................................................................................................................5 The TrafficScript Language...........................................................................................................................5 TrafficScript Examples ...........................................................................................................................6 Application of Rules......................................................................................................................................7 Using a TrafficScript Rule .............................................................................................................................8 Chapter 2 - TrafficScript Syntax ..............................................................................................................13 Statements.....................................................................................................................................................13 Constants.......................................................................................................................................................14 Variables........................................................................................................................................................14 Expressions ...................................................................................................................................................15 Operators ...............................................................................................................................................15 Type Casts in TrafficScript...................................................................................................................17 Conditionals .................................................................................................................................................18 The “If” Statement................................................................................................................................18 The "switch" Statement ........................................................................................................................19 Loops .............................................................................................................................................................20 Brocade Virtual Traffic Manager: TrafficScript Guide i Contents “for” Loops ............................................................................................................................................20 ‘while’ Loops .........................................................................................................................................20 “do” Loops.............................................................................................................................................21 “foreach” Loops ....................................................................................................................................21 Other Flow Control......................................................................................................................................21 Complex Data Types ...................................................................................................................................22 Arrays.....................................................................................................................................................22 Hashes ....................................................................................................................................................23 The Global Associative Array.............................................................................................................23 The Process-Local Associative Array.................................................................................................24 The Connection-Local Array...............................................................................................................24 Libraries .................................................................................................................................................25 Functions.......................................................................................................................................................26 Escaping Regular Expressions ...................................................................................................................26 Creating New Subroutines in TrafficScript ..............................................................................................27 Syntax .....................................................................................................................................................27 Request and Response Rules......................................................................................................................28 Processing Multiple