RESTAPI: Generate Dell BIOS Update Task from Dell Command Update Results - Windows
Log In or Register to download the BES file, and more.

0 Votes

Description

This task will create BIOS update tasks in the same site as this task is run from using the current console operator username and password and the REST API. This task uses secure parameters so the password is encrypted.

NOTE:  The password will be visible when typed into the prompt, which is due to a JavaScript limitation.

 

References:

http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/RESTAPI%20Task

https://github.com/bigfix/restapi-examples/tree/master/evaluate-relevance/cURL

 

Parameter Values:   (queried using JavaScript & console based session relevance)


Property Details

ID3905
StatusBeta - Preliminary testing ready for more
TitleRESTAPI: Generate Dell BIOS Update Task from Dell Command Update Results - Windows
DomainBESC
CategoryConfiguration
Download Size0
Source IDjgstew
Source Release Date10/9/2014 12:00:00 AM
Added by on 10/29/2014 1:23:16 PM
Last Modified by on 10/29/2014 1:23:16 PM
Counters 8826 Views / 17 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Windows Only (Relevance 2997197)
Used in 6452 fixlets and 32 analyses   * Results in a true/false
Show indented relevance
/* Windows Only */ windows of operating system
Used in 158 fixlets and 17 analyses   * Results in a true/false
Show indented relevance
/* Windows XP or Higher */ version of operating system >= "5.1"
BES Client is version 9+ (Relevance 2999387)
Used in 20 fixlets   * Results in a true/false
Show indented relevance
version of client >= "9.0" as version
Used in 32 fixlets and 2 analyses   * Results in a true/false
Show indented relevance
/* DELL Only */ exists values "vendor" whose(it as string as uppercase contains "DELL") of structures "bios_information" of smbios
Used in 17 fixlets and 1 analsis   * Results in a true/false
Show indented relevance
/* check for supported model: OptiPlex, Latitude, Precision, Venue Tablets, XPS */ exists ((value "product_name" of structures "system_information" of smbios) as string as uppercase) whose(it starts with "OPTIPLEX" OR it starts with "LATITUDE" OR it starts with "PRECISION" OR it starts with "XPS" OR it starts with "VENUE")
Used in 1 fixlet   * Results in a true/false
Show indented relevance
/* Only if there is a BIOS update in the Dell Command Update results */ exists node values whose(it as trimmed string as lowercase starts with "downloads.dell.com") of child nodes of child nodes whose(node name of it = "file") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client
Used in 1 fixlet   * Results in a true/false
Show indented relevance
/* Only if the update is the same or newer than the current BIOS version */ exists (node values of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client) whose(it as string as trimmed string as version >= ( (it as string as trimmed string as version) of value "bios_version" of structures "bios_information" of smbios ) )
Used in 1 fixlet   * Results in a true/false
Show indented relevance
/* Only if the task has not been run in the past 7 days */ (not exists files whose(name of it starts with "RESTAPI_ImportedTasksDellBIOS_" AND name of it as lowercase ends with ".log" AND (now - modification time of it < 7*day) ) of folder "__BESData\__Global\Logs" of parent folder of client)
Used in 1 fixlet   * Results in a true/false
Show indented relevance
/* if this relevance is updated using the session relevance referenced, then only computers that do not already have a BIOS update task available will be relevant */ not exists (it) whose( (it as trimmed string starts with "Update: Dell BIOS - Model:'") AND ( (preceding text of first "' - " of following text of first "' Version:'" of it) = ( (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client ) ) AND ( (preceding text of first "' Version:'" of following text of first "Update: Dell BIOS - Model:'" of it)=( (value "product_name" of structures "system_information" of smbios) as string as trimmed string ) ) ) of /* The following should be periodically replaced with the output of the session relevance found here: http://bigfix.me/relevance/details/2999468 */ ( "";"" )

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
// DEBUGGING: The following is for debugging
// appendfile {parameter "RootServerURL"}
// appendfile {parameter "currentSiteName"}
// appendfile {parameter "currentSiteType"}
// appendfile {parameter "currentConsoleUser"}
// move __appendfile __Download\parameters.txt
// parameter "secret" of action

// -- START:DOWNLOADS -------------------------

// - This is the commandline 7zip console which is use to unpack installers
// - https://www.virustotal.com/en/file/2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac/analysis
prefetch 7za.zip sha1:9ce9ce89ebc070fea5d679936f21f9dde25faae0 size:384846 http://softlayer-dal.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7za920.zip

// - This unzip is a compiled verion of unzip v5.52 fom http://info-zip.org/
// - https://www.virustotal.com/en/file/8d9b5190aace52a1db1ac73a65ee9999c329157c8e88f61a772433323d6b7a4a/analysis
prefetch unzip.exe sha1:e1652b058195db3f5f754b7ab430652ae04a50b8 size:167936 http://software.bigfix.com/download/redist/unzip-5.52.exe

// Download CURL http://curl.haxx.se/download.html
// - Analysis of the CURL.exe inside: https://www.virustotal.com/en/file/7e4379dc72cc25e8d546b3f4b4305b93b6521aaae47c1ea2ee49e4cc4ce8b033/analysis/
prefetch curl.cab sha1:3edb8cfb34ba149ca36b2540cf58a50430a3c8bc size:432989 http://home.arcor.de/skanthak/download/curl-7.38.0.cab

// -- END:DOWNLOADS ---------------------------


// ADD TO UTILITY CACHE: unzip,7zip,curl
utility __Download\unzip.exe
utility __Download\7za.zip
utility __Download\curl.cab

// EXTRACT using unzip: the 7zip command line utility
waithidden __Download\unzip.exe -o "{pathname of file "7za.zip" of folder "__Download" of client folder of current site}" 7za.exe -d "{pathname of folder "__Download" of client folder of current site}"

// EXTRACT using 7zip: CURL
waithidden "{ (pathname of file "7za.exe" of folder "__Download" of client folder of current site) }" e -i!Curl.EXE -y -o"{pathname of folder "__Download" of client folder of current site}" "{pathname of file "curl.cab" of folder "__Download" of client folder of current site}"


// VERIFY: Make sure the parameters are set
continue if { (parameter "currentSiteName" as trimmed string != "") AND (parameter "currentSiteType" as trimmed string != "") AND (parameter "RootServerURL" as trimmed string != "") }

// DELETE: the tasks output of current site in case it exists already
delete "{pathname of folder "__Download" of client folder of current site}\Tasks_{parameter "currentSiteName"}.xml"

// REST API: Get names of all tasks in current site
waithidden "{ (pathname of file "Curl.EXE" of folder "__Download" of client folder of current site) }" -k -o "{pathname of folder "__Download" of client folder of current site}\Tasks_{parameter "currentSiteName"}.xml" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/tasks/{parameter "currentSiteType"}/{parameter "currentSiteName"}

// VERIFY: Make sure the same version bios update task does not already exist for the same model of machine
continue if{ not exists node values whose( (it as trimmed string starts with "Update: Dell BIOS - Model:'") AND ( (preceding text of first "' - " of following text of first "' Version:'" of it) = ( (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client ) ) AND ( (preceding text of first "' Version:'" of following text of first "Update: Dell BIOS - Model:'" of it)=( (value "product_name" of structures "system_information" of smbios) as string as trimmed string ) ) ) of xpaths "/BESAPI/Task/Name/text()" of xml documents of files ( "Tasks_" & (parameter "currentSiteName") & ".xml" ) of folders "__Download" of client folder of current site }
// not exists node values whose( (it as trimmed string starts with "Update: Dell BIOS - Model:'") AND ( (preceding text of first "' - " of following text of first "' Version:'" of it) = ( (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client ) ) AND ( (preceding text of first "' Version:'" of following text of first "Update: Dell BIOS - Model:'" of it)=( (value "product_name" of structures "system_information" of smbios) as string as trimmed string ) ) ) of xpaths "/BESAPI/Task/Name/text()" of xml documents of files ( "Tasks_" & (parameter "currentSiteName") & ".xml" ) of folders "__Download" of client folder of current site

// DOWNLOAD: BIOS Update using CURL
waithidden "{ (pathname of file "Curl.EXE" of folder "__Download" of client folder of current site) }" -k -o "{pathname of folder "__Download" of client folder of current site}\BIOS_Update.exe" { "https://" & unique value of node values whose(it as trimmed string as lowercase starts with "downloads.dell.com") of child nodes of child nodes whose(node name of it = "file") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client }

// VERIFY: size of download = size reported by dell command update
continue if{ (size of file "BIOS_Update.exe" of folder "__Download" of client folder of current site) = ( (it as trimmed string as integer) of unique value of node values of child nodes of child nodes whose(node name of it = "bytes") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client ) }

// Generate BIOS Update task
delete __createfile
delete Tasks.bes

// CREATEFILE
createfile until END_OF_FILE
="1.0" encoding="UTF-8"?>
="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
    
        Update: Dell BIOS - Model:'<span class='actionscriptRelevance'>{ (value "product_name" of structures "system_information" of smbios) as string as trimmed string }</span>' Version:'<span class='actionscriptRelevance'>{ (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client }</span>' - Windows
        { (value "product_name" of structures "system_information" of smbios) as string as trimmed string } BIOS to version: { (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client } ]]>
        /* Windows Only */ windows of operating system
        = "5.1"]]>
        /* DELL Only */ exists values "vendor" whose(it as string as uppercase contains "DELL") of structures "bios_information" of smbios
        ("{ (value "product_name" of structures "system_information" of smbios) as string as trimmed string }" as uppercase) = ((value "product_name" of structures "system_information" of smbios) as string as trimmed string as uppercase)
        "{ (it as string as trimmed string) of node value of child nodes of child nodes whose(node name of it = "version") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client }" as trimmed string as version > ( (it as string as trimmed string as version) of value "bios_version" of structures "bios_information" of smbios )]]>
        Software Sharing
        { (it as trimmed string) of unique value of node values of child nodes of child nodes whose(node name of it = "bytes") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client }
        RESTAPI: Generate Dell BIOS Update Task from Dell Command Update Results - Windows
        {parameter "currentConsoleUser"}
        { (current year as string) & "-" & (current month as two digits) & "-" & (current day_of_month as string) }
        
        
        
        
            x-fixlet-modification-time
            Fri, 24 Oct 2014 17:46:21 +0000
        
        BESC
        ="Action1">
            
                Click
                here
                 to update BIOS.
            
            ="application/x-Fixlet-Windows-Shell"> with description "Enter BIOS Password, or leave blank if none." and with default value " "

// -- START:DOWNLOADS -------------------------

prefetch BIOS_Update.exe sha1:{ sha1 of file "BIOS_Update.exe" of folder "__Download" of client folder of current site } size:{ (it as trimmed string) of unique value of node values of child nodes of child nodes whose(node name of it = "bytes") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client } https://{ unique value of node values whose(it as trimmed string as lowercase starts with "downloads.dell.com") of child nodes of child nodes whose(node name of it = "file") of parent nodes of parent nodes of xpaths "/updates/update/type/text()" whose(node value of it as trimmed string as uppercase = "BIOS") of xml documents of files "results_DellUpdate.xml" of folders "__BESData\__Global\Logs" of parent folder of client }

// -- END:DOWNLOADS ---------------------------


// DELETE: current log file if it exists
delete "{{ pathname of folder "__BESData\__Global\Logs" of parent folder of client }\install_Dell_BIOS_Update.log"

// INSTALL: BIOS Update
if{{ ( 4 <= length of (it as trimmed string) of (parameter "BIOS_Password") ) }
    waithidden __Download\BIOS_Update.exe /s /p={{ (parameter "BIOS_Password") as trimmed string } /l="{{ pathname of folder "__BESData\__Global\Logs" of parent folder of client }\install_Dell_BIOS_Update.log"
else
    waithidden __Download\BIOS_Update.exe /s /l="{{ pathname of folder "__BESData\__Global\Logs" of parent folder of client }\install_Dell_BIOS_Update.log"
endif

// Exit Codes:
// 0 = SUCCESSFUL
// 1 = UNSUCCESSFUL (FAILURE)
// 2 = REBOOT_REQUIRED (SUCCESSFUL)
// 3 = DEP_SOFT_ERROR
// 4 = DEP_HARD_ERROR
// 5 = QUAL_HARD_ERROR
// 6 = REBOOTING_SYSTEM (SUCCESSFUL)
// 7 = ? (wrong password)
// 8 = ?
// 9 = RPM_VERIFY_FAILED

// http://en.community.dell.com/techcenter/enterprise-client/w/wiki/3462.dup-bios-updates
// Report failure if bad return code, continue if good return code
continue if{{ exists (exit codes of action) whose(it = 2 OR it = 0 OR it = 6) }

notify client ForceRefresh

action requires restart "DellUpdatesInstalled"
]]>
            ="OriginalRelevance">
        
    

END_OF_FILE

move __createfile __Download\Tasks.bes

// Import UninstallMSI_Tasks.bes into custom site using API if there is at least one task inside (use secure parameter for user password)
if{ (exists files "Tasks.bes" whose(exists contents whose(it contains "") of it) of folder "__Download" of client folder of current site) }
// IMPORT
// http://stackoverflow.com/questions/3872427/how-to-send-line-break-with-curl
    waithidden "{ (pathname of file "Curl.EXE" of folder "__Download" of client folder of current site) }" -k -X POST --data-binary @"{pathname of file "Tasks.bes" whose(exists contents whose(it contains "") of it) of folder "__Download" of client folder of current site}" --header "Content-Type:text/xml" -o "{(pathname of folder "__BESData\__Global\Logs" of parent folder of client)}\RESTAPI_ImportedTasksDellBIOS_{parameter "currentSiteName"}.log" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/tasks/{parameter "currentSiteType"}/{parameter "currentSiteName"}
endif

// VERIFY: Check if tasks were actually imported
// TODO: Need to add a check to see if the log file was created after the action started running (See adobe CC template for an example)
continue if{exists files whose((name of it = ("RESTAPI_ImportedTasksDellBIOS_" & (parameter "currentSiteName") & ".log")) AND exists lines whose(it contains "") of it) of folder "__BESData\__Global\Logs" of parent folder of client}
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!