iApp Lab 3 - Simple Extensions to an iApp

We need something extra in this iApp.

Sometimes a template almost does what a customer wants, but needs just that little bit extra. In this second lab, you are going to take the http iApp template and add the ability for the user to attach an arbitrary iRule to the iApp. This task will involve adding a new optional section and a new question and input to the presentation section and a small amount of code in the implementation section to handle that input and attach the iRule, if the user wants one.
Note: When it comes to editing your template, you have a choice as to how you want to do it.
1. You can edit the template on the BIG-IP in TMSH, using vi.
2. You can export the entire template as a file, load that file into your code editor for editing, and then import it back into the BIG-IP when you are finished.
3. You can cut-and-paste the contents of the section that you are working on into the code editor of your choice, work on it there, and cut-and-paste it back.
4. You can make your edits in the BIG-IP iApp Template UI, although this option is really not recommended.

Part 1: Copy the iApp template

1. Navigate to the iApp -> Templates screen.
2. Select the f5.http template to view it.
3. Scroll down to the bottom of the screen and click the Copy button.
4. Name your new template and save it.

Part 2: Edit the Presentation Section

The following is a series of tasks that need to be accomplished. If you are uncertain how to complete a task, you can look for examples of similar things being done in other templates or in the APL command reference.
1. Create a new section under the basic section.
2. Add a new yes/no question in that section that asks if the user wants to add an iRule to this virtual server.
3. Add a new optional based on that question that will be visible when the answer is yes.
4. Inside that optional, add a choice input that will be populated with a list of all of the iRules on the box.
5. Don’t forget to add all of your new controls to the text section to define their labels and questions.
6. Save your template. Import it back into the BIG-IP, if you edited it off-box.

Part 3: Testing the Presentation Section

It is a really good idea to always make sure that the presentation part of the template is working the way that you want before you dive into the implementation section.
1. Enter the template and verify that all of the visual elements, questions, and labels all look as they should.
2. If anything isn’t right, go back and fix it. If you need help figuring out what has gone wrong, ask your instructor.

Part 4: Edit the Implementation Section

The following is a series of tasks that need to be accomplished. If you are uncertain how to complete a task, you can look for examples of similar things being done in other templates.
1. In the implementation section, select a good place to process the new piece of the template.
a. A good place would to right below where the https redirect iRule is created.
2. Check to find out if the user has asked to add a new iRule.
3. If they have, get the name of the iRule and add it to the iRule list. Don’t forget to include the SSL iRule in the list, if it is already there.
4. Make sure that the iRules get applied to the virtual server(s).
5. Save your template. Import it back into the BIG-IP, if you edited it off-box.

Part 5: Edit the Help Section

Go into the Help section and add some guidance for your new template feature.

Part 6: Testing the Whole Template:

1. Enter the template and verify that all of the visual elements, questions, and labels look as they should.
2. Make sure that the template still works as expected if you elect to not add a new iRule.
3. Reenter the template and add an iRule.
a. After you have finished, go to the virtual server page and make sure that the iRule was attached.
b. Do this with SSL enabled and disabled to make sure that the iRule list is right in each case.
4. Reenter the template and remove the iRule.
a. After you have finished, go to the virtual server page and make sure that the iRule was removed.
5. Make sure that the help section looks right.

Optional/Bonus Step: Arbitrary number of iRules

Try this bonus exercise. Go back and change the template that you have created such that it can take an arbitrary number of iRules instead of just one.
1. In the presentation section, enclose your choice box for specifying iRules inside a table element to allow the user to specify an arbitrary number of iRules instead of just one. Alternatively, you could use a multichoice element.
2. In the implementation section, change the code to look for a variable number of iRules instead of just one and build a list of the iRules entered.
3. Test your results by selecting several iRules, and test that they all show up in the iRules list on the virtual server page.

Solution Attached Below

The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.