cli script /Common/license { proc show_help {} { set usage "Usage: [lindex $tmsh::argv 0] \[password-encrypted\] \[path path_to_cloud_libs\] host IP address of BIG-IP. Default localhost. port Port on which the BIG-IP management address is listening. Defaut 443. user BIG-IP admin user name. Default admin. password BIG-IP admin user password. Use this or password-url. password-url URL of file containing admin user password. Use this or password. Support file URLs only. password-encrypted Indicates that the password is encrypted. Default is unencrypted. license Registration key with which to license. Use this or BIG-IQ licensing. add-on Add-on key to apply. Default none. revoke Tell BIG-IQ to revoke this license instead of issuing a license. big-iq-host IP address of BIG-IQ. big-iq-user BIG-IQ admin user name. Default admin. big-iq-password BIG-IQ admin user password. Use this or big-iq-password-uri. big-iq-password-uri URI that returns BIG-IQ password. Use this or big-iq-password. Supports file and ARN uris. license-pool-name Name of the BIG-IQ license pool to use. cloud Name of cloud in which BIG-IP is running. Required for BIG-IQ 5.4. Valid values are aws, azure, gce, vmware, hyperv, kvm, xen sku-keyword-1 CLPv2 skuKeyword1 parameter. Default none. sku-keyword-2 CLPv2 skuKeyword2 parameter. Default none. unit-of-measure CLPv2 unitOfMeasure parameter. Default none. big-ip-mgmt-address IP address of BIG-IP which is routable from the BIG-IQ. Default is what is reported by /shared/identified-devices/config/device-info. big-ip-mgmt-port Port to use with big-ip-mgmt-address. Default is the 'port' parameter. path Override default path to f5-cloud-libs (for example /config/cloud/node_modules/@f5devcentral/f5-cloud-libs) log-level Log level. Default info. " puts $usage } proc get_local_mgmt_port {} { set port_output [tmsh::list sys httpd ssl-port] regexp {(?:ssl-port)\s(\d+)} $port_output -> local_port return $local_port } proc script::run {} { # maps command line options to whether or not they take a parameter array set option_has_parameter { help 0 path 1 host 1 port 1 user 1 password 1 password-url 1 password-encrypted 0 license 1 add-on 1 revoke 0 big-iq-host 1 big-iq-user 1 big-iq-password 1 big-iq-password-uri 1 license-pool-name 1 cloud 1 sku-keyword-1 1 sku-keyword-2 1 unit-of-measure 1 big-ip-mgmt-address 1 big-ip-mgmt-port 1 log-level 1 } set valid_options [array names option_has_parameter] if { [lsearch -start 1 $tmsh::argv help] != -1 } { show_help exit 0 } # If we're not using a reg key or add-on key, assume licensing from BIG-IQ if { [lsearch -start 1 $tmsh::argv license] == -1 && [lsearch -start 1 $tmsh::argv add-on] == -1} { set onboard_args "--license-pool" } set has_host 0 set has_port 0 set has_user 0 set has_big_iq_user 0 set tmsh_arglen [llength $tmsh::argv] set index 1 while { $index < $tmsh_arglen } { set option [lindex $tmsh::argv $index] if { [lsearch -exact $valid_options $option] == -1 } { puts "Invalid option $option. Valid options: $valid_options" exit 1 } if { $option == "path" } { set path [lindex $tmsh::argv [incr index]] incr index continue } elseif { $option == "host" } { set has_host 1 } elseif { $option == "user" } { set has_user 1 } elseif { $option == "port" } { set has_port 1 } elseif { $option == "big-iq-user" } { set has_big_iq_user 1 } lappend onboard_args --$option if { $option_has_parameter($option) } { lappend onboard_args [lindex $tmsh::argv [incr index]] } incr index } if { !$has_host } { lappend onboard_args --host localhost } if { !$has_user } { lappend onboard_args --user admin } if { !$has_port } { lappend onboard_args --port [get_local_mgmt_port] } if { !$has_big_iq_user } { lappend onboard_args --big-iq-user admin } if { [ catch { exec /bin/bash -c "/usr/bin/f5-rest-node $path/scripts/onboard.js $onboard_args" >&@ stdout } result ] } { puts "bash command returned error. exiting." } } }