Good news everyone....
I've worked out how to do it now using the "exec tmsh" method above and the correct escape characters. The iApp is based on f5.archiving.v1.0.0 and the template fits together like this:
Implementation:
package require iapp 1.0.0
iapp::template start
tmsh::cd ..
Create the iCall script
set script {
exec tmsh send-mail analytics application-security report view-by attack-type measures \{ \} drilldown \{ \{ entity policy values \{ /my_partition/VIRTSERV \} \} \{ entity severity values \{ Critical \} \} \{ entity violation values \{ \"Attack signature detected\" \} \} \} range now-1w format pdf file \"VIRTSERV.pdf\" email-addresses \{ MAILRCPT \}
}
set script [string map [list VIRTSERV $::time_select__vs_select MAILRCPT $::time_select__email] $script]
iapp::conf create sys icall script f5.asmreports definition \{ $script \} app-service none
Get time info for setting first-occurrence on daily handler from iApp input
set hr $::time_select__hr_select
set min $::time_select__min_select
set freq $::time_select__day_select
Create the handlers
if { $freq eq "Daily" } {
set cdate [clock format [clock seconds] -format "%Y-%m-%d"]
iapp::conf create sys icall handler periodic f5.asmreports-handler_$::time_select__vs_select \{ \
interval 86400 \
first-occurrence $cdate:$hr:$min:00 \
script f5.asmreports \}
} elseif { $freq eq "Weekly" } {
Get day of week info for setting first-occurrence on weekly handler from iApp input
array set dowmap {
Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
}
set sday_name $::time_select__dow_select
set sday_num $dowmap($sday_name)
set cday_name [clock format [clock seconds] -format "%A"]
set cday_num $dowmap($cday_name)
set date_offset [expr 86400*($sday_num - $cday_num)]
set date_final [clock format [expr [clock seconds] + $date_offset] -format "%Y-%m-%d"]
iapp::conf create sys icall handler periodic f5.asmreports-handler_$::time_select__vs_select \{ \
interval 604800 \
first-occurrence $date_final:$hr:$min:00 \
script f5.asmreports \}
}
iapp::template end
Presentation:
section time_select {
choice day_select display "large" { "Daily", "Weekly" }
optional ( day_select == "Weekly" ) {
choice dow_select display "medium" { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }
}
choice hr_select display "medium" tcl {
for { set x 0 } { $x < 24 } { incr x} {
append hrs "$x\n"
}
return $hrs
}
choice min_select display "medium" tcl {
for { set x 0 } { $x < 60 } { incr x } {
append mins "$x\n"
}
return $mins
}
choice vs_select display "large" {"vs-myvs1","vs-myvs2"}
string email display "medium"
}
text {
time_select "Reporting Schedule"
time_select.day_select "Choose the frequency the report should run:"
time_select.dow_select "Choose the day of the week the report should run:"
time_select.hr_select "Choose the hour the report should run:"
time_select.min_select "Choose the minute the report should run:"
time_select.vs_select "Choose the virtual server to report upon:"
time_select.email "Where should the report be e-mailed to?:"
}
The only downside at the moment is that you have to manually populate the template with the virtual server names you want to report on. Not sure I have the appetite at the moment to develop it further and make that a dynamically populated list!
The template creates a handler per instantiation of the template which allows you to keep the "Script updates" box ticked and amend the template with new virtual servers in the future.
The specific report in question is what I'm looking for but that section can be amended to suit your own needs.