Skip to content
Snippets Groups Projects
Commit 0682511a authored by Gioacchino Vino's avatar Gioacchino Vino
Browse files

Reviewed code

parent e253aed7
No related branches found
No related tags found
1 merge request!143Debug paas ci
......@@ -521,39 +521,4 @@ class GVMClient():
def get_version(self) -> str:
res = self.client.get_version()
return str(res.xpath('version/text()')[0])
def delete_port_list(self, pl: PortList):
res = self.client.delete_port_list(pl.id)
status = res.xpath(GVM_XPATH_STATUS)[0]
status_text = res.xpath(GVM_XPATH_STATUS_TEXT)[0]
if status == GVM_STATUS_OK:
logging.info(f"Port_list {pl} DELETED")
else:
logging.error(f"ERROR {status}: {status_text}")
def delete_target(self, target: Target):
res = self.client.delete_target(target.id)
status = res.xpath(GVM_XPATH_STATUS)[0]
status_text = res.xpath(GVM_XPATH_STATUS_TEXT)[0]
if status == GVM_STATUS_OK:
logging.info(f"Target {target} DELETED")
else:
logging.error(f"ERROR {status}: {status_text}")
def search_and_delete_target(self, target_name: str):
targets = self.get_targets(target_name)
if len(targets) == 1:
self.delete_target(targets[0]['id'])
else:
raise GvmException("Multiple results for search")
def search_and_delete_all_targets(self, target_name: str):
targets = self.get_targets(target_name)
for target in targets:
self.delete_target(target)
def delete_all_tasks(self, filter: str):
tasks = self.get_tasks(filter)
for task in tasks:
self.delete_task(task)
\ No newline at end of file
return str(res.xpath('version/text()')[0])
\ No newline at end of file
......@@ -96,19 +96,19 @@ for host,ports in endpoints.items():
summary_filename = f"{output_dir}/summary-report.json"
# Create PortList obj related to endpoint
port_list = PortList(client = gvm.get_client(),
port_list = PortList(client = gvm.client,
name = port_list_name,
ports = ports)
logging.info(f"Port list:\n {port_list}")
# Create Target obj related to endpoint
target = Target(client = gvm.get_client(),
target = Target(client = gvm.client,
name = target_name,
host = host,
port_list =port_list)
port_list = port_list)
logging.info(f"Target:\n {target}")
task = Task(client= gvm.get_client(),
task = Task(client= gvm.client,
name = task_name,
target = target)
logging.info(f"Task:\n {task}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment