I am trying to use the script send-schedules.gmp.py from the gvm-tools. I run the command and get the correct output on the command line saying ‘Schedule(s) created!’, but when I log in on the GSA to see if it was created, I can not see the desired schedule. The input XML-File looks like this:
Maybe the XML-File was created wrong? I used https://icalendar-creator.herokuapp.com/ to create a simple icalendar file of which I just copied the content into the <icalendar> parameter of the XML file. Any help would be appreciated.
I have solved it by writing my own parser. While debugging the execution, I noticed, that the debugger did not jump into the parse_send_xml_tree(gmp: Gmp, xml_tree: Element) function and so did not return anything (no error, no output…). I think the problem is, that the create_xml_tree(xml_doc) function returns an instance of Element and not ElementTree, so the parse could not actually traverse the tree and read out the values of the XML-Tags. If anyone else has the same issue I will provide my code below:
from lxml import etree
import sys
import xml.etree.ElementTree as ET
from gvm.protocols.latest import Gmp
from argparse import Namespace
def create_xml_tree(gmp, xml_doc):
xml_tree = ET.parse(xml_doc)
tree_root = xml_tree.getroot()
global name, comment, timezone, icalendar
for child in tree_root.findall("./name"):
name = child.text
for child in tree_root.findall("./comment"):
comment = child.text
for child in tree_root.findall("./timezone"):
timezone = child.text
for child in tree_root.findall("./icalendar"):
icalendar = child.text
gmp.create_schedule(name=name, comment=comment, timezone=timezone, icalendar=icalendar)
def main(gmp, args):
xml_doc = args.script[1]
print("\n Sending schedule...")
create_xml_tree(gmp, xml_doc)
print("\n Schedule created! \n")
if __name__ == "__gmp__":
main(gmp, args)