Restart windows server using fixlet in REST API

hi,

In my org, Patching team is using custom fixlet to restart the servers. It is kept in Master action site, but when I try to use that fixlet in automation via API call, it is showing Specified source object does not exist.
Find the XML below which I’m using to create restart action
Mater action site is referred as Patches for Windows in API. Please let me know what I’m missing

`<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
  <SourcedFixletAction>
    <SourceFixlet>
        <Sitename>Patches for Windows</Sitename>
        <FixletID>1627</FixletID>
        <Action>Action1</Action>
    </SourceFixlet>
    <Target>
        <ComputerName>test123</ComputerName>
    </Target>
  </SourcedFixletAction>

`

I think the problem is

<Sitename>Patches for Windows</Sitename>

This is the External Site name and if your fixlet is custom then it can’t reside in there.

1 Like

@FatScottishGuy, Here It is coming under Master action site only

The point isn’t that your fixlet isn’t in the Master Action Site, the point is that your XML defines it as being id 1627 in ‘Patches for Windows’.

Correct your code to correctly reference the fixlet as being 1627 in the Master Action site.

3 Likes

I’ve tries that also , but still it is showing there is no site name
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd"> <SourcedFixletAction> <SourceFixlet> <Sitename>Master Action Site</Sitename> <FixletID>1627</FixletID> <Action>Action1</Action> </SourceFixlet> <Target> <ComputerName>test123</ComputerName> </Target> </SourcedFixletAction> </BES>

Invoke-RestMethod : Site “Master Action Site” does not exist.

I tried giving BES Support (one of site name),and it worked, action id is also created but the server is not restarted

The Master Action Site is “actionsite

BES Support has its own fixlet ID 1627 so its not the same as the fixlet ID 1627 in the Master Action site (actionsite) site

2 Likes

I tried giving site name as ActionSite , it executed and gave the action id in return. Action ID:1630,
but restart is not triggered, the status is Waiting for restart to complete action.. but inside that fixlet in relevance part ‘restart’ is written

Is the account you use in the automation master operator? I have had problem executing similar stuff due to permission, so based on your description that is the first thing I would check. If your account is not MO, create a copy of the fixlet in a custom site that it has rights to and try to run it from that site instead. It may be the case that API is not allowing you to access actionsite which is technically MO site.

This means your API action POST is working perfectly fine.

You mean the actionscript, this is also expected & correct !

Check your action info & client logs, what happened when it was triggered on the target machine. It could be something blocking reboot while initiating using BESClient on the machine which is very common & you will see BESClient force reboot counts 1…2…3.etc

2 Likes

As suggested by @vk.khurava it looks like your post is creating the action and for the right fixlet. Do you have access to the machine you are issuing this to?

What is the actionscript for your fixlet, and what client version are you running? Is there 1 or more user logged into the system?

If the action uses restart then I believe that will present a UI to a logged in user and they have to invoke the restart, it won’t automatically perform the restart… If you use restart follow by a number, eg restart 60 that would trigger the UI to a logged in user but automatically invoke the restart after the number of seconds you specified.

2 Likes

even the status is pending restart, the system is getting restarted after few mins of action trigger.
and after sometime the status is getting changed to 'fixed’
Thanks @SLB for mentioning the proper site name,

XML input to restart:
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd"> <SourcedFixletAction> <SourceFixlet> <Sitename>ActionSite</Sitename> <FixletID>1627</FixletID> <Action>Action1</Action> </SourceFixlet> <Target> <ComputerName>testserver</ComputerName> </Target> </SourcedFixletAction> </BES>

API: https://BigFixServer:52311/api/actions

called the API with POST query.

No. its having proper permission, even the status is ‘pending restart’, but system is getting restarted, the status is getting changed after a few mins

Generally restarts are a Post-Action Setting rather than an ActionScript command. What’s your action script look like, and how about the client log when you run it?

I schedule a lot of actions using the REST API and here is what I include in the XML to automatically restart the device 1 minute after everything in the action has been completed:

<PostActionBehavior Behavior="Restart">
<AllowCancel>false</AllowCancel>
<PostActionDeadlineBehavior>RunAutomatically</PostActionDeadlineBehavior>
<PostActionDeadlineInterval>PT1M</PostActionDeadlineInterval>
<Title>Restart Now</Title>
<Text>Your system administrator is requesting that you restart your computer. Please save any unsaved work and then take this action to restart your computer.</Text>
</PostActionBehavior>
5 Likes

Actually inside the action script, it was written as ‘restart’ and now it’s working fine. Thanks for all your support guys in this topic.

2 Likes