Skip to content

Commit

Permalink
add ability for BigFixActioner to make an action instead of an offer.…
Browse files Browse the repository at this point in the history
….. like it used to.
  • Loading branch information
jgstew committed Apr 10, 2024
1 parent 6a5e0c7 commit 401863c
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions SharedProcessors/BigFixActioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
__all__ = ["BigFixActioner"]

# noqa: B950
BES_SourcedFixletAction = """\
# if this template is used, you get an offer:
BES_SourcedFixletActionOffer = """\
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
Expand Down Expand Up @@ -54,6 +55,22 @@
</BES>
"""

# if this template is used, you get an action:
BES_SourcedFixletAction = """\
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
<Sitename>{{bes_customsite}}</Sitename>
<FixletID>{{bes_id}}</FixletID>
<Action>{{bes_action}}</Action>
</SourceFixlet>
<Target>
<AllComputers>true</AllComputers>
</Target>
</SourcedFixletAction>
</BES>
"""


class BigFixActioner(BESImport):
"""AutoPkg Processor to create a BigFix action from imported content"""
Expand All @@ -75,6 +92,11 @@ class BigFixActioner(BESImport):
"default": "Action1",
"description": "Which Action to run",
},
"bes_action_type": {
"required": False,
"default": "Offer",
"description": "Tells autopkg to create an action or offer.",
},
}
output_variables = {
"bes_action_id": {
Expand All @@ -90,6 +112,8 @@ def main(self):
"""BigFixActioner Main Method"""
template_dict = {}
template_dict["bes_id"] = self.env.get("bes_id", 0)
bes_action_type = str(self.env.get("bes_action_type", "Offer"))

if template_dict["bes_id"] == 0:
self.output("Nothing to action.", 0)
else:
Expand All @@ -104,7 +128,12 @@ def main(self):
# clear password from ENV
self.env["BES_PASSWORD"] = ""

bes_action_data = chevron.render(BES_SourcedFixletAction, template_dict)
if "action" in bes_action_type.lower():
bes_action_data = chevron.render(BES_SourcedFixletAction, template_dict)
else:
bes_action_data = chevron.render(
BES_SourcedFixletActionOffer, template_dict
)

self.output(bes_action_data, 4)

Expand Down

0 comments on commit 401863c

Please sign in to comment.