Push baseline via REST API

I’ve started using the REST API in IEM to push baseline by creating the xml and then using the POST method via …/api/actions. The challenge is that you I have to include all the execution settings in the xml, and it becomes difficult managing that with different baselines with different constraints.

Is there a way to push a fixlet (i.e. a baseline) and it would use the fixlet’s default settings (start time, stop time, constraints, etc) rather than having to create the custom xml each time?

I don’t think you need to include that unless it is different than the default.

You could store the constraint xml as different templates and load in that xml depending on the constraints you want to use.

Related:

jgstew, so when you deploy a fixlet, which api do you use? /api/actions or /api/fixlet, or some other one?

When you are deploying a fixlet or task or multi action group or baseline, it should be a matter of creating an action.

In this code, I am using: BES_API_URL + “actions” which is …/api/actions

right, so you still have to create the xml file for the action. I was under the impression that there was a different way to execute a fixlet, where you don’t have to create the xml and use /api/actions, but instead, you could execute the fixlet via some other method, that uses the default settings of the fixlet.

Yes, you can do exactly what you just mentioned. You still have to create the action XML, but it is very small, it basically just contains a pointer to the source fixlet.

I would recommend reading through the BES.XSD

i tried creating a action in this way, with the action xml below and issuing it against the …/api/actions API. The action executes, but doesn’t include the default fixlet settings (i.e. constraints). Did I do something wrong?

<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
<Sitename>CustomSiteName</Sitename>
<FixletID>869</FixletID>
<Action>Action1</Action>
</SourceFixlet>
<Target>
<ComputerName>computername</ComputerName>
</Target>
<Parameter Name="_BESClient_EMsg_Detail">1000</Parameter>
</SourcedFixletAction>
</BES>

That seems correct. So it didn’t have the default constraints of the fixlet itself? I wonder if that means you have to specify them, if possible. I’m not certain why that would be.

In general, you shouldn’t have to generate much xml. You should be able to build a template of the most common cases you need by doing it in the console by hand, and then export the resulting action, and the use that xml as your template.

correct, I sent a default constraint in the fixlet, then executed the fixlet with the above xml action. The constraint did not carry over then into the newly created action in the console.

It’s strange because other fixlet defaults like Start Time (empty), stop time (+ 2days) are included in the console action when they are not specified in the action xml file.

1 Like

I am just reading this post today … but this is what I did to submit the baseline through REST API:

the XML take_action_site.xml has the fixletid which is the baseline ID:

take_action_site.xml.bes (1.3 KB)

curl -k -u “${USER}:${PASSWORD}” -X POST --data-binary “@take_action_site.xml” “https://${IEM_SERVER}:52311/api/actions”

PS: I renamed take_action_site.xml to take_action_site.xml.bes as I still don’t know how to add XML code in this forum :smile:

1 Like

So the FixletID in the xml is the ID of a baseline to take the action?

correct… and inside the Settings tag you can submit a blank test task with the proper execution parameters you ll want (like start on, end on, reapply, wait, etc) and export this action to get the proper syntax to update your XML code.

1 Like

I just wish there was a way to execute baseline/fixlet and it uses the default setings/parmameters stored within the fixlet.

not so sure I understood your last statement. What specific default setings/parmameters? execution parameters?

for example, one of my baselines has a default constraint of “run only when in Patching Windows” = “true”. I wish I could execute the baseline via the API and not have to re-create that constraint within the Settings section of the action xml file.

I also have a bunch of constrains in my baseline execution to be satisfied.
I added all the conditions to a automatic group and in the action XML I am just referring to apply if computers belongs to that automatic group under the CustomRelevance tag.

1 Like

A post was split to a new topic: Automating baseline deployment of patch cycle