iApp Lab 1 - Hello World¶
Creating your first iApp template¶
It is a common practice to begin training on a new system of
development with a Hello World program. In our case, a standard Hello
World would only touch the presentation section of iApp templates. So,
we are going to go just a couple of steps beyond that. In this first
lab, we will be learning how to create, edit, and run an application
template. We will display Hello World and create a few input fields in
the presentation section, and we will read and log their values in the
implementation section.
Part 1: Create a new iApp template¶
You can do this through the UI:
1. Navigate to the iApp -> Templates screen.
2. Click Create.
3. Name your new template and save it.
Or from TMSH
1. Enter TMSH and navigate to ‘/ sys application template’
2. Suggestion: type “modify /cli preference tcl-syntax-highlighting
enabled”
3. Type ‘create thanks_world_and_then_some’ and hit enter.
Part 2: Edit the Presentation Section¶
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 (edit
/sys application template ).
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.
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. Open your template in your favorite editing environment.
2. Find the presentation section. This is where you will be working
for this part of the lab.
3. Add a section element.
4. Inside that section element, add a message element. Make the text
of that message element say “Hello World”.
5. Add another section element named “some_variables”.
6. Inside that section element add the following
- A string element that is named “string_input_one”
b. A drop-down list (a choice element) with at least two options
(“choice 1” and “choice 2”).
c. A multichoice element with choices of “Option 1”, “Option 2”,
“Bonus Option”, and “Yet Another Option”.
- A table with two string elements of “name” and “value”.
7. Now add a text section
8. Add text strings for each element you added above.
{
<text strings go here>
}
9. Save your template.
10. If you edited your template off of your BIG-IP, import it back
into your BIG-IP.
11. View your new template by
- Navigating to iApp -> Application Services and clicking Create.
- Select your template from the drop-down list.
Optional/bonus¶
12. Add a yes/no question and an optional based on that question.
13. Place an element of your choice inside that optional.
Part 3: Testing the Presentation¶
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, or ask your instructor
for help.
1. Open your template in your favorite editing environment.
2. Find the implementation section. This is where you will be working
for this part of the lab.
3. Read each input field variable from the presentation section and
log their values to scriptd.out (/shared/tmp/scriptd.out) using the
puts command. It is a really good idea to label each variable in the
puts string, like this:
puts “string_input_one = $::some_variables__string_input_one”
Note: do not copy and paste the above string. The special “ characters
will cause you problems when you try to import.
Note: the above demonstrates why it is not a good idea to use Double
Underscores in your variable names
Part 5: Testing the Template as a whole:¶
1. Enter the template, fill in all of the fields, and click Finished.
2. If any errors are reported, correct them, return, and continue.
3. Open WinSCP and connect to your BIG-IP, or open a command line
shell to your BIG-IP.
4. Navigate to /var/tmp
5. Open the file scriptd.out and view the input fields that you
logged.
Optional/Bonus Step: Edit the Help Section¶
Optionally, you can go into the Help section and add some guidance for
your new template.
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.